org.geotools.renderer.j2d
Class Renderer

java.lang.Object
  extended byorg.geotools.renderer.j2d.Renderer
All Implemented Interfaces:
Renderer2D
Direct Known Subclasses:
StyledMapRenderer

Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D as part of the port of J2D-renderer to the new GO-1 based API. Note that it is not possible to mix J2D-renderer classes with GO-1 rendering engine. Migration from J2D-renderer to the GO-1 API will requires the replacement of all deprecated classes together. Because the new GO-1 rendering engine is a work in progress, see GEOT-776 in order to determine if enough functionalites have been ported for yours need.

public class Renderer
extends java.lang.Object
implements Renderer2D

A renderer for drawing map objects into a Graphics2D. A newly constructed Renderer is initially empty. To make something appears, RenderedLayers must be added using one of addLayer(...) methods. The visual content depends of the RenderedLayer subclass. It may be an isoline (RenderedGeometries), a remote sensing image (RenderedGridCoverage), a set of arbitrary marks (RenderedMarks), a map scale (RenderedMapScale), etc.

Version:
$Id: Renderer.java 17890 2006-02-06 08:46:14Z desruisseaux $
Author:
Martin Desruisseaux

Field Summary
protected  java.awt.RenderingHints hints
          Deprecated. A set of rendering hints.
protected  java.beans.PropertyChangeSupport listeners
          Deprecated. Listeners to be notified about any changes in this layer's properties.
 
Constructor Summary
Renderer(java.awt.Component owner)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D.
 
Method Summary
 void addLayer(RenderedLayer layer)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#add.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#addPropertyChangeListener.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#addPropertyChangeListener.
 void dispose()
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#dispose.
 javax.swing.Action getAction(GeoMouseEvent event)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getAction.
 CoordinateSystem getCoordinateSystem()
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getObjectiveCRS.
 int getLayerCount()
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getGraphics.
 RenderedLayer[] getLayers()
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getGraphics.
 java.util.Locale getLocale()
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getLocale.
 java.lang.String getName(java.util.Locale locale)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getTitle.
 ImageType getOffscreenBuffered(float zOrder)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getOffscreenBuffered.
 java.awt.geom.Rectangle2D getPreferredArea()
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getEnvelope2D.
 java.awt.geom.Dimension2D getPreferredPixelSize()
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getTypicalCellDimension.
 java.lang.Object getRenderingHint(java.awt.RenderingHints.Key key)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getRenderingHint.
 float getScale()
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getScale.
 java.lang.String getToolTipText(GeoMouseEvent event)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getToolTipText.
 void paint(java.awt.Graphics2D graph, java.awt.geom.AffineTransform zoom, java.awt.Rectangle zoomableBounds)
          Deprecated. Use paint(Graphics2D, Rectangle, AffineTransform) instead.
 void paint(java.awt.Graphics2D graph, java.awt.Rectangle zoomableBounds, java.awt.geom.AffineTransform zoom)
          Deprecated. Use paint(Graphics2D,Rectangle,AffineTransform,boolean) instead.
 void paint(java.awt.Graphics2D graph, java.awt.Rectangle zoomableBounds, java.awt.geom.AffineTransform zoom, boolean isPrinting)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#paint.
 void removeAllLayers()
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#removeAll.
 void removeLayer(RenderedLayer layer)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#remove.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#removePropertyChangeListener.
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#removePropertyChangeListener.
 void setCoordinateSystem(CoordinateSystem cs)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#setObjectiveCRS.
 void setOffscreenBuffered(float lower, float upper, ImageType type)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#setOffscreenBuffered.
 void setRenderingHint(java.awt.RenderingHints.Key key, java.lang.Object value)
          Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#setRenderingHint.
 java.lang.String toString()
          Deprecated. Returns a string representation of this renderer and all its RenderedLayers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hints

protected final java.awt.RenderingHints hints
Deprecated. 
A set of rendering hints. Recognized hints include Hints.COORDINATE_TRANSFORMATION_FACTORY and any of Hints.FINEST_RESOLUTION.

See Also:
Hints.FINEST_RESOLUTION, Hints.REQUIRED_RESOLUTION, Hints.COORDINATE_TRANSFORMATION_FACTORY, Hints.PREFETCH, RenderingHints.KEY_RENDERING, RenderingHints.KEY_COLOR_RENDERING, RenderingHints.KEY_INTERPOLATION

listeners

protected final java.beans.PropertyChangeSupport listeners
Deprecated. 
Listeners to be notified about any changes in this layer's properties. Examples of properties that may change: "preferredArea".

