Java Code Examples for org.jfree.ui.RectangleInsets#trim()

The following examples show how to use org.jfree.ui.RectangleInsets#trim() . 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: WaferMapPlot.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the wafermap view.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param state  the plot state.
 * @param info  the plot rendering info.
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
                 PlotState state,
                 PlotRenderingInfo info) {

    // if the plot area is too small, just return...
    boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
    boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
    if (b1 || b2) {
        return;
    }

    // record the plot area...
    if (info != null) {
        info.setPlotArea(area);
    }

    // adjust the drawing area for the plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    drawChipGrid(g2, area);
    drawWaferEdge(g2, area);

}
 
Example 2
Source File: WaferMapPlot.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Draws the wafermap view.
 * 
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param state  the plot state.
 * @param info  the plot rendering info.
 */
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
                 PlotState state, 
                 PlotRenderingInfo info) {

    // if the plot area is too small, just return...
    boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
    boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
    if (b1 || b2) {
        return;
    }

    // record the plot area...
    if (info != null) {
        info.setPlotArea(area);
    }

    // adjust the drawing area for the plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    drawChipGrid(g2, area);       
    drawWaferEdge(g2, area);
    
}
 
Example 3
Source File: WaferMapPlot.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Draws the wafermap view.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param state  the plot state.
 * @param info  the plot rendering info.
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
                 PlotState state,
                 PlotRenderingInfo info) {

    // if the plot area is too small, just return...
    boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
    boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
    if (b1 || b2) {
        return;
    }

    // record the plot area...
    if (info != null) {
        info.setPlotArea(area);
    }

    // adjust the drawing area for the plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    drawChipGrid(g2, area);
    drawWaferEdge(g2, area);

}
 
Example 4
Source File: WaferMapPlot.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the wafermap view.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param state  the plot state.
 * @param info  the plot rendering info.
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
                 PlotState state,
                 PlotRenderingInfo info) {

    // if the plot area is too small, just return...
    boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
    boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
    if (b1 || b2) {
        return;
    }

    // record the plot area...
    if (info != null) {
        info.setPlotArea(area);
    }

    // adjust the drawing area for the plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    drawChipGrid(g2, area);
    drawWaferEdge(g2, area);

}
 
Example 5
Source File: PiePlot.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a 
 * printer).
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot 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 info about the drawing 
 *              (<code>null</code> permitted).
 */
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
                 PlotState parentState, PlotRenderingInfo info) {

    // adjust for insets...
    RectangleInsets insets = getInsets();
    insets.trim(area);

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

    drawBackground(g2, area);
    drawOutline(g2, area);

    Shape savedClip = g2.getClip();
    g2.clip(area);

    Composite originalComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 
            getForegroundAlpha()));

    if (!DatasetUtilities.isEmptyOrNull(this.dataset)) {
        drawPie(g2, area, info);
    }
    else {
        drawNoDataMessage(g2, area);
    }

    g2.setClip(savedClip);
    g2.setComposite(originalComposite);

    drawOutline(g2, area);

}
 
Example 6
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 7
Source File: PolarPlot.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).
 * <P>
 * This plot relies on a {@link PolarItemRenderer} to draw each
 * item in the plot.  This allows the visual representation of the data to
 * be changed easily.
 * <P>
 * The optional info argument collects information about the rendering of
 * the plot (dimensions, tooltip information etc).  Just pass in
 * <code>null</code> if you do not need this information.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot (including axes and
 *              labels) should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  ignored.
 * @param info  collects chart drawing information (<code>null</code>
 *              permitted).
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
        PlotState parentState, PlotRenderingInfo info) {

    // if the plot area is too small, just return...
    boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
    boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
    if (b1 || b2) {
        return;
    }

    // record the plot area...
    if (info != null) {
        info.setPlotArea(area);
    }

    // adjust the drawing area for the plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);

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

    // draw the plot background and axes...
    drawBackground(g2, dataArea);
    int axisCount = this.axes.size();
    AxisState state = null;
    for (int i = 0; i < axisCount; i++) {
        ValueAxis axis = getAxis(i);
        if (axis != null) {
            PolarAxisLocation location
                    = (PolarAxisLocation) this.axisLocations.get(i);
            AxisState s = this.drawAxis(axis, location, g2, dataArea);
            if (i == 0) {
                state = s;
            }
        }
    }

    // now for each dataset, get the renderer and the appropriate axis
    // and render the dataset...
    Shape originalClip = g2.getClip();
    Composite originalComposite = g2.getComposite();

    g2.clip(dataArea);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
            getForegroundAlpha()));
    this.angleTicks = refreshAngleTicks();
    drawGridlines(g2, dataArea, this.angleTicks, state.getTicks());
    render(g2, dataArea, info);
    g2.setClip(originalClip);
    g2.setComposite(originalComposite);
    drawOutline(g2, dataArea);
    drawCornerTextItems(g2, dataArea);
}
 
