Example usage for org.jfree.chart.axis ValueAxis draw

List of usage examples for org.jfree.chart.axis ValueAxis draw

Introduction

In this page you can find the example usage for org.jfree.chart.axis ValueAxis draw.

Prototype

public abstract AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea,
        RectangleEdge edge, PlotRenderingInfo plotState);

Source Link

Document

Draws the axis on a Java 2D graphics device (such as the screen or a printer).

Usage

From source file:ucar.unidata.idv.control.chart.MyXYPlot.java

/**
 * 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)./*w  ww. j  av a 2 s  .  co  m*/
 *
 * @return A map containing the state for each axis drawn.
 */
protected Map drawAxes(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, PlotRenderingInfo plotState) {

    AxisCollection axisCollection = new AxisCollection();

    // add domain axes to lists...
    for (int index = 0; index < this.domainAxes.size(); index++) {
        ValueAxis axis = (ValueAxis) this.domainAxes.get(index);
        if (axis != null) {
            axisCollection.add(axis, getDomainAxisEdge(index));
        }
    }

    // add range axes to lists...
    for (int index = 0; index < this.rangeAxes.size(); index++) {
        ValueAxis yAxis = (ValueAxis) this.rangeAxes.get(index);
        if (yAxis != null) {
            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()) {
        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;
}