Java 类org.jfree.chart.plot.Plot 实例源码

项目:iveely.ml    文件:ChartUtils.java   
public static void setTimeSeriesBarRender(Plot plot, boolean isShowDataLabels) {

        XYPlot xyplot = (XYPlot) plot;
        xyplot.setNoDataMessage(NO_DATA_MSG);

        XYBarRenderer xyRenderer = new XYBarRenderer(0.1D);
        xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());

        if (isShowDataLabels) {
            xyRenderer.setBaseItemLabelsVisible(true);
            xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
        }

        StandardXYToolTipGenerator xyTooltipGenerator = new StandardXYToolTipGenerator("{1}:{2}", new SimpleDateFormat("yyyy-MM-dd"), new DecimalFormat("0"));
        xyRenderer.setBaseToolTipGenerator(xyTooltipGenerator);
        setXY_XAixs(xyplot);
        setXY_YAixs(xyplot);

    }
项目:iveely.ml    文件:ChartUtils.java   
public static void setPieRender(Plot plot) {

        plot.setNoDataMessage(NO_DATA_MSG);
        plot.setInsets(new RectangleInsets(10, 10, 5, 10));
        PiePlot piePlot = (PiePlot) plot;
        piePlot.setInsets(new RectangleInsets(0, 0, 0, 0));
        piePlot.setCircular(true);

        piePlot.setLabelGap(0.01);
        piePlot.setInteriorGap(0.05D);
        piePlot.setLegendItemShape(new Rectangle(10, 10));
        piePlot.setIgnoreNullValues(true);
        piePlot.setLabelBackgroundPaint(null);
        piePlot.setLabelShadowPaint(null);
        piePlot.setLabelOutlinePaint(null);
        piePlot.setShadowPaint(null);
        // 0:category 1:value:2 :percentage
        piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{2}"));
    }
项目:rapidminer    文件:AbstractChartPanel.java   
/**
 * Zooms in on an anchor point (specified in screen coordinate space).
 * 
 * @param x
 *            the x value (in screen coordinates).
 * @param y
 *            the y value (in screen coordinates).
 */

public void shrinkSelectionOnCenter(double x, double y, MouseEvent selectionEvent) {
    Plot plot = this.chart.getPlot();
    if (plot == null) {
        return;
    }
    // here we tweak the notify flag on the plot so that only
    // one notification happens even though we update multiple
    // axes...
    boolean savedNotify = plot.isNotify();
    plot.setNotify(false);
    shrinkSelectionOnDomain(x, y, selectionEvent);
    shrinkSelectionOnRange(x, y, selectionEvent);
    plot.setNotify(savedNotify);
}
项目:rapidminer    文件:AbstractChartPanel.java   
/**
 * Restores the auto-range calculation on both axes.
 */

@Override
public void restoreAutoBounds() {
    Plot plot = this.chart.getPlot();
    if (plot == null) {
        return;
    }
    // here we tweak the notify flag on the plot so that only
    // one notification happens even though we update multiple
    // axes...
    boolean savedNotify = plot.isNotify();
    plot.setNotify(false);
    selectCompleteDomainBounds();
    selectCompleteRangeBounds();
    plot.setNotify(savedNotify);
}
项目:open-java-trade-manager    文件:ChartJDialog.java   
private void plotTradeBubblesOnChart(ArrayList<Integer> toPlot, String p, int k, int j)
  {
    final Plot main_plot = (Plot)((CombinedDomainXYPlot)this.candlestickChart.getPlot()).getSubplots().get(0);
      final XYPlot plot = (XYPlot) main_plot;

    final TimeSeries series = new TimeSeries(p);
///*
for(Integer i: toPlot)
{
    switch(j)
    {
    case 0:
        series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getOpen());
        break;
    case 1:
        series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getHigh());
        break;
    case 2:
        series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getLow());
        break;
    case 3:
        series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getClose());
        break;
    }

}
/*
for (int i = 0; i < defaultHighLowDataset.getSeriesCount(); i++) 
{
          series.add(new Minute(defaultHighLowDataset.getXDate(0, i)),plot[i]);
      }
*/
XYDataset dataSet = new TimeSeriesCollection(series);

plot.setDataset(k, dataSet);
    XYItemRenderer ir = new XYShapeRenderer();
    //ir.s

    plot.setRenderer(k, ir);
  }
