Package org.geomajas.plugin.rasterizing.command.dto

Examples of org.geomajas.plugin.rasterizing.command.dto.MapRasterizingInfo


  }

  @Test
  public void testLegend() throws Exception {
    ClientMapInfo mapInfo = new ClientMapInfo();
    MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo();
    mapRasterizingInfo.setBounds(new Bbox(-180, -90, 360, 180));
    mapInfo.setCrs("EPSG:4326");
    mapRasterizingInfo.setScale(2);
    mapRasterizingInfo.setTransparent(true);
    mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo);

    ClientRasterLayerInfo cl1 = new ClientRasterLayerInfo();
    cl1.setServerLayerId(layerBluemarble.getId());
    cl1.setLabel("Blue Marble");
    RasterLayerRasterizingInfo rr1 = new RasterLayerRasterizingInfo();
    rr1.setCssStyle("opacity:0.5");
    cl1.getWidgetInfo().put(RasterLayerRasterizingInfo.WIDGET_KEY, rr1);
    mapInfo.getLayers().add(cl1);

    ClientVectorLayerInfo cl2 = new ClientVectorLayerInfo();
    cl2.setServerLayerId(layerBeansPoint.getId());
    cl2.setLayerInfo(layerBeansPoint.getLayerInfo());
    cl2.setLabel(layerBeansPoint.getId());
    VectorLayerRasterizingInfo lr2 = new VectorLayerRasterizingInfo();
    lr2.setStyle(layerBeansPointStyleInfo);
    cl2.getWidgetInfo().put(VectorLayerRasterizingInfo.WIDGET_KEY, lr2);
    mapInfo.getLayers().add(cl2);

    ClientVectorLayerInfo cl3 = new ClientVectorLayerInfo();
    cl3.setServerLayerId(layerBeansMultiLine.getId());
    cl3.setLayerInfo(layerBeansMultiLine.getLayerInfo());
    cl3.setLabel(layerBeansMultiLine.getId());
    VectorLayerRasterizingInfo lr3 = new VectorLayerRasterizingInfo();
    lr3.setStyle(layerBeansMultiLineStyleInfo);
    cl3.getWidgetInfo().put(VectorLayerRasterizingInfo.WIDGET_KEY, lr3);
    mapInfo.getLayers().add(cl3);

    LegendRasterizingInfo legendRasterizingInfo = new LegendRasterizingInfo();
    legendRasterizingInfo.setFont(new FontStyleInfo());
    legendRasterizingInfo.getFont().applyDefaults();
    legendRasterizingInfo.getFont().setSize(12);
    legendRasterizingInfo.getFont().setFamily("courier");
    legendRasterizingInfo.setTitle("legend");
    mapRasterizingInfo.setLegendRasterizingInfo(legendRasterizingInfo);
    new LegendAssert(mapInfo).assertEqualImage("legend.png", writeImages, DELTA);
  }
