ScaleInfo implements IsInfo { public double getPixelPerUnit() { return pixelPerUnit; } ScaleInfo();  ScaleInfo(double pixelPerUnit);  ScaleInfo(double numerator, double denominator);  ScaleInfo(ScaleInfo other); double getPixelPerUnit(); void setPixelPerUnit(double pixelPerUnit); boolean isPixelPerUnitBased(); void setPixelPerUnitBased(boolean pixelPerUnitBased); double getNumerator(); void setNumerator(double numerator); double getDenominator(); void setDenominator(double denominator); double getConversionFactor(); @Deprecated void setConversionFactor(double conversionFactor); static final double PIXEL_PER_METER; static final double MINIMUM_PIXEL_PER_UNIT; static final double MAXIMUM_PIXEL_PER_UNIT; }
@Test public void testNoZeroPixelsPerUnit() { ScaleInfo scaleInfo; scaleInfo = new ScaleInfo(); Assert.assertTrue(scaleInfo.getPixelPerUnit() > 0); scaleInfo = new ScaleInfo(0); Assert.assertTrue(scaleInfo.getPixelPerUnit() > 0); }
@Test public void testPixelsPerUnitRange() { ScaleInfo scaleInfo; scaleInfo = new ScaleInfo(-100); Assert.assertEquals(ScaleInfo.MINIMUM_PIXEL_PER_UNIT, scaleInfo.getPixelPerUnit(), DELTA); scaleInfo = new ScaleInfo(1e100); Assert.assertEquals(ScaleInfo.MAXIMUM_PIXEL_PER_UNIT, scaleInfo.getPixelPerUnit(), DELTA); }
@Test public void testSerializeAndBack() throws IOException, ClassNotFoundException { ScaleInfo info = new ScaleInfo(1, 100); Assert.assertEquals(37.7952, info.getPixelPerUnit(), 0.0001); ScaleInfo copy = new ScaleInfo(info); Assert.assertEquals(37.7952, copy.getPixelPerUnit(), 0.0001); ByteArrayOutputStream baos = new ByteArrayOutputStream(); JBossObjectOutputStream out = new JBossObjectOutputStream(baos); out.writeObject(info); out.flush(); out.close(); JBossObjectInputStream in = new JBossObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); ScaleInfo clone = (ScaleInfo) in.readObject(); Assert.assertNotSame(info, clone); Assert.assertEquals(37.7952, clone.getPixelPerUnit(), 0.0001); }