DefaultTemplateBuilder builder = new DefaultTemplateBuilder(mapBuilder); builder.setApplicationId(this.applicationId); builder.setMapPresenter(mapPresenter); builder.setMarginX((int) PrintingLayout.templateMarginX); builder.setMarginY((int) PrintingLayout.templateMarginY); PageSize size = PageSize.A4; builder.setPageHeight(size.getWidth()); builder.setPageWidth(size.getHeight()); } else { builder.setPageHeight(size.getHeight()); builder.setPageWidth(size.getWidth()); title = MESSAGES.defaultPrintTitle(); builder.setTitleText(title); builder.setWithArrow(true); builder.setWithScaleBar(true); builder.setRasterDpi(200); PrintTemplateInfo template = builder.buildTemplate(); request.setTemplate(template); final GwtCommand command = new GwtCommand(PrintGetTemplateRequest.COMMAND);
@Override protected ScaleBarComponentInfo buildScaleBar() { if (isWithScaleBar()) { ScaleBarComponentInfo bar = super.buildScaleBar(); bar.setTicNumber(3); bar.setTag("scalebar"); return bar; } else { return null; } }
@Override protected MapComponentInfo buildMap() { ViewPort viewPort = mapPresenter.getViewPort(); double printWidth = getPageWidth() - 2 * marginX; double printHeight = getPageHeight() - 2 * marginY; Bbox fittingBox = createFittingBox(viewPort.getBounds(), printWidth / printHeight); MapComponentInfo map = super.buildMap(fittingBox); map.getLayoutConstraint().setMarginX(marginX); map.getLayoutConstraint().setMarginY(marginY); map.setLocation(new org.geomajas.geometry.Coordinate(fittingBox.getX(), fittingBox.getY())); map.setPpUnit((float) (printWidth / fittingBox.getWidth())); map.setTag("map"); // GWT:map.setMapId(mapModel.getMapInfo().getId()); // Old puregwt: map.setMapId(mapPresenter.getConfiguration().getId()); map.setMapId(mapPresenter.getConfiguration().getServerConfiguration().getId()); map.setApplicationId(applicationId); map.setRasterResolution(rasterDpi); // use rasterized layers for pure GWT double rasterScale = map.getPpUnit() * map.getRasterResolution() / 72.0; // map.getPpUnit() = aantal pixels per map unit bij 72 dpi mapBuilder.build(mapPresenter, fittingBox, rasterScale); List<PrintComponentInfo> layers = new ArrayList<PrintComponentInfo>(); RasterizedLayersComponentInfo rasterizedLayersComponentInfo = new RasterizedLayersComponentInfo(); rasterizedLayersComponentInfo.setMapInfo(mapPresenter.getConfiguration().getServerConfiguration()); layers.add(rasterizedLayersComponentInfo); map.getChildren().addAll(0, layers); return map; }
map.getLayoutConstraint().setMarginY(marginY); MapView view = mapModel.getMapView(); double mapWidth = getPageWidth() - 2 * marginX; double mapHeight = getPageHeight() - 2 * marginY; Coordinate origin = view.getBounds().createFittingBox(mapWidth, mapHeight).getOrigin(); map.setLocation(new org.geomajas.geometry.Coordinate(origin.getX(), origin.getY()));
@Override protected ImageComponentInfo buildArrow() { if (isWithArrow()) { ImageComponentInfo northarrow = super.buildArrow(); northarrow.setImagePath("/images/northarrow.gif"); northarrow.getLayoutConstraint().setAlignmentX(LayoutConstraintInfo.RIGHT); northarrow.getLayoutConstraint().setAlignmentY(LayoutConstraintInfo.TOP); northarrow.getLayoutConstraint().setMarginX((float) PrintingLayout.templateMarginX); northarrow.getLayoutConstraint().setMarginY((float) PrintingLayout.templateMarginY); northarrow.getLayoutConstraint().setWidth((float) PrintingLayout.templateNorthArrowWidth); northarrow.setTag("arrow"); return northarrow; } else { return null; } }
graphic.setLayerId(layerInfo.getServerLayerId()); item.addChild(graphic); item.addChild(getLegendLabel(legend, title)); legend.addChild(item); icon.setLayerType(layerInfo.getLayerType()); item.addChild(icon); item.addChild(getLegendLabel(legend, layerInfo.getLabel())); legend.addChild(item);
map.getLayoutConstraint().setMarginY(marginY); MapView view = mapModel.getMapView(); double mapWidth = getPageWidth() - 2 * marginX; double mapHeight = getPageHeight() - 2 * marginY; Coordinate origin = view.getBounds().createFittingBox(mapWidth, mapHeight).getOrigin(); map.setLocation(new org.geomajas.geometry.Coordinate(origin.getX(), origin.getY()));
@Override protected ImageComponentInfo buildArrow() { if (isWithArrow()) { ImageComponentInfo northarrow = super.buildArrow(); northarrow.setImagePath("/images/northarrow.gif"); northarrow.getLayoutConstraint().setAlignmentX(LayoutConstraintInfo.RIGHT); northarrow.getLayoutConstraint().setAlignmentY(LayoutConstraintInfo.TOP); northarrow.getLayoutConstraint().setMarginX((float) PrintingLayout.templateMarginX); northarrow.getLayoutConstraint().setMarginY((float) PrintingLayout.templateMarginY); northarrow.getLayoutConstraint().setWidth((float) PrintingLayout.templateNorthArrowWidth); northarrow.setTag("arrow"); return northarrow; } else { return null; } }
graphic.setLayerId(layerInfo.getServerLayerId()); item.addChild(graphic); item.addChild(getLegendLabel(legend, title)); legend.addChild(item); icon.setLayerType(layerInfo.getLayerType()); item.addChild(icon); item.addChild(getLegendLabel(legend, layerInfo.getLabel())); legend.addChild(item);
PrintGetTemplateRequest request = new PrintGetTemplateRequest(); imageUrlService.makeRasterizable(mapWidget); DefaultTemplateBuilder builder = new DefaultTemplateBuilder(); builder.setApplicationId(mapWidget.getApplicationId()); builder.setMapModel(mapWidget.getMapModel()); builder.setMarginX((int) PrintingLayout.templateMarginX); builder.setMarginY((int) PrintingLayout.templateMarginY); PageSize size = PageSize.getByName((String) sizeItem.getValue()); if (LANDSCAPE.equals(orientationGroup.getValue())) { builder.setPageHeight(size.getWidth()); builder.setPageWidth(size.getHeight()); } else { builder.setPageHeight(size.getHeight()); builder.setPageWidth(size.getWidth()); builder.setTitleText((String) titleItem.getValue()); builder.setWithArrow((Boolean) arrowCheckbox.getValue()); builder.setWithScaleBar((Boolean) scaleBarCheckbox.getValue()); builder.setRasterDpi((Integer) rasterDpiSlider.getValue()); PrintTemplateInfo template = builder.buildTemplate(); request.setTemplate(template); final GwtCommand command = new GwtCommand(PrintGetTemplateRequest.COMMAND);
@Override protected ScaleBarComponentInfo buildScaleBar() { if (isWithScaleBar()) { ScaleBarComponentInfo bar = super.buildScaleBar(); bar.setTicNumber(3); bar.setTag("scalebar"); return bar; } else { return null; } }
@Override protected ImageComponentInfo buildArrow() { if (isWithArrow()) { ImageComponentInfo northarrow = super.buildArrow(); northarrow.setImagePath("/images/northarrow.gif"); northarrow.getLayoutConstraint().setAlignmentX(LayoutConstraintInfo.RIGHT); northarrow.getLayoutConstraint().setAlignmentY(LayoutConstraintInfo.TOP); northarrow.getLayoutConstraint().setMarginX((float) PrintingLayout.templateMarginX); northarrow.getLayoutConstraint().setMarginY((float) PrintingLayout.templateMarginY); northarrow.getLayoutConstraint().setWidth((float) PrintingLayout.templateNorthArrowWidth); northarrow.setTag("arrow"); return northarrow; } else { return null; } }
graphic.setLayerId(layerInfo.getServerLayerId()); item.addChild(graphic); item.addChild(getLegendLabel(legend, title)); legend.addChild(item); icon.setLayerType(layerInfo.getLayerType()); item.addChild(icon); item.addChild(getLegendLabel(legend, layerInfo.getLabel())); legend.addChild(item);
PrintGetTemplateRequest request = new PrintGetTemplateRequest(); imageUrlService.makeRasterizable(mapWidget); DefaultTemplateBuilder builder = new DefaultTemplateBuilder(); builder.setApplicationId(mapWidget.getApplicationId()); builder.setMapModel(mapWidget.getMapModel()); builder.setMarginX((int) PrintingLayout.templateMarginX); builder.setMarginY((int) PrintingLayout.templateMarginY); PageSize size = PageSize.getByName((String) sizeItem.getValue()); if (LANDSCAPE.equals(orientationGroup.getValue())) { builder.setPageHeight(size.getWidth()); builder.setPageWidth(size.getHeight()); } else { builder.setPageHeight(size.getHeight()); builder.setPageWidth(size.getWidth()); builder.setTitleText((String) titleItem.getValue()); builder.setWithArrow((Boolean) arrowCheckbox.getValue()); builder.setWithScaleBar((Boolean) scaleBarCheckbox.getValue()); builder.setRasterDpi((Integer) rasterDpiSlider.getValue()); PrintTemplateInfo template = builder.buildTemplate(); template.getPage().setLocale(LocaleInfo.getCurrentLocale().getLocaleName()); request.setTemplate(template);
@Override protected ScaleBarComponentInfo buildScaleBar() { if (isWithScaleBar()) { ScaleBarComponentInfo bar = super.buildScaleBar(); bar.setTicNumber(3); bar.setTag("scalebar"); return bar; } else { return null; } }