Java 类org.jfree.chart.axis.ValueAxis 实例源码

项目:parabuild-ci    文件:ValueAxisTests.java   
/**
 * Tests the the lower and upper margin settings produce the expected results.
 */
public void testAxisMargins() {
    XYSeries series = new XYSeries("S1");
    series.add(100.0, 1.1);
    series.add(200.0, 2.2);
    XYSeriesCollection dataset = new XYSeriesCollection(series);
    dataset.setIntervalWidth(0.0);
    JFreeChart chart = ChartFactory.createScatterPlot(
        "Title", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false
    );
    ValueAxis domainAxis = chart.getXYPlot().getDomainAxis();
    Range r = domainAxis.getRange();
    assertTrue(NumberUtils.equal(110.0, r.getLength()));
    domainAxis.setLowerMargin(0.10);
    domainAxis.setUpperMargin(0.10);
    r = domainAxis.getRange();
    assertTrue(NumberUtils.equal(120.0, r.getLength()));
}
项目:parabuild-ci    文件:LayeredBarRenderer.java   
/**
 * Draws the bar for one item in the dataset.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the plot area.
 * @param plot  the plot.
 * @param domainAxis  the domain (category) axis.
 * @param rangeAxis  the range (value) axis.
 * @param data  the data.
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 * @param pass  the pass index.
 */
public void drawItem(Graphics2D g2,
                     CategoryItemRendererState state,
                     Rectangle2D dataArea,
                     CategoryPlot plot,
                     CategoryAxis domainAxis,
                     ValueAxis rangeAxis,
                     CategoryDataset data,
                     int row,
                     int column,
                     int pass) {

    PlotOrientation orientation = plot.getOrientation();
    if (orientation == PlotOrientation.HORIZONTAL) {
        drawHorizontalItem(g2, state, dataArea, plot, domainAxis, rangeAxis, 
            data, row, column);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        drawVerticalItem(g2, state, dataArea, plot, domainAxis, rangeAxis, 
            data, row, column);
    }

}
项目:parabuild-ci    文件:CategoryPlot.java   
/**
 * Receives notification of a change to the plot's dataset.
 * <P>
 * The range axis bounds will be recalculated if necessary.
 *
 * @param event  information about the event (not used here).
 */
public void datasetChanged(DatasetChangeEvent event) {

    int count = this.rangeAxes.size();
    for (int axisIndex = 0; axisIndex < count; axisIndex++) {
        ValueAxis yAxis = getRangeAxis(axisIndex);
        if (yAxis != null) {
            yAxis.configure();
        }
    }
    if (getParent() != null) {
        getParent().datasetChanged(event);
    }
    else {
        PlotChangeEvent e = new PlotChangeEvent(this);
        notifyListeners(e);
    }

}
项目:parabuild-ci    文件:XYPlot.java   
/**
 * Returns the domain axis for a dataset.
 *
 * @param index  the dataset index.
 *
 * @return The axis.
 */
public ValueAxis getDomainAxisForDataset(int index) {

    if (index < 0 || index >= getDatasetCount()) {
        throw new IllegalArgumentException("Index 'index' out of bounds.");
    }

    ValueAxis valueAxis = null;
    Integer axisIndex = (Integer) this.datasetToDomainAxisMap.get(
            new Integer(index));
    if (axisIndex != null) {
        valueAxis = getDomainAxis(axisIndex.intValue());
    }
    else {
        valueAxis = getDomainAxis(0);
    }
    return valueAxis;

}
项目:parabuild-ci    文件:XYPlot.java   
/**
 * Sets a domain axis and, if requested, sends a {@link PlotChangeEvent} to
 * all registered listeners.
 *
 * @param index  the axis index.
 * @param axis  the axis.
 * @param notify  notify listeners?
 * 
 * @see #getDomainAxis(int)
 */
public void setDomainAxis(int index, ValueAxis axis, boolean notify) {
    ValueAxis existing = getDomainAxis(index);
    if (existing != null) {
        existing.removeChangeListener(this);
    }
    if (axis != null) {
        axis.setPlot(this);
    }
    this.domainAxes.set(index, axis);
    if (axis != null) {
        axis.configure();
        axis.addChangeListener(this);
    }
    if (notify) {
        notifyListeners(new PlotChangeEvent(this));
    }
}
项目:parabuild-ci    文件:ThermometerPlot.java   
/**
 * Sets the range axis for the plot.
 *
 * @param axis  the new axis.
 */
