Java Code Examples for org.jfree.chart.ChartRenderingInfo#getRenderingSource()

The following examples show how to use org.jfree.chart.ChartRenderingInfo#getRenderingSource() . 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 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;

}