/** * Utility to quickly render a set of vector data on top of a buffered image * * @param sources * @param styles * @return * @throws Exception */ public static BufferedImage render(MapContext map) throws Exception { StreamingRenderer r = new StreamingRenderer(); r.setContext(map); return RendererBaseTest.showRender("testPointLabeling", r, 5000, map.getLayerBounds()); }
map.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); map.addLayer(ft, style); map.setAreaOfInterest(map.getLayerBounds()); final ReferencedEnvelope env = (ReferencedEnvelope) map.getLayerBounds(); final ReferencedEnvelope bounds = new ReferencedEnvelope(JTS.transform(env, null, t, 10), crs);
map.setAreaOfInterest(map.getLayerBounds()); "testSimplePolygonRender", renderer, 1000, map.getLayerBounds());
/** * Tests what happens when the grid coverage is associated with a broken style with no * symbolizers inside. It should just render nothing, a NPE was reported instead in GEOT-2543. * * @throws Exception */ @Test public void paintWrongStyle() throws Exception { final GridCoverage2D gc = getGC(); final MapContext context = new DefaultMapContext(DefaultGeographicCRS.WGS84); // final Style style = new StyleBuilder().createStyle((Symbolizer) null); final Style style = RendererBaseTest.loadStyle(this, "empty.sld"); context.addLayer(gc, style); final StreamingRenderer renderer = new StreamingRenderer(); CountingRenderListener counter = new CountingRenderListener(); renderer.addRenderListener(counter); renderer.setContext(context); BufferedImage image = new BufferedImage(300, 300, BufferedImage.TYPE_4BYTE_ABGR); Graphics2D g2d = (Graphics2D) image.getGraphics(); renderer.paint(g2d, new Rectangle(0, 0, 300, 300), context.getLayerBounds()); g2d.dispose(); context.dispose(); // make sure no errors and no features assertEquals(0, counter.errors); assertEquals(0, counter.features); }
/** * Checks we won't label a feature with a sharp U turn, when using a large font * * @throws Exception */ public void testLineLabelingSharpTurn() throws Exception { FeatureCollection collection = createTightUTurnLineCollection(); Style style = loadStyle("LineStyleLarge.sld"); assertNotNull(style); MapContext map = new DefaultMapContext(DefaultGeographicCRS.WGS84); map.addLayer(collection, style); StreamingRenderer renderer = new StreamingRenderer(); renderer.setJava2DHints(new RenderingHints(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON)); renderer.setContext(map); int boundary = 2; ReferencedEnvelope env = map.getLayerBounds(); env = new ReferencedEnvelope( env.getMinX() - boundary, env.getMaxX() + boundary, env.getMinY() - boundary, env.getMaxY() + boundary, null); BufferedImage image = RendererBaseTest.showRender("U turn label", renderer, 1000, env); String refPath = "./src/test/resources/org/geotools/renderer/lite/test-data/lineLabelSharpTurn.png"; // small tolerance ImageAssert.assertEquals(new File(refPath), image, 100); }
/** * Checks we won't label a feature with a sharp U turn, when using a large font * * @throws Exception */ public void testLineLabelingSharpTurn2() throws Exception { FeatureCollection collection = createTightUTurnLineCollection2(); Style style = loadStyle("LineStyleLarge2.sld"); assertNotNull(style); MapContext map = new DefaultMapContext(DefaultGeographicCRS.WGS84); map.addLayer(collection, style); StreamingRenderer renderer = new StreamingRenderer(); renderer.setJava2DHints(new RenderingHints(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON)); renderer.setContext(map); double boundary = 2; ReferencedEnvelope env = map.getLayerBounds(); env = new ReferencedEnvelope( env.getMinX() - boundary, env.getMaxX() + boundary, env.getMinY() - boundary, env.getMaxY() + boundary, null); BufferedImage image = RendererBaseTest.showRender("U turn label", renderer, 1000, env); String refPath = "./src/test/resources/org/geotools/renderer/lite/test-data/lineLabelSharpTurn2.png"; // small tolerance ImageAssert.assertEquals(new File(refPath), image, 1000); }
map.setAreaOfInterest(map.getLayerBounds()); ReferencedEnvelope env = map.getLayerBounds(); env = new ReferencedEnvelope(
map.setAreaOfInterest(map.getLayerBounds()); ReferencedEnvelope env = map.getLayerBounds(); env = new ReferencedEnvelope(
public void testPointLabeling() throws Exception { FeatureCollection collection = createPointFeatureCollection(); Style style = loadStyle("PointStyle.sld"); assertNotNull(style); MapContext map = new DefaultMapContext(DefaultGeographicCRS.WGS84); map.addLayer(collection, style); StreamingRenderer renderer = new StreamingRenderer(); renderer.setContext(map); ReferencedEnvelope env = map.getLayerBounds(); int boundary = 10; env = new ReferencedEnvelope( env.getMinX() - boundary, env.getMaxX() + boundary, env.getMinY() - boundary, env.getMaxY() + boundary, null); RendererBaseTest.showRender("testPointLabeling", renderer, timout, env); }
public void testLineLabeling() throws Exception { FeatureCollection collection = createLineFeatureCollection(); Style style = loadStyle("LineStyle.sld"); assertNotNull(style); MapContext map = new DefaultMapContext(DefaultGeographicCRS.WGS84); map.addLayer(collection, style); StreamingRenderer renderer = new StreamingRenderer(); renderer.setContext(map); ReferencedEnvelope env = map.getLayerBounds(); int boundary = 10; env = new ReferencedEnvelope( env.getMinX() - boundary, env.getMaxX() + boundary, env.getMinY() - boundary, env.getMaxY() + boundary, null); RendererBaseTest.showRender("testLineLabeling", renderer, timout, env); }
public void testPolyLabeling() throws Exception { FeatureCollection collection = createPolyFeatureCollection(); Style style = loadStyle("PolyStyle.sld"); assertNotNull(style); MapContext map = new DefaultMapContext(DefaultGeographicCRS.WGS84); map.addLayer(collection, style); StreamingRenderer renderer = new StreamingRenderer(); renderer.setContext(map); ReferencedEnvelope env = map.getLayerBounds(); int boundary = 10; env = new ReferencedEnvelope( env.getMinX() - boundary, env.getMaxX() + boundary, env.getMinY() - boundary, env.getMaxY() + boundary, null); RendererBaseTest.showRender("testPolyLabeling", renderer, timout, env); }
/** * This test tests for custom unit of measurement features, where the feature size translates to * something 0 < size < 1. in this case, an infinite loop used to occur, see * https://jira.codehaus.org/browse/GEOT-4284 * * @throws Exception */ public void testLineLabelingUom() throws Exception { FeatureCollection collection = createLineFeatureCollection(); Style style = loadStyle("LineStyleUom.sld"); assertNotNull(style); MapContext map = new DefaultMapContext(DefaultGeographicCRS.WGS84); map.addLayer(collection, style); StreamingRenderer renderer = new StreamingRenderer(); renderer.setContext(map); ReferencedEnvelope env = map.getLayerBounds(); int boundary = 10000; env = new ReferencedEnvelope( env.getMinX() - boundary, env.getMaxX() + boundary, env.getMinY() - boundary, env.getMaxY() + boundary, null); RendererBaseTest.showRender("testLineLabeling", renderer, timout, env); }
RendererBaseTest.showRender("testGridCoverage", renderer, 1000, context.getLayerBounds());
public void layerAdded(MapLayerListEvent event) { changed = true; if (context.getLayers().length == 1) { // the first one try { mapArea = context.getLayerBounds(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } reset = true; } repaint(); }
public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if (map == null) { System.out.println("no map set in reset"); return; } if (map.context == null) { System.out.println("no context set in reset"); return; } try { map.mapArea = map.context.getLayerBounds(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } map.setReset(true); map.repaint(); }
renderer.setContext(map); ReferencedEnvelope env = map.getLayerBounds(); env = new ReferencedEnvelope(
renderer.setContext(map); ReferencedEnvelope env = map.getLayerBounds(); env = new ReferencedEnvelope(
renderer.setContext(context); ReferencedEnvelope env = context.getLayerBounds(); env = new ReferencedEnvelope(
StreamingRenderer renderer = new StreamingRenderer(); renderer.setContext(map); ReferencedEnvelope env = map.getLayerBounds(); int boundary = 10; env =
public void actionPerformed(ActionEvent arg0) { if (map != null) { MapContext context = map.getRenderingStrategy().getContext(); try { ReferencedEnvelope env = context.getLayerBounds(); if (env != null) { map.getRenderingStrategy().setMapArea(env); } } catch (IOException ex) { ex.printStackTrace(); } } }