Example 8
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 9
Source File: CombinedRangeXYPlot.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);

    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 10
Source File: CombinedRangeXYPlot.java    From SIMVA-SoS 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).
 */
@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 11
Source File: FastScatterPlot.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Draws the fast scatter plot on a Java 2D graphics device (such as the
 * screen or a printer).
 *
 * @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 (ignored).
 * @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 = new AxisSpace();
    space = this.domainAxis.reserveSpace(g2, this, area,
            RectangleEdge.BOTTOM, space);
    space = this.rangeAxis.reserveSpace(g2, this, area, RectangleEdge.LEFT,
            space);
    Rectangle2D dataArea = space.shrink(area, null);

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

    // draw the plot background and axes...
    drawBackground(g2, dataArea);

    AxisState domainAxisState = this.domainAxis.draw(g2,
            dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info);
    AxisState rangeAxisState = this.rangeAxis.draw(g2, dataArea.getMinX(),
            area, dataArea, RectangleEdge.LEFT, info);
    drawDomainGridlines(g2, dataArea, domainAxisState.getTicks());
    drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks());

    Shape originalClip = g2.getClip();
    Composite originalComposite = g2.getComposite();

    g2.clip(dataArea);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
            getForegroundAlpha()));

    render(g2, dataArea, info, null);

    g2.setClip(originalClip);
    g2.setComposite(originalComposite);
    drawOutline(g2, dataArea);

}
 
Example 12
Source File: FastScatterPlot.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws the fast scatter plot on a Java 2D graphics device (such as the
 * screen or a printer).
 *
 * @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 (ignored).
 * @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 = new AxisSpace();
    space = this.domainAxis.reserveSpace(g2, this, area,
            RectangleEdge.BOTTOM, space);
    space = this.rangeAxis.reserveSpace(g2, this, area, RectangleEdge.LEFT,
            space);
    Rectangle2D dataArea = space.shrink(area, null);

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

    // draw the plot background and axes...
    drawBackground(g2, dataArea);

    AxisState domainAxisState = this.domainAxis.draw(g2,
            dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info);
    AxisState rangeAxisState = this.rangeAxis.draw(g2, dataArea.getMinX(),
            area, dataArea, RectangleEdge.LEFT, info);
    drawDomainGridlines(g2, dataArea, domainAxisState.getTicks());
    drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks());

    Shape originalClip = g2.getClip();
    Composite originalComposite = g2.getComposite();

    g2.clip(dataArea);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
            getForegroundAlpha()));

    render(g2, dataArea, info, null);

    g2.setClip(originalClip);
    g2.setComposite(originalComposite);
    drawOutline(g2, dataArea);

}
 
Example 13
Source File: PolarPlot.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).
 * <P>
 * This plot relies on a {@link PolarItemRenderer} to draw each
 * item in the plot.  This allows the visual representation of the data to
 * be changed easily.
 * <P>
 * The optional info argument collects information about the rendering of
 * the plot (dimensions, tooltip information etc).  Just pass in
 * <code>null</code> if you do not need this information.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot (including axes and
 *              labels) should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  ignored.
 * @param info  collects chart drawing information (<code>null</code>
 *              permitted).
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
        PlotState parentState, PlotRenderingInfo info) {

    // if the plot area is too small, just return...
    boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
    boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
    if (b1 || b2) {
        return;
    }

    // record the plot area...
    if (info != null) {
        info.setPlotArea(area);
    }

    // adjust the drawing area for the plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);

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

    // draw the plot background and axes...
    drawBackground(g2, dataArea);
    int axisCount = this.axes.size();
    AxisState state = null;
    for (int i = 0; i < axisCount; i++) {
        ValueAxis axis = getAxis(i);
        if (axis != null) {
            PolarAxisLocation location
                    = (PolarAxisLocation) this.axisLocations.get(i);
            AxisState s = this.drawAxis(axis, location, g2, dataArea);
            if (i == 0) {
                state = s;
            }
        }
    }

    // now for each dataset, get the renderer and the appropriate axis
    // and render the dataset...
    Shape originalClip = g2.getClip();
    Composite originalComposite = g2.getComposite();

    g2.clip(dataArea);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
            getForegroundAlpha()));
    this.angleTicks = refreshAngleTicks();
    drawGridlines(g2, dataArea, this.angleTicks, state.getTicks());
    render(g2, dataArea, info);
    g2.setClip(originalClip);
    g2.setComposite(originalComposite);
    drawOutline(g2, dataArea);
    drawCornerTextItems(g2, dataArea);
}
 
