Java Code Examples for org.jfree.chart.plot.PlotRenderingInfo#getOwner()

The following examples show how to use org.jfree.chart.plot.PlotRenderingInfo#getOwner() . 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: AbstractXYItemRenderer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initialises the renderer and returns a state object that should be
 * passed to all subsequent calls to the drawItem() method.
 * <P>
 * This method will be called before the first item is rendered, giving the
 * renderer an opportunity to initialise any state information it wants to
 * maintain.  The renderer can do nothing if it chooses.
 *
 * @param g2  the graphics device.
 * @param dataArea  the area inside the axes.
 * @param plot  the plot.
 * @param dataset  the dataset.
 * @param info  an optional info collection object to return data back to
 *              the caller.
 *
 * @return The renderer state (never <code>null</code>).
 */
public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea,
        XYPlot plot, XYDataset dataset, PlotRenderingInfo info) {

    XYItemRendererState state = createState(info);

    // determine if there is any selection state for the dataset
    XYDatasetSelectionState selectionState = null;
    if (dataset instanceof SelectableXYDataset) {
        SelectableXYDataset sxyd = (SelectableXYDataset) dataset;
        selectionState = sxyd.getSelectionState();
    }
    // if the selection state is still null, go to the selection source
    // and ask if it has state...
    if (selectionState == null && info != null) {
        ChartRenderingInfo cri = info.getOwner();
        if (cri != null) {
            RenderingSource rs = cri.getRenderingSource();
            selectionState = (XYDatasetSelectionState)
                    rs.getSelectionState(dataset);
        }
    }
    state.setSelectionState(selectionState);

    return state;
}
 
Example 2
Source File: XYLineAndShapeRenderer.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the visual representation of a single data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the data is being drawn.
 * @param info  collects information about the drawing.
 * @param plot  the plot (can be used to obtain standard color
 *              information etc).
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param crosshairState  crosshair information for the plot
 *                        (<code>null</code> permitted).
 * @param pass  the pass index.
 */
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state,
        Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot,
        ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset,
        int series, int item, CrosshairState crosshairState, int pass) {

    // do nothing if item is not visible
    if (!getItemVisible(series, item)) {
        return;
    }

    // first pass draws the background (lines, for instance)
    if (isLinePass(pass)) {
        if (getItemLineVisible(series, item)) {
            if (this.drawSeriesLineAsPath) {
                drawPrimaryLineAsPath(state, g2, plot, dataset, pass,
                        series, item, domainAxis, rangeAxis, dataArea);
            }
            else {
                drawPrimaryLine(state, g2, plot, dataset, pass, series,
                        item, domainAxis, rangeAxis, dataArea);
            }
        }
    }
    // second pass adds shapes where the items are ..
    else if (isItemPass(pass)) {

        // setup for collecting optional entity info...
        EntityCollection entities = null;
        if (info != null && info.getOwner() != null) {
            entities = info.getOwner().getEntityCollection();
        }

        drawSecondaryPass(g2, plot, dataset, pass, series, item,
                domainAxis, dataArea, rangeAxis, crosshairState, entities);
    }
}
 
Example 3
Source File: Axis.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Created an entity for the axis.
 *
 * @param cursor  the initial cursor value.
 * @param state  the axis state after completion of the drawing with a
 *     possibly updated cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 * @param plotState  the PlotRenderingInfo from which a reference to the
 *     entity collection can be obtained.
 *
 * @since 1.0.13
 */
