Search in sources :

Example 6 with AxisSpace

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

the class CategoryPlot method calculateAxisSpace.

/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
protected AxisSpace calculateAxisSpace(Graphics2D g2, Rectangle2D plotArea) {
    AxisSpace space = new AxisSpace();
    space = calculateRangeAxisSpace(g2, plotArea, space);
    space = calculateDomainAxisSpace(g2, plotArea, space);
    return space;
}
Also used : AxisSpace(org.jfree.chart.axis.AxisSpace)

Example 7 with AxisSpace

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

the class CombinedDomainCategoryPlot method calculateAxisSpace.

/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
@Override
protected AxisSpace calculateAxisSpace(Graphics2D g2, Rectangle2D plotArea) {
    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();
    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedDomainAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.HORIZONTAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        } else if (orientation == PlotOrientation.VERTICAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    } else {
        CategoryAxis categoryAxis = getDomainAxis();
        RectangleEdge categoryEdge = Plot.resolveDomainAxisLocation(getDomainAxisLocation(), orientation);
        if (categoryAxis != null) {
            space = categoryAxis.reserveSpace(g2, this, plotArea, categoryEdge, space);
        } else {
            if (getDrawSharedDomainAxis()) {
                space = getDomainAxis().reserveSpace(g2, this, plotArea, categoryEdge, space);
            }
        }
    }
    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        CategoryPlot sub = (CategoryPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }
    this.subplotAreas = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    } else if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }
    for (int i = 0; i < n; i++) {
        CategoryPlot plot = (CategoryPlot) this.subplots.get(i);
        // calculate sub-plot area
        if (orientation == PlotOrientation.HORIZONTAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        } else if (orientation == PlotOrientation.VERTICAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }
        AxisSpace subSpace = plot.calculateRangeAxisSpace(g2, this.subplotAreas[i], null);
        space.ensureAtLeast(subSpace);
    }
    return space;
}
Also used : CategoryAxis(org.jfree.chart.axis.CategoryAxis) Rectangle2D(java.awt.geom.Rectangle2D) AxisSpace(org.jfree.chart.axis.AxisSpace) RectangleEdge(org.jfree.ui.RectangleEdge)

Example 8 with AxisSpace

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

the class CombinedRangeCategoryPlot method calculateAxisSpace.

/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
@Override
protected AxisSpace calculateAxisSpace(Graphics2D g2, Rectangle2D plotArea) {
    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();
    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        } else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    } else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(getRangeAxisLocation(), orientation);
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, space);
        }
    }
    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        CategoryPlot sub = (CategoryPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }
    // calculate plotAreas of all sub-plots, maximum vertical/horizontal
    // axis width/height
    this.subplotArea = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    } else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }
    for (int i = 0; i < n; i++) {
        CategoryPlot plot = (CategoryPlot) this.subplots.get(i);
        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        } else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }
        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, this.subplotArea[i], null);
        space.ensureAtLeast(subSpace);
    }
    return space;
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis) Rectangle2D(java.awt.geom.Rectangle2D) AxisSpace(org.jfree.chart.axis.AxisSpace) RectangleEdge(org.jfree.ui.RectangleEdge)

Example 9 with AxisSpace

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

the class CombinedRangeCategoryPlot method draw.

/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a
 * printer).  Will perform all the placement calculations for each
 * sub-plots and then tell these to draw themselves.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot (including axis labels)
 *              should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  the parent state.
 * @param info  collects information about the drawing (<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);
    // calculate the data area...
    AxisSpace space = calculateAxisSpace(g2, area);
    Rectangle2D dataArea = space.shrink(area, null);
    // set the width and height of non-shared axis of all sub-plots
    setFixedDomainAxisSpaceForSubplots(space);
    // draw the shared axis
    ValueAxis axis = getRangeAxis();
    RectangleEdge rangeEdge = getRangeAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, rangeEdge);
    AxisState state = axis.draw(g2, cursor, area, dataArea, rangeEdge, info);
    if (parentState == null) {
        parentState = new PlotState();
    }
    parentState.getSharedAxisStates().put(axis, state);
    // draw all the charts
    for (int i = 0; i < this.subplots.size(); i++) {
        CategoryPlot plot = (CategoryPlot) this.subplots.get(i);
        PlotRenderingInfo subplotInfo = null;
        if (info != null) {
            subplotInfo = new PlotRenderingInfo(info.getOwner());
            info.addSubplotInfo(subplotInfo);
        }
        Point2D subAnchor = null;
        if (anchor != null && this.subplotArea[i].contains(anchor)) {
            subAnchor = anchor;
        }
        plot.draw(g2, this.subplotArea[i], subAnchor, parentState, subplotInfo);
    }
    if (info != null) {
        info.setDataArea(dataArea);
    }
}
Also used : AxisState(org.jfree.chart.axis.AxisState) Point2D(java.awt.geom.Point2D) 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 10 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)

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