throws InvocationTargetException {
monitor.beginTask("Rendering map", sortedContexts.size());
RenderContext mainContext = decisive.getContext();
ILabelPainter labelPainter = mainContext.getLabelPainter();
labelPainter.clear();
labelPainter.start();
Dimension displaySize = params.destinationSize;
Iterator<RenderContext> iter = sortedContexts.iterator();
while (iter.hasNext()) {
RenderContext context = (RenderContext) iter.next();
ILayer layer = context.getLayer();
boolean isLayerFromGrid = layer.getGeoResource().canResolve(GridCoverage.class);
String layerId = getLayerId(layer);
if( !(layer instanceof SelectionLayer) ||
((layer instanceof SelectionLayer) && params.selectionStyle.getShowLabels()) ){
labelPainter.startLayer(layerId);
}
try {
if (context instanceof CompositeRenderContext) {
CompositeRenderContext compositeContext = (CompositeRenderContext) context;
List<ILayer> layers = compositeContext.getLayers();
boolean visible = false;
for (ILayer tmpLayer : layers) {
visible = visible || tmpLayer.isVisible();
}
if (!visible)
continue;
} else if (!layer.isVisible())
continue;
Renderer renderer = decisive.getRenderer(context);
ProjectUIPlugin
.trace(
ApplicationGIS.class,
"Issuing render call to " + renderer.getName(), null); //$NON-NLS-1$
try {
Graphics2D graphics = (Graphics2D) params.graphics.create();
if (params.doBufferedImageForGrids && isLayerFromGrid) {
Rectangle clipBounds = graphics.getClipBounds();
BufferedImage bi = new BufferedImage(clipBounds.width,
clipBounds.height, BufferedImage.TYPE_INT_ARGB);
Graphics2D biG2D = (Graphics2D) bi.getGraphics();
renderer.render(biG2D, monitor);
graphics.drawImage(bi, null, 0, 0);
biG2D.dispose();
}else{
renderer.render(graphics, monitor);
}
} catch (RenderException e) {
throw new InvocationTargetException(e);
}
} finally {
labelPainter.endLayer(layerId, params.graphics,
new Rectangle(displaySize));
}
}
labelPainter.end(
params.graphics,
new Rectangle(displaySize));
labelPainter.clear();
}
private String getLayerId(ILayer layer ) {
String layerId = layer.getID().toString();
if ( layer instanceof SelectionLayer )