/**
* Confirm that the equals method can distinguish all the required fields.
*/
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);
assertTrue(item1.equals(item2));
assertTrue(item2.equals(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);
assertFalse(item1.equals(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);
assertTrue(item1.equals(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);
assertFalse(item1.equals(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);
assertTrue(item1.equals(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);
assertFalse(item1.equals(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);
assertTrue(item1.equals(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);
assertFalse(item1.equals(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);
assertTrue(item1.equals(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);
assertFalse(item1.equals(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);
assertTrue(item1.equals(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);
assertFalse(item1.equals(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);
assertTrue(item1.equals(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);
assertFalse(item1.equals(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);
assertTrue(item1.equals(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);
assertFalse(item1.equals(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);
assertTrue(item1.equals(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);
assertFalse(item1.equals(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);
assertTrue(item1.equals(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);
assertFalse(item1.equals(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);
assertTrue(item1.equals(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);
assertFalse(item1.equals(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);
assertTrue(item1.equals(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);
assertFalse(item1.equals(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);
assertTrue(item1.equals(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
);
assertFalse(item1.equals(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);
assertTrue(item1.equals(item2));
// fillPaintTransformer
item1.setFillPaintTransformer(new StandardGradientPaintTransformer(
GradientPaintTransformType.CENTER_VERTICAL));
assertFalse(item1.equals(item2));
item2.setFillPaintTransformer(new StandardGradientPaintTransformer(
GradientPaintTransformType.CENTER_VERTICAL));
assertTrue(item1.equals(item2));
// labelFont
item1.setLabelFont(new Font("Dialog", Font.PLAIN, 13));
assertFalse(item1.equals(item2));
item2.setLabelFont(new Font("Dialog", Font.PLAIN, 13));
assertTrue(item1.equals(item2));
// labelPaint
item1.setLabelPaint(Color.red);
assertFalse(item1.equals(item2));
item2.setLabelPaint(Color.red);
assertTrue(item1.equals(item2));
// fillPaint
item1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f,
4.0f, Color.blue));
assertFalse(item1.equals(item2));
item2.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f,
4.0f, Color.blue));
assertTrue(item1.equals(item2));
// outlinePaint
item1.setOutlinePaint(new GradientPaint(1.1f, 2.2f, Color.green, 3.3f,
4.4f, Color.blue));
assertFalse(item1.equals(item2));
item2.setOutlinePaint(new GradientPaint(1.1f, 2.2f, Color.green, 3.3f,
4.4f, Color.blue));
assertTrue(item1.equals(item2));
// linePaint
item1.setLinePaint(new GradientPaint(0.1f, 0.2f, Color.green, 0.3f,
0.4f, Color.blue));
assertFalse(item1.equals(item2));
item2.setLinePaint(new GradientPaint(0.1f, 0.2f, Color.green, 0.3f,
0.4f, Color.blue));
assertTrue(item1.equals(item2));
}