/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
XYShapeAnnotation a1 = new XYShapeAnnotation(
new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0),
new BasicStroke(1.2f), Color.red, Color.blue);
XYShapeAnnotation a2 = new XYShapeAnnotation(
new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0),
new BasicStroke(1.2f), Color.red, Color.blue);
assertTrue(a1.equals(a2));
assertTrue(a2.equals(a1));
// shape
a1 = new XYShapeAnnotation(
new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0),
new BasicStroke(1.2f), Color.red, Color.blue);
assertFalse(a1.equals(a2));
a2 = new XYShapeAnnotation(
new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0),
new BasicStroke(1.2f), Color.red, Color.blue);
assertTrue(a1.equals(a2));
// stroke
a1 = new XYShapeAnnotation(
new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0),
new BasicStroke(2.3f), Color.red, Color.blue);
assertFalse(a1.equals(a2));
a2 = new XYShapeAnnotation(
new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0),
new BasicStroke(2.3f), Color.red, Color.blue);
assertTrue(a1.equals(a2));
GradientPaint gp1a = new GradientPaint(1.0f, 2.0f, Color.blue,
3.0f, 4.0f, Color.red);
GradientPaint gp1b = new GradientPaint(1.0f, 2.0f, Color.blue,
3.0f, 4.0f, Color.red);
GradientPaint gp2a = new GradientPaint(5.0f, 6.0f, Color.pink,
7.0f, 8.0f, Color.white);
GradientPaint gp2b = new GradientPaint(5.0f, 6.0f, Color.pink,
7.0f, 8.0f, Color.white);
// outlinePaint
a1 = new XYShapeAnnotation(
new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0),
new BasicStroke(2.3f), gp1a, Color.blue);
assertFalse(a1.equals(a2));
a2 = new XYShapeAnnotation(
new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0),
new BasicStroke(2.3f), gp1b, Color.blue);
assertTrue(a1.equals(a2));
// fillPaint
a1 = new XYShapeAnnotation(
new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0),
new BasicStroke(2.3f), gp1a, gp2a);
assertFalse(a1.equals(a2));
a2 = new XYShapeAnnotation(
new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0),
new BasicStroke(2.3f), gp1b, gp2b);
assertTrue(a1.equals(a2));
}