Search in sources :

Example 36 with LegendItem

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

the class XYPlotTest method testEquals.

/**
 * Some checks for the equals() method.
 */
@Test
public void testEquals() {
    XYPlot plot1 = new XYPlot();
    XYPlot plot2 = new XYPlot();
    assertTrue(plot1.equals(plot2));
    // orientation...
    plot1.setOrientation(PlotOrientation.HORIZONTAL);
    assertFalse(plot1.equals(plot2));
    plot2.setOrientation(PlotOrientation.HORIZONTAL);
    assertTrue(plot1.equals(plot2));
    // axisOffset...
    plot1.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05));
    assertFalse(plot1.equals(plot2));
    plot2.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05));
    assertTrue(plot1.equals(plot2));
    // domainAxis...
    plot1.setDomainAxis(new NumberAxis("Domain Axis"));
    assertFalse(plot1.equals(plot2));
    plot2.setDomainAxis(new NumberAxis("Domain Axis"));
    assertTrue(plot1.equals(plot2));
    // domainAxisLocation...
    plot1.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
    assertFalse(plot1.equals(plot2));
    plot2.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
    assertTrue(plot1.equals(plot2));
    // secondary DomainAxes...
    plot1.setDomainAxis(11, new NumberAxis("Secondary Domain Axis"));
    assertFalse(plot1.equals(plot2));
    plot2.setDomainAxis(11, new NumberAxis("Secondary Domain Axis"));
    assertTrue(plot1.equals(plot2));
    // secondary DomainAxisLocations...
    plot1.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
    assertFalse(plot1.equals(plot2));
    plot2.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
    assertTrue(plot1.equals(plot2));
    // rangeAxis...
    plot1.setRangeAxis(new NumberAxis("Range Axis"));
    assertFalse(plot1.equals(plot2));
    plot2.setRangeAxis(new NumberAxis("Range Axis"));
    assertTrue(plot1.equals(plot2));
    // rangeAxisLocation...
    plot1.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
    assertTrue(plot1.equals(plot2));
    // secondary RangeAxes...
    plot1.setRangeAxis(11, new NumberAxis("Secondary Range Axis"));
    assertFalse(plot1.equals(plot2));
    plot2.setRangeAxis(11, new NumberAxis("Secondary Range Axis"));
    assertTrue(plot1.equals(plot2));
    // secondary RangeAxisLocations...
    plot1.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
    assertTrue(plot1.equals(plot2));
    // secondary DatasetDomainAxisMap...
    plot1.mapDatasetToDomainAxis(11, 11);
    assertFalse(plot1.equals(plot2));
    plot2.mapDatasetToDomainAxis(11, 11);
    assertTrue(plot1.equals(plot2));
    // secondaryDatasetRangeAxisMap...
    plot1.mapDatasetToRangeAxis(11, 11);
    assertFalse(plot1.equals(plot2));
    plot2.mapDatasetToRangeAxis(11, 11);
    assertTrue(plot1.equals(plot2));
    // renderer
    plot1.setRenderer(new DefaultXYItemRenderer());
    assertFalse(plot1.equals(plot2));
    plot2.setRenderer(new DefaultXYItemRenderer());
    assertTrue(plot1.equals(plot2));
    // secondary renderers
    plot1.setRenderer(11, new DefaultXYItemRenderer());
    assertFalse(plot1.equals(plot2));
    plot2.setRenderer(11, new DefaultXYItemRenderer());
    assertTrue(plot1.equals(plot2));
    // domainGridlinesVisible
    plot1.setDomainGridlinesVisible(false);
    assertFalse(plot1.equals(plot2));
    plot2.setDomainGridlinesVisible(false);
    assertTrue(plot1.equals(plot2));
    // domainGridlineStroke
    Stroke stroke = new BasicStroke(2.0f);
    plot1.setDomainGridlineStroke(stroke);
    assertFalse(plot1.equals(plot2));
    plot2.setDomainGridlineStroke(stroke);
    assertTrue(plot1.equals(plot2));
    // domainGridlinePaint
    plot1.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red));
    assertFalse(plot1.equals(plot2));
    plot2.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red));
    assertTrue(plot1.equals(plot2));
    // rangeGridlinesVisible
    plot1.setRangeGridlinesVisible(false);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeGridlinesVisible(false);
    assertTrue(plot1.equals(plot2));
    // rangeGridlineStroke
    plot1.setRangeGridlineStroke(stroke);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeGridlineStroke(stroke);
    assertTrue(plot1.equals(plot2));
    // rangeGridlinePaint
    plot1.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.red));
    assertFalse(plot1.equals(plot2));
    plot2.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.red));
    assertTrue(plot1.equals(plot2));
    // rangeZeroBaselineVisible
    plot1.setRangeZeroBaselineVisible(true);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeZeroBaselineVisible(true);
    assertTrue(plot1.equals(plot2));
    // rangeZeroBaselineStroke
    plot1.setRangeZeroBaselineStroke(stroke);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeZeroBaselineStroke(stroke);
    assertTrue(plot1.equals(plot2));
    // rangeZeroBaselinePaint
    plot1.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.red));
    assertFalse(plot1.equals(plot2));
    plot2.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.red));
    assertTrue(plot1.equals(plot2));
    // rangeCrosshairVisible
    plot1.setRangeCrosshairVisible(true);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeCrosshairVisible(true);
    assertTrue(plot1.equals(plot2));
    // rangeCrosshairValue
    plot1.setRangeCrosshairValue(100.0);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeCrosshairValue(100.0);
    assertTrue(plot1.equals(plot2));
    // rangeCrosshairStroke
    plot1.setRangeCrosshairStroke(stroke);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeCrosshairStroke(stroke);
    assertTrue(plot1.equals(plot2));
    // rangeCrosshairPaint
    plot1.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.pink, 3.0f, 4.0f, Color.red));
    assertFalse(plot1.equals(plot2));
    plot2.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.pink, 3.0f, 4.0f, Color.red));
    assertTrue(plot1.equals(plot2));
    // rangeCrosshairLockedOnData
    plot1.setRangeCrosshairLockedOnData(false);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeCrosshairLockedOnData(false);
    assertTrue(plot1.equals(plot2));
    // range markers
    plot1.addRangeMarker(new ValueMarker(4.0));
    assertFalse(plot1.equals(plot2));
    plot2.addRangeMarker(new ValueMarker(4.0));
    assertTrue(plot1.equals(plot2));
    // secondary range markers
    plot1.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND);
    assertFalse(plot1.equals(plot2));
    plot2.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND);
    assertTrue(plot1.equals(plot2));
    plot1.addRangeMarker(1, new ValueMarker(99.0), Layer.BACKGROUND);
    assertFalse(plot1.equals(plot2));
    plot2.addRangeMarker(1, new ValueMarker(99.0), Layer.BACKGROUND);
    assertTrue(plot1.equals(plot2));
    // fixed legend items
    plot1.setFixedLegendItems(new LegendItemCollection());
    assertFalse(plot1.equals(plot2));
    plot2.setFixedLegendItems(new LegendItemCollection());
    assertTrue(plot1.equals(plot2));
    // weight
    plot1.setWeight(3);
    assertFalse(plot1.equals(plot2));
    plot2.setWeight(3);
    assertTrue(plot1.equals(plot2));
    // quadrant origin
    plot1.setQuadrantOrigin(new Point2D.Double(12.3, 45.6));
    assertFalse(plot1.equals(plot2));
    plot2.setQuadrantOrigin(new Point2D.Double(12.3, 45.6));
    assertTrue(plot1.equals(plot2));
    // quadrant paint
    plot1.setQuadrantPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));
    assertFalse(plot1.equals(plot2));
    plot2.setQuadrantPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));
    assertTrue(plot1.equals(plot2));
    plot1.setQuadrantPaint(1, new GradientPaint(2.0f, 3.0f, Color.red, 4.0f, 5.0f, Color.blue));
    assertFalse(plot1.equals(plot2));
    plot2.setQuadrantPaint(1, new GradientPaint(2.0f, 3.0f, Color.red, 4.0f, 5.0f, Color.blue));
    assertTrue(plot1.equals(plot2));
    plot1.setQuadrantPaint(2, new GradientPaint(3.0f, 4.0f, Color.red, 5.0f, 6.0f, Color.blue));
    assertFalse(plot1.equals(plot2));
    plot2.setQuadrantPaint(2, new GradientPaint(3.0f, 4.0f, Color.red, 5.0f, 6.0f, Color.blue));
    assertTrue(plot1.equals(plot2));
    plot1.setQuadrantPaint(3, new GradientPaint(4.0f, 5.0f, Color.red, 6.0f, 7.0f, Color.blue));
    assertFalse(plot1.equals(plot2));
    plot2.setQuadrantPaint(3, new GradientPaint(4.0f, 5.0f, Color.red, 6.0f, 7.0f, Color.blue));
    assertTrue(plot1.equals(plot2));
    plot1.setDomainTickBandPaint(Color.red);
    assertFalse(plot1.equals(plot2));
    plot2.setDomainTickBandPaint(Color.red);
    assertTrue(plot1.equals(plot2));
    plot1.setRangeTickBandPaint(Color.blue);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeTickBandPaint(Color.blue);
    assertTrue(plot1.equals(plot2));
    plot1.setDomainMinorGridlinesVisible(true);
    assertFalse(plot1.equals(plot2));
    plot2.setDomainMinorGridlinesVisible(true);
    assertTrue(plot1.equals(plot2));
    plot1.setDomainMinorGridlinePaint(Color.red);
    assertFalse(plot1.equals(plot2));
    plot2.setDomainMinorGridlinePaint(Color.red);
    assertTrue(plot1.equals(plot2));
    plot1.setDomainGridlineStroke(new BasicStroke(1.1f));
    assertFalse(plot1.equals(plot2));
    plot2.setDomainGridlineStroke(new BasicStroke(1.1f));
    assertTrue(plot1.equals(plot2));
    plot1.setRangeMinorGridlinesVisible(true);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeMinorGridlinesVisible(true);
    assertTrue(plot1.equals(plot2));
    plot1.setRangeMinorGridlinePaint(Color.blue);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeMinorGridlinePaint(Color.blue);
    assertTrue(plot1.equals(plot2));
    plot1.setRangeMinorGridlineStroke(new BasicStroke(1.23f));
    assertFalse(plot1.equals(plot2));
    plot2.setRangeMinorGridlineStroke(new BasicStroke(1.23f));
    assertTrue(plot1.equals(plot2));
    List axisIndices = Arrays.asList(new Integer[] { new Integer(0), new Integer(1) });
    plot1.mapDatasetToDomainAxes(0, axisIndices);
    assertFalse(plot1.equals(plot2));
    plot2.mapDatasetToDomainAxes(0, axisIndices);
    assertTrue(plot1.equals(plot2));
    plot1.mapDatasetToRangeAxes(0, axisIndices);
    assertFalse(plot1.equals(plot2));
    plot2.mapDatasetToRangeAxes(0, axisIndices);
    assertTrue(plot1.equals(plot2));
    // shadowGenerator
    plot1.setShadowGenerator(new DefaultShadowGenerator(5, Color.gray, 0.6f, 4, -Math.PI / 4));
    assertFalse(plot1.equals(plot2));
    plot2.setShadowGenerator(new DefaultShadowGenerator(5, Color.gray, 0.6f, 4, -Math.PI / 4));
    assertTrue(plot1.equals(plot2));
    plot1.setShadowGenerator(null);
    assertFalse(plot1.equals(plot2));
    plot2.setShadowGenerator(null);
    assertTrue(plot1.equals(plot2));
    LegendItemCollection lic1 = new LegendItemCollection();
    lic1.add(new LegendItem("XYZ", Color.red));
    plot1.setFixedLegendItems(lic1);
    assertFalse(plot1.equals(plot2));
    LegendItemCollection lic2 = new LegendItemCollection();
    lic2.add(new LegendItem("XYZ", Color.red));
    plot2.setFixedLegendItems(lic2);
    assertTrue(plot1.equals(plot2));
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) NumberAxis(org.jfree.chart.axis.NumberAxis) LegendItemCollection(org.jfree.chart.LegendItemCollection) GradientPaint(java.awt.GradientPaint) DefaultShadowGenerator(org.jfree.chart.util.DefaultShadowGenerator) DefaultXYItemRenderer(org.jfree.chart.renderer.xy.DefaultXYItemRenderer) Point2D(java.awt.geom.Point2D) LegendItem(org.jfree.chart.LegendItem) RectangleInsets(org.jfree.ui.RectangleInsets) List(java.util.List) Test(org.junit.Test)

