map.addLayer(ft, style); map.setAreaOfInterest(map.getLayerBounds()); ReferencedEnvelope env = map.getLayerBounds(); env = new ReferencedEnvelope( env.getMinY() - 20, env.getMaxY() + 20, map.getCoordinateReferenceSystem()); RendererBaseTest.showRender("testSimplePointRender", renderer, 1000, env);
/** * Transform the current area of interest for this context using the provided transform. This * may be useful for zooming and panning processes. Does nothing if no area of interest is set. * * @param transform The transform to change map viewport */ public void transform(AffineTransform transform) { ReferencedEnvelope oldBounds = getAreaOfInterest(); if (!(oldBounds == null || oldBounds.isEmpty())) { double[] coords = new double[4]; coords[0] = oldBounds.getMinX(); coords[1] = oldBounds.getMinY(); coords[2] = oldBounds.getMaxX(); coords[3] = oldBounds.getMaxY(); transform.transform(coords, 0, coords, 0, 2); ReferencedEnvelope newBounds = new ReferencedEnvelope( coords[0], coords[2], coords[1], coords[3], oldBounds.getCoordinateReferenceSystem()); setAreaOfInterest(newBounds); } }
public MapContent(MapContext context) { this(); for (MapLayer mapLayer : context.getLayers()) { layerList.add(mapLayer.toLayer()); } if (context.getTitle() != null) { setTitle(context.getTitle()); } if (context.getAbstract() != null) { getUserData().put("abstract", context.getAbstract()); } if (context.getContactInformation() != null) { getUserData().put("contact", context.getContactInformation()); } if (context.getKeywords() != null) { getUserData().put("keywords", context.getKeywords()); } if (context.getAreaOfInterest() != null) { getViewport().setBounds(context.getAreaOfInterest()); } }
/** * Creates a context from the provided map content. * * <p>This method is used to prevent duplication in classes supporting deprecated * getMapContext() methods. * * @param content MapContent to be represented */ public MapContext(MapContent content) { this(content.getCoordinateReferenceSystem()); for (Layer layer : content.layers()) { addLayer(layer); } this.setAreaOfInterest(content.getViewport().getBounds()); } /**
context.addLayer(gc, style); RendererBaseTest.showRender("testGridCoverage", renderer, 1000, context.getLayerBounds());
if(crs==null)crs=DefaultGeographicCRS.WGS84; MapContext context = new DefaultMapContext(crs); context.addLayer(fs,style[0]); context.getLayerBounds(); mp.setHighlightLayer(context.getLayer(0)); mp.setSelectionLayer(context.getLayer(0));
public synchronized BufferedImage createBufferImage(MapLayer layer) { try { buffercontext.setCoordinateReferenceSystem(getContext().getCoordinateReferenceSystem()); } catch (Exception e) { } buffercontext.addLayer(layer); BufferedImage buf = createBufferImage(buffercontext); buffercontext.clearLayerList(); return buf; }
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.addLayer(ft, style); map.setAreaOfInterest(map.getLayerBounds()); "testSimplePolygonRender", renderer, 1000, map.getLayerBounds());
/** * @deprecated */ public void paint(Graphics2D graphics, Rectangle paintArea, Envelope mapArea, AffineTransform worldToScreen) { paint(graphics, paintArea, new ReferencedEnvelope(mapArea, context.getCoordinateReferenceSystem()), worldToScreen); } }
/** * Add a new layer and trigger a {@link LayerListEvent}. * * @param collection Collection with the new layer that will be added. */ public void addLayer(Collection collection, Style style) { if (collection instanceof FeatureCollection) { FeatureCollection featureCollection = (FeatureCollection) collection; addLayer(featureCollection, style); } else { throw new IllegalArgumentException("FeatureCollection required"); } }
/** * 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); }
private void renderEmptyGeometry(SimpleFeature f, Style style) { SimpleFeatureCollection fc = DataUtilities.collection(f); MapContext mc = new DefaultMapContext(); mc.addLayer(fc, style); StreamingRenderer sr = new StreamingRenderer(); sr.setContext(mc); BufferedImage bi = new BufferedImage(640, 480, BufferedImage.TYPE_4BYTE_ABGR); sr.addRenderListener( new RenderListener() { public void featureRenderer(SimpleFeature feature) {} public void errorOccurred(Exception e) { java.util.logging.Logger.getGlobal() .log(java.util.logging.Level.INFO, "", e); fail( "Got an exception during rendering, this should not happen, " + "not even with emtpy geometries"); } }); sr.paint( (Graphics2D) bi.getGraphics(), new Rectangle(640, 480), new ReferencedEnvelope(new Envelope(0, 10, 0, 10), DefaultGeographicCRS.WGS84)); mc.dispose(); } }
computeScale( envelope, context.getCoordinateReferenceSystem(), paintArea, transform, MapLayer[] layers = context.getLayers(); CoordinateReferenceSystem destinationCrs = context.getCoordinateReferenceSystem(); labelCache.start(); labelCache.clear();
public MapContext duplicateContext(MapContext context) { if (context != null) { DefaultMapContext copycontext = new DefaultMapContext(context.getCoordinateReferenceSystem()); MapLayer[] layers = duplicateLayers(context.getLayers()); copycontext.addLayers( layers ); copycontext.setTitle(context.getTitle()); return copycontext; } else { return null; } }
private void adjusteContexts() { MapContext context = renderingStrategy.getContext(); if (!context.getCoordinateReferenceSystem().equals(memoryMapContext.getCoordinateReferenceSystem())) { try { memoryMapContext.setCoordinateReferenceSystem(context.getCoordinateReferenceSystem()); } catch (TransformException ex) { ex.printStackTrace(); } catch (FactoryException ex) { ex.printStackTrace(); } } memoryStrategy.setMapArea(renderingStrategy.getMapArea()); memoryStrategy.refresh(); }
/** * add a maplayer into a node, used for drag and drop * @param newChild the new node * @param parent the father node * @param index new position of the child node */ void insertLayerInto(ContextTreeNode newChild, ContextTreeNode parent, int index) { if (newChild.getUserObject() instanceof MapLayer && parent.getUserObject() instanceof MapContext) { MapContext context = (MapContext) parent.getUserObject(); MapLayer layer = (MapLayer) newChild.getUserObject(); index = context.getLayerCount() - index; if (index < 0) { index = 0; } if (index > context.getLayerCount()) { index = context.getLayerCount(); } if (index > parent.getChildCount()) { index = 0; } context.addLayer(index, layer); } }
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(); }
void mergeBuffers() { VolatileImage vi = createBackBuffer(); Graphics2D g2d = (Graphics2D) vi.getGraphics(); MapLayer[] layers = getContext().getLayers(); for (int i = 0, max = layers.length; i < max; i++) { // for (int i= layers.length-1; i>=0; i--){ MapLayer layer = layers[i]; BufferedImage img = stock.get(layer); if (img != null) { g2d.drawImage(img, null, 0, 0); } } comp.setBuffer(vi); }