org.geotools.renderer.lite
Class StreamingRenderer

java.lang.Object
  extended by org.geotools.renderer.lite.StreamingRenderer
All Implemented Interfaces:
GTRenderer

public final class StreamingRenderer
extends java.lang.Object
implements GTRenderer

A streaming implementation of the GTRenderer interface.

Use this class if you need a stateless renderer that provides low memory footprint and decent rendering performance on the first call but don't need good optimal performance on subsequent calls on the same data.

The streaming renderer is not thread safe

Version:
$Id: StreamingRenderer.java 35746 2010-06-21 17:25:23Z aaime $
Author:
James Macgill, dblasby, jessie eichar, Simone Giannecchini, Andrea Aime, Alessio Fabiani

Field Summary
static java.lang.String ADVANCED_PROJECTION_HANDLING_KEY
          Enables advanced reprojection handling.
static java.lang.String DECLARED_SCALE_DENOM_KEY
           
static java.lang.String DPI_KEY
           
static java.lang.String LABEL_CACHE_KEY
           
protected  LabelCache labelCache
           
static java.lang.String LINE_WIDTH_OPTIMIZATION_KEY
          Whether the thin line width optimization should be used, or not.
static java.lang.String OPTIMIZE_FTS_RENDERING_KEY
          Boolean flag controlling a memory/speed trade off related to how multiple feature type styles are rendered.
static java.lang.String OPTIMIZED_DATA_LOADING_KEY
           
static boolean RESCALE_SUPPORT_ENABLED
          Whether the rescale support is enabled or not.
static java.lang.String RESCALE_SUPPORT_ENABLED_KEY
          Enables the hidden DPI and UOM rescaling support
static java.lang.String SCALE_ACCURATE
          Computes the scale as the ratio between map distances and real world distances, assuming 90dpi and taking into consideration projection deformations and actual earth shape.
static java.lang.String SCALE_COMPUTATION_METHOD_KEY
           
static java.lang.String SCALE_OGC
          Very simple and lenient scale computation method that conforms to the OGC SLD specification 1.0, page 26.
static java.lang.String TEXT_RENDERING_KEY
          The text rendering method, either TEXT_RENDERING_OUTLINE or TEXT_RENDERING_STRING
static java.lang.String TEXT_RENDERING_OUTLINE
          Text will be rendered using the associated GlyphVector outline, that is, a Shape.
static java.lang.String TEXT_RENDERING_STRING
          Text will be rendered using the usual calls gc.drawString/drawGlyphVector.
static java.lang.String VECTOR_RENDERING_KEY
          Boolean flag indicating whether vector rendering should be preferred when painting graphic fills.
 
Constructor Summary
StreamingRenderer()
          Creates a new instance of LiteRenderer without a context.
 
Method Summary
 void addRenderListener(RenderListener listener)
          adds a listener that responds to error events of feature rendered events.
 boolean getConcatTransforms()
          Flag which controls behaviour for applying affine transformation to the graphics object.
 MapContext getContext()
           
 double getGeneralizationDistance()
          Returns the generalization distance in the screen space.
 java.awt.RenderingHints getJava2DHints()
           
