Java Code Examples for org.jfree.chart.axis.ValueAxis#draw()

The following examples show how to use org.jfree.chart.axis.ValueAxis#draw() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CombinedRangeCategoryPlot.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
    }

}
 
Example 2
Source File: CombinedRangeCategoryPlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
    }

}
 
Example 3
Source File: CombinedRangeXYPlot.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * 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).
 */
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 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);
    }

    // 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);
    
    if (info != null) {
        info.setDataArea(dataArea);
    }

}
 
Example 4
Source File: CombinedDomainXYPlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
    }

}
 
Example 5
Source File: CombinedDomainXYPlot.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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).
 */
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);
    }

}
 
Example 6
Source File: CombinedDomainXYPlot.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * 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).
 */
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);

    // set the width and height of non-shared axis of all sub-plots
    setFixedRangeAxisSpaceForSubplots(space);

    // 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);
    }

    // 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);
    
    if (info != null) {
        info.setDataArea(dataArea);
    }
    
}
 
Example 7
Source File: CombinedDomainXYPlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
    }

}
 
Example 8
Source File: CombinedDomainXYPlot.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
    }

}
 
Example 9
Source File: PolarPlot.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws the axis with the specified index.
 *
 * @param axis  the axis.
 * @param location  the axis location.
 * @param g2  the graphics target.
 * @param plotArea  the plot area.
 *
 * @return The axis state.
 *
 * @since 1.0.14
 */
protected AxisState drawAxis(ValueAxis axis, PolarAxisLocation location,
        Graphics2D g2, Rectangle2D plotArea) {

    double centerX = plotArea.getCenterX();
    double centerY = plotArea.getCenterY();
    double r = Math.min(plotArea.getWidth() / 2.0,
            plotArea.getHeight() / 2.0) - this.margin;
    double x = centerX - r;
    double y = centerY - r;

    Rectangle2D dataArea = null;
    AxisState result = null;
    if (location == PolarAxisLocation.NORTH_RIGHT) {
        dataArea = new Rectangle2D.Double(x, y, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.RIGHT, null);
    }
    else if (location == PolarAxisLocation.NORTH_LEFT) {
        dataArea = new Rectangle2D.Double(centerX, y, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.LEFT, null);
    }
    else if (location == PolarAxisLocation.SOUTH_LEFT) {
        dataArea = new Rectangle2D.Double(centerX, centerY, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.LEFT, null);
    }
    else if (location == PolarAxisLocation.SOUTH_RIGHT) {
        dataArea = new Rectangle2D.Double(x, centerY, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.RIGHT, null);
    }
    else if (location == PolarAxisLocation.EAST_ABOVE) {
        dataArea = new Rectangle2D.Double(centerX, centerY, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.TOP, null);
    }
    else if (location == PolarAxisLocation.EAST_BELOW) {
        dataArea = new Rectangle2D.Double(centerX, y, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.BOTTOM, null);
    }
    else if (location == PolarAxisLocation.WEST_ABOVE) {
        dataArea = new Rectangle2D.Double(x, centerY, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.TOP, null);
    }
    else if (location == PolarAxisLocation.WEST_BELOW) {
        dataArea = new Rectangle2D.Double(x, y, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.BOTTOM, null);
    }

    return result;
}
 
Example 10
Source File: CombinedRangeCategoryPlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
    }

}
 
Example 11
Source File: PolarPlot.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the axis with the specified index.
 *
 * @param axis  the axis.
 * @param location  the axis location.
 * @param g2  the graphics target.
 * @param plotArea  the plot area.
 *
 * @return The axis state.
 *
 * @since 1.0.14
 */
protected AxisState drawAxis(ValueAxis axis, PolarAxisLocation location,
        Graphics2D g2, Rectangle2D plotArea) {

    double centerX = plotArea.getCenterX();
    double centerY = plotArea.getCenterY();
    double r = Math.min(plotArea.getWidth() / 2.0,
            plotArea.getHeight() / 2.0) - this.margin;
    double x = centerX - r;
    double y = centerY - r;

    Rectangle2D dataArea = null;
    AxisState result = null;
    if (location == PolarAxisLocation.NORTH_RIGHT) {
        dataArea = new Rectangle2D.Double(x, y, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.RIGHT, null);
    }
    else if (location == PolarAxisLocation.NORTH_LEFT) {
        dataArea = new Rectangle2D.Double(centerX, y, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.LEFT, null);
    }
    else if (location == PolarAxisLocation.SOUTH_LEFT) {
        dataArea = new Rectangle2D.Double(centerX, centerY, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.LEFT, null);
    }
    else if (location == PolarAxisLocation.SOUTH_RIGHT) {
        dataArea = new Rectangle2D.Double(x, centerY, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.RIGHT, null);
    }
    else if (location == PolarAxisLocation.EAST_ABOVE) {
        dataArea = new Rectangle2D.Double(centerX, centerY, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.TOP, null);
    }
    else if (location == PolarAxisLocation.EAST_BELOW) {
        dataArea = new Rectangle2D.Double(centerX, y, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.BOTTOM, null);
    }
    else if (location == PolarAxisLocation.WEST_ABOVE) {
        dataArea = new Rectangle2D.Double(x, centerY, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.TOP, null);
    }
    else if (location == PolarAxisLocation.WEST_BELOW) {
        dataArea = new Rectangle2D.Double(x, y, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.BOTTOM, null);
    }

    return result;
}
 
