protected MapRasterizingInfo buildMap(MapPresenter mapPresenter) { MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo(); ViewPort viewPort = mapPresenter.getViewPort(); mapRasterizingInfo.setBounds(viewPort.getBounds()); mapRasterizingInfo.setScale(viewPort.getScale()); mapRasterizingInfo.setTransparent(true); LegendRasterizingInfo legendRasterizingInfo = new LegendRasterizingInfo(); legendRasterizingInfo.setTitle("Legend"); FontStyleInfo font = new FontStyleInfo(); font.applyDefaults(); legendRasterizingInfo.setFont(font); mapRasterizingInfo.setLegendRasterizingInfo(legendRasterizingInfo); // Support for selection of layer object : create container for info on selected features; // store the selections layer per layer List<ClientLayerInfo> selectedLayers = new ArrayList<ClientLayerInfo>(); mapRasterizingInfo.setExtraLayers(selectedLayers); ClientMapInfo mapInfo = mapPresenter.getConfiguration().getServerConfiguration(); mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo); // Note: mapRasterizingInfo at this time is pretty empty (rastering info for // layers not yet filled in) return mapRasterizingInfo; }
for (ClientLayerInfo clientLayerInfo : mapRasterizingInfo.getExtraLayers()) { if (clientLayerInfo instanceof ClientGeometryLayerInfo) { for (Geometry geometry : ((ClientGeometryLayerInfo) clientLayerInfo).getGeometries()) { mapRasterizingInfo.setBounds(dtoConverterService.toDto(bounds)); mapRasterizingInfo.setScale(scale); imageService.writeMap(stream, request.getClientMapInfo()); container.setMapImageData(stream.toByteArray()); stream.reset(); mapRasterizingInfo.getLegendRasterizingInfo().setWidth(request.getLegendWidth()); mapRasterizingInfo.getLegendRasterizingInfo().setHeight(request.getLegendHeight()); imageService.writeLegend(stream, clientMapInfo); container.setLegendImageData(stream.toByteArray()); String key = UUID.randomUUID().toString(); cacheManagerService.put(null, CacheCategory.RASTER, key, container, dtoConverterService.toInternal(mapRasterizingInfo.getBounds())); response.setKey(key); response.setCacheCategory(CacheCategory.RASTER.toString());
@Override public void render(PdfContext context) { try { bbox = createBbox(); MapRasterizingInfo mapRasterizingInfo = (MapRasterizingInfo) clientMapInfo .getWidgetInfo(MapRasterizingInfo.WIDGET_KEY); mapRasterizingInfo.setBounds(new Bbox(bbox.getMinX(), bbox.getMinY(), bbox.getWidth(), bbox.getHeight())); mapRasterizingInfo.setScale(getMap().getPpUnit()); Graphics2D graphics = context.getGraphics2D(getBounds()); imageService.writeMap(graphics, clientMapInfo); graphics.dispose(); } catch (Exception e) { log.warn("Failed to render rasterized layers", e); } super.render(context); }
private void createWidgetPrintLayers(MapPresenter mapPresenter, MapRasterizingInfo mapRasterizingInfo, Bbox worldBounds, double rasterResolution) { AbsolutePanel mapPresenterAsAbsolutePanel = ((AbsolutePanel) mapPresenter.asWidget()); for (int i = 0 ; i < mapPresenterAsAbsolutePanel.getWidgetCount(); i++) { Widget widget = mapPresenterAsAbsolutePanel.getWidget(i); for (PrintableWidgetLayerBuilder widgetLayerPrintBuilder : getWidgetLayerBuilders()) { if (widgetLayerPrintBuilder.supports(widget)) { mapRasterizingInfo.getExtraLayers().add( widgetLayerPrintBuilder.build(mapPresenter, widget, worldBounds, rasterResolution)); break; } } } }
private MapRasterizingInfo buildMap(MapPresenter mapPresenter) { MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo(); ViewPort viewPort = mapPresenter.getViewPort(); mapRasterizingInfo.setBounds(viewPort.getBounds()); mapRasterizingInfo.setScale(1 / viewPort.getResolution()); mapRasterizingInfo.setTransparent(true); LegendRasterizingInfo legendRasterizingInfo = new LegendRasterizingInfo(); legendRasterizingInfo.setTitle("Legend"); FontStyleInfo font = new FontStyleInfo(); font.applyDefaults(); legendRasterizingInfo.setFont(font); mapRasterizingInfo.setLegendRasterizingInfo(legendRasterizingInfo); // Support for selection of layer object : create container for info on selected features; // store the selections layer per layer List<ClientLayerInfo> selectedLayers = new ArrayList<ClientLayerInfo>(); mapRasterizingInfo.setExtraLayers(selectedLayers); ClientMapInfo mapInfo = mapPresenter.getConfiguration().getHintValue(GeomajasServerExtension.MAPINFO); mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo); // Note: mapRasterizingInfo at this time is pretty empty (rastering info for // layers not yet filled in) return mapRasterizingInfo; }