protected void createAndAddEntity(double cursor, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge,
        PlotRenderingInfo plotState) {

    if (plotState == null || plotState.getOwner() == null) {
        return;  // no need to create entity if we can't save it anyways...
    }
    Rectangle2D hotspot = null;
    if (edge.equals(RectangleEdge.TOP)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(),
                state.getCursor(), dataArea.getWidth(),
                cursor - state.getCursor());
    }
    else if (edge.equals(RectangleEdge.BOTTOM)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(), cursor,
                dataArea.getWidth(), state.getCursor() - cursor);
    }
    else if (edge.equals(RectangleEdge.LEFT)) {
        hotspot = new Rectangle2D.Double(state.getCursor(),
                dataArea.getY(), cursor - state.getCursor(),
                dataArea.getHeight());
    }
    else if (edge.equals(RectangleEdge.RIGHT)) {
        hotspot = new Rectangle2D.Double(cursor, dataArea.getY(),
                state.getCursor() - cursor, dataArea.getHeight());
    }
    EntityCollection e = plotState.getOwner().getEntityCollection();
    if (e != null) {
        e.add(new AxisEntity(hotspot, this));
    }
}
 
Example 4
Source File: XYLineAndShapeRenderer.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the visual representation of a single data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the data is being drawn.
 * @param info  collects information about the drawing.
 * @param plot  the plot (can be used to obtain standard color
 *              information etc).
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param crosshairState  crosshair information for the plot
 *                        (<code>null</code> permitted).
 * @param pass  the pass index.
 */
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state,
        Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot,
        ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset,
        int series, int item, CrosshairState crosshairState, int pass) {

    // do nothing if item is not visible
    if (!getItemVisible(series, item)) {
        return;
    }

    // first pass draws the background (lines, for instance)
    if (isLinePass(pass)) {
        if (getItemLineVisible(series, item)) {
            if (this.drawSeriesLineAsPath) {
                drawPrimaryLineAsPath(state, g2, plot, dataset, pass,
                        series, item, domainAxis, rangeAxis, dataArea);
            }
            else {
                drawPrimaryLine(state, g2, plot, dataset, pass, series,
                        item, domainAxis, rangeAxis, dataArea);
            }
        }
    }
    // second pass adds shapes where the items are ..
    else if (isItemPass(pass)) {

        // setup for collecting optional entity info...
        EntityCollection entities = null;
        if (info != null && info.getOwner() != null) {
            entities = info.getOwner().getEntityCollection();
        }

        drawSecondaryPass(g2, plot, dataset, pass, series, item,
                domainAxis, dataArea, rangeAxis, crosshairState, entities);
    }
}
 
Example 5
Source File: Axis.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Created an entity for the axis.
 *
 * @param cursor  the initial cursor value.
 * @param state  the axis state after completion of the drawing with a
 *     possibly updated cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 * @param plotState  the PlotRenderingInfo from which a reference to the
 *     entity collection can be obtained.
 *
 * @since 1.0.13
 */
protected void createAndAddEntity(double cursor, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge,
        PlotRenderingInfo plotState) {

    if (plotState == null || plotState.getOwner() == null) {
        return;  // no need to create entity if we can't save it anyways...
    }
    Rectangle2D hotspot = null;
    if (edge.equals(RectangleEdge.TOP)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(),
                state.getCursor(), dataArea.getWidth(),
                cursor - state.getCursor());
    }
    else if (edge.equals(RectangleEdge.BOTTOM)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(), cursor,
                dataArea.getWidth(), state.getCursor() - cursor);
    }
    else if (edge.equals(RectangleEdge.LEFT)) {
        hotspot = new Rectangle2D.Double(state.getCursor(),
                dataArea.getY(), cursor - state.getCursor(),
                dataArea.getHeight());
    }
    else if (edge.equals(RectangleEdge.RIGHT)) {
        hotspot = new Rectangle2D.Double(cursor, dataArea.getY(),
                state.getCursor() - cursor, dataArea.getHeight());
    }
    EntityCollection e = plotState.getOwner().getEntityCollection();
    if (e != null) {
        e.add(new AxisEntity(hotspot, this));
    }
}
 