public void setRangeAxis(ValueAxis axis) {

    if (axis != null) {
        axis.setPlot(this);
        axis.addChangeListener(this);
    }

    // plot is likely registered as a listener with the existing axis...
    if (this.rangeAxis != null) {
        this.rangeAxis.removeChangeListener(this);
    }

    this.rangeAxis = axis;

}
项目:parabuild-ci    文件:ThermometerPlot.java   
/**
 * Sets the range axis for the plot.
 * <P>
 * An exception is thrown if the new axis and the plot are not mutually compatible.
 *
 * @param axis  the new axis.
 */
public void setRangeAxis(ValueAxis axis) {

  if (axis != null) {
    axis.setPlot(this);
    axis.addChangeListener(this);
  }

  // plot is likely registered as a listener with the existing axis...
  if (this.rangeAxis != null) {
    this.rangeAxis.removeChangeListener(this);
  }

  this.rangeAxis = axis;

}
项目:parabuild-ci    文件:ContourPlot.java   
/**
 * Returns the range for an axis.
 *
 * @param axis  the axis.
 *
 * @return The range for an axis.
 */
public Range getDataRange(ValueAxis axis) {

    if (this.dataset == null) {
        return null;
    }

    Range result = null;

    if (axis == getDomainAxis()) {
        result = DatasetUtilities.findDomainExtent(this.dataset);
    }
    else if (axis == getRangeAxis()) {
        result = DatasetUtilities.findRangeExtent(this.dataset);
    }

    return result;

}
项目:parabuild-ci    文件:CategoryPlot.java   
/**
 * Draws a range crosshair.
 * 
 * @param g2  the graphics target.
 * @param dataArea  the data area.
 * @param orientation  the plot orientation.
 * @param value  the crosshair value.
 * @param axis  the axis against which the value is measured.
 * @param stroke  the stroke used to draw the crosshair line.
 * @param paint  the paint used to draw the crosshair line.
 * 
 * @since 1.0.5
 */
protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, 
        PlotOrientation orientation, double value, ValueAxis axis, 
        Stroke stroke, Paint paint) {

    if (!axis.getRange().contains(value)) {
        return;
    }
    Line2D line = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        double xx = axis.valueToJava2D(value, dataArea, 
                RectangleEdge.BOTTOM);
        line = new Line2D.Double(xx, dataArea.getMinY(), xx, 
                dataArea.getMaxY());
    }
    else {
        double yy = axis.valueToJava2D(value, dataArea, 
                RectangleEdge.LEFT);
        line = new Line2D.Double(dataArea.getMinX(), yy, 
                dataArea.getMaxX(), yy);
    }
    g2.setStroke(stroke);
    g2.setPaint(paint);
    g2.draw(line);

}
项目:parabuild-ci    文件:XYPlot.java   
/**
 * Draws the range tick bands, if any.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param ticks  the ticks.
 */
public void drawRangeTickBands(Graphics2D g2, Rectangle2D dataArea, List ticks) {

    // draw the range tick bands, if any...
    Paint bandPaint = getRangeTickBandPaint();
    if (bandPaint != null) {
        boolean fillBand = false;
        final ValueAxis axis = getRangeAxis();
        double previous = axis.getLowerBound();
        Iterator iterator = ticks.iterator();
        while (iterator.hasNext()) {
            ValueTick tick = (ValueTick) iterator.next();
            double current = tick.getValue();
            if (fillBand) {
                getRenderer().fillRangeGridBand(g2, this, axis, dataArea, previous, current);
            }
            previous = current;
            fillBand = !fillBand;
        }
        double end = axis.getUpperBound();
        if (fillBand) {
            getRenderer().fillRangeGridBand(g2, this, axis, dataArea, previous, end);
        }
    }
}
项目:parabuild-ci    文件:XYPlot.java   
/**
 * Sets a range axis and, if requested, sends a {@link PlotChangeEvent} to 
 * all registered listeners.
 *
 * @param index  the axis index.
 * @param axis  the axis (<code>null</code> permitted).
 * @param notify  notify listeners?
 * 
 * @see #getRangeAxis(int)
 */