项目:jfreechart-fx    文件:ScrollHandlerFX.java   
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, 
        ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = canvas.getRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = new Point2D.Double(e.getX(), e.getY());
    if (pinfo.getDataArea().contains(p)) {
        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
        boolean notifyState = plot.isNotify();
        plot.setNotify(false);
        int clicks = (int) e.getDeltaY();
        double zf = 1.0 + this.zoomFactor;
        if (clicks < 0) {
            zf = 1.0 / zf;
        }
        if (canvas.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (canvas.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    } 
}
项目:parabuild-ci    文件:XYDrawableAnnotation.java   
/**
 * Draws the annotation.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param rendererIndex  the renderer index.
 * @param info  if supplied, this info object will be populated with
 *              entity information.
 */
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
                 ValueAxis domainAxis, ValueAxis rangeAxis, 
                 int rendererIndex,
                 PlotRenderingInfo info) {

    PlotOrientation orientation = plot.getOrientation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
            plot.getDomainAxisLocation(), orientation);
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
            plot.getRangeAxisLocation(), orientation);
    float j2DX = (float) domainAxis.valueToJava2D(this.x, dataArea, 
            domainEdge);
    float j2DY = (float) rangeAxis.valueToJava2D(this.y, dataArea, 
            rangeEdge);
    Rectangle2D area = new Rectangle2D.Double(j2DX - this.width / 2.0, 
            j2DY - this.height / 2.0, this.width, this.height);
    this.drawable.draw(g2, area);
    String toolTip = getToolTipText();
    String url = getURL();
    if (toolTip != null || url != null) {
        addEntity(info, area, rendererIndex, toolTip, url);
    }

}
项目:parabuild-ci    文件:SubCategoryAxis.java   
/**
 * Estimates the space required for the axis, given a specific drawing area.
 *
 * @param g2  the graphics device (used to obtain font information).
 * @param plot  the plot that the axis belongs to.
 * @param plotArea  the area within which the axis should be drawn.
 * @param edge  the axis location (top or bottom).
 * @param space  the space already reserved.
 *
 * @return The space required to draw the axis.
 */
public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, 
                              RectangleEdge edge, AxisSpace space) {

    // create a new space object if one wasn't supplied...
    if (space == null) {
        space = new AxisSpace();
    }

    // if the axis is not visible, no additional space is required...
    if (!isVisible()) {
        return space;
    }

    space = super.reserveSpace(g2, plot, plotArea, edge, space);
    double maxdim = getMaxDim(g2, edge);
    if (RectangleEdge.isTopOrBottom(edge)) {
        space.add(maxdim, edge);
    }
    else if (RectangleEdge.isLeftOrRight(edge)) {
        space.add(maxdim, edge);
    }
    return space;
}
项目:parabuild-ci    文件:XYDrawableAnnotation.java   
/**
 * Draws the annotation.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 */
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
                 ValueAxis domainAxis, ValueAxis rangeAxis) {

    PlotOrientation orientation = plot.getOrientation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(), 
                                                              orientation);
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(), 
                                                            orientation);
    float j2DX = (float) domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
    float j2DY = (float) rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
    Rectangle2D area = new Rectangle2D.Double(j2DX - this.width / 2.0,
                                              j2DY - this.height / 2.0,
                                              this.width, this.height);
    this.drawable.draw(g2, area);

}
项目:parabuild-ci    文件:SubCategoryAxis.java   
/**
 * Estimates the space required for the axis, given a specific drawing area.
 *
 * @param g2  the graphics device (used to obtain font information).
 * @param plot  the plot that the axis belongs to.
 * @param plotArea  the area within which the axis should be drawn.
 * @param edge  the axis location (top or bottom).
 * @param space  the space already reserved.
 *
 * @return The space required to draw the axis.
 */
public AxisSpace reserveSpace(Graphics2D g2, Plot plot, 
                              Rectangle2D plotArea, 
                              RectangleEdge edge, AxisSpace space) {

    // create a new space object if one wasn't supplied...
    if (space == null) {
        space = new AxisSpace();
    }

    // if the axis is not visible, no additional space is required...
    if (!isVisible()) {
        return space;
    }

    space = super.reserveSpace(g2, plot, plotArea, edge, space);
    double maxdim = getMaxDim(g2, edge);
    if (RectangleEdge.isTopOrBottom(edge)) {
        space.add(maxdim, edge);
    }
    else if (RectangleEdge.isLeftOrRight(edge)) {
        space.add(maxdim, edge);
    }
    return space;
}
项目:parabuild-ci    文件:PeriodAxis.java   
/**
 * Rescales the axis to ensure that all data is visible.
 */
