javax.media.jai
Class WarpOpImage

java.lang.Object
  extended byjavax.media.jai.PlanarImage
      extended byjavax.media.jai.OpImage
          extended byjavax.media.jai.GeometricOpImage
              extended byjavax.media.jai.WarpOpImage
All Implemented Interfaces:
ImageJAI, PropertyChangeEmitter, PropertySource, RenderedImage, WritablePropertySource

public abstract class WarpOpImage
extends GeometricOpImage

A general implementation of image warping, and a superclass for specific image warping operations.

The image warp is specified by a Warp object and an Interpolation object.

Subclasses of WarpOpImage may choose whether they wish to implement the cobbled or non-cobbled variant of computeRect by means of the cobbleSources constructor parameter. The class comments for OpImage provide more information about how to override computeRect. It should be noted that the superclass GeometricOpImage automatically adds a value of Boolean.TRUE for the JAI.KEY_REPLACE_INDEX_COLOR_MODEL to the given configuration and passes it up to its superclass constructor so that geometric operations are performed on the pixel values instead of being performed on the indices into the color map for those operations whose source(s) have an IndexColorModel. This addition will take place only if a value for the JAI.KEY_REPLACE_INDEX_COLOR_MODEL has not already been provided by the user. Note that the configuration Map is cloned before the new hint is added to it. Regarding the value for the JAI.KEY_REPLACE_INDEX_COLOR_MODEL RenderingHints, the operator itself can be smart based on the parameters, i.e. while the default value for the JAI.KEY_REPLACE_INDEX_COLOR_MODEL is Boolean.TRUE for operations that extend this class, in some cases the operator could set the default.

See Also:
GeometricOpImage, OpImage, Warp, Interpolation

Field Summary
protected  Warp warp
          The Warp object describing the backwards pixel map.
 
Fields inherited from class javax.media.jai.GeometricOpImage
backgroundValues, computableBounds, extender, intBackgroundValues, interp, setBackground
 
Fields inherited from class javax.media.jai.OpImage
cache, cobbleSources, OP_COMPUTE_BOUND, OP_IO_BOUND, OP_NETWORK_BOUND, tileCacheMetric, tileRecycler
 
Fields inherited from class javax.media.jai.PlanarImage
colorModel, eventManager, height, minX, minY, properties, sampleModel, tileFactory, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, width
 
Constructor Summary
WarpOpImage(RenderedImage source, ImageLayout layout, Map configuration, boolean cobbleSources, BorderExtender extender, Interpolation interp, Warp warp)
          Constructor.
WarpOpImage(RenderedImage source, ImageLayout layout, Map configuration, boolean cobbleSources, BorderExtender extender, Interpolation interp, Warp warp, double[] backgroundValues)
          Constructor.
 
Method Summary
protected  Rectangle backwardMapRect(Rectangle destRect, int sourceIndex)
          Returns the minimum bounding box of the region of the specified source to which a particular Rectangle of the destination will be mapped.
 Raster computeTile(int tileX, int tileY)
          Computes a tile.
protected  Rectangle forwardMapRect(Rectangle sourceRect, int sourceIndex)
          Returns the minimum bounding box of the region of the destination to which a particular Rectangle of the specified source will be mapped.
 int getBottomPadding()
          Deprecated. as of JAI 1.1.
 int getLeftPadding()
          Deprecated. as of JAI 1.1.
 int getRightPadding()
          Deprecated. as of JAI 1.1.
 int getTopPadding()
          Deprecated. as of JAI 1.1.
 Point2D mapDestPoint(Point2D destPt, int sourceIndex)
          Computes the position in the specified source that best matches the supplied destination image position.
 Point2D mapSourcePoint(Point2D sourcePt, int sourceIndex)
          Computes the position in the destination that best matches the supplied source image position.
 
Methods inherited from class javax.media.jai.GeometricOpImage
getBorderExtender, getInterpolation, mapDestRect, mapSourceRect
 
Methods inherited from class javax.media.jai.OpImage
addTileToCache, cancelTiles, computeRect, computeRect, computesUniqueTiles, createTile, dispose, getExpandedNumBands, getFormatTags, getOperationComputeType, getTile, getTileCache, getTileCacheMetric, getTileDependencies, getTileFromCache, getTileRecycler, getTiles, hasExtender, prefetchTiles, queueTiles, recycleTile, setTileCache, vectorize, vectorize, vectorize
 