Example 6
Source File: XYLineAndShapeRenderer.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Draws the visual representation of a single data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the data is being drawn.
 * @param info  collects information about the drawing.
 * @param plot  the plot (can be used to obtain standard color
 *              information etc).
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param crosshairState  crosshair information for the plot
 *                        (<code>null</code> permitted).
 * @param pass  the pass index.
 */
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state,
        Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot,
        ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset,
        int series, int item, CrosshairState crosshairState, int pass) {

    // do nothing if item is not visible
    if (!getItemVisible(series, item)) {
        return;
    }

    // first pass draws the background (lines, for instance)
    if (isLinePass(pass)) {
        if (getItemLineVisible(series, item)) {
            if (this.drawSeriesLineAsPath) {
                drawPrimaryLineAsPath(state, g2, plot, dataset, pass,
                        series, item, domainAxis, rangeAxis, dataArea);
            }
            else {
                drawPrimaryLine(state, g2, plot, dataset, pass, series,
                        item, domainAxis, rangeAxis, dataArea);
            }
        }
    }
    // second pass adds shapes where the items are ..
    else if (isItemPass(pass)) {

        // setup for collecting optional entity info...
        EntityCollection entities = null;
        if (info != null && info.getOwner() != null) {
            entities = info.getOwner().getEntityCollection();
        }

        drawSecondaryPass(g2, plot, dataset, pass, series, item,
                domainAxis, dataArea, rangeAxis, crosshairState, entities);
    }
}
 
Example 7
Source File: Axis.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Created an entity for the axis.
 *
 * @param cursor  the initial cursor value.
 * @param state  the axis state after completion of the drawing with a
 *     possibly updated cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 * @param plotState  the PlotRenderingInfo from which a reference to the
 *     entity collection can be obtained.
 *
 * @since 1.0.13
 */
protected void createAndAddEntity(double cursor, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge,
        PlotRenderingInfo plotState) {

    if (plotState == null || plotState.getOwner() == null) {
        return;  // no need to create entity if we can't save it anyways...
    }
    Rectangle2D hotspot = null;
    if (edge.equals(RectangleEdge.TOP)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(),
                state.getCursor(), dataArea.getWidth(),
                cursor - state.getCursor());
    }
    else if (edge.equals(RectangleEdge.BOTTOM)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(), cursor,
                dataArea.getWidth(), state.getCursor() - cursor);
    }
    else if (edge.equals(RectangleEdge.LEFT)) {
        hotspot = new Rectangle2D.Double(state.getCursor(),
                dataArea.getY(), cursor - state.getCursor(),
                dataArea.getHeight());
    }
    else if (edge.equals(RectangleEdge.RIGHT)) {
        hotspot = new Rectangle2D.Double(cursor, dataArea.getY(),
                state.getCursor() - cursor, dataArea.getHeight());
    }
    EntityCollection e = plotState.getOwner().getEntityCollection();
    if (e != null) {
        e.add(new AxisEntity(hotspot, this));
    }
}
 
Example 8
Source File: JGenProg2017_006_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Draws the axis label.
 *
 * @param label  the label text.
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param dataArea  the area inside the axes.
 * @param edge  the location of the axis.
 * @param state  the axis state (<code>null</code> not permitted).
 * @param plotState  the plot state (<code>null</code> permitted).
 *
 * @return Information about the axis.
 */
protected AxisState drawLabel(String label, Graphics2D g2, 
        Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, 
        AxisState state, PlotRenderingInfo plotState) {

    // it is unlikely that 'state' will be null, but check anyway...
    if (state == null) {
        throw new IllegalArgumentException("Null 'state' argument.");
    }
    
    if ((label == null) || (label.equals(""))) {
        return state;
    }

    Font font = getLabelFont();
    RectangleInsets insets = getLabelInsets();
    g2.setFont(font);
    g2.setPaint(getLabelPaint());
    FontMetrics fm = g2.getFontMetrics();
    Rectangle2D labelBounds = TextUtilities.getTextBounds(label, g2, fm);
    Shape hotspot = null;
    
    if (plotState != null && hotspot != null) {
        ChartRenderingInfo owner = plotState.getOwner();
            EntityCollection entities = owner.getEntityCollection();
            if (entities != null) {
                entities.add(new AxisLabelEntity(this, hotspot, 
                        this.labelToolTip, this.labelURL));
            }
    }
    return state;

}
 
