Examples of MapContext


Examples of org.geotools.map.MapContext

  @Autowired
  private GeoService geoService;

  public void execute(PipelineContext context, RasterizingContainer response) throws GeomajasException {
    ClientMapInfo clientMapInfo = context.get(RasterizingPipelineCode.CLIENT_MAP_INFO_KEY, ClientMapInfo.class);
    MapContext mapContext = context.get(RasterizingPipelineCode.MAP_CONTEXT_KEY, MapContext.class);
    MapRasterizingInfo mapRasterizingInfo = (MapRasterizingInfo) clientMapInfo
        .getWidgetInfo(MapRasterizingInfo.WIDGET_KEY);
    mapContext.getUserData().put(LayerFactory.USERDATA_RASTERIZING_INFO, mapRasterizingInfo);
    Crs mapCrs = geoService.getCrs2(clientMapInfo.getCrs());
    ReferencedEnvelope mapArea = new ReferencedEnvelope(
        converterService.toInternal(mapRasterizingInfo.getBounds()), mapCrs);
    Rectangle paintArea = new Rectangle((int) (mapRasterizingInfo.getScale() * mapArea.getWidth()),
        (int) (mapRasterizingInfo.getScale() * mapArea.getHeight()));
    mapContext.getViewport().setBounds(mapArea);
    mapContext.getViewport().setCoordinateReferenceSystem(mapCrs);
    mapContext.getViewport().setScreenArea(paintArea);
    // add the configured layers
    for (ClientLayerInfo clientLayerInfo : clientMapInfo.getLayers()) {
      clientLayerInfo.getWidgetInfo(RasterizingConstants.WIDGET_KEY);
      Layer layer = layerFactoryService.createLayer(mapContext, clientLayerInfo);
      boolean showing = (Boolean) layer.getUserData().get(LayerFactory.USERDATA_KEY_SHOWING);
      if (showing) {
        mapContext.addLayer(layer);
      }
    }
    // add the extra layers
    for (ClientLayerInfo clientLayerInfo : mapRasterizingInfo.getExtraLayers()) {
      Layer layer = layerFactoryService.createLayer(mapContext, clientLayerInfo);
      boolean showing = (Boolean) layer.getUserData().get(LayerFactory.USERDATA_KEY_SHOWING);
      if (showing) {
        mapContext.addLayer(layer);
      }
    }
  }
View Full Code Here

Examples of org.geotools.map.MapContext

    renderer.setContext(mapContext);
  }

  public void writeTo(OutputStream out) throws ServiceException, IOException {
      try {
      MapContext map = renderer.getContext();
      double width = -1;
      double height = -1;

      if (map instanceof WMSMapContext) {
        WMSMapContext wmsMap = (WMSMapContext) map;
        width = wmsMap.getMapWidth();
        height = wmsMap.getMapHeight();
      } else {
        // guess a width and height based on the envelope
        Envelope area = map.getAreaOfInterest();

        if ((area.getHeight() > 0) && (area.getWidth() > 0)) {
          if (area.getHeight() >= area.getWidth()) {
            height = 600;
            width = height * (area.getWidth() / area.getHeight());
View Full Code Here

Examples of org.geotools.map.MapContext

                    continue;
                }
            }

            final MapLayer layer = layers[i];
            MapContext map = this.mapContext;
            map.clearLayerList();
            map.addLayer(layer);

            final int width = this.mapContext.getMapWidth();
            final int height = this.mapContext.getMapHeight();

            LOGGER.fine(new StringBuffer("setting up ").append(width).append("x").append(height)
                                                       .append(" image").toString());

            // simone: ARGB should be much better
            BufferedImage curImage = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);

            // simboss: this should help out with coverages
            final Graphics2D graphic = GraphicsJAI.createGraphicsJAI(curImage.createGraphics(), null);

            LOGGER.fine("setting to transparent");

            int type = AlphaComposite.SRC;
            graphic.setComposite(AlphaComposite.getInstance(type));

            Color c = new Color(this.mapContext.getBgColor().getRed(),
                    this.mapContext.getBgColor().getGreen(),
                    this.mapContext.getBgColor().getBlue(), 0);

            //LOGGER.info("****** bg color: "+c.getRed()+","+c.getGreen()+","+c.getBlue()+","+c.getAlpha()+", trans: "+c.getTransparency());
            graphic.setBackground(this.mapContext.getBgColor());
            graphic.setColor(c);
            graphic.fillRect(0, 0, width, height);

            type = AlphaComposite.SRC_OVER;
            graphic.setComposite(AlphaComposite.getInstance(type));

            Rectangle paintArea = new Rectangle(width, height);

            final StreamingRenderer renderer = new StreamingRenderer();
            renderer.setContext(map);

            RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
            renderer.setJava2DHints(hints);

            // we already do everything that the optimized data loading does...
            // if we set it to true then it does it all twice...
            Map rendererParams = new HashMap();
            rendererParams.put("optimizedDataLoadingEnabled", Boolean.TRUE);
            rendererParams.put("renderingBuffer", new Integer(mapContext.getBuffer()));
            renderer.setRendererHints(rendererParams);

            Envelope dataArea = map.getAreaOfInterest();
            AffineTransform at = RendererUtilities.worldToScreenTransform(dataArea, paintArea);
            renderer.paint(graphic, paintArea, dataArea, at);
            graphic.dispose();

            // /////////////////////////////////////////////////////////////////
View Full Code Here

Examples of org.geotools.map.MapContext

    public void createMapFor(final CoordinateReferenceSystem crs,
            final com.vividsolutions.jts.geom.Envelope areaOfInterest, final Graphics2D graphics)
            throws IOException {

        Geometry geographicBoundingBox = getGeographicBoundingBox(crs);
        MapContext mapContext = getMapContext(crs, geographicBoundingBox, areaOfInterest);

        graphics.setColor(new Color(153, 179, 204));
        graphics.fillRect(0, 0, mapWidth, mapHeight);

        Rectangle paintArea = new Rectangle(mapWidth, mapHeight);

        mapContext.setAreaOfInterest(areaOfInterest, crs);

        GTRenderer renderer = new StreamingRenderer();
        renderer.setContext(mapContext);
        RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.