org.geotools.coverage
Class AbstractCoverage.Renderable

java.lang.Object
  extended byjavax.media.jai.PropertySourceImpl
      extended byorg.geotools.coverage.AbstractCoverage.Renderable
All Implemented Interfaces:
javax.media.jai.ImageFunction, javax.media.jai.PropertySource, java.awt.image.renderable.RenderableImage, java.io.Serializable
Direct Known Subclasses:
GridCoverage2D.Renderable
Enclosing class:
AbstractCoverage

protected class AbstractCoverage.Renderable
extends javax.media.jai.PropertySourceImpl
implements java.awt.image.renderable.RenderableImage, javax.media.jai.ImageFunction

A view of a coverage as a renderable image. Renderable images allow interoperability with Java2D for a two-dimensional slice of a coverage (which may or may not be a grid coverage).

Version:
$Id: AbstractCoverage.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
AbstractCoverage.getRenderableImage(int, int), Serialized Form

Field Summary
protected  GeneralDirectPosition coordinate
          A coordinate point where to evaluate the function.
protected  int xAxis
          Dimension to use for x axis.
protected  int yAxis
          Dimension to use for y axis.
 
Fields inherited from class javax.media.jai.PropertySourceImpl
cachedPropertyNames, properties, propertySources
 
Fields inherited from interface java.awt.image.renderable.RenderableImage
HINTS_OBSERVED
 
Constructor Summary
AbstractCoverage.Renderable(int xAxis, int yAxis)
          Constructs a renderable image.
 
Method Summary
 java.awt.image.RenderedImage createDefaultRendering()
          Returns a rendered image with a default width and height in pixels.
protected  java.awt.image.renderable.RenderContext createRenderContext(java.awt.geom.Rectangle2D gridBounds, java.awt.RenderingHints hints)
          Initialize a render context with an affine transform that maps the coverage envelope to the specified destination rectangle.
 java.awt.image.RenderedImage createRendering(java.awt.image.renderable.RenderContext context)
          Creates a rendered image using a given render context.
 java.awt.image.RenderedImage createScaledRendering(int width, int height, java.awt.RenderingHints hints)
          Creates a rendered image with width and height in pixels.
 void getElements(double startX, double startY, double deltaX, double deltaY, int countX, int countY, int element, double[] real, double[] imag)
          Returns all values of a given element for a specified set of coordinates.
 void getElements(float startX, float startY, float deltaX, float deltaY, int countX, int countY, int element, float[] real, float[] imag)
          Returns all values of a given element for a specified set of coordinates.
 float getHeight()
          Gets the height in coverage coordinate space.
 float getMinX()
          Gets the minimum X coordinate of the rendering-independent image data.
 float getMinY()
          Gets the minimum Y coordinate of the rendering-independent image data.
 int getNumElements()
          Returns the number of elements per value at each position.
 java.util.Vector getSources()
          Returns to indicate that no source information is available.
 float getWidth()
          Gets the width in coverage coordinate space.
 boolean isComplex()
          Returns since values are not complex.
 boolean isDynamic()
          Returns if successive renderings with the same arguments may produce different results.
 
Methods inherited from class javax.media.jai.PropertySourceImpl
getProperties, getProperty, getPropertyClass, getPropertyNames, getPropertyNames
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.image.renderable.RenderableImage
getProperty, getPropertyNames
 

Field Detail

xAxis

protected final int xAxis
Dimension to use for x axis.


yAxis

protected final int yAxis
Dimension to use for y axis.


coordinate

protected final GeneralDirectPosition coordinate
A coordinate point where to evaluate the function. The point dimension is equals to the coverage's dimension. The x and y ordinates will be ignored, since they will vary for each pixel to be evaluated. Other ordinates, if any, should be set to a fixed value. For example a coverage may be three-dimensional, where the third dimension is the time axis. In such case, should be set to the point in time where to evaluate the coverage. By default, all ordinates are initialized to 0. Subclasses should set the desired values in their constructor if needed.

Constructor Detail

AbstractCoverage.Renderable

public AbstractCoverage.Renderable(int xAxis,
                                   int yAxis)
Constructs a renderable image.

Parameters:
xAxis - Dimension to use for x axis.
yAxis - Dimension to use for y axis.
Method Detail

getSources

public java.util.Vector getSources()
Returns to indicate that no source information is available.

Specified by:
getSources in interface java.awt.image.renderable.RenderableImage

isDynamic

public boolean isDynamic()
Returns if successive renderings with the same arguments may produce different results. The default implementation returns .

Specified by:
isDynamic in interface java.awt.image.renderable.RenderableImage
See Also:
GridCoverage2D.isDataEditable()

isComplex

public boolean isComplex()
Returns since values are not complex.

Specified by:
isComplex in interface javax.media.jai.ImageFunction