Example 37 with LegendItem

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

the class PolarPlotTest method testGetLegendItems2.

/**
 * Some checks for the getLegendItems() method with multiple datasets.
 */
@Test
public void testGetLegendItems2() {
    XYSeriesCollection d1 = new XYSeriesCollection();
    d1.addSeries(new XYSeries("A"));
    d1.addSeries(new XYSeries("B"));
    XYSeriesCollection d2 = new XYSeriesCollection();
    d2.addSeries(new XYSeries("C"));
    d2.addSeries(new XYSeries("D"));
    DefaultPolarItemRenderer r = new DefaultPolarItemRenderer();
    PolarPlot plot = new PolarPlot();
    plot.setDataset(d1);
    plot.setDataset(1, d2);
    plot.setRenderer(r);
    plot.setRenderer(1, new DefaultPolarItemRenderer());
    LegendItemCollection items = plot.getLegendItems();
    assertEquals(4, items.getItemCount());
    LegendItem item1 = items.get(0);
    assertEquals("A", item1.getLabel());
    LegendItem item2 = items.get(1);
    assertEquals("B", item2.getLabel());
    LegendItem item3 = items.get(2);
    assertEquals("C", item3.getLabel());
    LegendItem item4 = items.get(3);
    assertEquals("D", item4.getLabel());
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) LegendItem(org.jfree.chart.LegendItem) LegendItemCollection(org.jfree.chart.LegendItemCollection) DefaultPolarItemRenderer(org.jfree.chart.renderer.DefaultPolarItemRenderer) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) Test(org.junit.Test)