static org.opengis.referencing.operation.MathTransform getMathTransform(org.opengis.referencing.crs.CoordinateReferenceSystem sourceCRS, org.opengis.referencing.crs.CoordinateReferenceSystem destCRS)
           
 int getMaxBackBufferMemory(int width, int height)
          When drawing in optimized mode a 32bit surface is created for each FeatureTypeStyle other than the first in order to draw features in parallel while respecting the feature draw ordering multiple FTS impose.
 java.util.Map getRendererHints()
           
 boolean isCanTransform()
           
 boolean isInteractive()
          Getter for property interactive.
 void paint(java.awt.Graphics2D graphics, java.awt.Rectangle paintArea, java.awt.geom.AffineTransform worldToScreen)
          Deprecated. Use paint(Graphics2D graphics, Rectangle paintArea, ReferencedEnvelope mapArea) or paint(Graphics2D graphics, Rectangle paintArea, ReferencedEnvelope mapArea, AffineTransform worldToScreen) instead.
 void paint(java.awt.Graphics2D graphics, java.awt.Rectangle paintArea, com.vividsolutions.jts.geom.Envelope mapArea)
          Deprecated. Use paint(Graphics2D graphics, Rectangle paintArea, ReferencedEnvelope mapArea) or paint(Graphics2D graphics, Rectangle paintArea, ReferencedEnvelope mapArea, AffineTransform worldToScreen) instead.
 void paint(java.awt.Graphics2D graphics, java.awt.Rectangle paintArea, com.vividsolutions.jts.geom.Envelope mapArea, java.awt.geom.AffineTransform worldToScreen)
          Deprecated. Use paint(Graphics2D graphics, Rectangle paintArea, ReferencedEnvelope mapArea) or paint(Graphics2D graphics, Rectangle paintArea, ReferencedEnvelope mapArea, AffineTransform worldToScreen) instead.
 void paint(java.awt.Graphics2D graphics, java.awt.Rectangle paintArea, ReferencedEnvelope mapArea)
          Renders features based on the map layers and their styles as specified in the map context using setContext.
 void paint(java.awt.Graphics2D graphics, java.awt.Rectangle paintArea, ReferencedEnvelope mapArea, java.awt.geom.AffineTransform worldToScreen)
          Renders features based on the map layers and their styles as specified in the map context using setContext.
 void removeRenderListener(RenderListener listener)
          Removes a render listener.
 void setConcatTransforms(boolean flag)
          Sets the flag which controls behaviour for applying affine transformation to the graphics object.
 void setContext(MapContext context)
           
 void setGeneralizationDistance(double d)
           Sets the generalizazion distance in the screen space.
 void setInteractive(boolean interactive)
          Sets the interactive status of the renderer.
 void setJava2DHints(java.awt.RenderingHints hints)
           
 void setRendererHints(java.util.Map hints)
           
 void stopRendering()
          If you call this method from another thread than the one that called paint or render the rendering will be forcefully stopped before termination
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESCALE_SUPPORT_ENABLED_KEY

public static final java.lang.String RESCALE_SUPPORT_ENABLED_KEY
Enables the hidden DPI and UOM rescaling support

See Also:
Constant Field Values

RESCALE_SUPPORT_ENABLED

public static final boolean RESCALE_SUPPORT_ENABLED
Whether the rescale support is enabled or not. It can be activated setting the RESCALE_SUPPORT_ENABLED_KEY system variable to "true". On GeoTools 2.7.0 this feature will become enabled by default and this variable will disappear


SCALE_ACCURATE

public static final java.lang.String SCALE_ACCURATE
Computes the scale as the ratio between map distances and real world distances, assuming 90dpi and taking into consideration projection deformations and actual earth shape.
Use this method only when in need of accurate computation. Will break if the data extent is outside of the currenct projection definition area.

See Also:
Constant Field Values

SCALE_OGC

public static final java.lang.String SCALE_OGC
Very simple and lenient scale computation method that conforms to the OGC SLD specification 1.0, page 26.
This method is quite approximative, but should never break and ensure constant scale even on lat/lon unprojected maps (because in that case scale is computed as if the area was along the equator no matter what the real position is).

See Also:
Constant Field Values

labelCache

protected LabelCache labelCache

TEXT_RENDERING_STRING

public static final java.lang.String TEXT_RENDERING_STRING
Text will be rendered using the usual calls gc.drawString/drawGlyphVector. This is a little faster, and more consistent with how the platform renders the text in other applications. The downside is that on most platform the label and its eventual halo are not properly centered.

See Also:
Constant Field Values

TEXT_RENDERING_OUTLINE

public static final java.lang.String TEXT_RENDERING_OUTLINE
Text will be rendered using the associated GlyphVector outline, that is, a Shape. This ensures perfect centering between the text and the halo, but introduces more text aliasing.

See Also:
Constant Field Values

TEXT_RENDERING_KEY

public static final java.lang.String TEXT_RENDERING_KEY
The text rendering method, either TEXT_RENDERING_OUTLINE or TEXT_RENDERING_STRING

See Also:
Constant Field Values

LINE_WIDTH_OPTIMIZATION_KEY

public static final java.lang.String LINE_WIDTH_OPTIMIZATION_KEY
Whether the thin line width optimization should be used, or not.

When rendering non antialiased lines adopting a width of 0 makes the java2d renderer get into a fast path that generates the same output as a 1 pixel wide line

Unfortunately for antialiased rendering that optimization does not help, and disallows controlling the width of thin lines. It is provided as an explicit option as the optimization has been hard coded for years, removing it when antialiasing is on by default will invalidate lots of existing styles (making lines appear thicker).

See Also:
Constant Field Values

OPTIMIZE_FTS_RENDERING_KEY

public static final java.lang.String OPTIMIZE_FTS_RENDERING_KEY
Boolean flag controlling a memory/speed trade off related to how multiple feature type styles are rendered.

When enabled (by default) multiple feature type styles against the same data source will be rendered in separate memory back buffers in a way that allows the source to be scanned only once (each back buffer is as big as the image being rendered).

