/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DialPointer i1 = new DialPointer.Pin(1); DialPointer i2 = new DialPointer.Pin(1); assertTrue(i1.equals(i2)); // dataset index i1 = new DialPointer.Pin(2); assertFalse(i1.equals(i2)); i2 = new DialPointer.Pin(2); assertTrue(i1.equals(i2)); // check an inherited attribute i1.setVisible(false); assertFalse(i1.equals(i2)); i2.setVisible(false); assertTrue(i1.equals(i2)); }
/** * Check the equals() method for the DialPointer.Pin class. */ public void testEqualsPin() { DialPointer.Pin p1 = new DialPointer.Pin(); DialPointer.Pin p2 = new DialPointer.Pin(); assertEquals(p1, p2); p1.setPaint(Color.green); assertFalse(p1.equals(p2)); p2.setPaint(Color.green); assertTrue(p1.equals(p2)); BasicStroke s = new BasicStroke(4.4f); p1.setStroke(s); assertFalse(p1.equals(p2)); p2.setStroke(s); assertTrue(p1.equals(p2)); }
/** * Check the equals() method for the DialPointer.Pointer class. */ public void testEqualsPointer() { DialPointer.Pointer p1 = new DialPointer.Pointer(); DialPointer.Pointer p2 = new DialPointer.Pointer(); assertEquals(p1, p2); p1.setFillPaint(Color.green); assertFalse(p1.equals(p2)); p2.setFillPaint(Color.green); assertTrue(p1.equals(p2)); p1.setOutlinePaint(Color.green); assertFalse(p1.equals(p2)); p2.setOutlinePaint(Color.green); assertTrue(p1.equals(p2)); }
private ChartPanel buildDialPlot(int minimumValue, int maximumValue,int majorTickGap) { plot = new DialPlot(dataset); plot.setDialFrame(new StandardDialFrame()); plot.addLayer(new DialValueIndicator()); plot.addLayer(new DialPointer.Pointer()); StandardDialScale scale = new StandardDialScale(minimumValue, maximumValue,-120, -300, majorTickGap, majorTickGap - 1); scale.setTickRadius(0.88); scale.setTickLabelOffset(0.20); plot.addScale(0, scale); return new ChartPanel(new JFreeChart(plot)); }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { DialPointer i1 = new DialPointer.Pin(1); DialPointer i2 = new DialPointer.Pin(1); assertTrue(i1.equals(i2)); int h1 = i1.hashCode(); int h2 = i2.hashCode(); assertEquals(h1, h2); }