org.geotools.renderer.j2d
Class RenderedGridCoverage

java.lang.Object
  extended byorg.geotools.renderer.j2d.RenderedLayer
      extended byorg.geotools.renderer.j2d.RenderedGridCoverage
All Implemented Interfaces:
java.awt.image.TileObserver

public class RenderedGridCoverage
extends RenderedLayer
implements java.awt.image.TileObserver

A layer for rendering a grid coverage. More than one RenderedGridCoverage can share the same grid coverage, for example in order to display an image in many MapPane with different zoom.

Version:
$Id: RenderedGridCoverage.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux

Field Summary
 
Fields inherited from class org.geotools.renderer.j2d.RenderedLayer
listeners
 
Constructor Summary
RenderedGridCoverage(GridCoverage coverage)
          Construct a new layer for the specified grid coverage.
 
Method Summary
 void dispose()
          Provides a hint that a layer will no longer be accessed from a reference in user space.
 GridCoverage getGridCoverage()
          Returns the grid coverage, or null if none.
 java.lang.String getName(java.util.Locale locale)
          Returns the name of this layer.
 java.awt.geom.Rectangle2D getPreferredArea()
          Returns the preferred area for this layer.
 java.awt.geom.Dimension2D getPreferredPixelSize()
          Returns the preferred pixel size in rendering coordinates.
 float getZOrder()
          Returns the z-order for this layer.
protected  void paint(RenderingContext context)
          Paint the grid coverage.
protected  void prefetch(RenderingContext context)
          Hints that this layer might be painted in the near future.
protected  void setCoordinateSystem(CoordinateSystem cs)
          Set the rendering coordinate system for this layer.
 void setGridCoverage(GridCoverage newCoverage)
          Set the grid coverage to renderer.
 void tileUpdate(java.awt.image.WritableRenderedImage source, int tileX, int tileY, boolean willBeWritable)
          Notify that a tile in the coverage's image has been updated.
 
Methods inherited from class org.geotools.renderer.j2d.RenderedLayer
addPropertyChangeListener, addPropertyChangeListener, getAction, getCoordinateSystem, getLocale, getRenderer, getToolTipText, getTreeLock, isVisible, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, setPreferredArea, setPreferredPixelSize, setVisible, setZOrder, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RenderedGridCoverage

public RenderedGridCoverage(GridCoverage coverage)
Construct a new layer for the specified grid coverage. It is legal to construct many layers for the same grid coverage.

Parameters:
coverage - The grid coverage, or null if none.
Method Detail

setGridCoverage

public void setGridCoverage(GridCoverage newCoverage)
                     throws org.opengis.referencing.operation.TransformException
Set the grid coverage to renderer. This grid coverage will be automatically projected to the rendering coordinate system, if needed.

Parameters:
newCoverage - The new grid coverage, or null if none.
Throws:
org.opengis.referencing.operation.TransformException - if the specified coverage can't be projected to the current rendering coordinate system.

getGridCoverage

public GridCoverage getGridCoverage()
Returns the grid coverage, or null if none. This is the grid coverage given to the last call of setGridCoverage(org.geotools.gc.GridCoverage). The rendered grid coverage may not be the same, since a map projection may be applied at rendering time.


getName

public java.lang.String getName(java.util.Locale locale)
Returns the name of this layer.

Overrides:
getName in class RenderedLayer
Parameters:
locale - The desired locale, or null for a default locale.
Returns:
This layer's name.
See Also:
RenderedLayer.getLocale(), Renderer.getName(java.util.Locale)

setCoordinateSystem

protected void setCoordinateSystem(CoordinateSystem cs)
                            throws org.opengis.referencing.operation.TransformException
Set the rendering coordinate system for this layer.

Overrides:
setCoordinateSystem in class RenderedLayer
Parameters:
cs - The coordinate system.
Throws:
org.opengis.referencing.operation.TransformException - If cs if the grid coverage can't be resampled to the specified coordinate system.

getPreferredArea

public java.awt.geom.Rectangle2D getPreferredArea()
Returns the preferred area for this layer. If no preferred area has been explicitely set, then this method returns the grid coverage's bounding box.

Overrides:
getPreferredArea in class RenderedLayer
Returns:
The preferred area in the rendering coordinate system, or null if unknow or not applicable.
See Also:
RenderedLayer.getPreferredPixelSize(), RenderedLayer.getCoordinateSystem()

getPreferredPixelSize

public java.awt.geom.Dimension2D getPreferredPixelSize()
Returns the preferred pixel size in rendering coordinates. If no preferred pixel size has been explicitely set, then this method returns the grid coverage's pixel size.

Overrides:
getPreferredPixelSize in class RenderedLayer
Returns:
The preferred pixel size in this rendering coordinate system, or null if none.
See Also:
RenderedLayer.getPreferredArea(), RenderedLayer.getCoordinateSystem()

getZOrder

public float getZOrder()
Returns the z-order for this layer. If the grid coverage has at least 3 dimension, then the default z-order is gridCoverage.getEnvelope().getCenter(2). Otherwise, the default value is Float.NEGATIVE_INFINITY in order to paint the coverage under anything else. The default value can be overriden with a call to RenderedLayer.setZOrder(float).

Overrides:
getZOrder in class RenderedLayer
See Also:
RenderedLayer.setZOrder(float)

prefetch

protected void prefetch(RenderingContext context)
Hints that this layer might be painted in the near future. The default implementation determines which tiles are going to be drawn and invokes PlanarImage.prefetchTiles(java.awt.Point[]).

Overrides:
prefetch in class RenderedLayer
Parameters:
context - Information relatives to the rendering context.
See Also:
PlanarImage.prefetchTiles(java.awt.Point[])

paint

protected void paint(RenderingContext context)
              throws org.opengis.referencing.operation.TransformException
Paint the grid coverage.

Specified by:
paint in class RenderedLayer
Parameters:
context - Information relatives to the rendering context.
Throws:
org.opengis.referencing.operation.TransformException - If a coordinate transformation failed during the rendering process.

tileUpdate

public void tileUpdate(java.awt.image.WritableRenderedImage source,
                       int tileX,
                       int tileY,
                       boolean willBeWritable)
Notify that a tile in the coverage's image has been updated. The default implementation repaint the modified tiles if willBeWritable is false (i.e. the update is finished).

Specified by:
tileUpdate in interface java.awt.image.TileObserver
Parameters:
source - The image that owns the tile.
tileX - The X index of the tile that is being updated.
tileY - The Y index of the tile that is being updated.
willBeWritable - If true, the tile will be grabbed for writing; otherwise it is being released.

dispose

public void dispose()
Provides a hint that a layer 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 layer, 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.

Overrides:
dispose in class RenderedLayer
See Also:
Renderer.dispose(), PlanarImage.dispose()


Copyright © GeoTools. All Rights Reserved.