When disabled no memory back buffers will be used but the feature source will be scanned once for every feature type style declared against it

See Also:
Constant Field Values

ADVANCED_PROJECTION_HANDLING_KEY

public static final java.lang.String ADVANCED_PROJECTION_HANDLING_KEY
Enables advanced reprojection handling. Geometries will be sliced to fit into the area of definition of the rendering projection, and for projections that can wrap the world in a continuous way (e.g., Mercator) a Google Maps like effect will be generated (continuous horizontal map).

See Also:
Constant Field Values

VECTOR_RENDERING_KEY

public static final java.lang.String VECTOR_RENDERING_KEY
Boolean flag indicating whether vector rendering should be preferred when painting graphic fills. See SLDStyleFactory.isVectorRenderingEnabled() for more details.

See Also:
Constant Field Values

LABEL_CACHE_KEY

public static final java.lang.String LABEL_CACHE_KEY
See Also:
Constant Field Values

DPI_KEY

public static final java.lang.String DPI_KEY
See Also:
Constant Field Values

DECLARED_SCALE_DENOM_KEY

public static final java.lang.String DECLARED_SCALE_DENOM_KEY
See Also:
Constant Field Values

OPTIMIZED_DATA_LOADING_KEY

public static final java.lang.String OPTIMIZED_DATA_LOADING_KEY
See Also:
Constant Field Values

SCALE_COMPUTATION_METHOD_KEY

public static final java.lang.String SCALE_COMPUTATION_METHOD_KEY
See Also:
Constant Field Values
Constructor Detail

StreamingRenderer

public StreamingRenderer()
Creates a new instance of LiteRenderer without a context. Use it only to gain access to utility methods of this class or if you want to render random feature collections instead of using the map context interface

Method Detail

setConcatTransforms

public void setConcatTransforms(boolean flag)
Sets the flag which controls behaviour for applying affine transformation to the graphics object.

Parameters:
flag - If true then the transform will be concatenated to the existing transform. If false it will be replaced.

getConcatTransforms

public boolean getConcatTransforms()
Flag which controls behaviour for applying affine transformation to the graphics object.

Returns:
a boolean flag. If true then the transform will be concatenated to the existing transform. If false it will be replaced.

addRenderListener

public void addRenderListener(RenderListener listener)
adds a listener that responds to error events of feature rendered events.

Specified by:
addRenderListener in interface GTRenderer
Parameters:
listener - the listener to add.
See Also:
RenderListener

removeRenderListener

public void removeRenderListener(RenderListener listener)
Removes a render listener.

Specified by:
removeRenderListener in interface GTRenderer
Parameters:
listener - the listener to remove.
See Also:
RenderListener

stopRendering

public void stopRendering()
If you call this method from another thread than the one that called paint or render the rendering will be forcefully stopped before termination

Specified by:
stopRendering in interface GTRenderer

paint

public void paint(java.awt.Graphics2D graphics,
                  java.awt.Rectangle paintArea,
                  java.awt.geom.AffineTransform worldToScreen)
Deprecated. Use paint(Graphics2D graphics, Rectangle paintArea, ReferencedEnvelope mapArea) or paint(Graphics2D graphics, Rectangle paintArea, ReferencedEnvelope mapArea, AffineTransform worldToScreen) instead.

Renders features based on the map layers and their styles as specified in the map context using setContext.

This version of the method assumes that the size of the output area and the transformation from coordinates to pixels are known. The latter determines the map scale. The viewport (the visible part of the map) will be calculated internally.

Specified by:
paint in interface GTRenderer
Parameters:
graphics - The graphics object to draw to.
paintArea - The size of the output area in output units (eg: pixels).
worldToScreen - A transform which converts World coordinates to Screen coordinates.

paint

public void paint(java.awt.Graphics2D graphics,
                  java.awt.Rectangle paintArea,
                  com.vividsolutions.jts.geom.Envelope mapArea)
Deprecated. Use paint(Graphics2D graphics, Rectangle paintArea, ReferencedEnvelope mapArea) or paint(Graphics2D graphics, Rectangle paintArea, ReferencedEnvelope mapArea, AffineTransform worldToScreen) instead.

Renders features based on the map layers and their styles as specified in the map context using setContext.

This version of the method assumes that the area of the visible part of the map and the size of the output area are known. The transform between the two is calculated internally.

Specified by:
paint in interface GTRenderer
Parameters:
graphics - The graphics object to draw to.
paintArea - The size of the output area in output units (eg: pixels).
mapArea - the map's visible area (viewport) in map coordinates.