protected void autoAdjustRange() {

    Plot plot = getPlot();
    if (plot == null) {
        return;  // no plot, no data
    }

    if (plot instanceof ValueAxisPlot) {
        ValueAxisPlot vap = (ValueAxisPlot) plot;

        Range r = vap.getDataRange(this);
        if (r == null) {
            r = getDefaultAutoRange();
        }

        long upper = Math.round(r.getUpperBound());
        long lower = Math.round(r.getLowerBound());
        this.first = createInstance(this.autoRangeTimePeriodClass, 
                new Date(lower), this.timeZone);
        this.last = createInstance(this.autoRangeTimePeriodClass, 
                new Date(upper), this.timeZone);
        setRange(r, false, false);
    }

}
项目:iveely.ml    文件:ChartUtils.java   
public static void setTimeSeriesRender(Plot plot, boolean isShowData, boolean isShapesVisible) {

        XYPlot xyplot = (XYPlot) plot;
        xyplot.setNoDataMessage(NO_DATA_MSG);
        xyplot.setInsets(new RectangleInsets(10, 10, 5, 10));

        XYLineAndShapeRenderer xyRenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();

        xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
        xyRenderer.setBaseShapesVisible(false);
        if (isShowData) {
            xyRenderer.setBaseItemLabelsVisible(true);
            xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
            xyRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.BOTTOM_CENTER));
        }
        xyRenderer.setBaseShapesVisible(isShapesVisible);

        DateAxis domainAxis = (DateAxis) xyplot.getDomainAxis();
        domainAxis.setAutoTickUnitSelection(false);
        DateTickUnit dateTickUnit = new DateTickUnit(DateTickUnitType.YEAR, 1, new SimpleDateFormat("yyyy-MM"));
        domainAxis.setTickUnit(dateTickUnit);

        StandardXYToolTipGenerator xyTooltipGenerator = new StandardXYToolTipGenerator("{1}:{2}", new SimpleDateFormat("yyyy-MM-dd"), new DecimalFormat("0"));
        xyRenderer.setBaseToolTipGenerator(xyTooltipGenerator);

        setXY_XAixs(xyplot);
        setXY_YAixs(xyplot);

    }