getWidth

public float getWidth()
Gets the width in coverage coordinate space.

Specified by:
getWidth in interface java.awt.image.renderable.RenderableImage
See Also:
AbstractCoverage.getEnvelope(), AbstractCoverage.getCoordinateReferenceSystem()

getHeight

public float getHeight()
Gets the height in coverage coordinate space.

Specified by:
getHeight in interface java.awt.image.renderable.RenderableImage
See Also:
AbstractCoverage.getEnvelope(), AbstractCoverage.getCoordinateReferenceSystem()

getMinX

public float getMinX()
Gets the minimum X coordinate of the rendering-independent image data. This is the coverage's envelope minimal value for the x axis.

Specified by:
getMinX in interface java.awt.image.renderable.RenderableImage
See Also:
AbstractCoverage.getEnvelope(), AbstractCoverage.getCoordinateReferenceSystem()

getMinY

public float getMinY()
Gets the minimum Y coordinate of the rendering-independent image data. This is the coverage's envelope minimal value for the y axis.

Specified by:
getMinY in interface java.awt.image.renderable.RenderableImage
See Also:
AbstractCoverage.getEnvelope(), AbstractCoverage.getCoordinateReferenceSystem()

createDefaultRendering

public java.awt.image.RenderedImage createDefaultRendering()
Returns a rendered image with a default width and height in pixels.

Specified by:
createDefaultRendering in interface java.awt.image.renderable.RenderableImage
Returns:
A rendered image containing the rendered data

createScaledRendering

public java.awt.image.RenderedImage createScaledRendering(int width,
                                                          int height,
                                                          java.awt.RenderingHints hints)
Creates a rendered image with width and height in pixels. If is 0, it will be computed automatically from . Conversely, if is 0, il will be computed automatically from . The default implementation creates a render context with createRenderContext(java.awt.geom.Rectangle2D, java.awt.RenderingHints) and invokes createRendering(RenderContext).

Specified by:
createScaledRendering in interface java.awt.image.renderable.RenderableImage
Parameters:
width - The width of rendered image in pixels, or 0.
height - The height of rendered image in pixels, or 0.
hints - Rendering hints, or .
Returns:
A rendered image containing the rendered data

createRendering

public java.awt.image.RenderedImage createRendering(java.awt.image.renderable.RenderContext context)
Creates a rendered image using a given render context. This method will uses an "ImageFunction" operation if possible (i.e. if the area of interect is rectangular and the affine transform contains only translation and scale coefficients).

Specified by:
createRendering in interface java.awt.image.renderable.RenderableImage
Parameters:
context - The render context to use to produce the rendering.
Returns:
A rendered image containing the rendered data

createRenderContext

protected java.awt.image.renderable.RenderContext createRenderContext(java.awt.geom.Rectangle2D gridBounds,
                                                                      java.awt.RenderingHints hints)
Initialize a render context with an affine transform that maps the coverage envelope to the specified destination rectangle. The affine transform mays swap axis in order to normalize their order (i.e. make them appear in the (x,y) order), so that the image appears properly oriented when rendered.

Parameters:
gridBounds - The two-dimensional destination rectangle.
hints - The rendering hints, or if none.
Returns:
A render context initialized with an affine transform from the coverage to the grid coordinate system. This transform is the inverse of GridGeometry2D.getGridToCoordinateSystem2D().
See Also:
GridGeometry2D.getGridToCoordinateSystem2D()

getNumElements

public int getNumElements()
Returns the number of elements per value at each position. This is the maximum value plus 1 allowed in methods invocation. The default implementation returns the number of sample dimensions in the coverage.

Specified by:
getNumElements in interface javax.media.jai.ImageFunction

getElements

public void getElements(float startX,
                        float startY,
                        float deltaX,
                        float deltaY,
                        int countX,
                        int countY,
                        int element,
                        float[] real,
                        float[] imag)
Returns all values of a given element for a specified set of coordinates. This method is automatically invoked at rendering time for populating an image tile, providing that the rendered image is created using the "ImageFunction" operator and the image type is not . The default implementation invokes AbstractCoverage.evaluate(DirectPosition,float[]) recursively.

Specified by:
getElements in interface javax.media.jai.ImageFunction

getElements

public void getElements(double startX,
                        double startY,
                        double deltaX,
                        double deltaY,
                        int countX,
                        int countY,
                        int element,
                        double[] real,
                        double[] imag)
Returns all values of a given element for a specified set of coordinates. This method is automatically invoked at rendering time for populating an image tile, providing that the rendered image is created using the "ImageFunction" operator and the image type is . The default implementation invokes AbstractCoverage.evaluate(DirectPosition,double[]) recursively.

Specified by:
getElements in interface javax.media.jai.ImageFunction


Copyright © GeoTools. All Rights Reserved.