Search in sources :

Example 1 with AxisSpace

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

the class CategoryPlotTest method testCloning2.

/**
 * Some more cloning checks.
 */
@Test
public void testCloning2() {
    AxisSpace da1 = new AxisSpace();
    AxisSpace ra1 = new AxisSpace();
    CategoryPlot p1 = new CategoryPlot();
    p1.setFixedDomainAxisSpace(da1);
    p1.setFixedRangeAxisSpace(ra1);
    CategoryPlot p2;
    try {
        p2 = (CategoryPlot) p1.clone();
    } catch (CloneNotSupportedException e) {
        fail("Cloning failed.");
        return;
    }
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
    da1.setBottom(99.0);
    assertFalse(p1.equals(p2));
    p2.getFixedDomainAxisSpace().setBottom(99.0);
    assertTrue(p1.equals(p2));
    ra1.setBottom(11.0);
    assertFalse(p1.equals(p2));
    p2.getFixedRangeAxisSpace().setBottom(11.0);
    assertTrue(p1.equals(p2));
}
Also used : AxisSpace(org.jfree.chart.axis.AxisSpace) Test(org.junit.Test)

Example 2 with AxisSpace

use of org.jfree.chart.axis.AxisSpace 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 3 with AxisSpace

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

the class CategoryPlot method calculateDomainAxisSpace.

