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

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


    createImageUrl(map, imageCallBack, true);
  }

  public void makeRasterizable(MapWidget map) {
    ClientMapInfo mapInfo = map.getMapModel().getMapInfo();
    MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo();
    MapView mapView = map.getMapModel().getMapView();
    mapRasterizingInfo.setBounds(GeometryConverter.toDto(map.getMapModel().getMapView().getBounds()));
    mapRasterizingInfo.setScale(mapView.getCurrentScale());
    mapRasterizingInfo.setTransparent(true);
    LegendRasterizingInfo legendRasterizingInfo = new LegendRasterizingInfo();
    legendRasterizingInfo.setTitle("Legend");
    FontStyleInfo font = new FontStyleInfo();
    font.applyDefaults();
    legendRasterizingInfo.setFont(font);
    mapRasterizingInfo.setLegendRasterizingInfo(legendRasterizingInfo);
    mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo);
    for (Layer<?> layer : map.getMapModel().getLayers()) {
      if (layer instanceof VectorLayer) {
        VectorLayer vectorLayer = (VectorLayer) layer;
        VectorLayerRasterizingInfo vectorRasterizingInfo = new VectorLayerRasterizingInfo();
        vectorRasterizingInfo.setPaintGeometries(true);
        vectorRasterizingInfo.setPaintLabels(layer.isLabeled());
        vectorRasterizingInfo.setShowing(layer.isShowing());
        ClientVectorLayerInfo layerInfo = vectorLayer.getLayerInfo();
        vectorRasterizingInfo.setStyle(layerInfo.getNamedStyleInfo());
        if (vectorLayer.getSelectedFeatures().size() > 0) {
          Set<String> selectedFeatures = vectorLayer.getSelectedFeatures();
          vectorRasterizingInfo.setSelectedFeatureIds(selectedFeatures.toArray(new String[selectedFeatures
              .size()]));
          FeatureStyleInfo selectStyle = null;
          switch (layerInfo.getLayerType()) {
            case GEOMETRY:
              break;
            case LINESTRING:
            case MULTILINESTRING:
              selectStyle = mapInfo.getLineSelectStyle();
              break;
            case MULTIPOINT:
            case POINT:
              selectStyle = mapInfo.getPointSelectStyle();
              break;
            case MULTIPOLYGON:
            case POLYGON:
              selectStyle = mapInfo.getPolygonSelectStyle();
              break;
          }
          selectStyle.applyDefaults();
          vectorRasterizingInfo.setSelectionStyle(selectStyle);
        }
        layerInfo.getWidgetInfo().put(VectorLayerRasterizingInfo.WIDGET_KEY, vectorRasterizingInfo);
      } else if (layer instanceof RasterLayer) {
        RasterLayerRasterizingInfo rasterInfo = new RasterLayerRasterizingInfo();
        ClientRasterLayerInfo layerInfo = (ClientRasterLayerInfo) layer.getLayerInfo();
        rasterInfo.setShowing(layer.isShowing());
        rasterInfo.setCssStyle(layerInfo.getStyle());
        layerInfo.getWidgetInfo().put(RasterLayerRasterizingInfo.WIDGET_KEY, rasterInfo);
      }
    }
    mapRasterizingInfo.getExtraLayers().clear();
    for (WorldPaintable worldPaintable : map.getWorldPaintables().values()) {
      if (worldPaintable instanceof GfxGeometry) {
        ClientGeometryLayerInfo layer = new ClientGeometryLayerInfo();
        GfxGeometry geometry = (GfxGeometry) worldPaintable;
        layer.getGeometries().add(GeometryConverter.toDto((Geometry) geometry.getOriginalLocation()));
        FeatureStyleInfo style = new FeatureStyleInfo();
        style.setFillColor(geometry.getStyle().getFillColor());
        style.setFillOpacity(geometry.getStyle().getFillOpacity());
        style.setStrokeColor(geometry.getStyle().getStrokeColor());
        style.setStrokeOpacity(geometry.getStyle().getStrokeOpacity());
        style.setStrokeWidth((int) geometry.getStyle().getStrokeWidth());
        style.applyDefaults();
        layer.setStyle(style);
        layer.setLayerType(geometry.getGeometry().getLayerType());
        layer.setLabel(geometry.getId());
        layer.setId(geometry.getId());
        mapRasterizingInfo.getExtraLayers().add(layer);
      }
    }
  }