Constructor Detail

Renderer

public Renderer(java.awt.Component owner)
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D.

Construct a new renderer for the specified component.

Parameters:
owner - The widget that own this renderer, or null if none.
Method Detail

getName

public java.lang.String getName(java.util.Locale locale)
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getTitle.

Returns this renderer's name. The default implementation returns the title of the window which contains the map pane.

Parameters:
locale - The desired locale, or null for a default locale.
Returns:
This renderer's name, or null if none.
See Also:
getLocale(), Component.getName(), RenderedLayer.getName(java.util.Locale)

getLocale

public java.util.Locale getLocale()
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getLocale.

Returns to locale for this renderer. The renderer will inherit the locale of its Component, if it have one. Otherwise, a default locale will be returned.

See Also:
Component.getLocale(), JComponent.getDefaultLocale(), Locale.getDefault()

getCoordinateSystem

public CoordinateSystem getCoordinateSystem()
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getObjectiveCRS.

Returns the view coordinate system. This is the "real world" coordinate system used for displaying all RenderedLayers. Note that underlying data in RenderedLayers doesn't need to be in this coordinate system: transformations will performed on the fly as needed at rendering time.

Returns:
The two dimensional coordinate system used for display.

setCoordinateSystem

public void setCoordinateSystem(CoordinateSystem cs)
                         throws org.opengis.referencing.operation.TransformException
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#setObjectiveCRS.

Set the view coordinate system. This is the "real world" coordinate system to use for displaying all RenderedLayers. Layers are notified of the coordinate system change with RenderedLayer.setCoordinateSystem(org.geotools.cs.CoordinateSystem).

Parameters:
cs - The view coordinate system. If the specified coordinate system has more than two dimensions, then it must be a CompoundCoordinateSystem with a two dimensional headCS.
Throws:
org.opengis.referencing.operation.TransformException - If cs can't be reduced to a two-dimensional coordinate system, or if data can't be transformed for some other reason.

getPreferredArea

public java.awt.geom.Rectangle2D getPreferredArea()
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getEnvelope2D.

Returns a bounding box that completely encloses all layer's preferred area, visible or not. This bounding box should be representative of the geographic area to drawn. Coordinates are expressed in this renderer's coordinate system.

Returns:
The enclosing area computed from available data, or null if this area can't be computed.

getPreferredPixelSize

public java.awt.geom.Dimension2D getPreferredPixelSize()
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getTypicalCellDimension.

Returns the preferred pixel size in "real world" coordinates. For image layers, this is the size of image's pixels. For other kind of layers, "pixel size" are to be understood as some dimension representative of the layer's resolution. This method invokes RenderedLayer.getPreferredPixelSize() for each layers and returns the finest resolution.

