use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class PolarPlotTest method testGetLegendItems.
/**
* Some checks for the getLegendItems() method.
*/
@Test
public void testGetLegendItems() {
XYSeriesCollection<String> d = new XYSeriesCollection<>();
d.addSeries(new XYSeries<>("A"));
d.addSeries(new XYSeries<>("B"));
DefaultPolarItemRenderer r = new DefaultPolarItemRenderer();
PolarPlot plot = new PolarPlot();
plot.setDataset(d);
plot.setRenderer(r);
LegendItemCollection items = plot.getLegendItems();
assertEquals(2, items.getItemCount());
LegendItem item1 = items.get(0);
assertEquals("A", item1.getLabel());
LegendItem item2 = items.get(1);
assertEquals("B", item2.getLabel());
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class PolarPlotTest method testEquals.
/**
* Some checks for the equals() method.
*/
@Test
public void testEquals() {
PolarPlot plot1 = new PolarPlot();
PolarPlot plot2 = new PolarPlot();
assertEquals(plot1, plot2);
assertEquals(plot2, plot1);
plot1.setAngleGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE));
assertNotEquals(plot1, plot2);
plot2.setAngleGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE));
assertEquals(plot1, plot2);
Stroke s = new BasicStroke(1.23f);
plot1.setAngleGridlineStroke(s);
assertNotEquals(plot1, plot2);
plot2.setAngleGridlineStroke(s);
assertEquals(plot1, plot2);
plot1.setAngleTickUnit(new NumberTickUnit(11.0));
assertNotEquals(plot1, plot2);
plot2.setAngleTickUnit(new NumberTickUnit(11.0));
assertEquals(plot1, plot2);
plot1.setAngleGridlinesVisible(false);
assertNotEquals(plot1, plot2);
plot2.setAngleGridlinesVisible(false);
assertEquals(plot1, plot2);
plot1.setAngleLabelFont(new Font("Serif", Font.PLAIN, 9));
assertNotEquals(plot1, plot2);
plot2.setAngleLabelFont(new Font("Serif", Font.PLAIN, 9));
assertEquals(plot1, plot2);
plot1.setAngleLabelPaint(new GradientPaint(9.0f, 8.0f, Color.BLUE, 7.0f, 6.0f, Color.RED));
assertNotEquals(plot1, plot2);
plot2.setAngleLabelPaint(new GradientPaint(9.0f, 8.0f, Color.BLUE, 7.0f, 6.0f, Color.RED));
assertEquals(plot1, plot2);
plot1.setAngleLabelsVisible(false);
assertNotEquals(plot1, plot2);
plot2.setAngleLabelsVisible(false);
assertEquals(plot1, plot2);
plot1.setAxis(new NumberAxis("Test"));
assertNotEquals(plot1, plot2);
plot2.setAxis(new NumberAxis("Test"));
assertEquals(plot1, plot2);
plot1.setRadiusGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.BLACK));
assertNotEquals(plot1, plot2);
plot2.setRadiusGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.BLACK));
assertEquals(plot1, plot2);
plot1.setRadiusGridlineStroke(s);
assertNotEquals(plot1, plot2);
plot2.setRadiusGridlineStroke(s);
assertEquals(plot1, plot2);
plot1.setRadiusGridlinesVisible(false);
assertNotEquals(plot1, plot2);
plot2.setRadiusGridlinesVisible(false);
assertEquals(plot1, plot2);
plot1.setRadiusMinorGridlinesVisible(false);
assertNotEquals(plot1, plot2);
plot2.setRadiusMinorGridlinesVisible(false);
assertEquals(plot1, plot2);
plot1.addCornerTextItem("XYZ");
assertNotEquals(plot1, plot2);
plot2.addCornerTextItem("XYZ");
assertEquals(plot1, plot2);
plot1.setMargin(6);
assertNotEquals(plot1, plot2);
plot2.setMargin(6);
assertEquals(plot1, plot2);
LegendItemCollection lic1 = new LegendItemCollection();
lic1.add(new LegendItem("XYZ", Color.RED));
plot1.setFixedLegendItems(lic1);
assertNotEquals(plot1, plot2);
LegendItemCollection lic2 = new LegendItemCollection();
lic2.add(new LegendItem("XYZ", Color.RED));
plot2.setFixedLegendItems(lic2);
assertEquals(plot1, plot2);
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class AbstractCategoryItemRendererTest method test2947660.
/**
* A test that reproduces the problem reported in bug 2947660.
*/
@Test
public void test2947660() {
AbstractCategoryItemRenderer r = new LineAndShapeRenderer();
assertNotNull(r.getLegendItems());
assertEquals(0, r.getLegendItems().getItemCount());
DefaultCategoryDataset<String, String> dataset = new DefaultCategoryDataset<>();
CategoryPlot<String, String> plot = new CategoryPlot<>();
plot.setDataset(dataset);
plot.setRenderer(r);
assertEquals(0, r.getLegendItems().getItemCount());
dataset.addValue(1.0, "S1", "C1");
LegendItemCollection lic = r.getLegendItems();
assertEquals(1, lic.getItemCount());
assertEquals("S1", lic.get(0).getLabel());
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class XYPlotTest method testEquals.
/**
* Some checks for the equals() method.
*/
@Test
public void testEquals() {
XYPlot<String> plot1 = new XYPlot<>();
XYPlot<String> plot2 = new XYPlot<>();
assertEquals(plot1, plot2);
// orientation...
plot1.setOrientation(PlotOrientation.HORIZONTAL);
assertNotEquals(plot1, plot2);
plot2.setOrientation(PlotOrientation.HORIZONTAL);
assertEquals(plot1, plot2);
// axisOffset...
plot1.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05));
assertNotEquals(plot1, plot2);
plot2.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05));
assertEquals(plot1, plot2);
// domainAxis...
plot1.setDomainAxis(new NumberAxis("Domain Axis"));
assertNotEquals(plot1, plot2);
plot2.setDomainAxis(new NumberAxis("Domain Axis"));
assertEquals(plot1, plot2);
// domainAxisLocation...
plot1.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
assertNotEquals(plot1, plot2);
plot2.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
assertEquals(plot1, plot2);
// secondary DomainAxes...
plot1.setDomainAxis(11, new NumberAxis("Secondary Domain Axis"));
assertNotEquals(plot1, plot2);
plot2.setDomainAxis(11, new NumberAxis("Secondary Domain Axis"));
assertEquals(plot1, plot2);
// secondary DomainAxisLocations...
plot1.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
assertNotEquals(plot1, plot2);
plot2.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
assertEquals(plot1, plot2);
// rangeAxis...
plot1.setRangeAxis(new NumberAxis("Range Axis"));
assertNotEquals(plot1, plot2);
plot2.setRangeAxis(new NumberAxis("Range Axis"));
assertEquals(plot1, plot2);
// rangeAxisLocation...
plot1.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
assertNotEquals(plot1, plot2);
plot2.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
assertEquals(plot1, plot2);
// secondary RangeAxes...
plot1.setRangeAxis(11, new NumberAxis("Secondary Range Axis"));
assertNotEquals(plot1, plot2);
plot2.setRangeAxis(11, new NumberAxis("Secondary Range Axis"));
assertEquals(plot1, plot2);
// secondary RangeAxisLocations...
plot1.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
assertNotEquals(plot1, plot2);
plot2.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
assertEquals(plot1, plot2);
// secondary DatasetDomainAxisMap...
plot1.mapDatasetToDomainAxis(11, 11);
assertNotEquals(plot1, plot2);
plot2.mapDatasetToDomainAxis(11, 11);
assertEquals(plot1, plot2);
// secondaryDatasetRangeAxisMap...
plot1.mapDatasetToRangeAxis(11, 11);
assertNotEquals(plot1, plot2);
plot2.mapDatasetToRangeAxis(11, 11);
assertEquals(plot1, plot2);
// renderer
plot1.setRenderer(new DefaultXYItemRenderer());
assertNotEquals(plot1, plot2);
plot2.setRenderer(new DefaultXYItemRenderer());
assertEquals(plot1, plot2);
// secondary renderers
plot1.setRenderer(11, new DefaultXYItemRenderer());
assertNotEquals(plot1, plot2);
plot2.setRenderer(11, new DefaultXYItemRenderer());
assertEquals(plot1, plot2);
// domainGridlinesVisible
plot1.setDomainGridlinesVisible(false);
assertNotEquals(plot1, plot2);
plot2.setDomainGridlinesVisible(false);
assertEquals(plot1, plot2);
// domainGridlineStroke
Stroke stroke = new BasicStroke(2.0f);
plot1.setDomainGridlineStroke(stroke);
assertNotEquals(plot1, plot2);
plot2.setDomainGridlineStroke(stroke);
assertEquals(plot1, plot2);
// domainGridlinePaint
plot1.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.RED));
assertNotEquals(plot1, plot2);
plot2.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.RED));
assertEquals(plot1, plot2);
// rangeGridlinesVisible
plot1.setRangeGridlinesVisible(false);
assertNotEquals(plot1, plot2);
plot2.setRangeGridlinesVisible(false);
assertEquals(plot1, plot2);
// rangeGridlineStroke
plot1.setRangeGridlineStroke(stroke);
assertNotEquals(plot1, plot2);
plot2.setRangeGridlineStroke(stroke);
assertEquals(plot1, plot2);
// rangeGridlinePaint
plot1.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.GREEN, 3.0f, 4.0f, Color.RED));
assertNotEquals(plot1, plot2);
plot2.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.GREEN, 3.0f, 4.0f, Color.RED));
assertEquals(plot1, plot2);
// rangeZeroBaselineVisible
plot1.setRangeZeroBaselineVisible(true);
assertNotEquals(plot1, plot2);
plot2.setRangeZeroBaselineVisible(true);
assertEquals(plot1, plot2);
// rangeZeroBaselineStroke
plot1.setRangeZeroBaselineStroke(stroke);
assertNotEquals(plot1, plot2);
plot2.setRangeZeroBaselineStroke(stroke);
assertEquals(plot1, plot2);
// rangeZeroBaselinePaint
plot1.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.RED));
assertNotEquals(plot1, plot2);
plot2.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.RED));
assertEquals(plot1, plot2);
// rangeCrosshairVisible
plot1.setRangeCrosshairVisible(true);
assertNotEquals(plot1, plot2);
plot2.setRangeCrosshairVisible(true);
assertEquals(plot1, plot2);
// rangeCrosshairValue
plot1.setRangeCrosshairValue(100.0);
assertNotEquals(plot1, plot2);
plot2.setRangeCrosshairValue(100.0);
assertEquals(plot1, plot2);
// rangeCrosshairStroke
plot1.setRangeCrosshairStroke(stroke);
assertNotEquals(plot1, plot2);
plot2.setRangeCrosshairStroke(stroke);
assertEquals(plot1, plot2);
// rangeCrosshairPaint
plot1.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.PINK, 3.0f, 4.0f, Color.RED));
assertNotEquals(plot1, plot2);
plot2.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.PINK, 3.0f, 4.0f, Color.RED));
assertEquals(plot1, plot2);
// rangeCrosshairLockedOnData
plot1.setRangeCrosshairLockedOnData(false);
assertNotEquals(plot1, plot2);
plot2.setRangeCrosshairLockedOnData(false);
assertEquals(plot1, plot2);
// range markers
plot1.addRangeMarker(new ValueMarker(4.0));
assertNotEquals(plot1, plot2);
plot2.addRangeMarker(new ValueMarker(4.0));
assertEquals(plot1, plot2);
// secondary range markers
plot1.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND);
assertNotEquals(plot1, plot2);
plot2.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND);
assertEquals(plot1, plot2);
plot1.addRangeMarker(1, new ValueMarker(99.0), Layer.BACKGROUND);
assertNotEquals(plot1, plot2);
plot2.addRangeMarker(1, new ValueMarker(99.0), Layer.BACKGROUND);
assertEquals(plot1, plot2);
// fixed legend items
plot1.setFixedLegendItems(new LegendItemCollection());
assertNotEquals(plot1, plot2);
plot2.setFixedLegendItems(new LegendItemCollection());
assertEquals(plot1, plot2);
// weight
plot1.setWeight(3);
assertNotEquals(plot1, plot2);
plot2.setWeight(3);
assertEquals(plot1, plot2);
// quadrant origin
plot1.setQuadrantOrigin(new Point2D.Double(12.3, 45.6));
assertNotEquals(plot1, plot2);
plot2.setQuadrantOrigin(new Point2D.Double(12.3, 45.6));
assertEquals(plot1, plot2);
// quadrant paint
plot1.setQuadrantPaint(0, new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE));
assertNotEquals(plot1, plot2);
plot2.setQuadrantPaint(0, new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE));
assertEquals(plot1, plot2);
plot1.setQuadrantPaint(1, new GradientPaint(2.0f, 3.0f, Color.RED, 4.0f, 5.0f, Color.BLUE));
assertNotEquals(plot1, plot2);
plot2.setQuadrantPaint(1, new GradientPaint(2.0f, 3.0f, Color.RED, 4.0f, 5.0f, Color.BLUE));
assertEquals(plot1, plot2);
plot1.setQuadrantPaint(2, new GradientPaint(3.0f, 4.0f, Color.RED, 5.0f, 6.0f, Color.BLUE));
assertNotEquals(plot1, plot2);
plot2.setQuadrantPaint(2, new GradientPaint(3.0f, 4.0f, Color.RED, 5.0f, 6.0f, Color.BLUE));
assertEquals(plot1, plot2);
plot1.setQuadrantPaint(3, new GradientPaint(4.0f, 5.0f, Color.RED, 6.0f, 7.0f, Color.BLUE));
assertNotEquals(plot1, plot2);
plot2.setQuadrantPaint(3, new GradientPaint(4.0f, 5.0f, Color.RED, 6.0f, 7.0f, Color.BLUE));
assertEquals(plot1, plot2);
plot1.setDomainTickBandPaint(Color.RED);
assertNotEquals(plot1, plot2);
plot2.setDomainTickBandPaint(Color.RED);
assertEquals(plot1, plot2);
plot1.setRangeTickBandPaint(Color.BLUE);
assertNotEquals(plot1, plot2);
plot2.setRangeTickBandPaint(Color.BLUE);
assertEquals(plot1, plot2);
plot1.setDomainMinorGridlinesVisible(true);
assertNotEquals(plot1, plot2);
plot2.setDomainMinorGridlinesVisible(true);
assertEquals(plot1, plot2);
plot1.setDomainMinorGridlinePaint(Color.RED);
assertNotEquals(plot1, plot2);
plot2.setDomainMinorGridlinePaint(Color.RED);
assertEquals(plot1, plot2);
plot1.setDomainGridlineStroke(new BasicStroke(1.1f));
assertNotEquals(plot1, plot2);
plot2.setDomainGridlineStroke(new BasicStroke(1.1f));
assertEquals(plot1, plot2);
plot1.setRangeMinorGridlinesVisible(true);
assertNotEquals(plot1, plot2);
plot2.setRangeMinorGridlinesVisible(true);
assertEquals(plot1, plot2);
plot1.setRangeMinorGridlinePaint(Color.BLUE);
assertNotEquals(plot1, plot2);
plot2.setRangeMinorGridlinePaint(Color.BLUE);
assertEquals(plot1, plot2);
plot1.setRangeMinorGridlineStroke(new BasicStroke(1.23f));
assertNotEquals(plot1, plot2);
plot2.setRangeMinorGridlineStroke(new BasicStroke(1.23f));
assertEquals(plot1, plot2);
List<Integer> axisIndices = Arrays.asList(new Integer[] { 0, 1 });
plot1.mapDatasetToDomainAxes(0, axisIndices);
assertNotEquals(plot1, plot2);
plot2.mapDatasetToDomainAxes(0, axisIndices);
assertEquals(plot1, plot2);
plot1.mapDatasetToRangeAxes(0, axisIndices);
assertNotEquals(plot1, plot2);
plot2.mapDatasetToRangeAxes(0, axisIndices);
assertEquals(plot1, plot2);
// shadowGenerator
plot1.setShadowGenerator(new DefaultShadowGenerator(5, Color.GRAY, 0.6f, 4, -Math.PI / 4));
assertNotEquals(plot1, plot2);
plot2.setShadowGenerator(new DefaultShadowGenerator(5, Color.GRAY, 0.6f, 4, -Math.PI / 4));
assertEquals(plot1, plot2);
plot1.setShadowGenerator(null);
assertNotEquals(plot1, plot2);
plot2.setShadowGenerator(null);
assertEquals(plot1, plot2);
LegendItemCollection lic1 = new LegendItemCollection();
lic1.add(new LegendItem("XYZ", Color.RED));
plot1.setFixedLegendItems(lic1);
assertNotEquals(plot1, plot2);
LegendItemCollection lic2 = new LegendItemCollection();
lic2.add(new LegendItem("XYZ", Color.RED));
plot2.setFixedLegendItems(lic2);
assertEquals(plot1, plot2);
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class MultiplePiePlotTest method testGetLegendItems.
/**
* Fetches the legend items and checks the values.
*/
@Test
public void testGetLegendItems() {
DefaultCategoryDataset<String, String> 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");
MultiplePiePlot plot = new MultiplePiePlot(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());
}
Aggregations