BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
Graphics2D g = image.createGraphics();
IMap renderedMap;
try {
monitor.worked(1);
pattern = Messages.ExportMapToImageWizard_renderingTaskname;
args = new Object[]{map.getName()};
monitor.setTaskName(MessageFormat.format(pattern, args));
int scaleDenom = MapSelectorPageWithScaleColumn.getScaleDenom(map);
BoundsStrategy boundsStrategy = new BoundsStrategy(scaleDenom);
//final Map mapCopy = (Map) EcoreUtil.copy((EObject) map);
final Map mapCopy = (Map) ApplicationGIS.copyMap(map);
DrawMapParameter drawMapParameter =
new DrawMapParameter(g,
new java.awt.Dimension(width, height),
mapCopy,
boundsStrategy,
imageSettingsPage.getFormat().getDPI(),
imageSettingsPage.getSelectionHandling(),
monitor);
renderedMap = ApplicationGIS.drawMap(drawMapParameter);
}
finally {
g.dispose();
}
monitor.worked(1);
pattern = Messages.ExportMapToImageWizard_writingTaskname;
args = new Object[]{map.getName()};
monitor.setTaskName(MessageFormat.format(pattern, args));
imageSettingsPage.getFormat().write(renderedMap, image, destination);
String baseFile = destination.getPath().substring(0, destination.getPath().lastIndexOf("."));
createWorldFile(renderedMap.getViewportModel().worldToScreenTransform().createInverse(), baseFile);
createProjectionFile(baseFile, renderedMap.getViewportModel().getCRS());
addToCatalog(destination);
monitor.done();
}