Search in sources :

Example 1 with AxisCollection

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

the class CategoryPlot method drawAxes.

/**
 * A utility method for drawing the plot's axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param dataArea  the data area.
 * @param plotState  collects information about the plot (<code>null</code>
 *                   permitted).
 *
 * @return A map containing the axis states.
 */
protected Map drawAxes(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, PlotRenderingInfo plotState) {
    AxisCollection axisCollection = new AxisCollection();
    // add domain axes to lists...
    for (CategoryAxis xAxis : this.domainAxes.values()) {
        if (xAxis != null) {
            int index = getDomainAxisIndex(xAxis);
            axisCollection.add(xAxis, getDomainAxisEdge(index));
        }
    }
    // add range axes to lists...
    for (ValueAxis yAxis : this.rangeAxes.values()) {
        if (yAxis != null) {
            int index = findRangeAxisIndex(yAxis);
            axisCollection.add(yAxis, getRangeAxisEdge(index));
        }
    }
    Map axisStateMap = new HashMap();
    // draw the top axes
    double cursor = dataArea.getMinY() - this.axisOffset.calculateTopOutset(dataArea.getHeight());
    Iterator iterator = axisCollection.getAxesAtTop().iterator();
    while (iterator.hasNext()) {
        Axis axis = (Axis) iterator.next();
        if (axis != null) {
            AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.TOP, plotState);
            cursor = axisState.getCursor();
            axisStateMap.put(axis, axisState);
        }
    }
    // draw the bottom axes
    cursor = dataArea.getMaxY() + this.axisOffset.calculateBottomOutset(dataArea.getHeight());
    iterator = axisCollection.getAxesAtBottom().iterator();
    while (iterator.hasNext()) {
        Axis axis = (Axis) iterator.next();
        if (axis != null) {
            AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.BOTTOM, plotState);
            cursor = axisState.getCursor();
            axisStateMap.put(axis, axisState);
        }
    }
    // draw the left axes
    cursor = dataArea.getMinX() - this.axisOffset.calculateLeftOutset(dataArea.getWidth());
    iterator = axisCollection.getAxesAtLeft().iterator();
    while (iterator.hasNext()) {
        Axis axis = (Axis) iterator.next();
        if (axis != null) {
            AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.LEFT, plotState);
            cursor = axisState.getCursor();
            axisStateMap.put(axis, axisState);
        }
    }
    // draw the right axes
    cursor = dataArea.getMaxX() + this.axisOffset.calculateRightOutset(dataArea.getWidth());
    iterator = axisCollection.getAxesAtRight().iterator();
    while (iterator.hasNext()) {
        Axis axis = (Axis) iterator.next();
        if (axis != null) {
            AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.RIGHT, plotState);
            cursor = axisState.getCursor();
            axisStateMap.put(axis, axisState);
        }
    }
    return axisStateMap;
}
Also used : AxisState(org.jfree.chart.axis.AxisState) AxisCollection(org.jfree.chart.axis.AxisCollection) CategoryAxis(org.jfree.chart.axis.CategoryAxis) HashMap(java.util.HashMap) ValueAxis(org.jfree.chart.axis.ValueAxis) Iterator(java.util.Iterator) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Paint(java.awt.Paint) CategoryAxis(org.jfree.chart.axis.CategoryAxis) Axis(org.jfree.chart.axis.Axis) ValueAxis(org.jfree.chart.axis.ValueAxis)

Example 2 with AxisCollection

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

the class XYPlot method drawAxes.

/**
 * A utility method for drawing the axes.
 *
 * @param g2  the graphics device (<code>null</code> not permitted).
 * @param plotArea  the plot area (<code>null</code> not permitted).
 * @param dataArea  the data area (<code>null</code> not permitted).
 * @param plotState  collects information about the plot (<code>null</code>
 *                   permitted).
 *
 * @return A map containing the state for each axis drawn.
 */
protected Map<Axis, AxisState> drawAxes(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, PlotRenderingInfo plotState) {
    AxisCollection axisCollection = new AxisCollection();
    // add domain axes to lists...
    for (ValueAxis axis : this.domainAxes.values()) {
        if (axis != null) {
            int axisIndex = findDomainAxisIndex(axis);
            axisCollection.add(axis, getDomainAxisEdge(axisIndex));
        }
    }
    // add range axes to lists...
    for (ValueAxis axis : this.rangeAxes.values()) {
        if (axis != null) {
            int axisIndex = findRangeAxisIndex(axis);
            axisCollection.add(axis, getRangeAxisEdge(axisIndex));
        }
    }
    Map axisStateMap = new HashMap();
    // draw the top axes
    double cursor = dataArea.getMinY() - this.axisOffset.calculateTopOutset(dataArea.getHeight());
    Iterator iterator = axisCollection.getAxesAtTop().iterator();
    while (iterator.hasNext()) {
        ValueAxis axis = (ValueAxis) iterator.next();
        AxisState info = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.TOP, plotState);
        cursor = info.getCursor();
        axisStateMap.put(axis, info);
    }
    // draw the bottom axes
    cursor = dataArea.getMaxY() + this.axisOffset.calculateBottomOutset(dataArea.getHeight());
    iterator = axisCollection.getAxesAtBottom().iterator();
    while (iterator.hasNext()) {
        ValueAxis axis = (ValueAxis) iterator.next();
        AxisState info = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.BOTTOM, plotState);
        cursor = info.getCursor();
        axisStateMap.put(axis, info);
    }
    // draw the left axes
    cursor = dataArea.getMinX() - this.axisOffset.calculateLeftOutset(dataArea.getWidth());
    iterator = axisCollection.getAxesAtLeft().iterator();
    while (iterator.hasNext()) {
        ValueAxis axis = (ValueAxis) iterator.next();
        AxisState info = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.LEFT, plotState);
        cursor = info.getCursor();
        axisStateMap.put(axis, info);
    }
    // draw the right axes
    cursor = dataArea.getMaxX() + this.axisOffset.calculateRightOutset(dataArea.getWidth());
    iterator = axisCollection.getAxesAtRight().iterator();
    while (iterator.hasNext()) {
        ValueAxis axis = (ValueAxis) iterator.next();
        AxisState info = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.RIGHT, plotState);
        cursor = info.getCursor();
        axisStateMap.put(axis, info);
    }
    return axisStateMap;
}
Also used : AxisState(org.jfree.chart.axis.AxisState) AxisCollection(org.jfree.chart.axis.AxisCollection) HashMap(java.util.HashMap) ValueAxis(org.jfree.chart.axis.ValueAxis) Iterator(java.util.Iterator) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Paint(java.awt.Paint)

Aggregations

Paint (java.awt.Paint)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 AxisCollection (org.jfree.chart.axis.AxisCollection)2 AxisState (org.jfree.chart.axis.AxisState)2 ValueAxis (org.jfree.chart.axis.ValueAxis)2 Axis (org.jfree.chart.axis.Axis)1 CategoryAxis (org.jfree.chart.axis.CategoryAxis)1