Java Code Examples for org.jfree.chart.renderer.category.BarRenderer#getLegendItem()

The following examples show how to use org.jfree.chart.renderer.category.BarRenderer#getLegendItem() . 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: BarRendererTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
public void testGetLegendItemSeriesIndex() {
    DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();
    dataset0.addValue(21.0, "R1", "C1");
    dataset0.addValue(22.0, "R2", "C1");
    DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
    dataset1.addValue(23.0, "R3", "C1");
    dataset1.addValue(24.0, "R4", "C1");
    dataset1.addValue(25.0, "R5", "C1");
    BarRenderer r = new BarRenderer();
    CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, dataset1);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("R5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example 2
Source File: BarRendererTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
public void testGetLegendItemSeriesIndex() {
    DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();
    dataset0.addValue(21.0, "R1", "C1");
    dataset0.addValue(22.0, "R2", "C1");        
    DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
    dataset1.addValue(23.0, "R3", "C1");
    dataset1.addValue(24.0, "R4", "C1");        
    dataset1.addValue(25.0, "R5", "C1");        
    BarRenderer r = new BarRenderer();
    CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, dataset1);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("R5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example 3
Source File: BarRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getLegendItem() method.
 */
public void testGetLegendItem() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(21.0, "R1", "C1");
    BarRenderer r = new BarRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"),
            new NumberAxis("y"), r);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(0, 0);
    assertNotNull(li);
    r.setSeriesVisibleInLegend(0, Boolean.FALSE);
    li = r.getLegendItem(0, 0);
    assertNull(li);
}
 
Example 4
Source File: BarRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getLegendItem() method.
 */
public void testGetLegendItem() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(21.0, "R1", "C1");
    BarRenderer r = new BarRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"),
            new NumberAxis("y"), r);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(0, 0);
    assertNotNull(li);
    r.setSeriesVisibleInLegend(0, Boolean.FALSE);
    li = r.getLegendItem(0, 0);
    assertNull(li);
}