public void paint( final Graphics2D graphics, final LiteShape2 shape, final Style2D style, final double scale) { paint(graphics, shape, style, scale, false); }
@Override void execute() { if (graphic instanceof DelayedBackbufferGraphic) { ((DelayedBackbufferGraphic) graphic).init(); } try { painter.paint(graphic, shape, style, scale, labelObstacle); } catch (Throwable t) { fireErrorEvent(t); } } }
throw new RuntimeException("Unxpected exception building lite shape", e); paint(g, stippleShape, graphicFill, scale);
shapePainter.paint(graphics, tempShape, graphic, graphic.getMaxScale());
public void testGraphicLegendNullLegend() throws Exception { StyledShapePainter painter = new StyledShapePainter(); BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = (Graphics2D) image.getGraphics(); MathTransform transform = ProjectiveTransform.create(new AffineTransform()); Decimator decimator = new Decimator(transform); Point point = new GeometryFactory().createPoint(new Coordinate(10, 10)); LiteShape2 pointShape = new LiteShape2(point, transform, decimator, false); try { painter.paint(g2, pointShape, (GraphicLegend) null, 1, false); fail(); } catch (NullPointerException e) { assertEquals("ShapePainter has been asked to paint a null legend!!", e.getMessage()); } }
public void paint(final Graphics2D graphics, final LiteShape2 shape, final Style2D style, final double scale) { paint(graphics, shape, style, scale, false); }
@Test public void testGraphicLegend() throws Exception { // Load image directly from file, for comparison with painter output final URL imageURL = TestData.getResource(this, "icon64.png"); final BufferedImage testImage = ImageIO.read(imageURL); final int width = testImage.getWidth(); final int height = testImage.getHeight(); // Get graphic legend from style final Style style = RendererBaseTest.loadStyle(this, "testGraphicLegend.sld"); final Rule rule = style.featureTypeStyles().get(0).rules().get(0); final GraphicLegend legend = (GraphicLegend) rule.getLegend(); // Paint legend using StyledShapePainter final Point point = new GeometryFactory().createPoint(new Coordinate(width / 2, height / 2)); final LiteShape2 shape = new LiteShape2(point, null, null, false); int imageType = testImage.getType(); if (imageType == BufferedImage.TYPE_CUSTOM) { imageType = BufferedImage.TYPE_INT_RGB; } final BufferedImage paintedImage = new BufferedImage(width, height, imageType); final Graphics2D graphics = paintedImage.createGraphics(); final StyledShapePainter painter = new StyledShapePainter(); painter.paint(graphics, shape, legend, 1, false); graphics.dispose(); // Ensure painted legend matches image from file Assert.assertTrue(imagesIdentical(paintedImage, testImage)); }
@Test public void testGraphicLegendNegativeScale() throws Exception { // Load image directly from file, for comparison with painter output final URL imageURL = TestData.getResource(this, "icon64.png"); final BufferedImage testImage = ImageIO.read(imageURL); final int width = testImage.getWidth(); final int height = testImage.getHeight(); // Get graphic legend from style final Style style = RendererBaseTest.loadStyle(this, "testGraphicLegend.sld"); final Rule rule = style.featureTypeStyles().get(0).rules().get(0); final GraphicLegend legend = (GraphicLegend) rule.getLegend(); // Paint legend using StyledShapePainter final Point point = new GeometryFactory().createPoint(new Coordinate(width / 2, height / 2)); final LiteShape2 shape = new LiteShape2(point, null, null, false); int imageType = testImage.getType(); if (imageType == BufferedImage.TYPE_CUSTOM) { imageType = BufferedImage.TYPE_INT_RGB; } final BufferedImage paintedImage = new BufferedImage(width, height, imageType); final Graphics2D graphics = paintedImage.createGraphics(); final StyledShapePainter painter = new StyledShapePainter(); painter.paint(graphics, shape, legend, -1, false); graphics.dispose(); // Ensure painted legend matches image from file Assert.assertTrue(imagesIdentical(paintedImage, testImage)); }
public void testGraphicLegendRotation() throws Exception { FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(); GeometryFactory gf = JTSFactoryFinder.getGeometryFactory(); // Load image directly from file, for comparison with painter output final URL imageURL = TestData.getResource(this, "icon64.png"); final BufferedImage testImage = ImageIO.read(imageURL); final int width = testImage.getWidth(); final int height = testImage.getHeight(); // Get graphic legend from style final Style style = RendererBaseTest.loadStyle(this, "testGraphicLegend.sld"); final Rule rule = style.featureTypeStyles().get(0).rules().get(0); final GraphicLegend legend = (GraphicLegend) rule.getLegend(); // Set rotation to 45 degrees legend.setRotation(ff.literal(45.0)); // Paint legend using StyledShapePainter final Point point = gf.createPoint(new Coordinate(width / 2, height / 2)); final LiteShape2 shape = new LiteShape2(point, null, null, false); int imageType = testImage.getType(); if (imageType == BufferedImage.TYPE_CUSTOM) { imageType = BufferedImage.TYPE_INT_RGB; } final BufferedImage paintedImage = new BufferedImage(width, height, imageType); final Graphics2D graphics = paintedImage.createGraphics(); final StyledShapePainter painter = new StyledShapePainter(); painter.paint(graphics, shape, legend, 1, false); graphics.dispose(); // Ensure painted legend does not match image from file Assert.assertFalse(imagesIdentical(paintedImage, testImage)); }
Point point = new GeometryFactory().createPoint(new Coordinate(10, 10)); LiteShape2 pointShape = new LiteShape2(point, transform, decimator, false); painter.paint(g2, pointShape, legend, 1, false); painter.paint(g2, pointShape, legend, 2, false); assertEquals(255, image.getRaster().getSample(0, 0, 0)); assertEquals(255, image.getRaster().getSample(0, 0, 1));
@Override void execute() { if(graphic instanceof DelayedBackbufferGraphic) { ((DelayedBackbufferGraphic) graphic).init(); } try { painter.paint(graphic, shape, style, scale, labelObstacle); } catch(Throwable t) { fireErrorEvent(t); } } }
paint(g, stippleShape, graphicFill, scale);
shapePainter.paint(graphics, tempShape, graphic, graphic.getMaxScale());
shapePainter.paint(graphics, shape, style2d, scaleDenominator);
Style2D style = styleFactory.createStyle(drawMe.content, symbolizer, scaleRange); painter.paint(graphics, shape, style, scaleDenominator);
new StyledShapePainter(this).paint(graphics, tempShape, labelItem.getTextStyle().getGraphic(), 5.0); graphics.setTransform(tempTransform);