public void setRangeAxis(int index, ValueAxis axis, boolean notify) {
    ValueAxis existing = getRangeAxis(index);
    if (existing != null) {
        existing.removeChangeListener(this);
    }
    if (axis != null) {
        axis.setPlot(this);
    }
    this.rangeAxes.set(index, axis);
    if (axis != null) {
        axis.configure();
        axis.addChangeListener(this);
    }
    if (notify) {
        notifyListeners(new PlotChangeEvent(this));
    }
}
项目:parabuild-ci    文件:AbstractXYItemRenderer.java   
/**
 * Fills a band between two values on the axis.  This can be used to color
 * bands between the grid lines.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the domain axis.
 * @param dataArea  the data area.
 * @param start  the start value.
 * @param end  the end value.
 */
public void fillDomainGridBand(Graphics2D g2,
                               XYPlot plot,
                               ValueAxis axis,
                               Rectangle2D dataArea,
                               double start, double end) {

    double x1 = axis.valueToJava2D(start, dataArea,
            plot.getDomainAxisEdge());
    double x2 = axis.valueToJava2D(end, dataArea,
            plot.getDomainAxisEdge());
    // TODO: need to change the next line to take account of plot
    //       orientation...
    Rectangle2D band = new Rectangle2D.Double(x1, dataArea.getMinY(),
            x2 - x1, dataArea.getMaxY() - dataArea.getMinY());
    Paint paint = plot.getDomainTickBandPaint();

    if (paint != null) {
        g2.setPaint(paint);
        g2.fill(band);
    }

}
项目:parabuild-ci    文件:StackedBarChartTests.java   
/**
 * Replaces the dataset and checks that it has changed as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-30), new Integer(-20)},
         {new Integer(-10), new Integer(10)},
         {new Integer(20), new Integer(30)}};

    CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", 
            "C", data);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    plot.setDataset(newData);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around -30: "
                + range.getLowerBound(), range.getLowerBound() <= -30);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
项目:parabuild-ci    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code> 
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code> 
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
                                                String timeAxisLabel,
                                                String valueAxisLabel,
                                                OHLCDataset dataset,
                                                boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    return chart;

}
项目:parabuild-ci    文件:XYPlot.java   
/**
 * Draws a range crosshair.
 * 
 * @param g2  the graphics target.
 * @param dataArea  the data area.
 * @param orientation  the plot orientation.
 * @param value  the crosshair value.
 * @param axis  the axis against which the value is measured.
 * @param stroke  the stroke used to draw the crosshair line.
 * @param paint  the paint used to draw the crosshair line.
 * 
 * @since 1.0.4
 */
protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, 
        PlotOrientation orientation, double value, ValueAxis axis, 
        Stroke stroke, Paint paint) {

    if (axis.getRange().contains(value)) {
        Line2D line = null;
        if (orientation == PlotOrientation.HORIZONTAL) {
            double xx = axis.valueToJava2D(value, dataArea, 
                    RectangleEdge.BOTTOM);
            line = new Line2D.Double(xx, dataArea.getMinY(), xx, 
                    dataArea.getMaxY());
        }
        else {
            double yy = axis.valueToJava2D(value, dataArea, 
                    RectangleEdge.LEFT);
            line = new Line2D.Double(dataArea.getMinX(), yy, 
                    dataArea.getMaxX(), yy);
        }
        g2.setStroke(stroke);
        g2.setPaint(paint);
        g2.draw(line);
    }

}
项目:parabuild-ci    文件:ContourPlot.java   
/**
 * Sets the domain axis for the plot (this must be compatible with the plot
 * type or an exception is thrown).
 *
 * @param axis The new axis.
 */
public void setDomainAxis(ValueAxis axis) {

    if (isCompatibleDomainAxis(axis)) {

        if (axis != null) {
            axis.setPlot(this);
            axis.addChangeListener(this);
        }

        // plot is likely registered as a listener with the existing axis...
        if (this.domainAxis != null) {
            this.domainAxis.removeChangeListener(this);
        }

        this.domainAxis = axis;
        notifyListeners(new PlotChangeEvent(this));

    }

}
项目:parabuild-ci    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a high-low-open-close chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code> permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return a high-low-open-close chart.
 */