Example 9
Source File: XYLineAndShapeRenderer.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws the visual representation of a single data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the data is being drawn.
 * @param info  collects information about the drawing.
 * @param plot  the plot (can be used to obtain standard color
 *              information etc).
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param crosshairState  crosshair information for the plot
 *                        (<code>null</code> permitted).
 * @param pass  the pass index.
 */
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state,
        Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot,
        ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset,
        int series, int item, CrosshairState crosshairState, int pass) {

    // do nothing if item is not visible
    if (!getItemVisible(series, item)) {
        return;
    }

    // first pass draws the background (lines, for instance)
    if (isLinePass(pass)) {
        if (getItemLineVisible(series, item)) {
            if (this.drawSeriesLineAsPath) {
                drawPrimaryLineAsPath(state, g2, plot, dataset, pass,
                        series, item, domainAxis, rangeAxis, dataArea);
            }
            else {
                drawPrimaryLine(state, g2, plot, dataset, pass, series,
                        item, domainAxis, rangeAxis, dataArea);
            }
        }
    }
    // second pass adds shapes where the items are ..
    else if (isItemPass(pass)) {

        // setup for collecting optional entity info...
        EntityCollection entities = null;
        if (info != null && info.getOwner() != null) {
            entities = info.getOwner().getEntityCollection();
        }

        drawSecondaryPass(g2, plot, dataset, pass, series, item,
                domainAxis, dataArea, rangeAxis, crosshairState, entities);
    }
}
 
Example 10
Source File: Axis.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Created an entity for the axis.
 *
 * @param cursor  the initial cursor value.
 * @param state  the axis state after completion of the drawing with a
 *     possibly updated cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 * @param plotState  the PlotRenderingInfo from which a reference to the
 *     entity collection can be obtained.
 *
 * @since 1.0.13
 */
protected void createAndAddEntity(double cursor, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge,
        PlotRenderingInfo plotState) {

    if (plotState == null || plotState.getOwner() == null) {
        return;  // no need to create entity if we can't save it anyways...
    }
    Rectangle2D hotspot = null;
    if (edge.equals(RectangleEdge.TOP)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(),
                state.getCursor(), dataArea.getWidth(),
                cursor - state.getCursor());
    }
    else if (edge.equals(RectangleEdge.BOTTOM)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(), cursor,
                dataArea.getWidth(), state.getCursor() - cursor);
    }
    else if (edge.equals(RectangleEdge.LEFT)) {
        hotspot = new Rectangle2D.Double(state.getCursor(),
                dataArea.getY(), cursor - state.getCursor(),
                dataArea.getHeight());
    }
    else if (edge.equals(RectangleEdge.RIGHT)) {
        hotspot = new Rectangle2D.Double(cursor, dataArea.getY(),
                state.getCursor() - cursor, dataArea.getHeight());
    }
    EntityCollection e = plotState.getOwner().getEntityCollection();
    if (e != null) {
        e.add(new AxisEntity(hotspot, this));
    }
}
 
Example 11
Source File: XYLineAndShapeRenderer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initialises the renderer.
 * <P>
 * This method will be called before the first item is rendered, giving the
 * renderer an opportunity to initialise any state information it wants to
 * maintain.  The renderer can do nothing if it chooses.
 *
 * @param g2  the graphics device.
 * @param dataArea  the area inside the axes.
 * @param plot  the plot.
 * @param dataset  the dataset.
 * @param info  an optional info collection object to return data back to
 *              the caller.
 *
 * @return The renderer state.
 */
