map.setApplicationId(applicationId);
map.setRasterResolution(rasterDpi);
List<PrintComponentInfo> layerChildren = new ArrayList<PrintComponentInfo>();
for (Layer layer : mapModel.getLayers()) {
if (layer instanceof VectorLayer && layer.isShowing()) {
VectorLayerComponentInfo info = new VectorLayerComponentInfo();
VectorLayer vectorLayer = (VectorLayer) layer;
info.setLayerId(vectorLayer.getServerLayerId());
ClientVectorLayerInfo layerInfo = vectorLayer.getLayerInfo();
info.setStyleInfo(layerInfo.getNamedStyleInfo());
info.setFilter(vectorLayer.getFilter());
info.setLabelsVisible(vectorLayer.isLabeled());
info.setSelected(vectorLayer.isSelected());
Set<String> features = vectorLayer.getSelectedFeatures();
info.setSelectedFeatureIds(features.toArray(new String[features.size()]));
layerChildren.add(info);
} else if (layer instanceof RasterLayer && layer.isShowing()) {
RasterLayerComponentInfo info = new RasterLayerComponentInfo();
RasterLayer rasterLayer = (RasterLayer) layer;
info.setLayerId(rasterLayer.getServerLayerId());
info.setStyle(rasterLayer.getLayerInfo().getStyle());
layerChildren.add(info);
}
}
map.getChildren().addAll(0, layerChildren);
return map;