public static JFreeChart createHighLowChart(String title,
                                            String timeAxisLabel,
                                            String valueAxisLabel,
                                            OHLCDataset dataset,
                                            boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    HighLowRenderer renderer = new HighLowRenderer();
    renderer.setToolTipGenerator(new HighLowItemLabelGenerator());
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

    return chart;

}
项目:parabuild-ci    文件:XYPlot.java   
/**
 * Draws the domain markers (if any) for an axis and layer.  This method is 
 * typically called from within the draw(...) method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the renderer index.
 * @param layer  the layer (foreground or background).
 */
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea, int index, 
                                 Layer layer) {

    XYItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }

    Collection markers = getDomainMarkers(index, layer);
    ValueAxis axis = getDomainAxis(index);
    // TODO: get the axis that the renderer maps to
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawDomainMarker(g2, this, axis, marker, dataArea);
        }
    }

}
项目:parabuild-ci    文件:AbstractXYItemRenderer.java   
/**
 * Draws all the annotations for the specified layer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param layer  the layer.
 * @param info  the plot rendering info.
 */
public void drawAnnotations(Graphics2D g2,
                            Rectangle2D dataArea,
                            ValueAxis domainAxis,
                            ValueAxis rangeAxis,
                            Layer layer,
                            PlotRenderingInfo info) {

    Iterator iterator = null;
    if (layer.equals(Layer.FOREGROUND)) {
        iterator = this.foregroundAnnotations.iterator();
    }
    else if (layer.equals(Layer.BACKGROUND)) {
        iterator = this.backgroundAnnotations.iterator();
    }
    else {
        // should not get here
        throw new RuntimeException("Unknown layer.");
    }
    while (iterator.hasNext()) {
        XYAnnotation annotation = (XYAnnotation) iterator.next();
        annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis,
                0, info);
    }

}
项目: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);
    }

}
项目:ojAlgo-extensions    文件:JFreeChartBuilder.java   
@SuppressWarnings("unchecked")
protected final <A extends ValueAxis> A makeValueAxis(final JFreeChartBuilder.AxisParameters parameters) {

    final A retVal = (A) new NumberAxis(parameters.getLabel());

    if (parameters.isIntervalSet()) {
        retVal.setAutoRange(false);
        retVal.setRange(parameters.getInterval());
    } else {
        retVal.setAutoRange(true);
    }
    ((NumberAxis) retVal).setNumberFormatOverride(parameters.getFormat());

    return retVal;

}
项目:parabuild-ci    文件:XYDifferenceRenderer.java   
/**
 * Draws the visual representation of a single data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the data is being drawn.
 * @param info  collects information about the drawing.
 * @param plot  the plot (can be used to obtain standard color 
 *              information etc).
 * @param domainAxis  the domain (horizontal) axis.
 * @param rangeAxis  the range (vertical) axis.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param crosshairState  crosshair information for the plot 
 *                        (<code>null</code> permitted).
 * @param pass  the pass index.
 */
public void drawItem(Graphics2D g2,
                     XYItemRendererState state,
                     Rectangle2D dataArea,
                     PlotRenderingInfo info,
                     XYPlot plot,
                     ValueAxis domainAxis,
                     ValueAxis rangeAxis,
                     XYDataset dataset,
                     int series,
                     int item,
                     CrosshairState crosshairState,
                     int pass) {

    if (pass == 0) {
        drawItemPass0(g2, dataArea, info, plot, domainAxis, rangeAxis, 
                dataset, series, item, crosshairState);
    }
    else if (pass == 1) {
        drawItemPass1(g2, dataArea, info, plot, domainAxis, rangeAxis, 
                dataset, series, item, crosshairState);
    }

}
项目:parabuild-ci    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a box and whisker chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code> 
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code> 
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A box and whisker chart.
 */
