use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class CategoryPlotTest method testEquals.
/**
* Test that the equals() method differentiates all the required fields.
*/
@Test
public void testEquals() {
CategoryPlot<String, String> plot1 = new CategoryPlot<>();
CategoryPlot<String, String> plot2 = new CategoryPlot<>();
assertEquals(plot1, plot2);
assertEquals(plot2, plot1);
// 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 - no longer a separate field but test anyway...
plot1.setDomainAxis(new CategoryAxis("Category Axis"));
assertNotEquals(plot1, plot2);
plot2.setDomainAxis(new CategoryAxis("Category Axis"));
assertEquals(plot1, plot2);
// domainAxes...
plot1.setDomainAxis(11, new CategoryAxis("Secondary Axis"));
assertNotEquals(plot1, plot2);
plot2.setDomainAxis(11, new CategoryAxis("Secondary Axis"));
assertEquals(plot1, plot2);
// domainAxisLocation - no longer a separate field but test anyway...
plot1.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
assertNotEquals(plot1, plot2);
plot2.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
assertEquals(plot1, plot2);
// domainAxisLocations...
plot1.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
assertNotEquals(plot1, plot2);
plot2.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
assertEquals(plot1, plot2);
// draw shared domain axis...
plot1.setDrawSharedDomainAxis(!plot1.getDrawSharedDomainAxis());
assertNotEquals(plot1, plot2);
plot2.setDrawSharedDomainAxis(!plot2.getDrawSharedDomainAxis());
assertEquals(plot1, plot2);
// rangeAxis - no longer a separate field but test anyway...
plot1.setRangeAxis(new NumberAxis("Range Axis"));
assertNotEquals(plot1, plot2);
plot2.setRangeAxis(new NumberAxis("Range Axis"));
assertEquals(plot1, plot2);
// rangeAxes...
plot1.setRangeAxis(11, new NumberAxis("Secondary Range Axis"));
assertNotEquals(plot1, plot2);
plot2.setRangeAxis(11, new NumberAxis("Secondary Range Axis"));
assertEquals(plot1, plot2);
// rangeAxisLocation - no longer a separate field but test anyway...
plot1.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
assertNotEquals(plot1, plot2);
plot2.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
assertEquals(plot1, plot2);
// rangeAxisLocations...
plot1.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
assertNotEquals(plot1, plot2);
plot2.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
assertEquals(plot1, plot2);
// datasetToDomainAxisMap...
plot1.mapDatasetToDomainAxis(11, 11);
assertNotEquals(plot1, plot2);
plot2.mapDatasetToDomainAxis(11, 11);
assertEquals(plot1, plot2);
// datasetToRangeAxisMap...
plot1.mapDatasetToRangeAxis(11, 11);
assertNotEquals(plot1, plot2);
plot2.mapDatasetToRangeAxis(11, 11);
assertEquals(plot1, plot2);
// renderer - no longer a separate field but test anyway...
plot1.setRenderer(new AreaRenderer());
assertNotEquals(plot1, plot2);
plot2.setRenderer(new AreaRenderer());
assertEquals(plot1, plot2);
// renderers...
plot1.setRenderer(11, new AreaRenderer());
assertNotEquals(plot1, plot2);
plot2.setRenderer(11, new AreaRenderer());
assertEquals(plot1, plot2);
// rendering order...
plot1.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
assertNotEquals(plot1, plot2);
plot2.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
assertEquals(plot1, plot2);
// columnRenderingOrder...
plot1.setColumnRenderingOrder(SortOrder.DESCENDING);
assertNotEquals(plot1, plot2);
plot2.setColumnRenderingOrder(SortOrder.DESCENDING);
assertEquals(plot1, plot2);
// rowRenderingOrder...
plot1.setRowRenderingOrder(SortOrder.DESCENDING);
assertNotEquals(plot1, plot2);
plot2.setRowRenderingOrder(SortOrder.DESCENDING);
assertEquals(plot1, plot2);
// domainGridlinesVisible
plot1.setDomainGridlinesVisible(true);
assertNotEquals(plot1, plot2);
plot2.setDomainGridlinesVisible(true);
assertEquals(plot1, plot2);
// domainGridlinePosition
plot1.setDomainGridlinePosition(CategoryAnchor.END);
assertNotEquals(plot1, plot2);
plot2.setDomainGridlinePosition(CategoryAnchor.END);
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.YELLOW));
assertNotEquals(plot1, plot2);
plot2.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.YELLOW));
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.YELLOW));
assertNotEquals(plot1, plot2);
plot2.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.GREEN, 3.0f, 4.0f, Color.YELLOW));
assertEquals(plot1, plot2);
// anchorValue
plot1.setAnchorValue(100.0);
assertNotEquals(plot1, plot2);
plot2.setAnchorValue(100.0);
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.WHITE, 3.0f, 4.0f, Color.YELLOW));
assertNotEquals(plot1, plot2);
plot2.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.YELLOW));
assertEquals(plot1, plot2);
// rangeCrosshairLockedOnData
plot1.setRangeCrosshairLockedOnData(false);
assertNotEquals(plot1, plot2);
plot2.setRangeCrosshairLockedOnData(false);
assertEquals(plot1, plot2);
// foreground domain markers
plot1.addDomainMarker(new CategoryMarker("C1"), Layer.FOREGROUND);
assertNotEquals(plot1, plot2);
plot2.addDomainMarker(new CategoryMarker("C1"), Layer.FOREGROUND);
assertEquals(plot1, plot2);
// background domain markers
plot1.addDomainMarker(new CategoryMarker("C2"), Layer.BACKGROUND);
assertNotEquals(plot1, plot2);
plot2.addDomainMarker(new CategoryMarker("C2"), Layer.BACKGROUND);
assertEquals(plot1, plot2);
// range markers - no longer separate fields but test anyway...
plot1.addRangeMarker(new ValueMarker(4.0), Layer.FOREGROUND);
assertNotEquals(plot1, plot2);
plot2.addRangeMarker(new ValueMarker(4.0), Layer.FOREGROUND);
assertEquals(plot1, plot2);
plot1.addRangeMarker(new ValueMarker(5.0), Layer.BACKGROUND);
assertNotEquals(plot1, plot2);
plot2.addRangeMarker(new ValueMarker(5.0), Layer.BACKGROUND);
assertEquals(plot1, plot2);
// foreground 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);
// background range markers...
plot1.addRangeMarker(1, new ValueMarker(5.0), Layer.BACKGROUND);
assertNotEquals(plot1, plot2);
plot2.addRangeMarker(1, new ValueMarker(5.0), Layer.BACKGROUND);
assertEquals(plot1, plot2);
// annotations
plot1.addAnnotation(new CategoryTextAnnotation("Text", "Category", 43.0));
assertNotEquals(plot1, plot2);
plot2.addAnnotation(new CategoryTextAnnotation("Text", "Category", 43.0));
assertEquals(plot1, plot2);
// weight
plot1.setWeight(3);
assertNotEquals(plot1, plot2);
plot2.setWeight(3);
assertEquals(plot1, plot2);
// fixed domain axis space...
plot1.setFixedDomainAxisSpace(new AxisSpace());
assertNotEquals(plot1, plot2);
plot2.setFixedDomainAxisSpace(new AxisSpace());
assertEquals(plot1, plot2);
// fixed range axis space...
plot1.setFixedRangeAxisSpace(new AxisSpace());
assertNotEquals(plot1, plot2);
plot2.setFixedRangeAxisSpace(new AxisSpace());
assertEquals(plot1, plot2);
// fixed legend items
plot1.setFixedLegendItems(new LegendItemCollection());
assertNotEquals(plot1, plot2);
plot2.setFixedLegendItems(new LegendItemCollection());
assertEquals(plot1, plot2);
// crosshairDatasetIndex
plot1.setCrosshairDatasetIndex(99);
assertNotEquals(plot1, plot2);
plot2.setCrosshairDatasetIndex(99);
assertEquals(plot1, plot2);
// domainCrosshairColumnKey
plot1.setDomainCrosshairColumnKey("A");
assertNotEquals(plot1, plot2);
plot2.setDomainCrosshairColumnKey("A");
assertEquals(plot1, plot2);
// domainCrosshairRowKey
plot1.setDomainCrosshairRowKey("B");
assertNotEquals(plot1, plot2);
plot2.setDomainCrosshairRowKey("B");
assertEquals(plot1, plot2);
// domainCrosshairVisible
plot1.setDomainCrosshairVisible(true);
assertNotEquals(plot1, plot2);
plot2.setDomainCrosshairVisible(true);
assertEquals(plot1, plot2);
// domainCrosshairPaint
plot1.setDomainCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE));
assertNotEquals(plot1, plot2);
plot2.setDomainCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE));
assertEquals(plot1, plot2);
// domainCrosshairStroke
plot1.setDomainCrosshairStroke(new BasicStroke(1.23f));
assertNotEquals(plot1, plot2);
plot2.setDomainCrosshairStroke(new BasicStroke(1.23f));
assertEquals(plot1, plot2);
plot1.setRangeMinorGridlinesVisible(true);
assertNotEquals(plot1, plot2);
plot2.setRangeMinorGridlinesVisible(true);
assertEquals(plot1, plot2);
plot1.setRangeMinorGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE));
assertNotEquals(plot1, plot2);
plot2.setRangeMinorGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE));
assertEquals(plot1, plot2);
plot1.setRangeMinorGridlineStroke(new BasicStroke(1.23f));
assertNotEquals(plot1, plot2);
plot2.setRangeMinorGridlineStroke(new BasicStroke(1.23f));
assertEquals(plot1, plot2);
plot1.setRangeZeroBaselineVisible(!plot1.isRangeZeroBaselineVisible());
assertNotEquals(plot1, plot2);
plot2.setRangeZeroBaselineVisible(!plot2.isRangeZeroBaselineVisible());
assertEquals(plot1, plot2);
plot1.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE));
assertNotEquals(plot1, plot2);
plot2.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE));
assertEquals(plot1, plot2);
plot1.setRangeZeroBaselineStroke(new BasicStroke(1.23f));
assertNotEquals(plot1, plot2);
plot2.setRangeZeroBaselineStroke(new BasicStroke(1.23f));
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);
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class CategoryPlotTest method testCloning3.
/**
* Some more cloning checks.
*/
@Test
public void testCloning3() {
LegendItemCollection c1 = new LegendItemCollection();
CategoryPlot<String, String> p1 = new CategoryPlot<>();
p1.setFixedLegendItems(c1);
CategoryPlot<String, String> p2;
try {
p2 = CloneUtils.clone(p1);
} catch (CloneNotSupportedException e) {
fail("Cloning failed.");
return;
}
assertNotSame(p1, p2);
assertSame(p1.getClass(), p2.getClass());
assertEquals(p1, p2);
c1.add(new LegendItem("X", "XX", "tt", "url", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.RED, true, Color.YELLOW, new BasicStroke(1.0f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.0f), Color.GREEN));
assertNotEquals(p1, p2);
p2.getFixedLegendItems().add(new LegendItem("X", "XX", "tt", "url", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.RED, true, Color.YELLOW, new BasicStroke(1.0f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.0f), Color.GREEN));
assertEquals(p1, p2);
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class XYPlotTest method testGetLegendItems.
/**
* Some checks for the getLegendItems() method.
*/
@Test
public void testGetLegendItems() {
// check the case where there is a secondary dataset that doesn't
// have a renderer (i.e. falls back to renderer 0)
XYDataset<String> d0 = createDataset1();
XYDataset<String> d1 = createDataset2();
XYItemRenderer r0 = new XYLineAndShapeRenderer();
XYPlot<String> plot = new XYPlot<>();
plot.setDataset(0, d0);
plot.setDataset(1, d1);
plot.setRenderer(0, r0);
LegendItemCollection items = plot.getLegendItems();
assertEquals(2, items.getItemCount());
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class PolarPlotTest method testGetLegendItems2.
/**
* Some checks for the getLegendItems() method with multiple datasets.
*/
@Test
public void testGetLegendItems2() {
XYSeriesCollection<String> d1 = new XYSeriesCollection<>();
d1.addSeries(new XYSeries<>("A"));
d1.addSeries(new XYSeries<>("B"));
XYSeriesCollection<String> 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());
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class SpiderWebPlotTest 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");
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());
}
Aggregations