ReferencedEnvelope bounds = (ReferencedEnvelope) params.toDraw.getViewportModel().getBounds();
ReferencedEnvelope boundsCopy = new ReferencedEnvelope(bounds);
RenderContext tools = configureMapForRendering(map, params.destinationSize, params.dpi, params.boundsStrategy, boundsCopy);
RendererCreator decisive = new RendererCreatorImpl();
decisive.setContext(tools);
decisive.getLayers().addAll(layersToRender);
SortedSet<RenderContext> sortedContexts = new TreeSet<RenderContext>(
decisive.getConfiguration());
render(params, monitor, decisive, sortedContexts);
}
private void render(final DrawMapParameter params,
IProgressMonitor monitor, RendererCreator decisive,
SortedSet<RenderContext> sortedContexts)
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 {