public static JFreeChart createBoxAndWhiskerChart(String title,
                                             String timeAxisLabel,
                                             String valueAxisLabel,
                                             BoxAndWhiskerXYDataset dataset,
                                             boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);
    XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
            legend);

}
项目:parabuild-ci    文件:CategoryPlot.java   
/**
 * Draws the range markers (if any) for an axis and layer.  This method is 
 * typically called from within the draw() method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the renderer index.
 * @param layer  the layer (foreground or background).
 * 
 * @see #drawDomainMarkers(Graphics2D, Rectangle2D, int, Layer)
 */
protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea, 
                                int index, Layer layer) {

    CategoryItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }

    Collection markers = getRangeMarkers(index, layer);
    ValueAxis axis = getRangeAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawRangeMarker(g2, this, axis, marker, dataArea);
        }
    }

}
项目:parabuild-ci    文件:IntervalBarRenderer.java   
/**
 * Draws the bar for a single (series, category) data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the data area.
 * @param plot  the plot.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataset  the dataset.
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 */
public void drawItem(Graphics2D g2,
                     CategoryItemRendererState state,
                     Rectangle2D dataArea,
                     CategoryPlot plot,
                     CategoryAxis domainAxis,
                     ValueAxis rangeAxis,
                     CategoryDataset dataset,
                     int row,
                     int column) {

     if (dataset instanceof IntervalCategoryDataset) {
         IntervalCategoryDataset d = (IntervalCategoryDataset) dataset;
         drawInterval(g2, state, dataArea, plot, domainAxis, rangeAxis, d, row, column);
     }
     else {
         super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column);
     } 

 }
项目:parabuild-ci    文件:AbstractXYItemRenderer.java   
/**
 * Fills a band between two values on the range axis.  This can be used to
 * color bands between the grid lines.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the range axis.
 * @param dataArea  the data area.
 * @param start  the start value.
 * @param end  the end value.
 */
public void fillRangeGridBand(Graphics2D g2,
                              XYPlot plot,
                              ValueAxis axis,
                              Rectangle2D dataArea,
                              double start, double end) {

    double y1 = axis.valueToJava2D(start, dataArea,
            plot.getRangeAxisEdge());
    double y2 = axis.valueToJava2D(end, dataArea, plot.getRangeAxisEdge());
    // TODO: need to change the next line to take account of the plot
    //       orientation
    Rectangle2D band = new Rectangle2D.Double(dataArea.getMinX(), y2,
            dataArea.getWidth(), y1 - y2);
    Paint paint = plot.getRangeTickBandPaint();

    if (paint != null) {
        g2.setPaint(paint);
        g2.fill(band);
    }

}
项目:parabuild-ci    文件:XYPlot.java   
/**
 * Sets the range axis for the plot and sends a {@link PlotChangeEvent} to all registered
 * listeners.
 *
 * @param axis  the axis (<code>null</code> permitted).
 *
 */
public void setRangeAxis(ValueAxis axis)  {

    if (axis != null) {
        axis.setPlot(this);
    }

    // plot is likely registered as a listener with the existing axis...
    ValueAxis existing = getRangeAxis();
    if (existing != null) {
        existing.removeChangeListener(this);
    }

    this.rangeAxes.set(0, axis);
    if (axis != null) {
        axis.configure();
        axis.addChangeListener(this);
    }
    notifyListeners(new PlotChangeEvent(this));

}
项目:parabuild-ci    文件:TimeSeriesChartTests.java   
/**
 * Replaces the dataset and checks that it has changed as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(10.0, 10.0);
    series1.add(20.0, 20.0);
    series1.add(30.0, 30.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    XYPlot plot = (XYPlot) this.chart.getPlot();
    plot.setDataset(dataset);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around 10: "
               + range.getLowerBound(), range.getLowerBound() <= 10);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
项目:parabuild-ci    文件:XYLineChartTests.java   
/**
 * Replaces the dataset and checks that it has changed as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(10.0, 10.0);
    series1.add(20.0, 20.0);
    series1.add(30.0, 30.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    XYPlot plot = (XYPlot) this.chart.getPlot();
    plot.setDataset(dataset);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around 10: "
               + range.getLowerBound(), range.getLowerBound() <= 10);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
项目:parabuild-ci    文件:ValueAxisTests.java   
/**
 * Tests the the lower and upper margin settings produce the expected 
 * results.
 */
