StyledShapePainter { public void paint(final Graphics2D graphics, final LiteShape2 shape, final Style2D style, final double scale) { paint(graphics, shape, style, scale, false); } StyledShapePainter(); @Deprecated  StyledShapePainter(LabelCache cache); void paint(final Graphics2D graphics, final LiteShape2 shape,
            final Style2D style, final double scale); void paint(final Graphics2D graphics, final LiteShape2 shape,
            final Style2D style, final double scale, boolean isLabelObstacle); void paint(final Graphics2D graphics, final LiteShape2 shape, final GraphicLegend legend, 
            final double symbolScale, boolean isLabelObstacle); final static Key TEXTURE_ANCHOR_HINT_KEY; static boolean ROUND_ICON_COORDS; }
@Test public void testGraphicLegend() throws Exception { final URL imageURL = TestData.getResource(this, "icon64.png"); final BufferedImage testImage = ImageIO.read(imageURL); final int width = testImage.getWidth(); final int height = testImage.getHeight(); final Style style = RendererBaseTest.loadStyle( this, "testGraphicLegend.sld"); final Rule rule = style.featureTypeStyles().get(0).rules().get(0); final GraphicLegend legend = (GraphicLegend) rule.getLegend(); 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(); Assert.assertTrue(imagesIdentical(paintedImage, testImage)); }
@Test public void testGraphicLegendNegativeScale() throws Exception { final URL imageURL = TestData.getResource(this, "icon64.png"); final BufferedImage testImage = ImageIO.read(imageURL); final int width = testImage.getWidth(); final int height = testImage.getHeight(); final Style style = RendererBaseTest.loadStyle( this, "testGraphicLegend.sld"); final Rule rule = style.featureTypeStyles().get(0).rules().get(0); final GraphicLegend legend = (GraphicLegend) rule.getLegend(); 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(); Assert.assertTrue(imagesIdentical(paintedImage, testImage)); }