View Full Code Here


  public void writeMap(OutputStream stream, ClientMapInfo clientMapInfo) throws GeomajasException {
    PipelineContext context = pipelineService.createContext();
    DefaultMapContext mapContext = new DefaultMapContext();
    mapContext.setCoordinateReferenceSystem(geoService.getCrs2(clientMapInfo.getCrs()));
    MapRasterizingInfo mapInfo = (MapRasterizingInfo) clientMapInfo.getWidgetInfo(MapRasterizingInfo.WIDGET_KEY);
    mapContext.setAreaOfInterest(new ReferencedEnvelope(dtoConverterService.toInternal(mapInfo.getBounds()),
        mapContext.getCoordinateReferenceSystem()));
    RenderingHints renderingHints = new Hints();
    renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    RasterizingContainer response = new RasterizingContainer();
    context.put(RasterizingPipelineCode.CLIENT_MAP_INFO_KEY, clientMapInfo);
View Full Code Here

  public void writeLegend(OutputStream stream, ClientMapInfo clientMapInfo) throws GeomajasException {
    PipelineContext context = pipelineService.createContext();
    DefaultMapContext mapContext = new DefaultMapContext();
    mapContext.setCoordinateReferenceSystem(geoService.getCrs2(clientMapInfo.getCrs()));
    MapRasterizingInfo mapInfo = (MapRasterizingInfo) clientMapInfo.getWidgetInfo(MapRasterizingInfo.WIDGET_KEY);
    mapContext.setAreaOfInterest(new ReferencedEnvelope(dtoConverterService.toInternal(mapInfo.getBounds()),
        mapContext.getCoordinateReferenceSystem()));
    RenderingHints renderingHints = new Hints();
    renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    RasterizingContainer response = new RasterizingContainer();
    context.put(RasterizingPipelineCode.CLIENT_MAP_INFO_KEY, clientMapInfo);
View Full Code Here

  private 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

  }

  @Test
  public void testOneVectorLayer() throws Exception {
    ClientMapInfo mapInfo = new ClientMapInfo();
    MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo();
    mapRasterizingInfo.setBounds(new Bbox(-80, -50, 100, 100));
    mapInfo.setCrs("EPSG:4326");
    mapRasterizingInfo.setScale(1);
    mapRasterizingInfo.setTransparent(true);
    mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo);
    ClientVectorLayerInfo clientBeansPointLayerInfo = new ClientVectorLayerInfo();
    clientBeansPointLayerInfo.setServerLayerId(layerBeansPoint.getId());
    VectorLayerRasterizingInfo layerRasterizingInfo = new VectorLayerRasterizingInfo();
    layerRasterizingInfo.setStyle(layerBeansPointStyleInfo);
View Full Code Here

  }

  @Test
  public void testTwoVectorLayers() throws Exception {
    ClientMapInfo mapInfo = new ClientMapInfo();
    MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo();
    mapRasterizingInfo.setBounds(new Bbox(-80, -50, 100, 100));
    mapInfo.setCrs("EPSG:4326");
    mapRasterizingInfo.setScale(1);
    mapRasterizingInfo.setTransparent(true);
    mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo);

    ClientVectorLayerInfo cl1 = new ClientVectorLayerInfo();
    cl1.setServerLayerId(layerBeansPoint.getId());
    VectorLayerRasterizingInfo lr1 = new VectorLayerRasterizingInfo();
View Full Code Here

  }

  @Test
  public void testGeometry() throws Exception {
    ClientMapInfo mapInfo = new ClientMapInfo();
    MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo();
    mapRasterizingInfo.setBounds(new Bbox(-80, -50, 100, 100));
    mapInfo.setCrs("EPSG:4326");
    mapRasterizingInfo.setScale(1);
    mapRasterizingInfo.setTransparent(true);
    mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo);

    ClientGeometryLayerInfo geo = new ClientGeometryLayerInfo();
    Geometry point = new Geometry(Geometry.POINT, 4326, 5);
    point.setCoordinates(new Coordinate[] { new Coordinate(20, 50) });
View Full Code Here

  }

  @Test
  public void testOneRasterLayer() 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());
    RasterLayerRasterizingInfo rr1 = new RasterLayerRasterizingInfo();
View Full Code Here

    } else if (style.getFeatureStyles().isEmpty()) {
      // only name specified, find it
      style = layer.getLayerInfo().getNamedStyleInfo(style.getName());
    }
    ClientMapInfo mapInfo = new ClientMapInfo();
    MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo();
    mapRasterizingInfo.setBounds(converterService.toDto(tileContainer.getTile().getBounds()));
    mapInfo.setCrs(tileMetadata.getCrs());
    mapRasterizingInfo.setScale(tileMetadata.getScale());
    mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo);
    ClientVectorLayerInfo clientVectorLayerInfo = new ClientVectorLayerInfo();
    clientVectorLayerInfo.setServerLayerId(tileMetadata.getLayerId());
    clientVectorLayerInfo.setNamedStyleInfo(style);
    VectorLayerRasterizingInfo vectorLayerRasterizingInfo = new VectorLayerRasterizingInfo();
View Full Code Here

  private TextService textService;

  @SuppressWarnings("unchecked")
  public RenderedImage paintLegend(MapContext mapContext) {
    LegendBuilder builder = new LegendBuilder();
    MapRasterizingInfo mapRasterizingInfo = (MapRasterizingInfo) mapContext.getUserData().get(
        LayerFactory.USERDATA_RASTERIZING_INFO);
    LegendRasterizingInfo legendRasterizingInfo = mapRasterizingInfo.getLegendRasterizingInfo();
    Font font = textService.getFont(legendRasterizingInfo.getFont());
    builder.setTitle(legendRasterizingInfo.getTitle(), font);
    if (legendRasterizingInfo.getWidth() > 0) {
      builder.setSize(legendRasterizingInfo.getWidth(), legendRasterizingInfo.getHeight());
    }
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.