项目:ojAlgo-extensions    文件:StackedBarChartBuilder.java   
@Override
protected Plot makePlot(final JFreeChartBuilder.PlotParameters parameters) {

    final DefaultKeyedValues2DDataset tmpDataset = this.getDataset();

    final CategoryAxis tmpCategoryAxis = this.makeCategoryAxis(domain);

    final ValueAxis tmpValueAxis = this.makeValueAxis(range);

    final StackedBarRenderer tmpRenderer = new StackedBarRenderer();
    tmpRenderer.setBarPainter(new StandardBarPainter());
    tmpRenderer.setShadowVisible(false);

    if (this.isTooltips()) {
        tmpRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (this.isUrls()) {
        tmpRenderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    this.setColours(tmpRenderer, tmpDataset);

    final CategoryPlot retVal = new CategoryPlot(tmpDataset, tmpCategoryAxis, tmpValueAxis, tmpRenderer);
    retVal.setOrientation(parameters.getOrientation());
    retVal.setBackgroundPaint(parameters.getBackground());
    retVal.setOutlinePaint(parameters.getOutline());

    return retVal;
}
项目:parabuild-ci    文件:PolarChartPanel.java   
/**
 * Test that the chart is using an xy plot with time as the domain axis.
 * 
 * @param chart  the chart.
 */
private void checkChart(JFreeChart chart) {
    Plot plot = chart.getPlot();
    if (!(plot instanceof PolarPlot)) {
        throw new IllegalArgumentException("plot is not a PolarPlot");
   }
}
项目:rapidminer    文件:AbstractChartPanel.java   
@Override
public Collection<String> resolveYAxis(int axisIndex) {
    Plot p = chart.getPlot();
    Collection<String> names = new LinkedList<>();
    if (p instanceof XYPlot) {
        XYPlot plot = (XYPlot) p;
        for (int i = 0; i < plot.getRangeAxisCount(); i++) {
            ValueAxis domain = plot.getRangeAxis(i);
            names.add(domain.getLabel());
        }
    }
    return names;
}
项目:rapidminer    文件:AbstractChartPanel.java   
/**
 * Sets the chart that is displayed in the panel.
 * 
 * @param chart
 *            the chart (<code>null</code> permitted).
 */

@Override
public void setChart(JFreeChart chart) {

    // stop listening for changes to the existing chart
    if (this.chart != null) {
        this.chart.removeChangeListener(this);
        this.chart.removeProgressListener(this);
    }

    // add the new chart
    this.chart = chart;
    if (chart != null) {
        this.chart.addChangeListener(this);
        this.chart.addProgressListener(this);
        Plot plot = chart.getPlot();
        this.domainZoomable = false;
        this.rangeZoomable = false;
        if (plot instanceof Zoomable) {
            Zoomable z = (Zoomable) plot;
            this.domainZoomable = z.isDomainZoomable();
            this.rangeZoomable = z.isRangeZoomable();
            this.orientation = z.getOrientation();
        }
    } else {
        this.domainZoomable = false;
        this.rangeZoomable = false;
    }

    repaint();

}
项目:rapidminer    文件:AbstractChartPanel.java   
/**
 * Sets the flag that controls whether or not zooming is enable for the domain axis. A check is
 * made to ensure that the current plot supports zooming for the domain values.
 * 
 * @param flag
 *            <code>true</code> enables zooming if possible.
 */

@Override
public void setDomainZoomable(boolean flag) {
    if (flag) {
        Plot plot = this.chart.getPlot();
        if (plot instanceof Zoomable) {
            Zoomable z = (Zoomable) plot;
            this.domainZoomable = flag && z.isDomainZoomable();
        }
    } else {
        this.domainZoomable = false;
    }
}
项目:rapidminer    文件:AbstractChartPanel.java   
/**
 * A flag that controls mouse-based zooming on the vertical axis.
 * 
 * @param flag
 *            <code>true</code> enables zooming.
 */

@Override
public void setRangeZoomable(boolean flag) {
    if (flag) {
        Plot plot = this.chart.getPlot();
        if (plot instanceof Zoomable) {
            Zoomable z = (Zoomable) plot;
            this.rangeZoomable = flag && z.isRangeZoomable();
        }
    } else {
        this.rangeZoomable = false;
    }
}
项目:rapidminer    文件:AbstractChartPanel.java   
/**
 * Receives notification of changes to the chart, and redraws the chart.
 * 
 * @param event
 *            details of the chart change event.
 */

@Override
public void chartChanged(ChartChangeEvent event) {
    Plot plot = this.chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable z = (Zoomable) plot;
        this.orientation = z.getOrientation();
    }
    repaint();
}
项目:rapidminer    文件:AbstractChartPanel.java   
/**
 * Decreases the length of the domain axis, centered about the given coordinate on the screen.
 * The length of the domain axis is reduced by the value of {@link #getZoomInFactor()}.
 * 
 * @param x
 *            the x coordinate (in screen coordinates).
 * @param y
 *            the y-coordinate (in screen coordinates).
 */

public void shrinkSelectionOnDomain(double x, double y, MouseEvent selectionEvent) {
    Plot p = this.chart.getPlot();
    if (p instanceof XYPlot) {
        XYPlot plot = (XYPlot) p;
        Selection selectionObject = new Selection();
        for (int i = 0; i < plot.getDomainAxisCount(); i++) {
            ValueAxis domain = plot.getDomainAxis(i);
            double zoomFactor = getZoomInFactor();
            shrinkSelectionXAxis(x, y, selectionObject, domain, i, zoomFactor);
        }
        informSelectionListener(selectionObject, selectionEvent);
    }
}
项目:rapidminer    文件:AbstractChartPanel.java   
/**
 * Increases the length of the domain axis, centered about the given coordinate on the screen.
 * The length of the domain axis is increased by the value of {@link #getZoomOutFactor()}.
 * 
 * @param x
 *            the x coordinate (in screen coordinates).
 * @param y
 *            the y-coordinate (in screen coordinates).
 */

public void enlargeSelectionOnDomain(double x, double y, MouseEvent selectionEvent) {
    Plot p = this.chart.getPlot();
    if (p instanceof XYPlot) {
        XYPlot plot = (XYPlot) p;
        Selection selectionObject = new Selection();
        for (int i = 0; i < plot.getDomainAxisCount(); i++) {
            ValueAxis domain = plot.getDomainAxis(i);
            double zoomFactor = getZoomOutFactor();
            shrinkSelectionXAxis(x, y, selectionObject, domain, i, zoomFactor);
        }
        informSelectionListener(selectionObject, selectionEvent);
    }
}
项目:rapidminer    文件:AbstractChartPanel.java   
/**
 * Decreases the length of the range axis, centered about the given coordinate on the screen.
 * The length of the range axis is reduced by the value of {@link #getZoomInFactor()}.
 * 
 * @param x
 *            the x-coordinate (in screen coordinates).
 * @param y
 *            the y coordinate (in screen coordinates).
 */

public void shrinkSelectionOnRange(double x, double y, MouseEvent selectionEvent) {
    Plot p = this.chart.getPlot();
    if (p instanceof XYPlot) {
        XYPlot plot = (XYPlot) p;
        Selection selectionObject = new Selection();
        for (int i = 0; i < plot.getRangeAxisCount(); i++) {
            ValueAxis domain = plot.getRangeAxis(i);
            double zoomFactor = getZoomInFactor();
            shrinkSelectionYAxis(x, y, selectionObject, domain, i, zoomFactor);
        }
        informSelectionListener(selectionObject, selectionEvent);
    }
}
项目:rapidminer    文件:AbstractChartPanel.java   
/**
 * Increases the length the range axis, centered about the given coordinate on the screen. The
 * length of the range axis is increased by the value of {@link #getZoomOutFactor()}.
 * 
 * @param x
 *            the x coordinate (in screen coordinates).
 * @param y
 *            the y-coordinate (in screen coordinates).
 */

public void enlargeSelectionOnRange(double x, double y, MouseEvent selectionEvent) {
    Plot p = this.chart.getPlot();
    if (p instanceof XYPlot) {
        XYPlot plot = (XYPlot) p;
        Selection selectionObject = new Selection();
        for (int i = 0; i < plot.getRangeAxisCount(); i++) {
            ValueAxis domain = plot.getRangeAxis(i);
            double zoomFactor = getZoomOutFactor();
            shrinkSelectionYAxis(x, y, selectionObject, domain, i, zoomFactor);
        }
        informSelectionListener(selectionObject, selectionEvent);
    }
}
项目:rapidminer    文件:AbstractChartPanel.java   
/**
 * Restores the auto-range calculation on the domain axis.
 */

public void selectCompleteDomainBounds() {
    Plot plot = this.chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable z = (Zoomable) plot;
        // here we tweak the notify flag on the plot so that only
        // one notification happens even though we update multiple
        // axes...
        boolean savedNotify = plot.isNotify();
        plot.setNotify(false);
        // we need to guard against this.zoomPoint being null
        Point2D zp = this.zoomPoint != null ? this.zoomPoint : new Point();
        z.zoomDomainAxes(0.0, this.info.getPlotInfo(), zp);
        plot.setNotify(savedNotify);

        if (plot instanceof XYPlot) {
            XYPlot xyPlot = (XYPlot) plot;
            Selection selectionObject = new Selection();
            for (int i = 0; i < xyPlot.getDomainAxisCount(); i++) {
                ValueAxis domain = xyPlot.getDomainAxis(i);
                Range axisRange = new Range(domain.getLowerBound(), domain.getUpperBound());
                for (String axisName : axisNameResolver.resolveXAxis(i)) {
                    selectionObject.addDelimiter(axisName, axisRange);
                }
            }
            informSelectionListener(selectionObject, null);
        }
    }
}
项目:rapidminer    文件:AbstractChartPanel.java   
/**
 * Restores the auto-range calculation on the range axis.
 */

