Search in sources :

Example 86 with ValueAxis

use of org.jfree.chart.axis.ValueAxis in project SIMVA-SoS by SESoS.

the class XYPlot method handleClick.

/**
 * Handles a 'click' on the plot by updating the anchor values.
 *
 * @param x  the x-coordinate, where the click occurred, in Java2D space.
 * @param y  the y-coordinate, where the click occurred, in Java2D space.
 * @param info  object containing information about the plot dimensions.
 */
@Override
public void handleClick(int x, int y, PlotRenderingInfo info) {
    Rectangle2D dataArea = info.getDataArea();
    if (dataArea.contains(x, y)) {
        // set the anchor value for the horizontal axis...
        ValueAxis xaxis = getDomainAxis();
        if (xaxis != null) {
            double hvalue = xaxis.java2DToValue(x, info.getDataArea(), getDomainAxisEdge());
            setDomainCrosshairValue(hvalue);
        }
        // set the anchor value for the vertical axis...
        ValueAxis yaxis = getRangeAxis();
        if (yaxis != null) {
            double vvalue = yaxis.java2DToValue(y, info.getDataArea(), getRangeAxisEdge());
            setRangeCrosshairValue(vvalue);
        }
    }
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis) Rectangle2D(java.awt.geom.Rectangle2D)

Example 87 with ValueAxis

use of org.jfree.chart.axis.ValueAxis in project SIMVA-SoS by SESoS.

the class XYPlot method clearRangeAxes.

/**
 * Clears the range axes from the plot and sends a {@link PlotChangeEvent}
 * to all registered listeners.
 *
 * @see #clearDomainAxes()
 */
public void clearRangeAxes() {
    for (ValueAxis axis : this.rangeAxes.values()) {
        if (axis != null) {
            axis.removeChangeListener(this);
        }
    }
    this.rangeAxes.clear();
    fireChangeEvent();
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis)

Example 88 with ValueAxis

use of org.jfree.chart.axis.ValueAxis in project SIMVA-SoS by SESoS.

the class XYPlot method drawRangeMarkers.

/**
 * Draws the range markers (if any) for a renderer 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 drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea, int index, Layer layer) {
    XYItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    // matter if the dataset is null)
    if (index >= getDatasetCount()) {
        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);
        }
    }
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis) Iterator(java.util.Iterator) LegendItemCollection(org.jfree.chart.LegendItemCollection) Collection(java.util.Collection) AxisCollection(org.jfree.chart.axis.AxisCollection) AbstractXYItemRenderer(org.jfree.chart.renderer.xy.AbstractXYItemRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer)

Example 89 with ValueAxis

use of org.jfree.chart.axis.ValueAxis in project SIMVA-SoS by SESoS.

the class XYPlot method calculateRangeAxisSpace.

/**
 * Calculates the space required for the range axis/axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param space  a carrier for the result (<code>null</code> permitted).
 *
 * @return The required space.
 */
protected AxisSpace calculateRangeAxisSpace(Graphics2D g2, Rectangle2D plotArea, AxisSpace space) {
    if (space == null) {
        space = new AxisSpace();
    }
    // reserve some space for the range axis...
    if (this.fixedRangeAxisSpace != null) {
        if (this.orientation == PlotOrientation.HORIZONTAL) {
            space.ensureAtLeast(this.fixedRangeAxisSpace.getTop(), RectangleEdge.TOP);
            space.ensureAtLeast(this.fixedRangeAxisSpace.getBottom(), RectangleEdge.BOTTOM);
        } else if (this.orientation == PlotOrientation.VERTICAL) {
            space.ensureAtLeast(this.fixedRangeAxisSpace.getLeft(), RectangleEdge.LEFT);
            space.ensureAtLeast(this.fixedRangeAxisSpace.getRight(), RectangleEdge.RIGHT);
        }
    } else {
        // reserve space for the range axes...
        for (ValueAxis axis : this.rangeAxes.values()) {
            if (axis != null) {
                RectangleEdge edge = getRangeAxisEdge(findRangeAxisIndex(axis));
                space = axis.reserveSpace(g2, this, plotArea, edge, space);
            }
        }
    }
    return space;
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis) AxisSpace(org.jfree.chart.axis.AxisSpace) RectangleEdge(org.jfree.ui.RectangleEdge)

Example 90 with ValueAxis

use of org.jfree.chart.axis.ValueAxis in project SIMVA-SoS by SESoS.

the class XYPlot method zoomRangeAxes.

/**
 * Multiplies the range on the range axis/axes by the specified factor.
 *
 * @param factor  the zoom factor.
 * @param info  the plot rendering info.
 * @param source  the source point.
 * @param useAnchor  a flag that controls whether or not the source point
 *         is used for the zoom anchor.
 *
 * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)
 *
 * @since 1.0.7
 */
@Override
public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor) {
    // perform the zoom on each range axis
    for (ValueAxis yAxis : this.rangeAxes.values()) {
        if (yAxis == null) {
            continue;
        }
        if (useAnchor) {
            // get the relevant source coordinate given the plot orientation
            double sourceY = source.getY();
            if (this.orientation == PlotOrientation.HORIZONTAL) {
                sourceY = source.getX();
            }
            double anchorY = yAxis.java2DToValue(sourceY, info.getDataArea(), getRangeAxisEdge());
            yAxis.resizeRange2(factor, anchorY);
        } else {
            yAxis.resizeRange(factor);
        }
    }
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis)

Aggregations

ValueAxis (org.jfree.chart.axis.ValueAxis)216 XYPlot (org.jfree.chart.plot.XYPlot)77 NumberAxis (org.jfree.chart.axis.NumberAxis)50 Range (org.jfree.data.Range)40 JFreeChart (org.jfree.chart.JFreeChart)39 CategoryPlot (org.jfree.chart.plot.CategoryPlot)35 Paint (java.awt.Paint)31 CategoryAxis (org.jfree.chart.axis.CategoryAxis)30 Rectangle2D (java.awt.geom.Rectangle2D)28 CombinedDomainXYPlot (org.jfree.chart.plot.CombinedDomainXYPlot)25 Test (org.junit.Test)24 CombinedRangeXYPlot (org.jfree.chart.plot.CombinedRangeXYPlot)22 XYDataset (org.jfree.data.xy.XYDataset)22 Iterator (java.util.Iterator)20 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)18 CategoryDataset (org.jfree.data.category.CategoryDataset)17 RectangleEdge (org.jfree.ui.RectangleEdge)16 Font (java.awt.Font)14 XYSeries (org.jfree.data.xy.XYSeries)14 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)14