public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea,
        XYPlot plot, XYDataset dataset, PlotRenderingInfo info) {

    State state = new State(info);
    state.seriesPath = new GeneralPath();
    // determine if there is any selection state for the dataset
    XYDatasetSelectionState selectionState = null;
    if (dataset instanceof SelectableXYDataset) {
        SelectableXYDataset sxyd = (SelectableXYDataset) dataset;
        selectionState = sxyd.getSelectionState();
    }
    // if the selection state is still null, go to the selection source
    // and ask if it has state...
    if (selectionState == null && info != null) {
        ChartRenderingInfo cri = info.getOwner();
        if (cri != null) {
            RenderingSource rs = cri.getRenderingSource();
            if (rs != null) {
                selectionState = (XYDatasetSelectionState)
                        rs.getSelectionState(dataset);
            }
        }
    }
    state.setSelectionState(selectionState);
    return state;

}
 
Example 12
Source File: Axis.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Created an entity for the axis.
 *
 * @param cursor  the initial cursor value.
 * @param state  the axis state after completion of the drawing with a
 *     possibly updated cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 * @param plotState  the PlotRenderingInfo from which a reference to the
 *     entity collection can be obtained.
 *
 * @since 1.0.13
 */
protected void createAndAddEntity(double cursor, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge,
        PlotRenderingInfo plotState) {

    if (plotState == null || plotState.getOwner() == null) {
        return;  // no need to create entity if we canĀ“t save it anyways...
    }
    Rectangle2D hotspot = null;
    if (edge.equals(RectangleEdge.TOP)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(),
                state.getCursor(), dataArea.getWidth(),
                cursor - state.getCursor());
    }
    else if (edge.equals(RectangleEdge.BOTTOM)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(), cursor,
                dataArea.getWidth(), state.getCursor() - cursor);
    }
    else if (edge.equals(RectangleEdge.LEFT)) {
        hotspot = new Rectangle2D.Double(state.getCursor(),
                dataArea.getY(), cursor - state.getCursor(),
                dataArea.getHeight());
    }
    else if (edge.equals(RectangleEdge.RIGHT)) {
        hotspot = new Rectangle2D.Double(cursor, dataArea.getY(),
                state.getCursor() - cursor, dataArea.getHeight());
    }
    EntityCollection e = plotState.getOwner().getEntityCollection();
    if (e != null) {
        e.add(new AxisEntity(hotspot, this));
    }
}
 
Example 13
Source File: XYLineAndShapeRenderer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the visual representation of a single data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the data is being drawn.
 * @param info  collects information about the drawing.
 * @param plot  the plot (can be used to obtain standard color
 *              information etc).
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param crosshairState  crosshair information for the plot
 *                        (<code>null</code> permitted).
 * @param pass  the pass index.
 */
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state,
        Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot,
        ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset,
        int series, int item, CrosshairState crosshairState, int pass) {

    // do nothing if item is not visible
    if (!getItemVisible(series, item)) {
        return;
    }

    // first pass draws the background (lines, for instance)
    if (isLinePass(pass)) {
        if (getItemLineVisible(series, item)) {
            if (this.drawSeriesLineAsPath) {
                drawPrimaryLineAsPath(state, g2, plot, dataset, pass,
                        series, item, domainAxis, rangeAxis, dataArea);
            }
            else {
                drawPrimaryLine(state, g2, plot, dataset, pass, series,
                        item, domainAxis, rangeAxis, dataArea);
            }
        }
    }
    // second pass adds shapes where the items are ..
    else if (isItemPass(pass)) {

        // setup for collecting optional entity info...
        EntityCollection entities = null;
        if (info != null && info.getOwner() != null) {
            entities = info.getOwner().getEntityCollection();
        }

        drawSecondaryPass(g2, plot, dataset, pass, series, item,
                domainAxis, dataArea, rangeAxis, crosshairState, entities);
    }
}
 
Example 14
Source File: Axis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Created an entity for the axis.
 *
 * @param cursor  the initial cursor value.
 * @param state  the axis state after completion of the drawing with a
 *     possibly updated cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 * @param plotState  the PlotRenderingInfo from which a reference to the
 *     entity collection can be obtained.
 *
 * @since 1.0.13
 */
