use of org.jfree.chart.legend.LegendItem in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class LegendItemTest method testCloning.
/**
* Basic checks for cloning.
* @throws java.lang.CloneNotSupportedException
*/
@Test
public void testCloning() throws CloneNotSupportedException {
LegendItem item1 = new LegendItem("Item");
LegendItem item2 = CloneUtils.clone(item1);
assertNotSame(item1, item2);
assertSame(item1.getClass(), item2.getClass());
assertEquals(item1, item2);
// the clone references the same dataset as the original
assertSame(item1.getDataset(), item2.getDataset());
}
use of org.jfree.chart.legend.LegendItem in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class LegendItemTest method testEquals.
/**
* Confirm that the equals method can distinguish all the required fields.
*/
@Test
public void testEquals() {
LegendItem item1 = new LegendItem("Label", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.RED, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
LegendItem item2 = new LegendItem("Label", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.RED, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertEquals(item1, item2);
assertEquals(item2, item1);
item1 = new LegendItem("Label2", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.RED, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertNotEquals(item1, item2);
item2 = new LegendItem("Label2", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.RED, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertEquals(item1, item2);
item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.RED, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertNotEquals(item1, item2);
item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.RED, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertEquals(item1, item2);
item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.RED, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertNotEquals(item1, item2);
item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.RED, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertEquals(item1, item2);
item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), true, Color.RED, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertNotEquals(item1, item2);
item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), true, Color.RED, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertEquals(item1, item2);
item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.RED, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertNotEquals(item1, item2);
item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.RED, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertEquals(item1, item2);
item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertNotEquals(item1, item2);
item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertEquals(item1, item2);
item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, false, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertNotEquals(item1, item2);
item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, false, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertEquals(item1, item2);
item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, false, Color.YELLOW, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertNotEquals(item1, item2);
item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, false, Color.YELLOW, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertEquals(item1, item2);
item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, false, Color.YELLOW, new BasicStroke(2.1f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertNotEquals(item1, item2);
item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, false, Color.YELLOW, new BasicStroke(2.1f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertEquals(item1, item2);
item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, false, Color.YELLOW, new BasicStroke(2.1f), false, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertNotEquals(item1, item2);
item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, false, Color.YELLOW, new BasicStroke(2.1f), false, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
assertEquals(item1, item2);
item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, false, Color.YELLOW, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.1f), Color.GREEN);
assertNotEquals(item1, item2);
item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, false, Color.YELLOW, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.1f), Color.GREEN);
assertEquals(item1, item2);
item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, false, Color.YELLOW, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(3.3f), Color.GREEN);
assertNotEquals(item1, item2);
item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, false, Color.YELLOW, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(3.3f), Color.GREEN);
assertEquals(item1, item2);
item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, false, Color.YELLOW, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(3.3f), Color.WHITE);
assertNotEquals(item1, item2);
item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.BLACK, false, Color.YELLOW, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(3.3f), Color.WHITE);
assertEquals(item1, item2);
// fillPaintTransformer
item1.setFillPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
assertNotEquals(item1, item2);
item2.setFillPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
assertEquals(item1, item2);
// labelFont
item1.setLabelFont(new Font("Dialog", Font.PLAIN, 13));
assertNotEquals(item1, item2);
item2.setLabelFont(new Font("Dialog", Font.PLAIN, 13));
assertEquals(item1, item2);
// labelPaint
item1.setLabelPaint(Color.RED);
assertNotEquals(item1, item2);
item2.setLabelPaint(Color.RED);
assertEquals(item1, item2);
// fillPaint
item1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.GREEN, 3.0f, 4.0f, Color.BLUE));
assertNotEquals(item1, item2);
item2.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.GREEN, 3.0f, 4.0f, Color.BLUE));
assertEquals(item1, item2);
// outlinePaint
item1.setOutlinePaint(new GradientPaint(1.1f, 2.2f, Color.GREEN, 3.3f, 4.4f, Color.BLUE));
assertNotEquals(item1, item2);
item2.setOutlinePaint(new GradientPaint(1.1f, 2.2f, Color.GREEN, 3.3f, 4.4f, Color.BLUE));
assertEquals(item1, item2);
// linePaint
item1.setLinePaint(new GradientPaint(0.1f, 0.2f, Color.GREEN, 0.3f, 0.4f, Color.BLUE));
assertNotEquals(item1, item2);
item2.setLinePaint(new GradientPaint(0.1f, 0.2f, Color.GREEN, 0.3f, 0.4f, Color.BLUE));
assertEquals(item1, item2);
}
use of org.jfree.chart.legend.LegendItem in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class LegendItemCollectionTest method testSerialization.
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() {
LegendItemCollection c1 = new LegendItemCollection();
c1.add(new LegendItem("Item", "Description", "ToolTip", "URL", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.RED));
LegendItemCollection c2 = TestUtils.serialised(c1);
assertEquals(c1, c2);
}
use of org.jfree.chart.legend.LegendItem in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class LegendItemCollectionTest method testEquals.
/**
* Confirm that the equals method can distinguish all the required fields.
*/
@Test
public void testEquals() {
LegendItemCollection c1 = new LegendItemCollection();
LegendItemCollection c2 = new LegendItemCollection();
assertEquals(c1, c2);
assertEquals(c2, c1);
LegendItem item1 = new LegendItem("Label", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.RED, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
LegendItem item2 = new LegendItem("Label", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.RED, true, Color.BLUE, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.GREEN);
c1.add(item1);
assertNotEquals(c1, c2);
c2.add(item2);
assertEquals(c1, c2);
}
use of org.jfree.chart.legend.LegendItem in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class LegendItemCollectionTest method testCloning.
/**
* Confirm that cloning works.
* @throws java.lang.CloneNotSupportedException
*/
@Test
public void testCloning() throws CloneNotSupportedException {
LegendItemCollection c1 = new LegendItemCollection();
LegendItem item1 = new LegendItem("Item 1");
c1.add(item1);
LegendItemCollection c2 = CloneUtils.clone(c1);
assertNotSame(c1, c2);
assertSame(c1.getClass(), c2.getClass());
assertEquals(c1, c2);
Rectangle2D item1Shape = (Rectangle2D) item1.getShape();
item1Shape.setRect(1.0, 2.0, 3.0, 4.0);
assertNotEquals(c1, c2);
}
Aggregations