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

The following examples show how to use org.jfree.chart.axis.CategoryAxis#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: CombinedDomainCategoryPlot.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 of the
 * 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 state from the parent plot, if there is one.
 * @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();
    area.setRect(area.getX() + insets.getLeft(),
            area.getY() + insets.getTop(),
            area.getWidth() - insets.getLeft() - insets.getRight(),
            area.getHeight() - insets.getTop() - insets.getBottom());


    // calculate the data 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
    CategoryAxis axis = getDomainAxis();
    RectangleEdge domainEdge = getDomainAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, domainEdge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea,
            domainEdge, 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++) {
        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.subplotAreas[i].contains(anchor)) {
            subAnchor = anchor;
        }
        plot.draw(g2, this.subplotAreas[i], subAnchor, parentState,
                subplotInfo);
    }

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

}
 
Example 2
Source File: CombinedDomainCategoryPlot.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 of the
 * 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 state from the parent plot, if there is one.
 * @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();
    area.setRect(area.getX() + insets.getLeft(),
            area.getY() + insets.getTop(),
            area.getWidth() - insets.getLeft() - insets.getRight(),
            area.getHeight() - insets.getTop() - insets.getBottom());


    // calculate the data 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
    CategoryAxis axis = getDomainAxis();
    RectangleEdge domainEdge = getDomainAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, domainEdge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea,
            domainEdge, 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++) {
        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.subplotAreas[i].contains(anchor)) {
            subAnchor = anchor;
        }
        plot.draw(g2, this.subplotAreas[i], subAnchor, parentState,
                subplotInfo);
    }

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

}
 
Example 3
Source File: CombinedDomainCategoryPlot.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 of the
 * 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 state from the parent plot, if there is one.
 * @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();
    area.setRect(area.getX() + insets.getLeft(),
            area.getY() + insets.getTop(),
            area.getWidth() - insets.getLeft() - insets.getRight(),
            area.getHeight() - insets.getTop() - insets.getBottom());


    // calculate the data 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
    CategoryAxis axis = getDomainAxis();
    RectangleEdge domainEdge = getDomainAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, domainEdge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea,
            domainEdge, 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++) {
        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.subplotAreas[i].contains(anchor)) {
            subAnchor = anchor;
        }
        plot.draw(g2, this.subplotAreas[i], subAnchor, parentState,
                subplotInfo);
    }

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

}
 
Example 4
Source File: CombinedDomainCategoryPlot.java    From ECG-Viewer 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 of the
 * 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 state from the parent plot, if there is one.
 * @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();
    area.setRect(area.getX() + insets.getLeft(),
            area.getY() + insets.getTop(),
            area.getWidth() - insets.getLeft() - insets.getRight(),
            area.getHeight() - insets.getTop() - insets.getBottom());


    // calculate the data 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
    CategoryAxis axis = getDomainAxis();
    RectangleEdge domainEdge = getDomainAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, domainEdge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea,
            domainEdge, 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++) {
        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.subplotAreas[i].contains(anchor)) {
            subAnchor = anchor;
        }
        plot.draw(g2, this.subplotAreas[i], subAnchor, parentState,
                subplotInfo);
    }

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

}
 
Example 5
Source File: CombinedDomainCategoryPlot.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 of the
 * 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 state from the parent plot, if there is one.
 * @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();
    area.setRect(area.getX() + insets.getLeft(),
            area.getY() + insets.getTop(),
            area.getWidth() - insets.getLeft() - insets.getRight(),
            area.getHeight() - insets.getTop() - insets.getBottom());


    // calculate the data 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
    CategoryAxis axis = getDomainAxis();
    RectangleEdge domainEdge = getDomainAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, domainEdge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea,
            domainEdge, 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++) {
        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.subplotAreas[i].contains(anchor)) {
            subAnchor = anchor;
        }
        plot.draw(g2, this.subplotAreas[i], subAnchor, parentState,
                subplotInfo);
    }

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

}
 
Example 6
Source File: CombinedDomainCategoryPlot.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 of the
 * 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 state from the parent plot, if there is one.
 * @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();
    area.setRect(area.getX() + insets.getLeft(),
            area.getY() + insets.getTop(),
            area.getWidth() - insets.getLeft() - insets.getRight(),
            area.getHeight() - insets.getTop() - insets.getBottom());


    // calculate the data 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
    CategoryAxis axis = getDomainAxis();
    RectangleEdge domainEdge = getDomainAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, domainEdge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea, 
            domainEdge, 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++) {
        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.subplotAreas[i], null, parentState, subplotInfo);
    }

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

}
 
Example 7
Source File: CombinedDomainCategoryPlot.java    From opensim-gui 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 of the
 * 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 state from the parent plot, if there is one.
 * @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();
    area.setRect(area.getX() + insets.getLeft(),
            area.getY() + insets.getTop(),
            area.getWidth() - insets.getLeft() - insets.getRight(),
            area.getHeight() - insets.getTop() - insets.getBottom());


    // calculate the data 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
    CategoryAxis axis = getDomainAxis();
    RectangleEdge domainEdge = getDomainAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, domainEdge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea, 
            domainEdge, 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++) {
        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.subplotAreas[i], null, parentState, subplotInfo);
    }

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

}
 
Example 8
Source File: CombinedDomainCategoryPlot.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 of the
 * 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 state from the parent plot, if there is one.
 * @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();
    area.setRect(area.getX() + insets.getLeft(),
            area.getY() + insets.getTop(),
            area.getWidth() - insets.getLeft() - insets.getRight(),
            area.getHeight() - insets.getTop() - insets.getBottom());


    // calculate the data 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
    CategoryAxis axis = getDomainAxis();
    RectangleEdge domainEdge = getDomainAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, domainEdge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea,
            domainEdge, 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++) {
        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.subplotAreas[i].contains(anchor)) {
            subAnchor = anchor;
        }
        plot.draw(g2, this.subplotAreas[i], subAnchor, parentState,
                subplotInfo);
    }

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

}
 
Example 9
Source File: CombinedDomainCategoryPlot.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 of the
 * 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 state from the parent plot, if there is one.
 * @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();
    area.setRect(area.getX() + insets.getLeft(),
            area.getY() + insets.getTop(),
            area.getWidth() - insets.getLeft() - insets.getRight(),
            area.getHeight() - insets.getTop() - insets.getBottom());


    // calculate the data 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
    CategoryAxis axis = getDomainAxis();
    RectangleEdge domainEdge = getDomainAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, domainEdge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea,
            domainEdge, 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++) {
        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.subplotAreas[i].contains(anchor)) {
            subAnchor = anchor;
        }
        plot.draw(g2, this.subplotAreas[i], subAnchor, parentState,
                subplotInfo);
    }

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

}