// make sure the hints are set before we start rendering the map
graphic.setRenderingHints(hintsMap);
RenderingHints hints = new RenderingHints(hintsMap);
GTRenderer renderer;
if (DefaultWebMapService.useShapefileRenderer()) {
renderer = new ShapefileRenderer();
} else {
StreamingRenderer sr = new StreamingRenderer();
sr.setThreadPool(DefaultWebMapService.getRenderingPool());
renderer = sr;
}
renderer.setContext(mapContext);
renderer.setJava2DHints(hints);
// setup the renderer hints
Map<Object, Object> rendererParams = new HashMap<Object, Object>();
rendererParams.put("optimizedDataLoadingEnabled", new Boolean(true));
rendererParams.put("renderingBuffer", new Integer(mapContext.getBuffer()));
rendererParams.put("maxFiltersToSendToDatastore", DefaultWebMapService.getMaxFilterRules());
rendererParams.put(ShapefileRenderer.SCALE_COMPUTATION_METHOD_KEY,
ShapefileRenderer.SCALE_OGC);
if (AA_NONE.equals(antialias)) {
rendererParams.put(ShapefileRenderer.TEXT_RENDERING_KEY,
StreamingRenderer.TEXT_RENDERING_STRING);
} else {
rendererParams.put(ShapefileRenderer.TEXT_RENDERING_KEY,
StreamingRenderer.TEXT_RENDERING_ADAPTIVE);
}
if (DefaultWebMapService.isLineWidthOptimizationEnabled()) {
rendererParams.put(StreamingRenderer.LINE_WIDTH_OPTIMIZATION_KEY, true);
}
// turn on advanced projection handling
rendererParams.put(StreamingRenderer.ADVANCED_PROJECTION_HANDLING_KEY, true);
if(DefaultWebMapService.isContinuousMapWrappingEnabled()) {
rendererParams.put(StreamingRenderer.CONTINUOUS_MAP_WRAPPING, true);
}
// see if the user specified a dpi
if (mapContext.getRequest().getFormatOptions().get("dpi") != null) {
rendererParams.put(StreamingRenderer.DPI_KEY, ((Integer) mapContext.getRequest()
.getFormatOptions().get("dpi")));
}
boolean kmplacemark = false;
if (mapContext.getRequest().getFormatOptions().get("kmplacemark") != null)
kmplacemark = ((Boolean) mapContext.getRequest().getFormatOptions().get("kmplacemark"))
.booleanValue();
if (kmplacemark) {
// create a StyleVisitor that copies a style, but removes the
// PointSymbolizers and TextSymbolizers
KMLStyleFilteringVisitor dupVisitor = new KMLStyleFilteringVisitor();
// Remove PointSymbolizers and TextSymbolizers from the
// layers' Styles to prevent their rendering on the
// raster image. Both are better served with the
// placemarks.
MapLayer[] layers = mapContext.getLayers();
for (int i = 0; i < layers.length; i++) {
Style style = layers[i].getStyle();
style.accept(dupVisitor);
Style copy = (Style) dupVisitor.getCopy();
layers[i].setStyle(copy);
}
}
renderer.setRendererHints(rendererParams);
// if abort already requested bail out
// if (this.abortRequested) {
// graphic.dispose();
// return null;
// }
// enforce no more than x rendering errors
int maxErrors = wms.getMaxRenderingErrors();
MaxErrorEnforcer errorChecker = new MaxErrorEnforcer(renderer, maxErrors);
// Add a render listener that ignores well known rendering exceptions and reports back non
// ignorable ones
final RenderExceptionStrategy nonIgnorableExceptionListener;
nonIgnorableExceptionListener = new RenderExceptionStrategy(renderer);
renderer.addRenderListener(nonIgnorableExceptionListener);
// setup the timeout enforcer (the enforcer is neutral when the timeout is 0)
int maxRenderingTime = wms.getMaxRenderingTime() * 1000;
RenderingTimeoutEnforcer timeout = new RenderingTimeoutEnforcer(maxRenderingTime, renderer,
graphic);
timeout.start();
try {
// finally render the image;
renderer.paint(graphic, paintArea, mapContext.getRenderingArea(),
mapContext.getRenderingTransform());
// apply watermarking
if (layout != null) {
try {