public void testAxisMargins() {
    XYSeries series = new XYSeries("S1");
    series.add(100.0, 1.1);
    series.add(200.0, 2.2);
    XYSeriesCollection dataset = new XYSeriesCollection(series);
    dataset.setIntervalWidth(0.0);
    JFreeChart chart = ChartFactory.createScatterPlot(
        "Title", "X", "Y", dataset, PlotOrientation.VERTICAL, 
        false, false, false
    );
    ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis();
    Range r = domainAxis.getRange();
    assertEquals(110.0, r.getLength(), EPSILON);
    domainAxis.setLowerMargin(0.10);
    domainAxis.setUpperMargin(0.10);
    r = domainAxis.getRange();
    assertEquals(120.0, r.getLength(), EPSILON);
}
项目:parabuild-ci    文件:CombinedRangeXYPlot.java   
/**
 * Returns a clone of the plot.
 * 
 * @return A clone.
 * 
 * @throws CloneNotSupportedException  this class will not throw this exception, but subclasses
 *         (if any) might.
 */
public Object clone() throws CloneNotSupportedException {

    CombinedRangeXYPlot result = (CombinedRangeXYPlot) super.clone(); 
    result.subplots = ObjectUtils.clone(this.subplots);
    for (Iterator it = result.subplots.iterator(); it.hasNext();) {
        Plot child = (Plot) it.next();
        child.setParent(result);
    }

    // after setting up all the subplots, the shared range axis may need reconfiguring
    ValueAxis rangeAxis = result.getRangeAxis();
    if (rangeAxis != null) {
        rangeAxis.configure();
    }

    return result;
}
项目:iveely.ml    文件:ChartUtils.java   
public static void setYAixs(CategoryPlot plot) {
    Color lineColor = new Color(192, 208, 224);
    ValueAxis axis = plot.getRangeAxis();
    axis.setAxisLinePaint(lineColor);
    axis.setTickMarkPaint(lineColor);
    axis.setAxisLineVisible(false);
    axis.setTickMarksVisible(false);
    plot.setRangeGridlinePaint(new Color(192, 192, 192));
    plot.setRangeGridlineStroke(new BasicStroke(1));

    plot.getRangeAxis().setUpperMargin(0.1);
    plot.getRangeAxis().setLowerMargin(0.1);

}
项目:NystagmusJava    文件:WaveChart.java   
private JFreeChart createChart(String chartContent, String title, String yaxisName){
    //创建时序图对象
    XYSeries = new XYSeries(chartContent);
    XYSeriesCollection xySeriesCollection=new XYSeriesCollection(XYSeries);

    // 设置中文主题样式 解决乱码
    StandardChartTheme chartTheme = new StandardChartTheme("CN");
    // 设置标题字体
    chartTheme.setExtraLargeFont(font);
    // 设置图例的字体
    chartTheme.setRegularFont(font);
    // 设置轴向的字体
    chartTheme.setLargeFont(font);
    chartTheme.setSmallFont(font);

    ChartFactory.setChartTheme(chartTheme);

    JFreeChart jfreechart = ChartFactory.createXYLineChart(title,"帧数",yaxisName,xySeriesCollection);
    XYPlot xyplot = jfreechart.getXYPlot();
    //纵坐标设定
    ValueAxis valueaxis = xyplot.getDomainAxis();
    //自动设置数据轴数据范围
    valueaxis.setAutoRange(true);
    //数据轴固定数据范围 30s
    //valueaxis.setFixedAutoRange(100);

    valueaxis = xyplot.getRangeAxis();

    return jfreechart;
}
项目:rapidminer    文件:ChartPanelShiftController.java   
@Override
public void mouseDragged(MouseEvent mouseEvent) {
    if (!mouseEvent.isControlDown()) {
        return;
    }

    if (oldx > -1 && oldy > -1) {
        int xdif = mouseEvent.getX() - oldx;
        int ydif = mouseEvent.getY() - oldy;

        final Rectangle2D scaledDataArea = chartPanel.getScreenDataArea();

        ValueAxis[] domAxes = getPlotAxis(chartPanel.getChart(), !axesSwaped);
        if (domAxes != null) {
            double[] xDelta = new double[domAxes.length];
            for (int i = 0; i < domAxes.length; i++) {
                xDelta[i] = xdif * domAxes[i].getRange().getLength() / (scaledDataArea.getWidth());
            }
            for (int i = 0; i < domAxes.length; i++) {
                domAxes[i].setRange(domAxes[i].getLowerBound() - xDelta[i], domAxes[i].getUpperBound() - xDelta[i]);
            }
        }

        ValueAxis[] rngAxes = getPlotAxis(chartPanel.getChart(), axesSwaped);
        if (rngAxes != null) {
            double[] yDelta = new double[rngAxes.length];
            for (int i = 0; i < rngAxes.length; i++) {
                yDelta[i] = ydif * rngAxes[i].getRange().getLength() / (scaledDataArea.getHeight());
            }
            if (!onlyXShift) {
                for (int i = 0; i < rngAxes.length; i++) {
                    rngAxes[i].setRange(rngAxes[i].getLowerBound() + yDelta[i], rngAxes[i].getUpperBound() + yDelta[i]);
                }
            }
        }
    }

    oldx = mouseEvent.getX();
    oldy = mouseEvent.getY();
}
项目:parabuild-ci    文件:XYPlot.java   
/**
 * Returns the range axis for a dataset.
 * 
 * @param index  the dataset index.
 * 
 * @return The axis 
 */