Example 12
Source File: CombinedRangeCategoryPlot.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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).
 */
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);
        }
        plot.draw(g2, this.subplotArea[i], null, parentState, subplotInfo);
    }

    if (info != null) {
        info.setDataArea(dataArea);
    }

}
 
Example 13
Source File: PolarPlot.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Draws the axis with the specified index.
 *
 * @param axis  the axis.
 * @param location  the axis location.
 * @param g2  the graphics target.
 * @param plotArea  the plot area.
 *
 * @return The axis state.
 *
 * @since 1.0.14
 */
protected AxisState drawAxis(ValueAxis axis, PolarAxisLocation location,
        Graphics2D g2, Rectangle2D plotArea) {

    double centerX = plotArea.getCenterX();
    double centerY = plotArea.getCenterY();
    double r = Math.min(plotArea.getWidth() / 2.0,
            plotArea.getHeight() / 2.0) - this.margin;
    double x = centerX - r;
    double y = centerY - r;

    Rectangle2D dataArea = null;
    AxisState result = null;
    if (location == PolarAxisLocation.NORTH_RIGHT) {
        dataArea = new Rectangle2D.Double(x, y, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.RIGHT, null);
    }
    else if (location == PolarAxisLocation.NORTH_LEFT) {
        dataArea = new Rectangle2D.Double(centerX, y, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.LEFT, null);
    }
    else if (location == PolarAxisLocation.SOUTH_LEFT) {
        dataArea = new Rectangle2D.Double(centerX, centerY, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.LEFT, null);
    }
    else if (location == PolarAxisLocation.SOUTH_RIGHT) {
        dataArea = new Rectangle2D.Double(x, centerY, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.RIGHT, null);
    }
    else if (location == PolarAxisLocation.EAST_ABOVE) {
        dataArea = new Rectangle2D.Double(centerX, centerY, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.TOP, null);
    }
    else if (location == PolarAxisLocation.EAST_BELOW) {
        dataArea = new Rectangle2D.Double(centerX, y, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.BOTTOM, null);
    }
    else if (location == PolarAxisLocation.WEST_ABOVE) {
        dataArea = new Rectangle2D.Double(x, centerY, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.TOP, null);
    }
    else if (location == PolarAxisLocation.WEST_BELOW) {
        dataArea = new Rectangle2D.Double(x, y, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.BOTTOM, null);
    }

    return result;
}
 
Example 14
Source File: CombinedRangeXYPlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
    }

}
 
Example 15
Source File: CombinedRangeCategoryPlot.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
    }

}
 
Example 16
Source File: CombinedDomainXYPlot.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
    }

}
 
Example 17
Source File: PolarPlot.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the axis with the specified index.
 *
 * @param axis  the axis.
 * @param location  the axis location.
 * @param g2  the graphics target.
 * @param plotArea  the plot area.
 *
 * @return The axis state.
 *
 * @since 1.0.14
 */
protected AxisState drawAxis(ValueAxis axis, PolarAxisLocation location,
        Graphics2D g2, Rectangle2D plotArea) {

    double centerX = plotArea.getCenterX();
    double centerY = plotArea.getCenterY();
    double r = Math.min(plotArea.getWidth() / 2.0,
            plotArea.getHeight() / 2.0) - this.margin;
    double x = centerX - r;
    double y = centerY - r;

    Rectangle2D dataArea = null;
    AxisState result = null;
    if (location == PolarAxisLocation.NORTH_RIGHT) {
        dataArea = new Rectangle2D.Double(x, y, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.RIGHT, null);
    }
    else if (location == PolarAxisLocation.NORTH_LEFT) {
        dataArea = new Rectangle2D.Double(centerX, y, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.LEFT, null);
    }
    else if (location == PolarAxisLocation.SOUTH_LEFT) {
        dataArea = new Rectangle2D.Double(centerX, centerY, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.LEFT, null);
    }
    else if (location == PolarAxisLocation.SOUTH_RIGHT) {
        dataArea = new Rectangle2D.Double(x, centerY, r, r);
        result = axis.draw(g2, centerX, plotArea, dataArea,
                RectangleEdge.RIGHT, null);
    }
    else if (location == PolarAxisLocation.EAST_ABOVE) {
        dataArea = new Rectangle2D.Double(centerX, centerY, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.TOP, null);
    }
    else if (location == PolarAxisLocation.EAST_BELOW) {
        dataArea = new Rectangle2D.Double(centerX, y, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.BOTTOM, null);
    }
    else if (location == PolarAxisLocation.WEST_ABOVE) {
        dataArea = new Rectangle2D.Double(x, centerY, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.TOP, null);
    }
    else if (location == PolarAxisLocation.WEST_BELOW) {
        dataArea = new Rectangle2D.Double(x, y, r, r);
        result = axis.draw(g2, centerY, plotArea, dataArea,
                RectangleEdge.BOTTOM, null);
    }

    return result;
}
 
Example 18
Source File: CombinedRangeXYPlot.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
    }

}
 
Example 19
Source File: CombinedRangeCategoryPlot.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
    }

}
 
Example 20
Source File: CombinedDomainXYPlot.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
    }

}