Example 14
Source File: FastScatterPlot.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Draws the fast scatter plot on a Java 2D graphics device (such as the 
 * screen or a printer).
 *
 * @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 (ignored).
 * @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 = new AxisSpace();
    space = this.domainAxis.reserveSpace(g2, this, area, 
            RectangleEdge.BOTTOM, space);
    space = this.rangeAxis.reserveSpace(g2, this, area, RectangleEdge.LEFT, 
            space);
    Rectangle2D dataArea = space.shrink(area, null);

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

    // draw the plot background and axes...
    drawBackground(g2, dataArea);

    AxisState domainAxisState = this.domainAxis.draw(g2, 
            dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info);
    AxisState rangeAxisState = this.rangeAxis.draw(g2, dataArea.getMinX(), 
            area, dataArea, RectangleEdge.LEFT, info);
    drawDomainGridlines(g2, dataArea, domainAxisState.getTicks());
    drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks());
    
    Shape originalClip = g2.getClip();
    Composite originalComposite = g2.getComposite();

    g2.clip(dataArea);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 
            getForegroundAlpha()));

    render(g2, dataArea, info, null);

    g2.setClip(originalClip);
    g2.setComposite(originalComposite);
    drawOutline(g2, 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: CombinedRangeCategoryPlot.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 
 * 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 17
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 18
Source File: PolarPlot.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).
 * <P>
 * This plot relies on a {@link PolarItemRenderer} to draw each 
 * item in the plot.  This allows the visual representation of the data to 
 * be changed easily.
 * <P>
 * The optional info argument collects information about the rendering of
 * the plot (dimensions, tooltip information etc).  Just pass in 
 * <code>null</code> if you do not need this information.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot (including axes and 
 *              labels) should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  ignored.
 * @param info  collects chart drawing information (<code>null</code> 
 *              permitted).
 */
public void draw(Graphics2D g2, 
                 Rectangle2D area, 
                 Point2D anchor,
                 PlotState parentState,
                 PlotRenderingInfo info) {
   
    // if the plot area is too small, just return...
    boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
    boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
    if (b1 || b2) {
        return;
    }
   
    // record the plot area...
    if (info != null) {
        info.setPlotArea(area);
    }
   
    // adjust the drawing area for the plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);
  
    Rectangle2D dataArea = area;
    if (info != null) {
        info.setDataArea(dataArea);
    }
   
    // draw the plot background and axes...
    drawBackground(g2, dataArea);
    double h = Math.min(dataArea.getWidth() / 2.0, 
            dataArea.getHeight() / 2.0) - MARGIN;
    Rectangle2D quadrant = new Rectangle2D.Double(dataArea.getCenterX(), 
            dataArea.getCenterY(), h, h);
    AxisState state = drawAxis(g2, area, quadrant);
    if (this.renderer != null) {
        Shape originalClip = g2.getClip();
        Composite originalComposite = g2.getComposite();
      
        g2.clip(dataArea);
        g2.setComposite(AlphaComposite.getInstance(
                AlphaComposite.SRC_OVER, getForegroundAlpha()));
      
        drawGridlines(g2, dataArea, this.angleTicks, state.getTicks());
      
        // draw...
        render(g2, dataArea, info);
      
        g2.setClip(originalClip);
        g2.setComposite(originalComposite);
    }
    drawOutline(g2, dataArea);
    drawCornerTextItems(g2, dataArea);
}
 
Example 19
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 20
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);
    }

}