public void selectCompleteRangeBounds() {
    Plot plot = this.chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable z = (Zoomable) plot;
        // here we tweak the notify flag on the plot so that only
        // one notification happens even though we update multiple
        // axes...
        boolean savedNotify = plot.isNotify();
        plot.setNotify(false);
        // we need to guard against this.zoomPoint being null
        Point2D zp = this.zoomPoint != null ? this.zoomPoint : new Point();
        z.zoomRangeAxes(0.0, this.info.getPlotInfo(), zp);
        plot.setNotify(savedNotify);

        if (plot instanceof XYPlot) {
            XYPlot xyPlot = (XYPlot) plot;
            Selection selectionObject = new Selection();
            for (int i = 0; i < xyPlot.getRangeAxisCount(); i++) {
                ValueAxis range = xyPlot.getRangeAxis(i);
                Range axisRange = new Range(range.getLowerBound(), range.getUpperBound());
                for (String axisName : axisNameResolver.resolveYAxis(i)) {
                    selectionObject.addDelimiter(axisName, axisRange);
                }
            }
            informSelectionListener(selectionObject, null);
        }
    }
}
项目:rapidminer    文件:LinkAndBrushChartPanel.java   
@Override
public void restoreAutoBounds() {
    Plot plot = getChart().getPlot();
    if (plot == null) {
        return;
    }
    // here we tweak the notify flag on the plot so that only
    // one notification happens even though we update multiple
    // axes...
    boolean savedNotify = plot.isNotify();
    plot.setNotify(false);

    if (plot instanceof LinkAndBrushPlot) {

        LinkAndBrushPlot LABPlot = (LinkAndBrushPlot) plot;

        List<Pair<Integer, Range>> zoomedDomainAxisRanges = new LinkedList<Pair<Integer, Range>>();
        List<Pair<Integer, Range>> zoomedRangeAxisRanges = new LinkedList<Pair<Integer, Range>>();

        zoomedDomainAxisRanges.addAll(LABPlot.restoreAutoDomainAxisBounds(zoomOnLinkAndBrushSelection));
        zoomedRangeAxisRanges.addAll(LABPlot.restoreAutoRangeAxisBounds(zoomOnLinkAndBrushSelection));

        if (zoomOnLinkAndBrushSelection) {
            informLinkAndBrushSelectionListeners(new LinkAndBrushSelection(SelectionType.RESTORE_AUTO_BOUNDS,
                    zoomedDomainAxisRanges, zoomedRangeAxisRanges));
        } else {
            informLinkAndBrushSelectionListeners(new LinkAndBrushSelection(SelectionType.RESTORE_SELECTION,
                    zoomedDomainAxisRanges, zoomedRangeAxisRanges));
        }

    } else {
        restoreAutoDomainBounds();
        restoreAutoRangeBounds();
    }

    plot.setNotify(savedNotify);
}
项目:rapidminer    文件:JFreeChartPlotEngine.java   
/**
 * Creates a new {@link JFreeChart} using the plotConfiguration of this Plotter2D.
 */
