RendererPlugin.log("Viewable area available in the layer CRS", te); //$NON-NLS-1$
endMessage = Messages.BasicFeatureRenderer_warning1;
endStatus = ILayer.WARNING;
return;
} catch (FactoryException e) {
throw (RenderException) new RenderException().initCause(e);
}
listener.init( new SubProgressMonitor( monitor,90) );
setQueries();
monitor.worked(5);
Point min = getContext().worldToPixel(
new Coordinate(validBounds.getMinX(), validBounds
.getMinY()));
Point max = getContext().worldToPixel(
new Coordinate(validBounds.getMaxX(), validBounds
.getMaxY()));
int width = Math.abs(max.x - min.x);
int height = Math.abs(max.y - min.y);
Rectangle paintArea = new Rectangle(Math.min(min.x, max.x), Math.min(min.y, max.y), width, height);
int expandPaintAreaBy = 0;
if (expandSizePaintArea > 0) {
expandPaintAreaBy = expandSizePaintArea;
}
// expand the painArea by 30 pixels each direction to get symbols
// rendered right (up to a size of 60 pix)
// upper left
paintArea.add( Math.min(min.x, max.x) - expandPaintAreaBy,
Math.min(min.y, max.y) - expandPaintAreaBy);
// lower right
paintArea.add( Math.max(min.x, max.x) + expandPaintAreaBy,
Math.max(min.y, max.y) + expandPaintAreaBy);
if( clear ){ // if partial update on live screen
graphics.setBackground(new Color(0,0,0,0));
graphics.clearRect(paintArea.x, paintArea.y, paintArea.width, paintArea.height);
}
validBounds=getContext().worldBounds(paintArea);
MapViewport mapViewport = new MapViewport( validBounds );
map.setViewport( mapViewport);
GTRenderer geotToolsRenderer = getRenderer();
if (bounds != null && !bounds.isNull()) {
graphics.setClip(paintArea);
}
java.util.Map<Object, Object> rendererHints = geotToolsRenderer.getRendererHints();
rendererHints.put(StreamingRenderer.DECLARED_SCALE_DENOM_KEY, getContext()
.getViewportModel().getScaleDenominator());
rendererHints.put(StreamingRenderer.SCALE_COMPUTATION_METHOD_KEY,
StreamingRenderer.SCALE_ACCURATE);
ILabelPainter labelPainter = getContext().getLabelPainter();
Point origin = new Point(paintArea.x, paintArea.y);
String layerId = getContext().getLayer().getID().toString();
if (getContext().getLayer() instanceof SelectionLayer)
layerId = layerId + "-Selection"; //$NON-NLS-1$
rendererHints.put(StreamingRenderer.LABEL_CACHE_KEY, new LabelCacheDecorator(
labelPainter, origin, layerId));
geotToolsRenderer.setRendererHints(rendererHints);
RenderingHints hints = new RenderingHints(Collections.EMPTY_MAP);
hints.add(new RenderingHints(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_SPEED));
hints.add(new RenderingHints(RenderingHints.KEY_DITHERING,
RenderingHints.VALUE_DITHER_DISABLE));
hints.add(new RenderingHints(RenderingHints.KEY_ALPHA_INTERPOLATION,
RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED));
hints.add(new RenderingHints(RenderingHints.KEY_COLOR_RENDERING,
RenderingHints.VALUE_COLOR_RENDER_SPEED));
hints.add(new RenderingHints(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR));
hints.add(new RenderingHints(RenderingHints.KEY_STROKE_CONTROL,
RenderingHints.VALUE_STROKE_PURE));
hints.add(new RenderingHints(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_OFF));
IPreferenceStore store = ProjectPlugin.getPlugin().getPreferenceStore();
boolean antiAliasing = store.getBoolean(PreferenceConstants.P_ANTI_ALIASING);
hints.add(new RenderingHints(RenderingHints.KEY_ANTIALIASING, antiAliasing
? RenderingHints.VALUE_ANTIALIAS_ON
: RenderingHints.VALUE_ANTIALIAS_OFF));
graphics.addRenderingHints(hints);
geotToolsRenderer.setJava2DHints(hints);
if (monitor.isCanceled()){
return;
}
if( paintArea == null || paintArea.isEmpty() || validBounds == null || validBounds.isEmpty() || validBounds.isNull() || validBounds.getWidth() <=0 || validBounds.getHeight()<=0 ){
System.out.println("nothing to draw");
// nothing to draw yet
}
else {
geotToolsRenderer.paint(graphics, paintArea, validBounds);
}
} catch (Throwable renderingProblem) {
if (renderingProblem instanceof InterruptedException){
// ignore the rendering process being interrupted this is expected
// if the user pans while we are drawing
return;
}
RenderException e2 = new RenderException( renderingProblem.getClass()+" occured during rendering: " //$NON-NLS-1$
+ renderingProblem.getLocalizedMessage(), renderingProblem );
throw e2;
} finally {
/*
* vitalus: Clear MapContext to remove <code>FeatureListener</code>s from FeatureStore
* implementation, otherwises listeners hell takes place (example is a
* ShapefileDataStore and its FeatureListenerManager).
*/
if (map != null) {
map.layers().clear();
}
getContext().setStatus(endStatus);
getContext().setStatusMessage(endMessage);
Exception renderingProblem = listener.exception;
if (renderingProblem != null) {
if (renderingProblem instanceof InterruptedException)
return;
if (!(renderingProblem instanceof TopologyException)) {
RenderException e2 = new RenderException(
Messages.BasicFeatureRenderer_renderingProblem
+ renderingProblem.getLocalizedMessage(), renderingProblem);
throw e2;
}
}