/** * Add the given collection as a new layer to the end of the list of layers held by this context * and trigger a {@linkplain MapLayerListEvent}. This is a convenience method equivalent to * {@linkplain #addLayer}(new DefaultMapLayer(collection, style). * * @param collection the collection of features for the new layer * @param style a Style object to be used in rendering this layer */ @SuppressWarnings("unchecked") public void addLayer(Collection collection, Style style) { if (collection instanceof FeatureCollection) { FeatureCollection featureCollection = (FeatureCollection) collection; addLayer(featureCollection, style); } else { throw new IllegalArgumentException("FeatureCollection required"); } }
public void testDefaultLabelCache() throws Exception { Style pStyle = RendererBaseTest.loadStyle(this, "textAnchorRotation.sld"); Style lStyle = RendererBaseTest.loadStyle(this, "lineGray.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(lineFS, lStyle); mc.addLayer(pointFS, pStyle); StreamingRenderer renderer = new StreamingRenderer(); renderer.setContext(mc); renderer.setJava2DHints(new RenderingHints(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON)); RendererBaseTest.showRender("Old labeller", renderer, TIME, bounds); }
public void testPartialLineLabelTrue() throws Exception { // System.setProperty("java.awt.headless", "false"); Thread.sleep(1000); Style style = RendererBaseTest.loadStyle(this, "partialLineLabelTrue.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(fs_line, style); renderer.setContext(mc); final BufferedImage image = RendererBaseTest.renderImage(renderer, bounds, null); // RenderedImageBrowser.showChain(image); RendererBaseTest.assertPixel(image, 150, 1, Color.BLACK, 30); }
public void testLabelCacheImpl() throws Exception { Style pStyle = RendererBaseTest.loadStyle(this, "textAnchorRotation.sld"); Style lStyle = RendererBaseTest.loadStyle(this, "lineGray.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(lineFS, lStyle); mc.addLayer(pointFS, pStyle); StreamingRenderer renderer = new StreamingRenderer(); renderer.setContext(mc); renderer.setJava2DHints(new RenderingHints(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON)); Map rendererParams = new HashMap(); LabelCacheImpl labelCache = new LabelCacheImpl(); rendererParams.put(StreamingRenderer.LABEL_CACHE_KEY, labelCache); renderer.setRendererHints(rendererParams); RendererBaseTest.showRender("New labeller", renderer, TIME, bounds); } }
public void testLabelLineOrientation() throws Exception { Style style = RendererBaseTest.loadStyle(this, "textLineOrientation.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(fs, style); renderer.setContext(mc); RendererBaseTest.showRender("Lines with circl stroke", renderer, TIME, bounds); } }
public void testPointLabelFalse() throws Exception { // System.setProperty("java.awt.headless", "false"); Thread.sleep(1000); Style style = RendererBaseTest.loadStyle(this, "partialPointLabelFalse.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(fs_point, style); renderer.setContext(mc); final BufferedImage image = RendererBaseTest.renderImage(renderer, bounds, null); RendererBaseTest.assertPixel(image, 282, 152, Color.WHITE); // Write to file // ImageIO.write(image, "png", new File("C:/Temp/testPartialPointLabelFalse.png")); // Interactive visualization // PartialsTest.showImage("Point Partials:False", TIME, image); }
public void testLabelNatural() throws Exception { Style style = RendererBaseTest.loadStyle(this, "textNaturalOrientation.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(fs, style); renderer.setContext(mc); RendererBaseTest.showRender("Lines with circle stroke", renderer, TIME, bounds); }
public void testPartialPointLabelNo() throws Exception { // System.setProperty("java.awt.headless", "false"); Thread.sleep(1000); Style style = RendererBaseTest.loadStyle(this, "partialPointLabelNo.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(fs_point, style); renderer.setContext(mc); final BufferedImage image = RendererBaseTest.renderImage(renderer, bounds, null); RendererBaseTest.assertPixel(image, 282, 152, Color.WHITE); // Write to file // ImageIO.write(image, "png", new File("C:/Temp/testPartialPointLabelNo.png")); // Interactive visualization // PartialsTest.showImage("Point Partials:No", TIME, image); }
public void testPartialAreaLabelNo() throws Exception { // System.setProperty("java.awt.headless", "false"); Thread.sleep(1000); Style style = RendererBaseTest.loadStyle(this, "partialAreaLabelNo.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(fs_area, style); renderer.setContext(mc); final BufferedImage image = RendererBaseTest.renderImage(renderer, bounds, null); RendererBaseTest.assertPixel(image, 282, 152, Color.WHITE); // Write to file // ImageIO.write(image, "png", new File("C:/Temp/testPartialAreaLabelNo.png")); // Interactive visualization // PartialsTest.showImage("Area Partials:No", TIME, image); }
public void testPartialAreaLabelFalse() throws Exception { // System.setProperty("java.awt.headless", "false"); Thread.sleep(1000); Style style = RendererBaseTest.loadStyle(this, "partialAreaLabelFalse.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(fs_area, style); renderer.setContext(mc); final BufferedImage image = RendererBaseTest.renderImage(renderer, bounds, null); RendererBaseTest.assertPixel(image, 282, 152, Color.WHITE); // Write to file // ImageIO.write(image, "png", new File("C:/Temp/testPartialAreaLabelFalse.png")); // Interactive visualization // PartialsTest.showImage("Area Partials:False", TIME, image); }
public void testPartialPointLabelTrue() throws Exception { // System.setProperty("java.awt.headless", "false"); Thread.sleep(1000); Style style = RendererBaseTest.loadStyle(this, "partialPointLabelTrue.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(fs_point, style); renderer.setContext(mc); final BufferedImage image = RendererBaseTest.renderImage(renderer, bounds, null); RendererBaseTest.assertPixel(image, 282, 152, Color.BLACK); // Write to file // ImageIO.write(image, "png", new File("C:/Temp/testPartialPointLabelTrue.png")); // Interactive visualization // PartialsTest.showImage("Point Partials:True", TIME, image); }
public void testPartialLineLabelNo() throws Exception { // System.setProperty("java.awt.headless", "false"); Thread.sleep(1000); Style style = RendererBaseTest.loadStyle(this, "partialLineLabelNo.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(fs_line, style); renderer.setContext(mc); final BufferedImage image = RendererBaseTest.renderImage(renderer, bounds, null); RendererBaseTest.assertPixel(image, 282, 155, Color.WHITE); // Write to file // ImageIO.write(image, "png", new File("C:/Temp/testPartialLineLabelNo.png")); // Interactive visualization // PartialsTest.showImage("Line Partials:No", TIME, image); }
public void testPartialLineLabelFalse() throws Exception { // System.setProperty("java.awt.headless", "false"); Thread.sleep(1000); Style style = RendererBaseTest.loadStyle(this, "partialLineLabelFalse.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(fs_line, style); renderer.setContext(mc); final BufferedImage image = RendererBaseTest.renderImage(renderer, bounds, null); RendererBaseTest.assertPixel(image, 282, 155, Color.WHITE); // Write to file // ImageIO.write(image, "png", new File("C:/Temp/testPartialLineLabelFalse.png")); // Interactive visualization // PartialsTest.showImage("Line Partials:False", TIME, image); }
public void testPartialAreaLabelTrue() throws Exception { // System.setProperty("java.awt.headless", "false"); Thread.sleep(1000); Style style = RendererBaseTest.loadStyle(this, "partialAreaLabelTrue.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(fs_area, style); renderer.setContext(mc); final BufferedImage image = RendererBaseTest.renderImage(renderer, bounds, null); RendererBaseTest.assertPixel(image, 282, 152, Color.BLACK); // Write to file // ImageIO.write(image, "png", new File("C:/Temp/testPartialAreaLabelTrue.png")); // Interactive visualization // PartialsTest.showImage("Area Partials:True", TIME, image); }
@Test public void testIsometric() throws Exception { Style style = RendererBaseTest.loadStyle(this, "isometric.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(bfs, style); StreamingRenderer renderer = new StreamingRenderer(); renderer.setContext(mc); renderer.setJava2DHints(new RenderingHints(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON)); RendererBaseTest.showRender("lineStartEnd.sld", renderer, TIME, bbounds); }
@Test public void testStartEnd() throws Exception { Style style = RendererBaseTest.loadStyle(this, "lineStartEnd.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(fs, style); StreamingRenderer renderer = new StreamingRenderer(); renderer.setContext(mc); RendererBaseTest.showRender("lineStartEnd.sld", renderer, TIME, bounds); }
@Test public void testVertices() throws Exception { Style style = RendererBaseTest.loadStyle(this, "lineVertices.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(fs, style); StreamingRenderer renderer = new StreamingRenderer(); renderer.setContext(mc); RendererBaseTest.showRender("lineVertices.sld", renderer, TIME, bounds); }
@Test public void testBufferLine() throws Exception { Style style = RendererBaseTest.loadStyle(this, "lineBuffer.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(fs, style); StreamingRenderer renderer = new StreamingRenderer(); renderer.setContext(mc); RendererBaseTest.showRender("lineBuffer.sld", renderer, TIME, bounds); }
@Test public void testBufferPoly() throws Exception { Style style = RendererBaseTest.loadStyle(this, "polyBuffer.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(bfs, style); StreamingRenderer renderer = new StreamingRenderer(); renderer.setContext(mc); RendererBaseTest.showRender("polyBuffer.sld", renderer, TIME, bounds); }
public void testLessFilters() throws Exception { Style style = RendererBaseTest.loadStyle(this, "fillSolidTwoRules.sld"); DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84); mc.addLayer(squareFS, style); renderer.setContext(mc); renderer.addRenderListener( new RenderListener() { public void featureRenderer(SimpleFeature feature) { count++; } public void errorOccurred(Exception e) {} }); RendererBaseTest.showRender("OneSquare", renderer, TIME, bounds); assertEquals(2, count); } }