private JFreeChart createChart() throws ChartPlottimeException {
    Plot plot = createPlot();

    if (plot == null) {
        throw new ChartPlottimeException("The plot created was a NULL plot.");
    }

    JFreeChart chart = new JFreeChart(plot);
    formatChart(chart);
    return chart;
}
项目:rapidminer    文件:JFreeChartPlotEngine.java   
private void setPlotBackgroundColor(Color backgroundColor) {
    JFreeChart chart = getCurrentChart();
    if (chart != null) {
        Plot plot = chart.getPlot();
        if (plot instanceof CategoryPlot) {
            CategoryPlot categoryPlot = (CategoryPlot) plot;
            categoryPlot.setBackgroundPaint(backgroundColor);
        } else {
            XYPlot xyPlot = (XYPlot) plot;
            xyPlot.setBackgroundPaint(backgroundColor);
        }
    }
}
项目:rapidminer    文件:JFreeChartPlotEngine.java   
private void plotOrientationChanged(PlotOrientation orientation) {
    JFreeChart chart = getCurrentChart();
    if (chart != null) {
        Plot plot = chart.getPlot();
        if (plot instanceof CategoryPlot) {
            CategoryPlot categoryPlot = (CategoryPlot) plot;
            categoryPlot.setOrientation(orientation);
        } else if (plot instanceof XYPlot) {
            XYPlot xyPlot = (XYPlot) plot;
            xyPlot.setOrientation(orientation);
        }
    }

}
项目:open-java-trade-manager    文件:ChartJDialog.java   
private void plotIndicatorOnChart(Double[] toPlot, String p, int k)
{
    final Plot main_plot = (Plot)((CombinedDomainXYPlot)this.candlestickChart.getPlot()).getSubplots().get(0);
    final XYPlot plot = (XYPlot) main_plot;

    plot.setDataset(k, createIndicatorPlot(p,toPlot));
    XYItemRenderer ir = new XYLineAndShapeRenderer(true,false);

    plot.setRenderer(k, ir);
}
项目:jfreechart-fx    文件:ScrollHandlerFX.java   
@Override
public void handleScroll(ChartCanvas canvas, ScrollEvent e) {
    JFreeChart chart = canvas.getChart();
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(canvas, zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation((int) e.getDeltaY());
    }
}
项目:parabuild-ci    文件:ChartPanel.java   
/**
 * Sets the chart that is displayed in the panel.
 *
 * @param chart  the chart (<code>null</code> permitted).
 */