Example 38 with LegendItem

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

the class PolarPlotTest method testEquals.

/**
 * Some checks for the equals() method.
 */
@Test
public void testEquals() {
    PolarPlot plot1 = new PolarPlot();
    PolarPlot plot2 = new PolarPlot();
    assertTrue(plot1.equals(plot2));
    assertTrue(plot2.equals(plot1));
    plot1.setAngleGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));
    assertFalse(plot1.equals(plot2));
    plot2.setAngleGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));
    assertTrue(plot1.equals(plot2));
    Stroke s = new BasicStroke(1.23f);
    plot1.setAngleGridlineStroke(s);
    assertFalse(plot1.equals(plot2));
    plot2.setAngleGridlineStroke(s);
    assertTrue(plot1.equals(plot2));
    plot1.setAngleTickUnit(new NumberTickUnit(11.0));
    assertFalse(plot1.equals(plot2));
    plot2.setAngleTickUnit(new NumberTickUnit(11.0));
    assertTrue(plot1.equals(plot2));
    plot1.setAngleGridlinesVisible(false);
    assertFalse(plot1.equals(plot2));
    plot2.setAngleGridlinesVisible(false);
    assertTrue(plot1.equals(plot2));
    plot1.setAngleLabelFont(new Font("Serif", Font.PLAIN, 9));
    assertFalse(plot1.equals(plot2));
    plot2.setAngleLabelFont(new Font("Serif", Font.PLAIN, 9));
    assertTrue(plot1.equals(plot2));
    plot1.setAngleLabelPaint(new GradientPaint(9.0f, 8.0f, Color.blue, 7.0f, 6.0f, Color.red));
    assertFalse(plot1.equals(plot2));
    plot2.setAngleLabelPaint(new GradientPaint(9.0f, 8.0f, Color.blue, 7.0f, 6.0f, Color.red));
    assertTrue(plot1.equals(plot2));
    plot1.setAngleLabelsVisible(false);
    assertFalse(plot1.equals(plot2));
    plot2.setAngleLabelsVisible(false);
    assertTrue(plot1.equals(plot2));
    plot1.setAxis(new NumberAxis("Test"));
    assertFalse(plot1.equals(plot2));
    plot2.setAxis(new NumberAxis("Test"));
    assertTrue(plot1.equals(plot2));
    plot1.setRadiusGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.black));
    assertFalse(plot1.equals(plot2));
    plot2.setRadiusGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.black));
    assertTrue(plot1.equals(plot2));
    plot1.setRadiusGridlineStroke(s);
    assertFalse(plot1.equals(plot2));
    plot2.setRadiusGridlineStroke(s);
    assertTrue(plot1.equals(plot2));
    plot1.setRadiusGridlinesVisible(false);
    assertFalse(plot1.equals(plot2));
    plot2.setRadiusGridlinesVisible(false);
    assertTrue(plot1.equals(plot2));
    plot1.setRadiusMinorGridlinesVisible(false);
    assertFalse(plot1.equals(plot2));
    plot2.setRadiusMinorGridlinesVisible(false);
    assertTrue(plot1.equals(plot2));
    plot1.addCornerTextItem("XYZ");
    assertFalse(plot1.equals(plot2));
    plot2.addCornerTextItem("XYZ");
    assertTrue(plot1.equals(plot2));
    plot1.setMargin(6);
    assertFalse(plot1.equals(plot2));
    plot2.setMargin(6);
    assertTrue(plot1.equals(plot2));
    LegendItemCollection lic1 = new LegendItemCollection();
    lic1.add(new LegendItem("XYZ", Color.red));
    plot1.setFixedLegendItems(lic1);
    assertFalse(plot1.equals(plot2));
    LegendItemCollection lic2 = new LegendItemCollection();
    lic2.add(new LegendItem("XYZ", Color.red));
    plot2.setFixedLegendItems(lic2);
    assertTrue(plot1.equals(plot2));
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) NumberAxis(org.jfree.chart.axis.NumberAxis) LegendItem(org.jfree.chart.LegendItem) LegendItemCollection(org.jfree.chart.LegendItemCollection) GradientPaint(java.awt.GradientPaint) Font(java.awt.Font) NumberTickUnit(org.jfree.chart.axis.NumberTickUnit) Test(org.junit.Test)