paint

public void paint(java.awt.Graphics2D graphics,
                  java.awt.Rectangle paintArea,
                  ReferencedEnvelope mapArea)
Renders features based on the map layers and their styles as specified in the map context using setContext.

This version of the method assumes that the area of the visible part of the map and the size of the output area are known. The transform between the two is calculated internally.

Specified by:
paint in interface GTRenderer
Parameters:
graphics - The graphics object to draw to.
paintArea - The size of the output area in output units (eg: pixels).
mapArea - the map's visible area (viewport) in map coordinates.

paint

public void paint(java.awt.Graphics2D graphics,
                  java.awt.Rectangle paintArea,
                  com.vividsolutions.jts.geom.Envelope mapArea,
                  java.awt.geom.AffineTransform worldToScreen)
Deprecated. Use paint(Graphics2D graphics, Rectangle paintArea, ReferencedEnvelope mapArea) or paint(Graphics2D graphics, Rectangle paintArea, ReferencedEnvelope mapArea, AffineTransform worldToScreen) instead.

Renders features based on the map layers and their styles as specified in the map context using setContext.

This version of the method assumes that paint area, envelope and worldToScreen transform are already computed. Use this method to avoid recomputation. Note however that no check is performed that they are really in sync!

Specified by:
paint in interface GTRenderer
Parameters:
graphics - The graphics object to draw to.
paintArea - The size of the output area in output units (eg: pixels).
mapArea - the map's visible area (viewport) in map coordinates.
worldToScreen - A transform which converts World coordinates to Screen coordinates.

paint

public void paint(java.awt.Graphics2D graphics,
                  java.awt.Rectangle paintArea,
                  ReferencedEnvelope mapArea,
                  java.awt.geom.AffineTransform worldToScreen)
Renders features based on the map layers and their styles as specified in the map context using setContext.

This version of the method assumes that paint area, envelope and worldToScreen transform are already computed. Use this method to avoid recomputation. Note however that no check is performed that they are really in sync!

Specified by:
paint in interface GTRenderer
Parameters:
graphics - The graphics object to draw to.
paintArea - The size of the output area in output units (eg: pixels).
mapArea - the map's visible area (viewport) in map coordinates. Its associate CRS is ALWAYS 2D
worldToScreen - A transform which converts World coordinates to Screen coordinates.

getMaxBackBufferMemory

public int getMaxBackBufferMemory(int width,
                                  int height)
When drawing in optimized mode a 32bit surface is created for each FeatureTypeStyle other than the first in order to draw features in parallel while respecting the feature draw ordering multiple FTS impose. This method allows to estimate how many megabytes will be needed, in terms of back buffers, to draw the current MapContext, assuming the feature type style optimizations are turned on (in the case they are off, no extra memory will be used).

Parameters:
width - the image width
height - the image height

isInteractive

public boolean isInteractive()
Getter for property interactive.

Returns:
Value of property interactive.

setInteractive

public void setInteractive(boolean interactive)
Sets the interactive status of the renderer. An interactive renderer won't wait for long image loading, preferring an alternative mark instead

Parameters:
interactive - new value for the interactive property

getGeneralizationDistance

public double getGeneralizationDistance()
Returns the generalization distance in the screen space.


setGeneralizationDistance

public void setGeneralizationDistance(double d)

Sets the generalizazion distance in the screen space.

Default value is 0.8, meaning that two subsequent points are collapsed to one if their on screen distance is less than one pixel

Set the distance to 0 if you don't want any kind of generalization

Parameters:
d -

setJava2DHints

public void setJava2DHints(java.awt.RenderingHints hints)
Specified by:
setJava2DHints in interface GTRenderer

getJava2DHints

public java.awt.RenderingHints getJava2DHints()
Specified by:
getJava2DHints in interface GTRenderer

setRendererHints

public void setRendererHints(java.util.Map hints)
Specified by:
setRendererHints in interface GTRenderer

getRendererHints

public java.util.Map getRendererHints()
Specified by:
getRendererHints in interface GTRenderer

setContext

public void setContext(MapContext context)
Specified by:
setContext in interface GTRenderer

getContext

public MapContext getContext()
Specified by:
getContext in interface GTRenderer

isCanTransform

public boolean isCanTransform()

getMathTransform

public static org.opengis.referencing.operation.MathTransform getMathTransform(org.opengis.referencing.crs.CoordinateReferenceSystem sourceCRS,
                                                                               org.opengis.referencing.crs.CoordinateReferenceSystem destCRS)


Copyright © 1996-2010 Geotools. All Rights Reserved.