Package org.geotools.map

Examples of org.geotools.map.MapContext


  @Autowired
  private RenderingService renderingService;

  public void execute(PipelineContext context, RasterizingContainer response) throws GeomajasException {
    MapContext mapContext = context.get(RasterizingPipelineCode.MAP_CONTEXT_KEY, MapContext.class);
    context.put(RasterizingPipelineCode.RENDERED_IMAGE, renderingService.paintLegend(mapContext));
  }
View Full Code Here


  @Autowired
  private RenderingService renderingService;

  public void execute(PipelineContext context, RasterizingContainer response) throws GeomajasException {
    MapContext mapContext = context.get(RasterizingPipelineCode.MAP_CONTEXT_KEY, MapContext.class);
    RenderingHints renderingHints = context.get(RasterizingPipelineCode.RENDERING_HINTS, RenderingHints.class);
    Rectangle paintArea = mapContext.getViewport().getScreenArea();
    MapRasterizingInfo mapRasterizingInfo = (MapRasterizingInfo) mapContext.getUserData().get(
        LayerFactory.USERDATA_RASTERIZING_INFO);
    BufferedImage image = createImage(paintArea.width, paintArea.height, mapRasterizingInfo.isTransparent());
    Graphics2D graphics = getGraphics(image, mapRasterizingInfo.isTransparent(), renderingHints);
    renderingService.paintMap(mapContext, graphics);
    context.put(RasterizingPipelineCode.RENDERED_IMAGE, image);
View Full Code Here

  @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

    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

                    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

    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

  public Map getMap() {
    return map;
  }

  public MapContext getMapContext() {
    MapContext mapContext = this.getMapPane().getMapContext();

    if (mapContext == null) {
      mapContext = new DefaultMapContext();
    }
View Full Code Here

          }
        }

        if (mapDesc != null) {
          map.initByMapDesc(mapDesc, this.getMapDescFilePath());
          MapContext mapContext = map.getMapContext();
          if (mapContext != null) {
            this.getMapPane().setBackground(
                mapDesc.getBackgroundColor());
            this.setMapContext(mapContext);
View Full Code Here

      }

      app.getMap().initByMapDesc(mapDesc, app.getMapDescFilePath());
      app.getMapPane().setBackground(bgColor);

      MapContext mapContext = app.getMap().getMapContext();
      if (mapContext != null) {
        app.setMapContext(mapContext);
        app.pack();
      }
    } catch (Exception ex) {
View Full Code Here

    private void testRender(SimpleFeatureSource featureSource) throws Exception {
        SimpleFeatureType schema = featureSource.getSchema();
        CoordinateReferenceSystem crs = schema.getCoordinateReferenceSystem();
        ReferencedEnvelope bounds = featureSource.getBounds();

        MapContext context = new DefaultMapContext(crs);
        Style style = new BasicPolygonStyle();
        context.addLayer(featureSource, style);
        context.setAreaOfInterest(bounds);
        StreamingRenderer renderer = new StreamingRenderer();
        renderer.setContext(context);

        BufferedImage image = new BufferedImage(800, 600, BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics = image.createGraphics();
View Full Code Here

TOP

Related Classes of org.geotools.map.MapContext

Copyright © 2018 www.massapicom. 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.