Java Code Examples for org.jfree.chart.plot.CategoryPlot#getRangeAxisForDataset()

The following examples show how to use org.jfree.chart.plot.CategoryPlot#getRangeAxisForDataset() . 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: BarRenderer.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Initialises the renderer and returns a state object that will be passed
 * to subsequent calls to the drawItem method.  This method gets called
 * once at the start of the process of drawing a chart.
 *
 * @param g2  the graphics device.
 * @param dataArea  the area in which the data is to be plotted.
 * @param plot  the plot.
 * @param rendererIndex  the renderer index.
 * @param info  collects chart rendering information for return to caller.
 *
 * @return The renderer state.
 */
@Override
public CategoryItemRendererState initialise(Graphics2D g2, 
        Rectangle2D dataArea, CategoryPlot plot, int rendererIndex,
        PlotRenderingInfo info) {

    CategoryItemRendererState state = super.initialise(g2, dataArea, plot,
            rendererIndex, info);

    // get the clipping values...
    ValueAxis rangeAxis = plot.getRangeAxisForDataset(rendererIndex);
    this.lowerClip = rangeAxis.getRange().getLowerBound();
    this.upperClip = rangeAxis.getRange().getUpperBound();

    // calculate the bar width
    calculateBarWidth(plot, dataArea, rendererIndex, state);

    return state;

}
 
Example 2
Source File: BarRenderer.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Initialises the renderer and returns a state object that will be passed
 * to subsequent calls to the drawItem method.  This method gets called
 * once at the start of the process of drawing a chart.
 *
 * @param g2  the graphics device.
 * @param dataArea  the area in which the data is to be plotted.
 * @param plot  the plot.
 * @param rendererIndex  the renderer index.
 * @param info  collects chart rendering information for return to caller.
 *
 * @return The renderer state.
 */
@Override
public CategoryItemRendererState initialise(Graphics2D g2, 
        Rectangle2D dataArea, CategoryPlot plot, int rendererIndex,
        PlotRenderingInfo info) {

    CategoryItemRendererState state = super.initialise(g2, dataArea, plot,
            rendererIndex, info);

    // get the clipping values...
    ValueAxis rangeAxis = plot.getRangeAxisForDataset(rendererIndex);
    this.lowerClip = rangeAxis.getRange().getLowerBound();
    this.upperClip = rangeAxis.getRange().getUpperBound();

    // calculate the bar width
    calculateBarWidth(plot, dataArea, rendererIndex, state);

    return state;

}
 
Example 3
Source File: BarRenderer.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Initialises the renderer and returns a state object that will be passed
 * to subsequent calls to the drawItem method.  This method gets called
 * once at the start of the process of drawing a chart.
 *
 * @param g2  the graphics device.
 * @param dataArea  the area in which the data is to be plotted.
 * @param plot  the plot.
 * @param rendererIndex  the renderer index.
 * @param info  collects chart rendering information for return to caller.
 *
 * @return The renderer state.
 */
@Override
public CategoryItemRendererState initialise(Graphics2D g2, 
        Rectangle2D dataArea, CategoryPlot plot, int rendererIndex,
        PlotRenderingInfo info) {

    CategoryItemRendererState state = super.initialise(g2, dataArea, plot,
            rendererIndex, info);

    // get the clipping values...
    ValueAxis rangeAxis = plot.getRangeAxisForDataset(rendererIndex);
    this.lowerClip = rangeAxis.getRange().getLowerBound();
    this.upperClip = rangeAxis.getRange().getUpperBound();

    // calculate the bar width
    calculateBarWidth(plot, dataArea, rendererIndex, state);

    return state;

}
 
Example 4
Source File: BarRenderer.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initialises the renderer and returns a state object that will be passed
 * to subsequent calls to the drawItem method.  This method gets called
 * once at the start of the process of drawing a chart.
 *
 * @param g2  the graphics device.
 * @param dataArea  the area in which the data is to be plotted.
 * @param plot  the plot.
 * @param rendererIndex  the renderer index.
 * @param info  collects chart rendering information for return to caller.
 *
 * @return The renderer state.
 */
@Override
public CategoryItemRendererState initialise(Graphics2D g2, 
        Rectangle2D dataArea, CategoryPlot plot, int rendererIndex,
        PlotRenderingInfo info) {

    CategoryItemRendererState state = super.initialise(g2, dataArea, plot,
            rendererIndex, info);

    // get the clipping values...
    ValueAxis rangeAxis = plot.getRangeAxisForDataset(rendererIndex);
    this.lowerClip = rangeAxis.getRange().getLowerBound();
    this.upperClip = rangeAxis.getRange().getUpperBound();

    // calculate the bar width
    calculateBarWidth(plot, dataArea, rendererIndex, state);

    return state;

}
 
Example 5
Source File: BarRenderer.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 will be passed 
 * to subsequent calls to the drawItem method.  This method gets called 
 * once at the start of the process of drawing a chart.
 *
 * @param g2  the graphics device.
 * @param dataArea  the area in which the data is to be plotted.
 * @param plot  the plot.
 * @param rendererIndex  the renderer index.
 * @param info  collects chart rendering information for return to caller.
 * 
 * @return The renderer state.
 */
