/** * Test that point features are rendered at the expected image coordinates when the map is * rotated. StreamingRenderer * * @throws Exception */ @Test public void testRotatedTransform() throws Exception { // If we rotate the world rectangle + 90 degrees around (0,0), we get the screen rectangle final Rectangle screen = new Rectangle(0, 0, 100, 50); final Envelope world = new Envelope(0, 50, 0, -100); final AffineTransform worldToScreen = AffineTransform.getRotateInstance(Math.toRadians(90), 0, 0); DefaultFeatureCollection fc = new DefaultFeatureCollection(); fc.add(createPoint(0, 0)); fc.add(createPoint(world.getMaxX(), world.getMinY())); MapContext mapContext = new DefaultMapContext(DefaultGeographicCRS.WGS84); mapContext.addLayer((FeatureCollection) fc, createPointStyle()); BufferedImage image = new BufferedImage(screen.width, screen.height, BufferedImage.TYPE_4BYTE_ABGR); final StreamingRenderer sr = new StreamingRenderer(); sr.setContext(mapContext); sr.paint(image.createGraphics(), screen, worldToScreen); assertTrue("Pixel should be drawn at 0,0 ", image.getRGB(0, 0) != 0); assertTrue( "Pixel should not be drawn in image centre ", image.getRGB(screen.width / 2, screen.height / 2) == 0); assertTrue( "Pixel should be drawn at image max corner ", image.getRGB(screen.width - 1, screen.height - 1) != 0); }