throw new IllegalArgumentException(pageSizeName + " is not a supported page size"); //$NON-NLS-1$
}
protected Page makePage(int width, int height) {
Template template = getTemplate();
Map mapCopy = null;
//make one copy of the map with no raster layers
mapCopy = (Map) ApplicationGIS.copyMap(map);
List<Layer> layersNoRasters = mapCopy.getLayersInternal();
if (!page1.getRasterEnabled()){
List<Layer> toRemove = new ArrayList<Layer>();
for (Layer layer : layersNoRasters ) {
for (IGeoResource resource : layer.getGeoResources()) {
if (resource.canResolve(GridCoverageReader.class)) {
toRemove.add(layer);
}
}
}
layersNoRasters.removeAll(toRemove);
}
//adjust scale
if (page1.getScaleOption() == PrintWizardPage1.CUSTOM_MAP_SCALE) {
float customScale = page1.getCustomScale();
template.setMapScaleHint(customScale);
}
else if (page1.getScaleOption() == PrintWizardPage1.CURRENT_MAP_SCALE) {
double currentViewportScaleDenom = map.getViewportModel().getScaleDenominator();
if (currentViewportScaleDenom == -1)
throw new IllegalStateException("no scale denominator is available from the viewport model"); //$NON-NLS-1$
template.setMapScaleHint(currentViewportScaleDenom);
}
else if (page1.getScaleOption() == PrintWizardPage1.ZOOM_TO_SELECTION) {
template.setZoomToSelectionHint(true);
}
//3. make the page itself
Page page = ModelFactory.eINSTANCE.createPage();
page.setSize(new Dimension(width, height));
//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[] { mapCopy.getName() }));
}
template.init(page, mapCopy);
//copy the boxes from the template into the page
Iterator<Box> iter = template.iterator();
while (iter.hasNext()) {
page.getBoxes().add(iter.next());
}
return page;
}