public CategoryItemRendererState initialise(Graphics2D g2,
                                            Rectangle2D dataArea,
                                            CategoryPlot plot,
                                            int rendererIndex,
                                            PlotRenderingInfo info) {

    CategoryItemRendererState state = super.initialise(g2, dataArea, plot, 
            rendererIndex, info);

    // get the clipping values...
    ValueAxis rangeAxis = plot.getRangeAxisForDataset(rendererIndex);
    this.lowerClip = rangeAxis.getRange().getLowerBound();
    this.upperClip = rangeAxis.getRange().getUpperBound();

    // calculate the bar width
    calculateBarWidth(plot, dataArea, rendererIndex, state);

    return state;
    
}
 
Example 6
Source File: BarRenderer.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Initialises the renderer and returns a state object that will be passed 
 * to subsequent calls to the drawItem method.  This method gets called 
 * once at the start of the process of drawing a chart.
 *
 * @param g2  the graphics device.
 * @param dataArea  the area in which the data is to be plotted.
 * @param plot  the plot.
 * @param rendererIndex  the renderer index.
 * @param info  collects chart rendering information for return to caller.
 * 
 * @return The renderer state.
 */
public CategoryItemRendererState initialise(Graphics2D g2,
                                            Rectangle2D dataArea,
                                            CategoryPlot plot,
                                            int rendererIndex,
                                            PlotRenderingInfo info) {

    CategoryItemRendererState state = super.initialise(g2, dataArea, plot, 
            rendererIndex, info);

    // get the clipping values...
    ValueAxis rangeAxis = plot.getRangeAxisForDataset(rendererIndex);
    this.lowerClip = rangeAxis.getRange().getLowerBound();
    this.upperClip = rangeAxis.getRange().getUpperBound();

    // calculate the bar width
    calculateBarWidth(plot, dataArea, rendererIndex, state);

    return state;
    
}
 
Example 7
Source File: BarRenderer.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Initialises the renderer and returns a state object that will be passed
 * to subsequent calls to the drawItem method.  This method gets called
 * once at the start of the process of drawing a chart.
 *
 * @param g2  the graphics device.
 * @param dataArea  the area in which the data is to be plotted.
 * @param plot  the plot.
 * @param rendererIndex  the renderer index.
 * @param info  collects chart rendering information for return to caller.
 *
 * @return The renderer state.
 */
@Override
public CategoryItemRendererState initialise(Graphics2D g2, 
        Rectangle2D dataArea, CategoryPlot plot, int rendererIndex,
        PlotRenderingInfo info) {

    CategoryItemRendererState state = super.initialise(g2, dataArea, plot,
            rendererIndex, info);

    // get the clipping values...
    ValueAxis rangeAxis = plot.getRangeAxisForDataset(rendererIndex);
    this.lowerClip = rangeAxis.getRange().getLowerBound();
    this.upperClip = rangeAxis.getRange().getUpperBound();

    // calculate the bar width
    calculateBarWidth(plot, dataArea, rendererIndex, state);

    return state;

}
 
Example 8
Source File: BarRenderer.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Initialises the renderer and returns a state object that will be passed
 * to subsequent calls to the drawItem method.  This method gets called
 * once at the start of the process of drawing a chart.
 *
 * @param g2  the graphics device.
 * @param dataArea  the area in which the data is to be plotted.
 * @param plot  the plot.
 * @param rendererIndex  the renderer index.
 * @param info  collects chart rendering information for return to caller.
 *
 * @return The renderer state.
 */
@Override
public CategoryItemRendererState initialise(Graphics2D g2, 
        Rectangle2D dataArea, CategoryPlot plot, int rendererIndex,
        PlotRenderingInfo info) {

    CategoryItemRendererState state = super.initialise(g2, dataArea, plot,
            rendererIndex, info);

    // get the clipping values...
    ValueAxis rangeAxis = plot.getRangeAxisForDataset(rendererIndex);
    this.lowerClip = rangeAxis.getRange().getLowerBound();
    this.upperClip = rangeAxis.getRange().getUpperBound();

    // calculate the bar width
    calculateBarWidth(plot, dataArea, rendererIndex, state);

    return state;

}
 
Example 9
Source File: CategoryPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some tests for the getRangeAxisForDataset() method.
 */
public void testGetRangeAxisForDataset() {
    CategoryDataset dataset = new DefaultCategoryDataset();
    CategoryAxis xAxis = new CategoryAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    CategoryItemRenderer renderer = new DefaultCategoryItemRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    // should get IllegalArgumentException for negative index
    boolean pass = false;
    try {
        plot.getRangeAxisForDataset(-1);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);

    // if multiple axes are mapped, the first in the list should be
    // returned...
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(1, yAxis2);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    plot.mapDatasetToRangeAxis(0, 1);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(0));

    List axisIndices = Arrays.asList(new Integer[] {new Integer(0),
            new Integer(1)});
    plot.mapDatasetToRangeAxes(0, axisIndices);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    axisIndices = Arrays.asList(new Integer[] {new Integer(1),
            new Integer(2)});
    plot.mapDatasetToRangeAxes(0, axisIndices);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(0));
}