/** Tests that symbols relative sizes are proportional. */ @org.junit.Test public void testLargeCirclePlacement() throws Exception { GetLegendGraphicRequest req = new GetLegendGraphicRequest(); req.setWidth(48); req.setHeight(25); FeatureTypeInfo ftInfo = getCatalog() .getFeatureTypeByName( MockData.MPOINTS.getNamespaceURI(), MockData.MPOINTS.getLocalPart()); req.setLayer(ftInfo.getFeatureType()); req.setStyle(readSLD("largeCircle.sld")); BufferedImage image = this.legendProducer.buildLegendGraphic(req); assertNotBlank("largeCircle", image, LegendUtils.DEFAULT_BG_COLOR); // the border is visible both top middle and bottom middle. Different JDK // build wildly different colors for the border unfortunately, so the test // checks that pixels at top/middle bottom/middle are similar color (they used to be // different, significantly) Color colorTop = getPixelColor(image, 24, 0); Color colorBottom = getPixelColor(image, 24, 24); assertColorSimilar(colorTop, colorBottom, 20); }
/** Tests that symbols relative sizes are proportional. */ @org.junit.Test public void testSimpleLine() throws Exception { GetLegendGraphicRequest req = new GetLegendGraphicRequest(); req.setWidth(20); req.setHeight(20); FeatureTypeInfo ftInfo = getCatalog() .getFeatureTypeByName( MockData.MPOINTS.getNamespaceURI(), MockData.MPOINTS.getLocalPart()); req.setLayer(ftInfo.getFeatureType()); req.setStyle(readSLD("line.sld")); BufferedImage image = this.legendProducer.buildLegendGraphic(req); assertNotBlank("line", image, LegendUtils.DEFAULT_BG_COLOR); // line in the middle, but off the middle, it's white Color colorCenter = getPixelColor(image, 10, 10); assertColorSimilar(Color.BLUE, colorCenter, 20); Color colorOutsideCenter = getPixelColor(image, 6, 6); assertColorSimilar(Color.WHITE, colorOutsideCenter, 20); }