public void setChart(JFreeChart chart) {

    // stop listening for changes to the existing chart
    if (this.chart != null) {
        this.chart.removeChangeListener(this);
        this.chart.removeProgressListener(this);
    }

    // add the new chart
    this.chart = chart;
    if (chart != null) {
        this.chart.addChangeListener(this);
        this.chart.addProgressListener(this);
        Plot plot = chart.getPlot();
        ValueAxis horizontalAxis = getHorizontalValueAxis(plot);
        this.horizontalZoom = this.horizontalZoom && (horizontalAxis != null);
        ValueAxis verticalAxis = getVerticalValueAxis(plot);
        this.verticalZoom = this.verticalZoom && (verticalAxis != null);
    }
    else {
        this.horizontalZoom = false;
        this.verticalZoom = false;
    }
    if (this.useBuffer) {
        this.refreshBuffer = true;
    }
    repaint();

}
项目:parabuild-ci    文件:AbstractXYItemRenderer.java   
/**
 * Draws a grid line against the range axis.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the value axis.
 * @param dataArea  the area for plotting data (not yet adjusted for any
 *                  3D effect).
 * @param value  the value at which the grid line should be drawn.
 */
public void drawDomainGridLine(Graphics2D g2,
                               XYPlot plot,
                               ValueAxis axis,
                               Rectangle2D dataArea,
                               double value) {

    Range range = axis.getRange();
    if (!range.contains(value)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    double v = axis.valueToJava2D(value, dataArea,
            plot.getDomainAxisEdge());
    Line2D line = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(dataArea.getMinX(), v,
                dataArea.getMaxX(), v);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(v, dataArea.getMinY(), v,
                dataArea.getMaxY());
    }

    Paint paint = plot.getDomainGridlinePaint();
    Stroke stroke = plot.getDomainGridlineStroke();
    g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);
    g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);
    g2.draw(line);

}
项目:parabuild-ci    文件:CategoryTextAnnotation.java   
/**
 * Draws the annotation.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 */
public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea,
                 CategoryAxis domainAxis, ValueAxis rangeAxis) {

    CategoryDataset dataset = plot.getDataset();
    int catIndex = dataset.getColumnIndex(this.category);
    int catCount = dataset.getColumnCount();

    float anchorX = 0.0f;
    float anchorY = 0.0f;
    PlotOrientation orientation = plot.getOrientation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
            plot.getDomainAxisLocation(), orientation);
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
            plot.getRangeAxisLocation(), orientation);

    if (orientation == PlotOrientation.HORIZONTAL) {
        anchorY = (float) domainAxis.getCategoryJava2DCoordinate(
                this.categoryAnchor, catIndex, catCount, dataArea, 
                domainEdge);
        anchorX = (float) rangeAxis.valueToJava2D(this.value, dataArea, 
                rangeEdge);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        anchorX = (float) domainAxis.getCategoryJava2DCoordinate(
                this.categoryAnchor, catIndex, catCount, dataArea, 
                domainEdge);
        anchorY = (float) rangeAxis.valueToJava2D(this.value, dataArea, 
                rangeEdge);
    }
    g2.setFont(getFont());
    g2.setPaint(getPaint());
    TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY,
            getTextAnchor(), getRotationAngle(), getRotationAnchor());

}
项目:parabuild-ci    文件:ChartPanel.java   
/**
 * Increases the range on the vertical axis, centered about a Java2D y coordinate.
 * <P>
 * The range on the y axis is doubled.
 *
 * @param y  the y coordinate in Java2D space.
 */
