Search in sources :

Example 46 with LegendItem

use of org.jfree.chart.LegendItem in project SIMVA-SoS by SESoS.

the class LineAndShapeRendererTest method testGetLegendItemSeriesIndex.

/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
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");
    LineAndShapeRenderer r = new LineAndShapeRenderer();
    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());
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) LegendItem(org.jfree.chart.LegendItem) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 47 with LegendItem

use of org.jfree.chart.LegendItem in project SIMVA-SoS by SESoS.

the class StandardXYItemRendererTest method testGetLegendItemSeriesIndex.

/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    XYSeriesCollection d1 = new XYSeriesCollection();
    XYSeries s1 = new XYSeries("S1");
    s1.add(1.0, 1.1);
    XYSeries s2 = new XYSeries("S2");
    s2.add(1.0, 1.1);
    d1.addSeries(s1);
    d1.addSeries(s2);
    XYSeriesCollection d2 = new XYSeriesCollection();
    XYSeries s3 = new XYSeries("S3");
    s3.add(1.0, 1.1);
    XYSeries s4 = new XYSeries("S4");
    s4.add(1.0, 1.1);
    XYSeries s5 = new XYSeries("S5");
    s5.add(1.0, 1.1);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);
    StandardXYItemRenderer r = new StandardXYItemRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/
    new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) LegendItem(org.jfree.chart.LegendItem) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 48 with LegendItem

use of org.jfree.chart.LegendItem in project SIMVA-SoS by SESoS.

the class SpiderWebPlotTest method testGetLegendItems.

/**
 * Fetches the legend items and checks the values.
 */
@Test
public void testGetLegendItems() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(35.0, "S1", "C1");
    dataset.addValue(45.0, "S1", "C2");
    dataset.addValue(55.0, "S2", "C1");
    dataset.addValue(15.0, "S2", "C2");
    SpiderWebPlot plot = new SpiderWebPlot(dataset);
    JFreeChart chart = new JFreeChart(plot);
    LegendItemCollection legendItems = plot.getLegendItems();
    assertEquals(2, legendItems.getItemCount());
    LegendItem item1 = legendItems.get(0);
    assertEquals("S1", item1.getLabel());
    assertEquals("S1", item1.getSeriesKey());
    assertEquals(0, item1.getSeriesIndex());
    assertEquals(dataset, item1.getDataset());
    assertEquals(0, item1.getDatasetIndex());
    LegendItem item2 = legendItems.get(1);
    assertEquals("S2", item2.getLabel());
    assertEquals("S2", item2.getSeriesKey());
    assertEquals(1, item2.getSeriesIndex());
    assertEquals(dataset, item2.getDataset());
    assertEquals(0, item2.getDatasetIndex());
}
Also used : LegendItem(org.jfree.chart.LegendItem) LegendItemCollection(org.jfree.chart.LegendItemCollection) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 49 with LegendItem

use of org.jfree.chart.LegendItem in project SIMVA-SoS by SESoS.

the class BoxAndWhiskerRendererTest method testGetLegendItemSeriesIndex.

/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
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");
    BoxAndWhiskerRenderer r = new BoxAndWhiskerRenderer();
    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());
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) LegendItem(org.jfree.chart.LegendItem) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 50 with LegendItem

use of org.jfree.chart.LegendItem in project SIMVA-SoS by SESoS.

the class AreaRendererTest method testGetLegendItemSeriesIndex.

/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
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");
    AreaRenderer r = new AreaRenderer();
    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());
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) LegendItem(org.jfree.chart.LegendItem) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Aggregations

LegendItem (org.jfree.chart.LegendItem)53 Paint (java.awt.Paint)26 Test (org.junit.Test)25 NumberAxis (org.jfree.chart.axis.NumberAxis)21 JFreeChart (org.jfree.chart.JFreeChart)19 LegendItemCollection (org.jfree.chart.LegendItemCollection)19 XYPlot (org.jfree.chart.plot.XYPlot)19 Stroke (java.awt.Stroke)18 Shape (java.awt.Shape)17 CategoryPlot (org.jfree.chart.plot.CategoryPlot)15 XYDataset (org.jfree.data.xy.XYDataset)13 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)9 XYSeries (org.jfree.data.xy.XYSeries)9 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)9 CategoryAxis (org.jfree.chart.axis.CategoryAxis)8 CategoryDataset (org.jfree.data.category.CategoryDataset)8 GradientPaint (java.awt.GradientPaint)7 BasicStroke (java.awt.BasicStroke)6 Iterator (java.util.Iterator)5 List (java.util.List)5