template.setZoomToSelectionHint(true);
template.setMapScaleHint(currentViewportScaleDenom);
}
//3. make the page itself
Page page = ModelFactory.eINSTANCE.createPage();
page.setSize(new Dimension((int)pageSize.getWidth(), (int)pageSize.getHeight()));
//page name stuff not required, because this page will just get discarded
MessageFormat formatter = new MessageFormat(Messages.CreatePageAction_newPageName, Locale.getDefault());
if (page.getName() == null || page.getName().length() == 0) {
page.setName(formatter.format(new Object[] { mapNoRasterLayers.getName() }));
}
template.init(page, mapNoRasterLayers);
if (page1.getRasterEnabled()) {
//make another copy with only raster layers
mapOnlyRasterLayers = (Map) ApplicationGIS.copyMap(map);
List<Layer> layersOnlyRasters = mapOnlyRasterLayers.getLayersInternal();
List<Layer> toRemove2 = new ArrayList<Layer>();
for (Layer layer : layersOnlyRasters ) {
for (IGeoResource resource : layer.getGeoResources()) {
if (!resource.canResolve(GridCoverageReader.class)) {
toRemove2.add(layer);
}
}
}
layersOnlyRasters.removeAll(toRemove2);
//set bounds to match the other map
SetViewportBBoxCommand cmdBbox = new SetViewportBBoxCommand(mapNoRasterLayers.getViewportModel().getBounds());
mapOnlyRasterLayers.sendCommandSync(cmdBbox);
if (layersNoRasters.size() > 0) {
writeRasterLayersOnlyToDocument(mapOnlyRasterLayers, template.getMapBounds(), doc, page.getSize(), /*currentViewportScaleDenom*/mapNoRasterLayers.getViewportModel().getScaleDenominator());
}
}
//copy the boxes from the template into the page
Iterator<Box> iter = template.iterator();
while (iter.hasNext()) {
page.getBoxes().add(iter.next());
}
return page;
//TODO Throw some sort of exception if the page can't be created