/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(), new NumberAxis("X")); PaintScaleLegend l2 = new PaintScaleLegend(new GrayPaintScale(), new NumberAxis("X")); assertTrue(l1.equals(l2)); int h1 = l1.hashCode(); int h2 = l2.hashCode(); assertEquals(h1, h2); }
/** * Test that the equals() method distinguishes all fields. */ public void testEquals() { // default instances XYBlockRenderer r1 = new XYBlockRenderer(); XYBlockRenderer r2 = new XYBlockRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); // blockHeight r1.setBlockHeight(2.0); assertFalse(r1.equals(r2)); r2.setBlockHeight(2.0); assertTrue(r1.equals(r2)); // blockWidth r1.setBlockWidth(2.0); assertFalse(r1.equals(r2)); r2.setBlockWidth(2.0); assertTrue(r1.equals(r2)); // paintScale r1.setPaintScale(new GrayPaintScale(0.0, 1.0)); assertFalse(r1.equals(r2)); r2.setPaintScale(new GrayPaintScale(0.0, 1.0)); assertTrue(r1.equals(r2)); }
/** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashcode() { PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(), new NumberAxis("X")); PaintScaleLegend l2 = new PaintScaleLegend(new GrayPaintScale(), new NumberAxis("X")); assertTrue(l1.equals(l2)); int h1 = l1.hashCode(); int h2 = l2.hashCode(); assertEquals(h1, h2); }
/** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(), new NumberAxis("X")); PaintScaleLegend l2 = (PaintScaleLegend) l1.clone(); assertTrue(l1 != l2); assertTrue(l1.getClass() == l2.getClass()); assertTrue(l1.equals(l2)); }
/** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() { PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(), new NumberAxis("X")); PaintScaleLegend l2 = (PaintScaleLegend) TestUtilities.serialised(l1); assertEquals(l1, l2); }
/** * Test that the equals() method distinguishes all fields. */ @Test public void testEquals() { // default instances XYBlockRenderer r1 = new XYBlockRenderer(); XYBlockRenderer r2 = new XYBlockRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); // blockHeight r1.setBlockHeight(2.0); assertFalse(r1.equals(r2)); r2.setBlockHeight(2.0); assertTrue(r1.equals(r2)); // blockWidth r1.setBlockWidth(2.0); assertFalse(r1.equals(r2)); r2.setBlockWidth(2.0); assertTrue(r1.equals(r2)); // paintScale r1.setPaintScale(new GrayPaintScale(0.0, 1.0)); assertFalse(r1.equals(r2)); r2.setPaintScale(new GrayPaintScale(0.0, 1.0)); assertTrue(r1.equals(r2)); }
/** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() { PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(), new NumberAxis("X")); PaintScaleLegend l2 = (PaintScaleLegend) TestUtils.serialised(l1); assertEquals(l1, l2); }
/** * Simple check for the default constructor. */ public void testConstructor() { GrayPaintScale gps = new GrayPaintScale(); assertEquals(0.0, gps.getLowerBound(), EPSILON); assertEquals(1.0, gps.getUpperBound(), EPSILON); assertEquals(255, gps.getAlpha()); }
/** * Some checks for the getPaint() method. */ public void testGetPaint() { GrayPaintScale gps = new GrayPaintScale(); Color c = (Color) gps.getPaint(0.0); assertTrue(c.equals(Color.black)); c = (Color) gps.getPaint(1.0); assertTrue(c.equals(Color.white)); // check lookup values that are outside the bounds - see bug report // 1767315 c = (Color) gps.getPaint(-0.5); assertTrue(c.equals(Color.black)); c = (Color) gps.getPaint(1.5); assertTrue(c.equals(Color.white)); }