@Test public void testCopying() { final Scale trans = new Scale(34, 67, 10, 66, 77, 5); Transform copy = trans.clone(); TransformHelper.assertMatrix(copy, 34, 0, 0, -2178, 0, 67, 0, -5082, 0, 0, 10, -45); }
@Test public void testToString() { final Scale trans = new Scale(5, 8); String s = trans.toString(); assertNotNull(s); assertFalse(s.isEmpty()); }
@Test public void testScale() { final Scale trans = new Scale() { { setX(25); setY(52); } }; final Rectangle n = new Rectangle(); n.getTransforms().add(trans); assertTx(n, BaseTransform.getScaleInstance(25, 52)); TransformHelper.assertMatrix(trans, 25, 0, 0, 0, 0, 52, 0, 0, 0, 0, 1, 0); trans.setX(34); Assert.assertEquals(34, trans.getX(), 1e-100); assertTx(n, BaseTransform.getScaleInstance(34, 52)); TransformHelper.assertMatrix(trans, 34, 0, 0, 0, 0, 52, 0, 0, 0, 0, 1, 0); trans.setY(67); assertTx(n, BaseTransform.getScaleInstance(34, 67)); TransformHelper.assertMatrix(trans, 34, 0, 0, 0, 0, 67, 0, 0, 0, 0, 1, 0); trans.setPivotX(66); Affine2D expTx = new Affine2D(); expTx.setToTranslation(trans.getPivotX(), trans.getPivotY()); expTx.scale(trans.getX(), trans.getY()); expTx.translate(-trans.getPivotX(), -trans.getPivotY()); assertTx(n, expTx); TransformHelper.assertMatrix(trans, 34, 0, 0, -2178, 0, 67, 0, 0, 0, 0, 1, 0); trans.setPivotY(77); expTx.setToTranslation(trans.getPivotX(), trans.getPivotY()); expTx.scale(trans.getX(), trans.getY()); expTx.translate(-trans.getPivotX(), -trans.getPivotY()); assertTx(n, expTx); TransformHelper.assertMatrix(trans, 34, 0, 0, -2178, 0, 67, 0, -5082, 0, 0, 1, 0); trans.setZ(10); trans.setPivotZ(5); TransformHelper.assertMatrix(trans, 34, 0, 0, -2178, 0, 67, 0, -5082, 0, 0, 10, -45); }