/**
* Confirm that cloning works.
*/
public void testCloning() {
LookupPaintScale g1 = new LookupPaintScale();
LookupPaintScale g2 = null;
try {
g2 = (LookupPaintScale) g1.clone();
}
catch (CloneNotSupportedException e) {
e.printStackTrace();
}
assertTrue(g1 != g2);
assertTrue(g1.getClass() == g2.getClass());
assertTrue(g1.equals(g2));
// check independence
g1.add(new Double(0.5), Color.red);
assertFalse(g1.equals(g2));
g2.add(new Double(0.5), Color.red);
assertTrue(g1.equals(g2));
// try with gradient paint
g1 = new LookupPaintScale(1.0, 2.0, new GradientPaint(1.0f, 2.0f,
Color.red, 3.0f, 4.0f, Color.green));
g1.add(new Double(1.5), new GradientPaint(1.0f, 2.0f, Color.red, 3.0f,
4.0f, Color.blue));
g2 = null;
try {
g2 = (LookupPaintScale) g1.clone();
}
catch (CloneNotSupportedException e) {
e.printStackTrace();
}
assertTrue(g1 != g2);
assertTrue(g1.getClass() == g2.getClass());
assertTrue(g1.equals(g2));
}