Methods inherited from class javax.media.jai.PlanarImage
addPropertyChangeListener, addPropertyChangeListener, addSink, addSink, addSource, addTileComputationListener, copyData, copyData, copyExtendedData, createColorModel, createSnapshot, createWritableRaster, finalize, getAsBufferedImage, getAsBufferedImage, getBounds, getColorModel, getData, getData, getDefaultColorModel, getExtendedData, getGraphics, getHeight, getImageID, getMaxTileX, getMaxTileY, getMaxX, getMaxY, getMinTileX, getMinTileY, getMinX, getMinY, getNumBands, getNumSources, getNumXTiles, getNumYTiles, getProperties, getProperty, getPropertyClass, getPropertyNames, getPropertyNames, getSampleModel, getSinks, getSource, getSourceImage, getSourceObject, getSources, getSplits, getTileComputationListeners, getTileFactory, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileIndices, getTileRect, getTiles, getTileWidth, getWidth, overlapsMultipleTiles, removeProperty, removePropertyChangeListener, removePropertyChangeListener, removeSink, removeSink, removeSinks, removeSource, removeSources, removeTileComputationListener, setImageLayout, setProperties, setProperty, setSource, setSources, tileXToX, tileXToX, tileYToY, tileYToY, toString, wrapRenderedImage, XToTileX, XToTileX, YToTileY, YToTileY
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

warp

protected Warp warp
The Warp object describing the backwards pixel map. It can not be null.

Constructor Detail

WarpOpImage

public WarpOpImage(RenderedImage source,
                   ImageLayout layout,
                   Map configuration,
                   boolean cobbleSources,
                   BorderExtender extender,
                   Interpolation interp,
                   Warp warp)
Constructor.

The image's layout is encapsulated in the layout argument. The user-supplied layout values supersedes the default settings. Any layout setting not specified by the user will take the corresponding value of the source image's layout.

Parameters:
layout - The layout of this image.
source - The source image; can not be null.
configuration - Configurable attributes of the image including configuration variables indexed by RenderingHints.Keys and image properties indexed by Strings or CaselessStringKeys. This is simply forwarded to the superclass constructor.
cobbleSources - A boolean indicating whether computeRect() expects contiguous sources. To use the default implementation of warping contained in this class, set cobbleSources to false.
extender - A BorderExtender, or null.
interp - The Interpolation object describing the interpolation method.
warp - The Warp object describing the warp.
Throws:
IllegalArgumentException - if source is null.
IllegalArgumentException - if combining the source bounds with the layout parameter results in negative output width or height.
IllegalArgumentException - If warp is null.
Since:
JAI 1.1

WarpOpImage

public WarpOpImage(RenderedImage source,
                   ImageLayout layout,
                   Map configuration,
                   boolean cobbleSources,
                   BorderExtender extender,
                   Interpolation interp,
                   Warp warp,
                   double[] backgroundValues)
Constructor.

The image's layout is encapsulated in the layout argument. The user-supplied layout values supersedes the default settings. Any layout setting not specified by the user will take the corresponding value of the source image's layout.

Parameters:
layout - The layout of this image.
source - The source image; can not be null.
configuration - Configurable attributes of the image including configuration variables indexed by RenderingHints.Keys and image properties indexed by Strings or CaselessStringKeys. This is simply forwarded to the superclass constructor.
cobbleSources - A boolean indicating whether computeRect() expects contiguous sources. To use the default implementation of warping contained in this class, set cobbleSources to false.
extender - A BorderExtender, or null.
interp - The Interpolation object describing the interpolation method.
warp - The Warp object describing the warp.
backgroundValues - The user-specified background values. If the provided array length is smaller than the number of bands, all the bands will be filled with the first element of the array. If the provided array is null, it will be set to new double[]{0.0} in the superclass.
Throws:
IllegalArgumentException - if source is null.
IllegalArgumentException - if combining the source bounds with the layout parameter results in negative output width or height.
IllegalArgumentException - If warp is null.
Since:
JAI 1.1.2
Method Detail

