package org.geotools.renderer.lite; import static java.awt.RenderingHints.KEY_ANTIALIASING; import static java.awt.RenderingHints.VALUE_ANTIALIAS_ON; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.File; import org.geotools.data.property.PropertyDataStore; import org.geotools.data.simple.SimpleFeatureSource; import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.image.test.ImageAssert; import org.geotools.map.FeatureLayer; import org.geotools.map.MapContent; import org.geotools.styling.Style; import org.geotools.test.TestData; import org.junit.Before; import org.junit.Test; public class CompositeLayeringTest { private static final long TIME = 40000; SimpleFeatureSource fs; SimpleFeatureSource bfs; ReferencedEnvelope bounds; @Before public void setUp() throws Exception { File property = new File(TestData.getResource(this, "square.properties").toURI()); PropertyDataStore ds = new PropertyDataStore(property.getParentFile()); fs = ds.getFeatureSource("square"); bfs = ds.getFeatureSource("bigsquare"); bounds = fs.getBounds(); bounds.expandBy(0.2, 0.2); // System.setProperty("org.geotools.test.interactive", "true"); } @Test public void testInternalBuffer() throws Exception { runSingleLayerTest("compositeInternalBuffer.sld"); } private void runSingleLayerTest(String styleName) throws Exception { runSingleLayerTest(styleName, 100); } private void runSingleLayerTest(String styleName, int threshold) throws Exception { Style style = RendererBaseTest.loadStyle(this, styleName); MapContent mc = new MapContent(); mc.addLayer(new FeatureLayer(fs, style)); StreamingRenderer renderer = new StreamingRenderer(); renderer.setMapContent(mc); renderer.setJava2DHints(new RenderingHints(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON)); // prepare an opaque background BufferedImage image = new BufferedImage(256, 256, BufferedImage.TYPE_3BYTE_BGR); Graphics2D graphics = image.createGraphics(); graphics.setColor(Color.lightGray); graphics.fillRect(0, 0, image.getWidth(), image.getHeight()); renderer.paint(graphics, new Rectangle(0, 0, image.getWidth(), image.getHeight()), bounds); File reference = new File("./src/test/resources/org/geotools/renderer/lite/test-data/" + styleName + ".png"); ImageAssert.assertEquals(reference, image, threshold); } }