Returns:
The preferred pixel size in "real world" coordinates (in this renderer's coordinate system) or null if no layer provided a preferred pixel size.
Task:
TODO: Transformations should use MathTransform.derivative(...) instead, but it is not yet implemented for projections.

getScale

public float getScale()
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getScale.

Returns the scale factor, or Float.NaN if the scale is unknow. The scale factor is usually smaller than 1. For example for a 1:1000 scale, the scale factor will be 0.001. This scale factor takes in account the physical size of the rendering device (e.g. the screen size) if such information is available. Note that this scale can't be more accurate than the information supplied by the underlying system.

Returns:
The rendering scale factor as a number between 0 and 1, or Float.NaN.
See Also:
RenderingContext.getScale()

addLayer

public void addLayer(RenderedLayer layer)
              throws java.lang.IllegalArgumentException
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#add.

Add a new layer to this renderer. A Renderer do not draw anything as long as at least one layer hasn't be added. A RenderedLayer can be anything like an isobath, a remote sensing image, city locations, map scale, etc. The drawing order (relative to other layers) is determined by the z-order property. A RenderedLayer object can be added to only one Renderer object.

Parameters:
layer - Layer to add to this Renderer. This method call will be ignored if layer has already been added to this Renderer.
Throws:
java.lang.IllegalArgumentException - If layer has already been added to an other Renderer, or if the layer can't be added for some other reason.
See Also:
removeLayer(org.geotools.renderer.j2d.RenderedLayer), removeAllLayers(), getLayers(), getLayerCount()

removeLayer

public void removeLayer(RenderedLayer layer)
                 throws java.lang.IllegalArgumentException
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#remove.

Remove a layer from this renderer. Note that if the layer is going to be added back to the same renderer later, then it is more efficient to invoke RenderedLayer.setVisible(false).

Parameters:
layer - The layer to remove. This method call will be ignored if layer has already been removed from this Renderer.
Throws:
java.lang.IllegalArgumentException - If layer is owned by an other Renderer than this.
See Also:
addLayer(org.geotools.renderer.j2d.RenderedLayer), removeAllLayers(), getLayers(), getLayerCount()

removeAllLayers

public void removeAllLayers()
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#removeAll.

Remove all layers from this renderer.

See Also:
addLayer(org.geotools.renderer.j2d.RenderedLayer), removeLayer(org.geotools.renderer.j2d.RenderedLayer), getLayers(), getLayerCount()

getLayers

public RenderedLayer[] getLayers()
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getGraphics.

Returns all registered layers. The returned array is sorted in increasing z-order: element at index 0 contains the first layer to be drawn.

Returns:
The sorted array of layers. May have a 0 length, but will never be null. Change to this array, will not affect this Renderer.
See Also:
addLayer(org.geotools.renderer.j2d.RenderedLayer), removeLayer(org.geotools.renderer.j2d.RenderedLayer), removeAllLayers(), getLayerCount()

getLayerCount

public int getLayerCount()
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getGraphics.

Returns the number of layers in this renderer.

See Also:
getLayers(), addLayer(org.geotools.renderer.j2d.RenderedLayer), removeLayer(org.geotools.renderer.j2d.RenderedLayer), removeAllLayers()

getRenderingHint

public java.lang.Object getRenderingHint(java.awt.RenderingHints.Key key)
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getRenderingHint.

Returns a rendering hint.

Parameters:
key - The hint key (e.g. Hints.FINEST_RESOLUTION).
Returns:
The hint value for the specified key, or null if there is no hint for the specified key.
See Also:
Hints.FINEST_RESOLUTION, Hints.REQUIRED_RESOLUTION, Hints.COORDINATE_TRANSFORMATION_FACTORY, Hints.PREFETCH, RenderingHints.KEY_RENDERING, RenderingHints.KEY_COLOR_RENDERING, RenderingHints.KEY_INTERPOLATION

setRenderingHint

public void setRenderingHint(java.awt.RenderingHints.Key key,
                             java.lang.Object value)
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#setRenderingHint.

Add a rendering hint. Hints provides optional information used by some rendering code.

Parameters:
key - The hint key (e.g. Hints.FINEST_RESOLUTION).
value - The hint value. A null value remove the hint.
See Also:
Hints.FINEST_RESOLUTION, Hints.REQUIRED_RESOLUTION, Hints.COORDINATE_TRANSFORMATION_FACTORY, Hints.PREFETCH, RenderingHints.KEY_RENDERING, RenderingHints.KEY_COLOR_RENDERING, RenderingHints.KEY_INTERPOLATION

getOffscreenBuffered

public ImageType getOffscreenBuffered(float zOrder)
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getOffscreenBuffered.

Returns the offscreen buffer type for the given z-order. This is the value of the type argument given to the last call to setOffscreenBuffered(...) for a range containing zOrder.

Parameters:
zOrder - The z-order to query.
Returns:
One of ImageType.NONE, ImageType.VOLATILE or ImageType.BUFFERED enumeration.

setOffscreenBuffered

public void setOffscreenBuffered(float lower,
                                 float upper,
                                 ImageType type)
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#setOffscreenBuffered.

Enable or disable the use of offscreen buffer for all layers in the given range of z-orders. When enabled, all layers in the given range will be rendered once in an offscreen buffer (for example an VolatileImage); the image will then been reused as much as possible. The offscreen buffer may be invalidate at any time by some external event (including a call to any of RenderedLayer.repaint() methods) and will be recreated as needed. Using offscreen buffer for background layers that do not change often (e.g. a background map) help to make the GUI more responsive to frequent changes in foreground layers (e.g. a glass pane with highlighted selections).

An arbitrary amount of ranges can be specified. Each distinct range will use its own offscreen buffer. This means that if this method is invoked twice for enabling buffering in overlapping range of z-values, then the union of the two ranges will shares the same offscreen image.

Parameters:
lower - The lower z-order, inclusive.
upper - The upper z-order, inclusive.
type - ImageType.VOLATILE for enabling offscreen buffering for the specified range, or ImageType.NONE for disabling it.

paint

public void paint(java.awt.Graphics2D graph,
                  java.awt.geom.AffineTransform zoom,
                  java.awt.Rectangle zoomableBounds)
Deprecated. Use paint(Graphics2D, Rectangle, AffineTransform) instead.

Paint this Renderer and all visible layers it contains. This method invokes RenderedLayer.paint(org.geotools.renderer.j2d.RenderingContext) for each layer.

Parameters:
graph - The graphics handler.
zoom - The zoom (usually provided by ZoomPane.zoom.
zoomableBounds - The bounds of drawing area (usually provided by ZoomPane.getZoomableBounds(java.awt.Rectangle)).

paint

public void paint(java.awt.Graphics2D graph,
                  java.awt.Rectangle zoomableBounds,
                  java.awt.geom.AffineTransform zoom)
Deprecated. Use paint(Graphics2D,Rectangle,AffineTransform,boolean) instead.

Paint this Renderer and all visible layers it contains.

Specified by:
paint in interface Renderer2D
Parameters:
graph - The graphics handler to draw to.
zoomableBounds - The bounds of the output area in output units (usually pixels). The upper left corner is (0,0) in most cases. However, a different value is allowed if some widget area must be preserved, for example a margin on the left and top size for painting a graduation.
zoom - A transform which converts "World coordinates" to output coordinates. This transform will be concatenated to the graphics transform (as of graphics.transform(transform)) before the rendering take place.

paint

public void paint(java.awt.Graphics2D graph,
                  java.awt.Rectangle zoomableBounds,
                  java.awt.geom.AffineTransform zoom,
                  boolean isPrinting)
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#paint.

Paint this Renderer and all visible layers it contains. This method invokes RenderedLayer.paint(org.geotools.renderer.j2d.RenderingContext) for each layer.

Parameters:
graph - The graphics handler to draw to.
zoomableBounds - The bounds of the output area in output units (usually pixels). Those bounds are usually provided by ZoomPane.getZoomableBounds(java.awt.Rectangle)).
zoom - A transform which converts "World coordinates" to output coordinates. This transform is usually provided by ZoomPane.zoom.
isPrinting - true if the map is printed instead of painted on screen. When printing, layers like RenderedGridCoverage should block until all data are available instead of painting only available data and invokes RenderedLayer.repaint() later.

getToolTipText

public java.lang.String getToolTipText(GeoMouseEvent event)
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getToolTipText.

Returns the string to be used as the tooltip for a given mouse event. This method queries registered layers in decreasing z-order until one is found to returns a non-null string. Note: This method is not a commited part of the API. It may moves elsewhere in a future version.

Parameters:
event - The mouse event.
Returns:
The tool tip text, or null if there is no tool tip for the given mouse location.

getAction

public javax.swing.Action getAction(GeoMouseEvent event)
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#getAction.

Returns the action to be used for a given mouse event. This method queries registered layers in decreasing z-order until one is found to returns a non-null action. Note: This method is not a commited part of the API. It may moves elsewhere in a future version.

Parameters:
event - The mouse event.
Returns:
The action, or null if there is no action for the given mouve event.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#addPropertyChangeListener.

Add a property change listener to the listener list. The listener is registered for all properties. For example, adding or removing layers may fire a "preferredArea" change events.

Parameters:
listener - The property change listener to be added

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#addPropertyChangeListener.

Add a PropertyChangeListener for a specific property. The listener will be invoked only when that specific property changes.

Parameters:
propertyName - The name of the property to listen on.
listener - The PropertyChangeListener to be added.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#removePropertyChangeListener.

Remove a property change listener from the listener list. This removes a PropertyChangeListener that was registered for all properties.

Parameters:
listener - The property change listener to be removed

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener listener)
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#removePropertyChangeListener.

Remove a PropertyChangeListener for a specific property.

Parameters:
propertyName - The name of the property that was listened on.
listener - The PropertyChangeListener to be removed.

dispose

public void dispose()
Deprecated. Replaced by org.geotools.display.canvas.BufferedCanvas2D#dispose.

Provides a hint that a renderer will no longer be accessed from a reference in user space. The results are equivalent to those that occur when the program loses its last reference to this renderer, the garbage collector discovers this, and finalize is called. This can be used as a hint in situations where waiting for garbage collection would be overly conservative.

Renderer defines this method to invoke RenderedLayer.dispose() for all layers. The results of referencing a renderer or any of its layers after a call to dispose() are undefined. However, invoking this method more than once is safe.

See Also:
RenderedLayer.dispose(), PlanarImage.dispose()

toString

public java.lang.String toString()
Deprecated. 
Returns a string representation of this renderer and all its RenderedLayers. The offscreen buffer type, if any, appears in the right column. This method is for debugging purpose only and may change in any future version.



Copyright © GeoTools. All Rights Reserved.