public ValueAxis getRangeAxisForDataset(int index) {

    if (index >= getDatasetCount()) {
        throw new IllegalArgumentException(); 
    }

    ValueAxis valueAxis = null;
    Integer axisIndex = (Integer) this.rangeAxisMap.get(index);
    valueAxis = getRangeAxis(axisIndex.intValue());
    return valueAxis;

}
项目:parabuild-ci    文件:ClipPath.java   
/**
 * Draws the clip path.
 *
 * @param g2  current graphics2D.
 * @param dataArea  the dataArea that the plot is being draw in.
 * @param horizontalAxis  the horizontal axis.
 * @param verticalAxis  the vertical axis.
 *
 * @return the GeneralPath defining the outline
 */
public GeneralPath draw(Graphics2D g2,
                        Rectangle2D dataArea,
                        ValueAxis horizontalAxis, ValueAxis verticalAxis) {

    GeneralPath generalPath = generateClipPath(dataArea, horizontalAxis, verticalAxis);
    if (this.fillPath || this.drawPath) {
        Composite saveComposite = g2.getComposite();
        Paint savePaint = g2.getPaint();
        Stroke saveStroke = g2.getStroke();

        if (this.fillPaint != null) {
            g2.setPaint(this.fillPaint);
        }
        if (this.composite != null) {
            g2.setComposite(this.composite);
        }
        if (this.fillPath) {
            g2.fill(generalPath);
        }

        if (this.drawStroke != null) {
            g2.setStroke(this.drawStroke);
        }
        if (this.drawPath) {
            g2.draw(generalPath);
        }
        g2.setPaint(savePaint);
        g2.setComposite(saveComposite);
        g2.setStroke(saveStroke);
    }
    return generalPath;

}
项目: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);
    }
}
项目:parabuild-ci    文件:CategoryPlot.java   
/**
 * Configures the range axes.
 */
public void configureRangeAxes() {
    for (int i = 0; i < this.rangeAxes.size(); i++) {
        ValueAxis axis = (ValueAxis) this.rangeAxes.get(i);
        if (axis != null) {
            axis.configure();
        }
    }
}
项目:parabuild-ci    文件:XYPlot.java   
/**
 * Multiplies the range on the domain axis/axes by the specified factor.
 *
 * @param factor  the zoom factor.
 * @param info  the plot rendering info.
 * @param source  the source point.
 */
public void zoomDomainAxes(double factor, PlotRenderingInfo info,
                           Point2D source) {
    for (int i = 0; i < this.domainAxes.size(); i++) {
        ValueAxis domainAxis = (ValueAxis) this.domainAxes.get(i);
        if (domainAxis != null) {
            domainAxis.resizeRange(factor);
        }
    }
}