View Full Code Here


  }

  @Test
  public void testLegendDynamic() throws Exception {
    ClientMapInfo mapInfo = new ClientMapInfo();
    MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo();
    // set the bounds so no features are visible
    mapRasterizingInfo.setBounds(new Bbox(-180, -90, -170, -80));
    mapInfo.setCrs("EPSG:4326");
    mapRasterizingInfo.setScale(2);
    mapRasterizingInfo.setTransparent(true);
    mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo);

    ClientRasterLayerInfo cl1 = new ClientRasterLayerInfo();
    cl1.setServerLayerId(layerBluemarble.getId());
    cl1.setLabel("Blue Marble");
    RasterLayerRasterizingInfo rr1 = new RasterLayerRasterizingInfo();
    rr1.setCssStyle("opacity:0.5");
    cl1.getWidgetInfo().put(RasterLayerRasterizingInfo.WIDGET_KEY, rr1);
    mapInfo.getLayers().add(cl1);

    ClientVectorLayerInfo cl2 = new ClientVectorLayerInfo();
    cl2.setServerLayerId(layerBeansPoint.getId());
    cl2.setLayerInfo(layerBeansPoint.getLayerInfo());
    cl2.setLabel(layerBeansPoint.getId());
    VectorLayerRasterizingInfo lr2 = new VectorLayerRasterizingInfo();
    lr2.setStyle(layerBeansPointStyleInfo);
    cl2.getWidgetInfo().put(VectorLayerRasterizingInfo.WIDGET_KEY, lr2);
    mapInfo.getLayers().add(cl2);

    ClientVectorLayerInfo cl3 = new ClientVectorLayerInfo();
    cl3.setServerLayerId(layerBeansMultiLine.getId());
    cl3.setLayerInfo(layerBeansMultiLine.getLayerInfo());
    cl3.setLabel(layerBeansMultiLine.getId());
    VectorLayerRasterizingInfo lr3 = new VectorLayerRasterizingInfo();
    lr3.setStyle(layerBeansMultiLineStyleInfo);
    cl3.getWidgetInfo().put(VectorLayerRasterizingInfo.WIDGET_KEY, lr3);
    mapInfo.getLayers().add(cl3);

    LegendRasterizingInfo legendRasterizingInfo = new LegendRasterizingInfo();
    legendRasterizingInfo.setFont(new FontStyleInfo());
    legendRasterizingInfo.getFont().applyDefaults();
    legendRasterizingInfo.getFont().setSize(12);
    legendRasterizingInfo.getFont().setFamily("courier");
    legendRasterizingInfo.setTitle("legend");
    mapRasterizingInfo.setLegendRasterizingInfo(legendRasterizingInfo);
    new LegendAssert(mapInfo).assertEqualImage("legend_dynamic.png", writeImages, DELTA);
  }
View Full Code Here

  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

  protected void checkOrRender(String fileName, boolean paintLabels, boolean paintGeometries, VectorLayer layer,
      NamedStyleInfo styleInfo, Bbox box) throws Exception {

    ClientMapInfo mapInfo = new ClientMapInfo();
    MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo();
    mapRasterizingInfo.setBounds(box);
    mapInfo.setCrs("EPSG:4326");
    mapRasterizingInfo.setScale(1);
    mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo);
    ClientVectorLayerInfo clientVectorLayerInfo = new ClientVectorLayerInfo();
    clientVectorLayerInfo.setVisible(true);
    clientVectorLayerInfo.setServerLayerId(layer.getId());
    clientVectorLayerInfo.setNamedStyleInfo(styleInfo);
View Full Code Here

  @Autowired
  private DtoConverterService dtoConverterService;

  public void execute(RasterizeMapRequest request, RasterizeMapResponse response) throws Exception {
    MapRasterizingInfo mapRasterizingInfo = (MapRasterizingInfo) request.getClientMapInfo().getWidgetInfo(
        MapRasterizingInfo.WIDGET_KEY);
    ByteArrayOutputStream mapStream = new ByteArrayOutputStream(1024 * 10);
    imageService.writeMap(mapStream, request.getClientMapInfo());
    String mapKey = putInCache(mapStream.toByteArray(), mapRasterizingInfo.getBounds());
    ByteArrayOutputStream legendStream = new ByteArrayOutputStream(1024);
    imageService.writeLegend(legendStream, request.getClientMapInfo());
    String legendKey = putInCache(legendStream.toByteArray(), mapRasterizingInfo.getBounds());
    response.setMapKey(mapKey);
    response.setLegendKey(legendKey);
  }
View Full Code Here

    geo.setStyle(createPolygonStyle());
    geo.setLayerType(LayerType.POLYGON);

    ClientMapInfo mapInfo = new ClientMapInfo();
    mapInfo.setCrs("EPSG:4326");
    MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo();
    mapRasterizingInfo.setBounds(new Bbox(0, 0, 100, 100));
    mapRasterizingInfo.setScale(1);
    mapRasterizingInfo.setTransparent(true);
    mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo);

    DefaultMapContext mapContext = new DefaultMapContext();
    mapContext.setCoordinateReferenceSystem(geoService.getCrs2("EPSG:4326"));
    mapContext.getViewport().setBounds(
View Full Code Here

  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

TOP

Related Classes of org.geomajas.plugin.rasterizing.command.dto.MapRasterizingInfo

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.