getLeftPadding

public int getLeftPadding()
Deprecated. as of JAI 1.1.

Returns the number of samples required to the left of the center.

Returns:
The left padding factor.

getRightPadding

public int getRightPadding()
Deprecated. as of JAI 1.1.

Returns the number of samples required to the right of the center.

Returns:
The right padding factor.

getTopPadding

public int getTopPadding()
Deprecated. as of JAI 1.1.

Returns the number of samples required above the center.

Returns:
The top padding factor.

getBottomPadding

public int getBottomPadding()
Deprecated. as of JAI 1.1.

Returns the number of samples required below the center.

Returns:
The bottom padding factor.

mapDestPoint

public Point2D mapDestPoint(Point2D destPt,
                            int sourceIndex)
Computes the position in the specified source that best matches the supplied destination image position.

The implementation in this class returns the value returned by warp.mapDestPoint(destPt). Subclasses requiring different behavior should override this method.

Overrides:
mapDestPoint in class GeometricOpImage
Parameters:
destPt - the position in destination image coordinates to map to source image coordinates.
sourceIndex - the index of the source image.
Returns:
a Point2D of the same class as destPt or null.
Throws:
IllegalArgumentException - if destPt is null.
IndexOutOfBoundsException - if sourceIndex is non-zero.
Since:
JAI 1.1.2

mapSourcePoint

public Point2D mapSourcePoint(Point2D sourcePt,
                              int sourceIndex)
Computes the position in the destination that best matches the supplied source image position.

The implementation in this class returns the value returned by warp.mapSourcePoint(sourcePt). Subclasses requiring different behavior should override this method.

Overrides:
mapSourcePoint in class GeometricOpImage
Parameters:
sourcePt - the position in source image coordinates to map to destination image coordinates.
sourceIndex - the index of the source image.
Returns:
a Point2D of the same class as sourcePt or null.
Throws:
IllegalArgumentException - if sourcePt is null.
IndexOutOfBoundsException - if sourceIndex is non-zero.
Since:
JAI 1.1.2

forwardMapRect

protected Rectangle forwardMapRect(Rectangle sourceRect,
                                   int sourceIndex)
Returns the minimum bounding box of the region of the destination to which a particular Rectangle of the specified source will be mapped.

Specified by:
forwardMapRect in class GeometricOpImage
Parameters:
sourceRect - the Rectangle in source coordinates.
sourceIndex - the index of the source image.
Returns:
a Rectangle indicating the destination bounding box, or null if the bounding box is unknown.
Throws:
IllegalArgumentException - if sourceIndex is negative or greater than the index of the last source.
IllegalArgumentException - if sourceRect is null.
Since:
JAI 1.1

backwardMapRect

protected Rectangle backwardMapRect(Rectangle destRect,
                                    int sourceIndex)
Returns the minimum bounding box of the region of the specified source to which a particular Rectangle of the destination will be mapped.

Specified by:
backwardMapRect in class GeometricOpImage
Parameters:
destRect - the Rectangle in destination coordinates.
sourceIndex - the index of the source image.
Returns:
a Rectangle indicating the source bounding box, or null if the bounding box is unknown.
Throws:
IllegalArgumentException - if sourceIndex is negative or greater than the index of the last source.
IllegalArgumentException - if destRect is null.
Since:
JAI 1.1

computeTile

public Raster computeTile(int tileX,
                          int tileY)
Computes a tile. A new WritableRaster is created to represent the requested tile. Its width and height equals to this image's tile width and tile height respectively. This method assumes that the requested tile either intersects or is within the bounds of this image.

Whether or not this method performs source cobbling is determined by the cobbleSources variable set at construction time. If cobbleSources is true, cobbling is performed on the source for areas that intersect multiple tiles, and computeRect(Raster[], WritableRaster, Rectangle) is called to perform the actual computation. Otherwise, computeRect(PlanarImage[], WritableRaster, Rectangle) is called to perform the actual computation.

Overrides:
computeTile in class GeometricOpImage
Parameters:
tileX - The X index of the tile.
tileY - The Y index of the tile.
Returns:
The tile as a Raster.