/**
 * Calculates the space required for the domain 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 calculateDomainAxisSpace(Graphics2D g2, Rectangle2D plotArea, AxisSpace space) {
    if (space == null) {
        space = new AxisSpace();
    }
    // reserve some space for the domain axis...
    if (this.fixedDomainAxisSpace != null) {
        if (this.orientation.isHorizontal()) {
            space.ensureAtLeast(this.fixedDomainAxisSpace.getLeft(), RectangleEdge.LEFT);
            space.ensureAtLeast(this.fixedDomainAxisSpace.getRight(), RectangleEdge.RIGHT);
        } else if (this.orientation.isVertical()) {
            space.ensureAtLeast(this.fixedDomainAxisSpace.getTop(), RectangleEdge.TOP);
            space.ensureAtLeast(this.fixedDomainAxisSpace.getBottom(), RectangleEdge.BOTTOM);
        }
    } else {
        // reserve space for the primary domain axis...
        RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(getDomainAxisLocation(), this.orientation);
        if (this.drawSharedDomainAxis) {
            space = getDomainAxis().reserveSpace(g2, this, plotArea, domainEdge, space);
        }
        // reserve space for any domain axes...
        for (CategoryAxis xAxis : this.domainAxes.values()) {
            if (xAxis != null) {
                int i = getDomainAxisIndex(xAxis);
                RectangleEdge edge = getDomainAxisEdge(i);
                space = xAxis.reserveSpace(g2, this, plotArea, edge, space);
            }
        }
    }
    return space;
}
Also used : CategoryAxis(org.jfree.chart.axis.CategoryAxis) AxisSpace(org.jfree.chart.axis.AxisSpace) Paint(java.awt.Paint) RectangleEdge(org.jfree.ui.RectangleEdge)

Example 4 with AxisSpace

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

the class CombinedDomainXYPlot method draw.

/**
 * Draws the plot within the specified area on a graphics device.
 *
 * @param g2  the graphics device.
 * @param area  the plot area (in Java2D space).
 * @param anchor  an anchor point in Java2D space (<code>null</code>
 *                permitted).
 * @param parentState  the state from the parent plot, if there is one
 *                     (<code>null</code> permitted).
 * @param info  collects chart drawing information (<code>null</code>
 *              permitted).
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) {
    // set up info collection...
    if (info != null) {
        info.setPlotArea(area);
    }
    // adjust the drawing area for plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);
    setFixedRangeAxisSpaceForSubplots(null);
    AxisSpace space = calculateAxisSpace(g2, area);
    Rectangle2D dataArea = space.shrink(area, null);
    // set the width and height of non-shared axis of all sub-plots
    setFixedRangeAxisSpaceForSubplots(space);
    // draw the shared axis
    ValueAxis axis = getDomainAxis();
    RectangleEdge edge = getDomainAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, edge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info);
    if (parentState == null) {
        parentState = new PlotState();
    }
    parentState.getSharedAxisStates().put(axis, axisState);
    // draw all the subplots
    for (int i = 0; i < this.subplots.size(); i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);
        PlotRenderingInfo subplotInfo = null;
        if (info != null) {
            subplotInfo = new PlotRenderingInfo(info.getOwner());
            info.addSubplotInfo(subplotInfo);
        }
        plot.draw(g2, this.subplotAreas[i], anchor, parentState, subplotInfo);
    }
    if (info != null) {
        info.setDataArea(dataArea);
    }
}
Also used : AxisState(org.jfree.chart.axis.AxisState) ValueAxis(org.jfree.chart.axis.ValueAxis) Rectangle2D(java.awt.geom.Rectangle2D) RectangleInsets(org.jfree.ui.RectangleInsets) AxisSpace(org.jfree.chart.axis.AxisSpace) RectangleEdge(org.jfree.ui.RectangleEdge)

Example 5 with AxisSpace

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

the class CombinedRangeXYPlot method draw.

/**
 * Draws the plot within the specified area on a graphics device.
 *
 * @param g2  the graphics device.
 * @param area  the plot area (in Java2D space).
 * @param anchor  an anchor point in Java2D space (<code>null</code>
 *                permitted).
 * @param parentState  the state from the parent plot, if there is one
 *                     (<code>null</code> permitted).
 * @param info  collects chart drawing information (<code>null</code>
 *              permitted).
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) {
    // set up info collection...
    if (info != null) {
        info.setPlotArea(area);
    }
    // adjust the drawing area for plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);
    AxisSpace space = calculateAxisSpace(g2, area);
    Rectangle2D dataArea = space.shrink(area, null);
    // this.axisOffset.trim(dataArea);
    // set the width and height of non-shared axis of all sub-plots
    setFixedDomainAxisSpaceForSubplots(space);
    // draw the shared axis
    ValueAxis axis = getRangeAxis();
    RectangleEdge edge = getRangeAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, edge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info);
    if (parentState == null) {
        parentState = new PlotState();
    }
    parentState.getSharedAxisStates().put(axis, axisState);
    // draw all the charts
    for (int i = 0; i < this.subplots.size(); i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);
        PlotRenderingInfo subplotInfo = null;
        if (info != null) {
            subplotInfo = new PlotRenderingInfo(info.getOwner());
            info.addSubplotInfo(subplotInfo);
        }
        plot.draw(g2, this.subplotAreas[i], anchor, parentState, subplotInfo);
    }
    if (info != null) {
        info.setDataArea(dataArea);
    }
}
Also used : AxisState(org.jfree.chart.axis.AxisState) ValueAxis(org.jfree.chart.axis.ValueAxis) Rectangle2D(java.awt.geom.Rectangle2D) RectangleInsets(org.jfree.ui.RectangleInsets) AxisSpace(org.jfree.chart.axis.AxisSpace) RectangleEdge(org.jfree.ui.RectangleEdge)

Aggregations

AxisSpace (org.jfree.chart.axis.AxisSpace)23 RectangleEdge (org.jfree.ui.RectangleEdge)15 Rectangle2D (java.awt.geom.Rectangle2D)14 ValueAxis (org.jfree.chart.axis.ValueAxis)11 RectangleInsets (org.jfree.ui.RectangleInsets)9 AxisState (org.jfree.chart.axis.AxisState)7 AlphaComposite (java.awt.AlphaComposite)4 Composite (java.awt.Composite)4 Paint (java.awt.Paint)4 Shape (java.awt.Shape)4 CategoryAxis (org.jfree.chart.axis.CategoryAxis)4 BasicStroke (java.awt.BasicStroke)3 Stroke (java.awt.Stroke)3 NumberAxis (org.jfree.chart.axis.NumberAxis)3 Color (java.awt.Color)2 Graphics2D (java.awt.Graphics2D)2 Point2D (java.awt.geom.Point2D)2 BufferedImage (java.awt.image.BufferedImage)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2