/** Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { NumberTickUnit t1 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); NumberTickUnit t2 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); }
protected void selectVerticalAutoTickUnit( Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { double tickLabelHeight = estimateMaximumTickLabelHeight(g2); TickUnitSource tickUnits = getStandardTickUnits(); TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit()); double unitHeight = lengthToJava2D(unit1.getSize(), dataArea, edge); double guess = unit1.getSize(); if (unitHeight > 0.0d) { guess = (tickLabelHeight / unitHeight) * unit1.getSize(); } NumberTickUnit unit2 = (NumberTickUnit) tickUnits.getCeilingTickUnit(guess); if (estimateMaximumTickLabelHeight(g2) > lengthToJava2D(unit2.getSize(), dataArea, edge)) { unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2); } setTickUnit(unit2, DEFAULT_VERTICAL_TICK_LABELS, DEFAULT_VERTICAL_TICK_LABELS); }
protected void selectHorizontalAutoTickUnit( Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { double tickLabelWidth = estimateMaximumTickLabelWidth(g2, getTickUnit()); TickUnitSource tickUnits = getStandardTickUnits(); TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit()); NumberTickUnit unit2 = (NumberTickUnit) tickUnits.getCeilingTickUnit( (tickLabelWidth / lengthToJava2D(unit1.getSize(), dataArea, edge)) * unit1.getSize()); if (estimateMaximumTickLabelWidth(g2, unit2) > lengthToJava2D(unit2.getSize(), dataArea, edge)) { unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2); } setTickUnit(unit2, DEFAULT_VERTICAL_TICK_LABELS, DEFAULT_VERTICAL_TICK_LABELS); }
/** Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { NumberTickUnit t1 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); NumberTickUnit t2 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); assertTrue(t1.equals(t2)); assertTrue(t2.equals(t1)); t1 = new NumberTickUnit(3.21, new DecimalFormat("0.00")); assertFalse(t1.equals(t2)); t2 = new NumberTickUnit(3.21, new DecimalFormat("0.00")); assertTrue(t1.equals(t2)); t1 = new NumberTickUnit(3.21, new DecimalFormat("0.000")); assertFalse(t1.equals(t2)); t2 = new NumberTickUnit(3.21, new DecimalFormat("0.000")); assertTrue(t1.equals(t2)); }