assertPixel(image, 1, 1, new Color(255, 255, 255)); assertPixel(image, 5, 5, new Color(255, 0, 0)); assertPixel(image, 10, 10, new Color(255, 0, 0)); assertPixel(image, 1, 21, new Color(255, 255, 255)); assertPixel(image, 5, 25, new Color(255, 255, 255)); assertPixel(image, 7, 27, new Color(255, 0, 0)); assertPixel(image, 10, 30, new Color(255, 0, 0)); assertPixel(image, 1, 41, new Color(255, 255, 255)); assertPixel(image, 5, 45, new Color(255, 255, 255)); assertPixel(image, 6, 46, new Color(255, 255, 255)); assertPixel(image, 10, 50, new Color(255, 0, 0)); assertPixel(image, 1, 61, new Color(255, 255, 255)); assertPixel(image, 6, 68, new Color(255, 255, 255)); assertPixel(image, 10, 70, new Color(255, 0, 0));
assertPixel(image, 1, 1, new Color(255, 255, 255)); assertPixel(image, 5, 5, new Color(255, 0, 0)); assertPixel(image, 10, 10, new Color(255, 0, 0)); assertPixel(image, 1, 21, new Color(255, 255, 255)); assertPixel(image, 5, 25, new Color(255, 255, 255)); assertPixel(image, 7, 27, new Color(255, 0, 0)); assertPixel(image, 10, 30, new Color(255, 0, 0)); assertPixel(image, 1, 41, new Color(255, 255, 255)); assertPixel(image, 5, 45, new Color(255, 255, 255)); assertPixel(image, 6, 46, new Color(255, 255, 255)); assertPixel(image, 10, 50, new Color(255, 0, 0)); assertPixel(image, 1, 61, new Color(255, 255, 255)); assertPixel(image, 6, 68, new Color(255, 255, 255)); assertPixel(image, 10, 70, new Color(255, 0, 0));
/** Tests that symbols relative sizes are proportional. */ @org.junit.Test public void testProportionalSymbolsLine() throws Exception { GetLegendGraphicRequest req = new GetLegendGraphicRequest(); FeatureTypeInfo ftInfo = getCatalog() .getFeatureTypeByName( MockData.MPOINTS.getNamespaceURI(), MockData.MPOINTS.getLocalPart()); req.setLayer(ftInfo.getFeatureType()); req.setStyle(readSLD("ProportionalSymbolsLine.sld")); BufferedImage image = this.legendProducer.buildLegendGraphic(req); assertNotBlank("ProportionalSymbolsLine", image, LegendUtils.DEFAULT_BG_COLOR); // biggest symbol, thick border assertPixel(image, 1, 1, new Color(255, 255, 255)); // outside assertPixel(image, 5, 5, new Color(0, 0, 0)); // border assertPixel(image, 7, 12, new Color(255, 0, 0)); // inside // second symbol, small, no border assertPixel(image, 1, 21, new Color(255, 255, 255)); // outside assertPixel(image, 5, 25, new Color(255, 255, 255)); // small, still outside assertPixel(image, 10, 30, new Color(255, 0, 0)); // inside }
/** Tests that symbols relative sizes are proportional. */ @org.junit.Test public void testProportionalSymbolThickBorder() throws Exception { GetLegendGraphicRequest req = new GetLegendGraphicRequest(); FeatureTypeInfo ftInfo = getCatalog() .getFeatureTypeByName( MockData.MPOINTS.getNamespaceURI(), MockData.MPOINTS.getLocalPart()); req.setLayer(ftInfo.getFeatureType()); req.setStyle(readSLD("ProportionalSymbolsThickBorder.sld")); BufferedImage image = this.legendProducer.buildLegendGraphic(req); assertNotBlank( "testProportionalSymbolSizeThickBorder", image, LegendUtils.DEFAULT_BG_COLOR); // biggest symbol, thick border assertPixel(image, 1, 1, new Color(255, 255, 255)); // outside assertPixel(image, 5, 5, new Color(0, 0, 0)); // border assertPixel(image, 10, 10, new Color(255, 0, 0)); // inside // second symbol, small, no border assertPixel(image, 1, 21, new Color(255, 255, 255)); // outside assertPixel(image, 5, 25, new Color(255, 255, 255)); // small, still outside assertPixel(image, 10, 30, new Color(255, 0, 0)); // inside }
/** Tests that minSymbolSize legend option is respected. */ @org.junit.Test public void testMinSymbolSize() throws Exception { GetLegendGraphicRequest req = new GetLegendGraphicRequest(); FeatureTypeInfo ftInfo = getCatalog() .getFeatureTypeByName( MockData.MPOINTS.getNamespaceURI(), MockData.MPOINTS.getLocalPart()); Map<String, String> options = new HashMap<String, String>(); options.put("minSymbolSize", "10"); req.setLegendOptions(options); req.setLayer(ftInfo.getFeatureType()); req.setStyle(readSLD("ProportionalSymbols.sld")); BufferedImage image = this.legendProducer.buildLegendGraphic(req); assertNotBlank("testProportionalSymbolSize", image, LegendUtils.DEFAULT_BG_COLOR); // biggest symbol assertPixel(image, 1, 1, new Color(255, 255, 255)); assertPixel(image, 5, 5, new Color(255, 0, 0)); assertPixel(image, 10, 10, new Color(255, 0, 0)); // smallest symbol assertPixel(image, 1, 61, new Color(255, 255, 255)); assertPixel(image, 7, 67, new Color(255, 0, 0)); assertPixel(image, 10, 70, new Color(255, 0, 0)); }
/** Tests that symbols relative sizes are proportional. */ @org.junit.Test public void testThickPolygonBorder() 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("ThickBorder.sld")); BufferedImage image = this.legendProducer.buildLegendGraphic(req); assertNotBlank("testThickPolygonBorder", image, LegendUtils.DEFAULT_BG_COLOR); // thick symbol, there is padding, black thick border, and center assertPixel(image, 1, 1, new Color(255, 255, 255)); assertPixel(image, 6, 6, new Color(0, 0, 0)); assertPixel(image, 10, 10, new Color(255, 0, 0)); // second symbol, padding, border, green center assertPixel(image, 1, 21, new Color(255, 255, 255)); // assertPixel(image, 4, 25, new Color(0, 0, 0)); // unsafe, the border is thin here assertPixel(image, 10, 30, new Color(0, 255, 0)); }
/** * Tests that symbols relative sizes are proportional also if using uoms in some Symbolizer and * not using them in others. */ @org.junit.Test public void testProportionalSymbolSizePartialUOM() throws Exception { GetLegendGraphicRequest req = new GetLegendGraphicRequest(); req.setScale(RendererUtilities.calculatePixelsPerMeterRatio(10, Collections.EMPTY_MAP)); FeatureTypeInfo ftInfo = getCatalog() .getFeatureTypeByName( MockData.MPOINTS.getNamespaceURI(), MockData.MPOINTS.getLocalPart()); req.setLayer(ftInfo.getFeatureType()); req.setStyle(readSLD("ProportionalSymbolsPartialUOM.sld")); BufferedImage image = this.legendProducer.buildLegendGraphic(req); assertNotBlank("testProportionalSymbolSize", image, LegendUtils.DEFAULT_BG_COLOR); // UOM symbol assertPixel(image, 1, 1, new Color(255, 255, 255)); assertPixel(image, 5, 5, new Color(255, 0, 0)); assertPixel(image, 10, 10, new Color(255, 0, 0)); // non UOM symbol assertPixel(image, 1, 1, new Color(255, 255, 255)); assertPixel(image, 5, 5, new Color(255, 0, 0)); assertPixel(image, 10, 10, new Color(255, 0, 0)); }
/** Tests that symbols relative sizes are proportional. */ @org.junit.Test public void testThickPolygonAsymmetricSymbol() throws Exception { GetLegendGraphicRequest req = new GetLegendGraphicRequest(); req.setWidth(40); req.setHeight(20); FeatureTypeInfo ftInfo = getCatalog() .getFeatureTypeByName( MockData.MPOINTS.getNamespaceURI(), MockData.MPOINTS.getLocalPart()); req.setLayer(ftInfo.getFeatureType()); req.setStyle(readSLD("ThickBorder.sld")); BufferedImage image = this.legendProducer.buildLegendGraphic(req); assertNotBlank("testThickPolygonBorder", image, LegendUtils.DEFAULT_BG_COLOR); // thick symbol, there is padding, black thick border, and center assertPixel(image, 1, 1, new Color(255, 255, 255)); assertPixel(image, 9, 6, new Color(0, 0, 0)); assertPixel(image, 20, 10, new Color(255, 0, 0)); // second symbol, padding, border, green center assertPixel(image, 1, 23, new Color(255, 255, 255)); // assertPixel(image, 4, 25, new Color(0, 0, 0)); // unsafe, the border is thin here assertPixel(image, 20, 30, new Color(0, 255, 0)); }
assertPixel(image, 1, titleHeight / 2, new Color(0, 0, 0)); assertPixel(image, 10, 10 + titleHeight, new Color(192, 160, 0)); assertPixel(image, 10, 30 + titleHeight, new Color(0, 0, 0)); assertPixel(image, 10, 50 + titleHeight, new Color(224, 64, 0)); assertPixel(image, 1, 60 + titleHeight + titleHeight / 2, new Color(0, 0, 0)); assertPixel(image, 10, 70 + titleHeight * 2, new Color(192, 160, 0)); assertPixel(image, 10, 90 + titleHeight * 2, new Color(0, 0, 0)); assertPixel(image, 10, 110 + titleHeight * 2, new Color(224, 64, 0));
assertPixel(image, 10, 10 + titleHeight, new Color(192, 160, 0)); assertPixel(image, 10, 30 + titleHeight, new Color(0, 0, 0)); assertPixel(image, 10, 50 + titleHeight, new Color(224, 64, 0)); assertPixel(image, 10, 70 + titleHeight * 2, new Color(64, 64, 192));
/** Tests that symbols are not bigger than the requested icon size. */ @org.junit.Test public void testSymbolContainedInIcon() throws Exception { GetLegendGraphicRequest req = new GetLegendGraphicRequest(); FeatureTypeInfo ftInfo = getCatalog() .getFeatureTypeByName( MockData.MPOINTS.getNamespaceURI(), MockData.MPOINTS.getLocalPart()); req.setLayer(ftInfo.getFeatureType()); req.setStyle(readSLD("BigSymbol.sld")); BufferedImage image = this.legendProducer.buildLegendGraphic(req); assertNotBlank("testSymbolSize", image, LegendUtils.DEFAULT_BG_COLOR); // background at borders assertPixel(image, 1, 1, new Color(255, 255, 255)); // symbol in the center assertPixel(image, 10, 10, new Color(255, 0, 0)); }
assertPixel(image, 10, 10, new Color(192, 160, 0)); assertPixel(image, 10, 30, new Color(0, 0, 0)); assertPixel(image, 10, 50, new Color(224, 64, 0)); assertPixel(image, 10, 70, new Color(192, 160, 0)); assertPixel(image, 10, 90, new Color(0, 0, 0)); assertPixel(image, 10, 110, new Color(224, 64, 0));
/** * Test that the legend is not the same if there is a rendering transformation that converts the * rendered layer from vector to raster */ @org.junit.Test public void testRenderingTransformationVectorRaster() throws Exception { Style transformStyle = readSLD("RenderingTransformVectorRaster.sld"); GetLegendGraphicRequest req = new GetLegendGraphicRequest(); FeatureTypeInfo ftInfo = getCatalog() .getFeatureTypeByName( MockData.NAMED_PLACES.getNamespaceURI(), MockData.NAMED_PLACES.getLocalPart()); assertNotNull(ftInfo); req.setLayer(ftInfo.getFeatureType()); req.setStyle(transformStyle); req.setLegendOptions(new HashMap()); this.legendProducer.buildLegendGraphic(req); BufferedImage image = this.legendProducer.buildLegendGraphic(req); // ImageIO.write(image, "PNG", new File("/tmp/vr.png")); assertNotBlank("testRenderingTransform", image, LegendUtils.DEFAULT_BG_COLOR); assertPixel(image, 10, 70, new Color(188, 188, 255)); assertPixel(image, 10, 80, new Color(68, 68, 255)); assertPixel(image, 10, 130, new Color(255, 152, 0)); }
assertPixel(image, 10, 10 + titleHeight, new Color(192, 160, 0)); assertPixel(image, 10, 30 + titleHeight, new Color(0, 0, 0)); assertPixel(image, 10, 50 + titleHeight, new Color(224, 64, 0));
/** * Tests that symbols are not bigger than the requested icon size, also if an expression is used * for the symbol Size. */ @org.junit.Test public void testSymbolContainedInIconUsingExpression() throws Exception { GetLegendGraphicRequest req = new GetLegendGraphicRequest(); FeatureTypeInfo ftInfo = getCatalog() .getFeatureTypeByName( MockData.MPOINTS.getNamespaceURI(), MockData.MPOINTS.getLocalPart()); req.setLayer(ftInfo.getFeatureType()); req.setStyle(readSLD("SymbolExpression.sld")); BufferedImage image = this.legendProducer.buildLegendGraphic(req); assertNotBlank( "testSymbolContainedInIconUsingExpression", image, LegendUtils.DEFAULT_BG_COLOR); // background at borders assertPixel(image, 1, 20, new Color(255, 255, 255)); // symbol in the center (second symbol, the first one is attribute dependent and would not // be drawn normally) assertPixel(image, 10, 30, new Color(255, 0, 0)); }
assertEquals(HEIGHT_HINT * 2, image.getHeight()); for (int x = 21; x <= 29; x++) { assertPixel(image, x, HEIGHT_HINT / 2, new Color(255, 255, 255)); assertEquals(HEIGHT_HINT * 2, image.getHeight()); for (int x = 21; x <= 39; x++) { assertPixel(image, x, HEIGHT_HINT / 2, new Color(255, 255, 255));
assertPixel(image, 10, 10 + titleHeight, new Color(192, 160, 0)); assertPixel(image, 10, 30 + titleHeight, new Color(0, 0, 0)); assertPixel(image, 10, 50 + titleHeight, new Color(224, 64, 0)); assertPixel(image, 10, 70 + titleHeight * 2, new Color(115, 38, 0)); } finally { RenderedImage ri = coverage.getRenderedImage();
assertPixel(image, 1, 1, new Color(255, 255, 255)); assertPixel(image, 10, 10, new Color(0, 0, 0)); assertPixel(image, 19, 19, new Color(255, 255, 255));
assertPixel(image, 10, 10, new Color(0, 0, 0)); assertPixel(image, 10, 30, new Color(0, 0, 255)); assertPixel(image, 10, 50, new Color(255, 0, 0));
assertPixel(image, 10, HEIGHT_HINT + HEIGHT_HINT / 2, Color.YELLOW); } finally { RenderedImage ri = coverage.getRenderedImage();