protected void createAndAddEntity(double cursor, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge,
        PlotRenderingInfo plotState) {

    if (plotState == null || plotState.getOwner() == null) {
        return;  // no need to create entity if we can't save it anyways...
    }
    Rectangle2D hotspot = null;
    if (edge.equals(RectangleEdge.TOP)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(),
                state.getCursor(), dataArea.getWidth(),
                cursor - state.getCursor());
    }
    else if (edge.equals(RectangleEdge.BOTTOM)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(), cursor,
                dataArea.getWidth(), state.getCursor() - cursor);
    }
    else if (edge.equals(RectangleEdge.LEFT)) {
        hotspot = new Rectangle2D.Double(state.getCursor(),
                dataArea.getY(), cursor - state.getCursor(),
                dataArea.getHeight());
    }
    else if (edge.equals(RectangleEdge.RIGHT)) {
        hotspot = new Rectangle2D.Double(cursor, dataArea.getY(),
                state.getCursor() - cursor, dataArea.getHeight());
    }
    EntityCollection e = plotState.getOwner().getEntityCollection();
    if (e != null) {
        e.add(new AxisEntity(hotspot, this));
    }
}
 
Example 15
Source File: XYLineAndShapeRenderer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the visual representation of a single data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the data is being drawn.
 * @param info  collects information about the drawing.
 * @param plot  the plot (can be used to obtain standard color
 *              information etc).
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param crosshairState  crosshair information for the plot
 *                        (<code>null</code> permitted).
 * @param pass  the pass index.
 */
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state,
        Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot,
        ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset,
        int series, int item, CrosshairState crosshairState, int pass) {

    // do nothing if item is not visible
    if (!getItemVisible(series, item)) {
        return;
    }

    // first pass draws the background (lines, for instance)
    if (isLinePass(pass)) {
        if (getItemLineVisible(series, item)) {
            if (this.drawSeriesLineAsPath) {
                drawPrimaryLineAsPath(state, g2, plot, dataset, pass,
                        series, item, domainAxis, rangeAxis, dataArea);
            }
            else {
                drawPrimaryLine(state, g2, plot, dataset, pass, series,
                        item, domainAxis, rangeAxis, dataArea);
            }
        }
    }
    // second pass adds shapes where the items are ..
    else if (isItemPass(pass)) {

        // setup for collecting optional entity info...
        EntityCollection entities = null;
        if (info != null && info.getOwner() != null) {
            entities = info.getOwner().getEntityCollection();
        }

        drawSecondaryPass(g2, plot, dataset, pass, series, item,
                domainAxis, dataArea, rangeAxis, crosshairState, entities);
    }
}
 
Example 16
Source File: Axis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Created an entity for the axis.
 *
 * @param cursor  the initial cursor value.
 * @param state  the axis state after completion of the drawing with a
 *     possibly updated cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 * @param plotState  the PlotRenderingInfo from which a reference to the
 *     entity collection can be obtained.
 *
 * @since 1.0.13
 */
protected void createAndAddEntity(double cursor, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge,
        PlotRenderingInfo plotState) {

    if (plotState == null || plotState.getOwner() == null) {
        return;  // no need to create entity if we can't save it anyways...
    }
    Rectangle2D hotspot = null;
    if (edge.equals(RectangleEdge.TOP)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(),
                state.getCursor(), dataArea.getWidth(),
                cursor - state.getCursor());
    }
    else if (edge.equals(RectangleEdge.BOTTOM)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(), cursor,
                dataArea.getWidth(), state.getCursor() - cursor);
    }
    else if (edge.equals(RectangleEdge.LEFT)) {
        hotspot = new Rectangle2D.Double(state.getCursor(),
                dataArea.getY(), cursor - state.getCursor(),
                dataArea.getHeight());
    }
    else if (edge.equals(RectangleEdge.RIGHT)) {
        hotspot = new Rectangle2D.Double(cursor, dataArea.getY(),
                state.getCursor() - cursor, dataArea.getHeight());
    }
    EntityCollection e = plotState.getOwner().getEntityCollection();
    if (e != null) {
        e.add(new AxisEntity(hotspot, this));
    }
}