public void zoomOutVertical(double y) {
    Plot p = this.chart.getPlot();
    if (p instanceof ValueAxisPlot) {
        ValueAxisPlot plot = (ValueAxisPlot) p;
        plot.zoomVerticalAxes(this.zoomOutFactor);
    }
}
项目:parabuild-ci    文件:ChartPanel.java   
/**
 * Zooms in on a selected region.
 *
 * @param selection  the selected region.
 */
public void zoom(Rectangle2D selection) {

    double hLower = 0.0;
    double hUpper = 0.0;
    double vLower = 0.0;
    double vUpper = 0.0;

    if ((selection.getHeight() > 0) && (selection.getWidth() > 0)) {

        Rectangle2D scaledDataArea = getScaledDataArea();
        hLower = (selection.getMinX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        hUpper = (selection.getMaxX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        vLower = (scaledDataArea.getMaxY() - selection.getMaxY()) / scaledDataArea.getHeight();
        vUpper = (scaledDataArea.getMaxY() - selection.getMinY()) / scaledDataArea.getHeight();

        LOGGER.debug("hLower = " + hLower);
        LOGGER.debug("hUpper = " + hUpper);
        LOGGER.debug("vLower = " + vLower);
        LOGGER.debug("vUpper = " + vUpper);
        Plot p = this.chart.getPlot();
        if (p instanceof ValueAxisPlot) {
            ValueAxisPlot plot = (ValueAxisPlot) p;
            plot.zoomHorizontalAxes(hLower, hUpper);
            plot.zoomVerticalAxes(vLower, vUpper);
        }

    }

}
项目:parabuild-ci    文件:AbstractXYItemRenderer.java   
/**
 * Draws a grid line against the range axis.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the value axis.
 * @param dataArea  the area for plotting data (not yet adjusted for any 3D effect).
 * @param value  the value at which the grid line should be drawn.
 *
 */
public void drawRangeGridLine(Graphics2D g2,
                              XYPlot plot,
                              ValueAxis axis,
                              Rectangle2D dataArea,
                              double value) {

    Range range = axis.getRange();
    if (!range.contains(value)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    Line2D line = null;
    double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v);
    }

    Paint paint = plot.getRangeGridlinePaint();
    Stroke stroke = plot.getRangeGridlineStroke();
    g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);
    g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);
    g2.draw(line);

}
项目:parabuild-ci    文件:PolarChartPanel.java   
/**
 * Test that the chart is using an xy plot with time as the domain axis.
 * 
 * @param chart  the chart.
 */
private void checkChart(JFreeChart chart) {
    Plot plot = chart.getPlot();
    if (!(plot instanceof PolarPlot)) {
        throw new IllegalArgumentException("plot is not a PolarPlot");
   }
}
项目:parabuild-ci    文件:JFreeChart.java   
/**
 * Constructs a chart.
 * <P>
 * Note that the {@link ChartFactory} class contains static methods that will
 * return a ready-made chart.
 *
 * @param plot  controller of the visual representation of the data (<code>null</code> not
 *              permitted).
 */
public JFreeChart(Plot plot) {

    this(null, // title
         null, // font
         plot,
         false // create legend
    );

}
项目:parabuild-ci    文件:JFreeChart.java   
/**
 * Clones the object, and takes care of listeners.
 * Note: caller shall register its own listeners on cloned graph.
 * 
 * @return A clone.
 * 
 * @throws CloneNotSupportedException if the chart is not cloneable.
 */
public Object clone() throws CloneNotSupportedException {
    JFreeChart chart = (JFreeChart) super.clone();

    chart.renderingHints = (RenderingHints) this.renderingHints.clone();
    // private boolean borderVisible;
    // private transient Stroke borderStroke;
    // private transient Paint borderPaint;

    if (this.title != null) {
        chart.title = (TextTitle) this.title.clone();
        chart.title.addChangeListener(chart);
    }

    chart.subtitles = new ArrayList();
    for (int i = 0; i < getSubtitleCount(); i++) {
        Title subtitle = (Title) getSubtitle(i).clone();
        chart.subtitles.add(subtitle);
        subtitle.addChangeListener(chart);
    }

    if (this.plot != null) {
        chart.plot = (Plot) this.plot.clone();
        chart.plot.addChangeListener(chart);
    }

    chart.progressListeners = new EventListenerList();
    chart.changeListeners = new EventListenerList();
    return chart;
}