@Test public void getTransformReverseYDir() throws Exception { System.out.println(" getTransform with reversed Y axis"); Rectangle world = new Rectangle(5000, 4000, 10000, 10000); Rectangle image = new Rectangle(10, -10, 100, 100); CoordinateTransform tr = CoordinateTransforms.getTransform(world, image, false, true); assertPoint(image.x, image.y, tr.worldToImage(world.x, world.y + world.height, null)); assertPoint(image.x + image.width, image.y + image.height, tr.worldToImage(world.x + world.width, world.y, null)); }
@Test public void unitBounds() throws Exception { System.out.println(" unit bounds transform"); Rectangle r = new Rectangle(-100, 100, 1000, 2000); CoordinateTransform tr = CoordinateTransforms.unitBounds(r); assertPoint(r.x, r.y, tr.worldToImage(0, 0, null)); assertPoint(r.x + r.width, r.y + r.height, tr.worldToImage(1, 1, null)); }
@Test public void getTransformDefault() throws Exception { System.out.println(" getTransform method"); Rectangle world = new Rectangle(0, 0, 10000, 10000); Rectangle image = new Rectangle(10, -10, 100, 100); CoordinateTransform tr = CoordinateTransforms.getTransform(world, image); assertPoint(image.x, image.y, tr.worldToImage(world.x, world.y, null)); assertPoint(image.x + image.width, image.y + image.height, tr.worldToImage(world.x + world.width, world.y + world.height, null)); }
@Test public void getTransformReverseXDir() throws Exception { System.out.println(" getTransform with reversed X axis"); Rectangle world = new Rectangle(5000, 4000, 10000, 10000); Rectangle image = new Rectangle(10, -10, 100, 100); CoordinateTransform tr = CoordinateTransforms.getTransform(world, image, true, false); assertPoint(image.x, image.y, tr.worldToImage(world.x + world.width, world.y, null)); assertPoint(image.x + image.width, image.y + image.height, tr.worldToImage(world.x, world.y + world.height, null)); }
@Test public void identity_direct() throws Exception { System.out.println(" identity transform created directly"); CoordinateTransform tr = IdentityCoordinateTransform.INSTANCE; Point pt = tr.worldToImage(10.4, 10.6, null); assertPoint(10, 11, pt); }
@Test public void scale() throws Exception { System.out.println(" scaling transform"); CoordinateTransform tr = CoordinateTransforms.scale(0.1, 0.2); Point pt = tr.worldToImage(100, 100, null); assertPoint(10, 20, pt); }
@Test public void affineRotation() throws Exception { System.out.println(" affine rotation"); // 90 degrees anti-clockwise rotation AffineTransform affine = AffineTransform.getRotateInstance(Math.PI/2, 50, 50); CoordinateTransform tr = new AffineCoordinateTransform(affine); assertPoint(100, 0, tr.worldToImage(0, 0, null)); assertPoint(0, 100, tr.worldToImage(100, 100, null)); }
@Test public void identity_fromHelper() throws Exception { System.out.println(" identity transform from helper"); CoordinateTransform tr = CoordinateTransforms.identity(); Point pt = tr.worldToImage(10.4, 10.6, null); assertPoint(10, 11, pt); }
@Test public void translation() throws Exception { System.out.println(" translation transform"); CoordinateTransform tr = CoordinateTransforms.translation(10, -10); Point pt = tr.worldToImage(100, 100, null); assertPoint(110, 90, pt); }