Example 39 with LegendItem

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

the class YIntervalRendererTest method testGetLegendItemSeriesIndex.

/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s2 = new YIntervalSeries("S2");
    s2.add(1.0, 1.1, 1.2, 1.3);
    d1.addSeries(s1);
    d1.addSeries(s2);
    YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
    YIntervalSeries s3 = new YIntervalSeries("S3");
    s3.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s4 = new YIntervalSeries("S4");
    s4.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s5 = new YIntervalSeries("S5");
    s5.add(1.0, 1.1, 1.2, 1.3);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);
    YIntervalRenderer r = new YIntervalRenderer();
    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 : YIntervalSeriesCollection(org.jfree.data.xy.YIntervalSeriesCollection) YIntervalSeries(org.jfree.data.xy.YIntervalSeries) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) LegendItem(org.jfree.chart.LegendItem) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 40 with LegendItem

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

the class LevelRendererTest 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");
    LevelRenderer r = new LevelRenderer();
    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)51 Paint (java.awt.Paint)26 Test (org.junit.Test)25 NumberAxis (org.jfree.chart.axis.NumberAxis)20 JFreeChart (org.jfree.chart.JFreeChart)19 Stroke (java.awt.Stroke)18 XYPlot (org.jfree.chart.plot.XYPlot)18 Shape (java.awt.Shape)17 LegendItemCollection (org.jfree.chart.LegendItemCollection)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