use of org.jfree.chart.legend.LegendItem in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class LegendItemTest method testSerialization2.
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization2() {
AttributedString as = new AttributedString("Test String");
as.addAttribute(TextAttribute.FONT, new Font("Dialog", Font.PLAIN, 12));
LegendItem item1 = new LegendItem(as, "Description", "ToolTip", "URL", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.RED);
LegendItem item2 = TestUtils.serialised(item1);
assertEquals(item1, item2);
}
use of org.jfree.chart.legend.LegendItem in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class LegendItemTest method testSerialization.
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() {
LegendItem item1 = new LegendItem("Item", "Description", "ToolTip", "URL", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new GradientPaint(5.0f, 6.0f, Color.BLUE, 7.0f, 8.0f, Color.GRAY));
item1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.YELLOW));
item1.setOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.GREEN, 2.0f, 1.0f, Color.RED));
item1.setLinePaint(new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.RED));
LegendItem item2 = TestUtils.serialised(item1);
assertEquals(item1, item2);
}
use of org.jfree.chart.legend.LegendItem in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
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<String, String> dataset0 = new DefaultCategoryDataset<>();
dataset0.addValue(21.0, "R1", "C1");
dataset0.addValue(22.0, "R2", "C1");
DefaultCategoryDataset<String, String> 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<String, String> 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());
}
use of org.jfree.chart.legend.LegendItem in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class XYAreaRenderer2Test method testGetLegendItemSeriesIndex.
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
XYSeriesCollection<String> d1 = new XYSeriesCollection<>();
XYSeries<String> s1 = new XYSeries<>("S1");
s1.add(1.0, 1.1);
XYSeries<String> s2 = new XYSeries<>("S2");
s2.add(1.0, 1.1);
d1.addSeries(s1);
d1.addSeries(s2);
XYSeriesCollection<String> d2 = new XYSeriesCollection<>();
XYSeries<String> s3 = new XYSeries<>("S3");
s3.add(1.0, 1.1);
XYSeries<String> s4 = new XYSeries<>("S4");
s4.add(1.0, 1.1);
XYSeries<String> s5 = new XYSeries<>("S5");
s5.add(1.0, 1.1);
d2.addSeries(s3);
d2.addSeries(s4);
d2.addSeries(s5);
XYAreaRenderer2 r = new XYAreaRenderer2();
XYPlot<String> 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());
}
use of org.jfree.chart.legend.LegendItem in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class XYBarRendererTest method testGetLegendItemSeriesIndex.
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
XYSeriesCollection<String> d1 = new XYSeriesCollection<>();
XYSeries<String> s1 = new XYSeries<>("S1");
s1.add(1.0, 1.1);
XYSeries<String> s2 = new XYSeries<>("S2");
s2.add(1.0, 1.1);
d1.addSeries(s1);
d1.addSeries(s2);
XYSeriesCollection<String> d2 = new XYSeriesCollection<>();
XYSeries<String> s3 = new XYSeries<>("S3");
s3.add(1.0, 1.1);
XYSeries<String> s4 = new XYSeries<>("S4");
s4.add(1.0, 1.1);
XYSeries<String> s5 = new XYSeries<>("S5");
s5.add(1.0, 1.1);
d2.addSeries(s3);
d2.addSeries(s4);
d2.addSeries(s5);
XYBarRenderer r = new XYBarRenderer();
XYPlot<String> plot = new XYPlot<>(new XYBarDataset<>(d1, 1.0), new NumberAxis("x"), new NumberAxis("y"), r);
plot.setDataset(1, new XYBarDataset<>(d2, 2.0));
JFreeChart chart = new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("S5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
Aggregations