javax.media.jai
Class WarpOpImage

java.lang.Object
  |
  +--javax.media.jai.PlanarImage
        |
        +--javax.media.jai.OpImage
              |
              +--javax.media.jai.WarpOpImage
Direct Known Subclasses:
ScaleOpImage

public abstract class WarpOpImage
extends OpImage

A general implementation of image warping, and a superclass for other geometric image 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.

See Also:
OpImage, ScaleOpImage, Warp, Interpolation

Field Summary
protected  Interpolation interp
          The Interpolation object describing the subpixel interpolation method.
protected  Warp warp
          The Warp object describing the backwards pixel map.
protected  java.awt.Rectangle writableBounds
          The writable boundary of this image.
 
Fields inherited from class javax.media.jai.OpImage
cache, cobbleSources, extenders, OP_COMPUTE_BOUND, OP_IO_BOUND, OP_NETWORK_BOUND
 
Fields inherited from class javax.media.jai.PlanarImage
colorModel, height, minX, minY, sampleModel, snapshot, source0, source1, sources, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, width
 
Constructor Summary
WarpOpImage(java.awt.image.RenderedImage source, BorderExtender extender, TileCache cache, ImageLayout layout, Warp warp, Interpolation interp, boolean cobbleSources)
          Constructs a WarpOpImage.
 
Method Summary
 java.awt.image.Raster computeTile(int tileX, int tileY)
          Computes a tile.
 int getBottomPadding()
          Returns the number of samples required below the center.
 int getLeftPadding()
          Returns the number of samples required to the left of the center.
 int getRightPadding()
          Returns the number of samples required to the right of the center.
 int getTopPadding()
          Returns the number of samples required above the center.
 java.awt.Rectangle mapDestRect(java.awt.Rectangle destRect, int sourceIndex)
          Returns a conservative estimate of the region of a specified source that is required in order to compute the pixels of a given destination rectangle.
 java.awt.Rectangle mapSourceRect(java.awt.Rectangle sourceRect, int sourceIndex)
          Returns a conservative estimate of the destination region that can potentially be affected by the pixels of a rectangle of a given source.
 
Methods inherited from class javax.media.jai.OpImage
addTileToCache, computeRect, computeRect, computesUniqueTiles, finalize, getExpandedNumBands, getFormatTags, getOperationComputeType, getTile, getTileDependencies, getTileFromCache, getTiles, hasExtender, prefetchTiles, setTileCache
 
Methods inherited from class javax.media.jai.PlanarImage
addSink, addSource, copyData, copyData, copyExtendedData, createColorModel, createSnapshot, dispose, getAsBufferedImage, getAsBufferedImage, getBounds, getColorModel, getData, getData, getExtendedData, getGraphics, getHeight, getMaxTileX, getMaxTileY, getMaxX, getMaxY, getMinTileX, getMinTileY, getMinX, getMinY, getNumSources, getNumXTiles, getNumYTiles, getProperties, getProperty, getPropertyNames, getPropertyNames, getSampleModel, getSinks, getSource, getSources, getSplits, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileRect, getTileWidth, getWidth, removeSink, removeSinks, removeSource, removeSources, setImageParameters, setImageParameters, setProperties, setProperty, setSources, tileXToX, tileXToX, tileYToY, tileYToY, wrapRenderedImage, XToTileX, XToTileX, YToTileY, YToTileY
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

warp

protected Warp warp
The Warp object describing the backwards pixel map.

interp

protected Interpolation interp
The Interpolation object describing the subpixel interpolation method.

writableBounds

protected java.awt.Rectangle writableBounds
The writable boundary of this image. By default, this is determined based on the boundary of the source image, the type of the border extender, and the interpolation method. Subclasses should set this variable based on individual cases.
Constructor Detail

WarpOpImage

public WarpOpImage(java.awt.image.RenderedImage source,
                   BorderExtender extender,
                   TileCache cache,
                   ImageLayout layout,
                   Warp warp,
                   Interpolation interp,
                   boolean cobbleSources)
Constructs a WarpOpImage. The output minX, minY, width, and height are derived from the source image unless overridden by the layout parameter. The SampleModel and ColorModel of the output are set in the standard way by the OpImage constructor.

Additional control over the image bounds, tile grid layout, SampleModel, and ColorModel may be obtained by specifying an ImageLayout parameter. This parameter will be passed to the superclass constructor unchanged.

Parameters:
source - A RenderedImage.
extender - A BorderExtender, or null.
cache - A TileCache object to store tiles from this OpImage, or null. If null, a default cache will be used.
layout - An ImageLayout optionally containing the tile grid layout, SampleModel, and ColorModel.
warp - The Warp object describing the warp.
interp - The Interpolation object describing the interpolation method.
cobbleSources - A boolean indicating whether computeRect() expects contiguous sources. To use the default implementation of warping contained in this class, set cobbleSources to false.
Throws:
java.lang.IllegalArgumentException - if combining the source bounds with the layout parameter results in negative output width or height.
Method Detail

getLeftPadding

public int getLeftPadding()
Returns the number of samples required to the left of the center.
Returns:
The left padding factor.

getRightPadding

public int getRightPadding()
Returns the number of samples required to the right of the center.
Returns:
The right padding factor.

getTopPadding

public int getTopPadding()
Returns the number of samples required above the center.
Returns:
The top padding factor.

getBottomPadding

public int getBottomPadding()
Returns the number of samples required below the center.
Returns:
The bottom padding factor.

mapSourceRect

public java.awt.Rectangle mapSourceRect(java.awt.Rectangle sourceRect,
                                        int sourceIndex)
Returns a conservative estimate of the destination region that can potentially be affected by the pixels of a rectangle of a given source.
Parameters:
sourceRect - The Rectangle in source coordinates.
sourceIndex - The index of the source image.
Returns:
a Rectangle indicating the potentially affected destination region, or null if the region is unknown.
Throws:
java.lang.IllegalArgumentException - if sourceIndex is negative or greater than the index of the last source.
NullPointerException - if sourceRect is null.
Overrides:
mapSourceRect in class OpImage

mapDestRect

public java.awt.Rectangle mapDestRect(java.awt.Rectangle destRect,
                                      int sourceIndex)
Returns a conservative estimate of the region of a specified source that is required in order to compute the pixels of a given destination rectangle.
Parameters:
destRect - The Rectangle in destination coordinates.
sourceIndex - The index of the source image.
Returns:
a Rectangle indicating the required source region.
Throws:
java.lang.IllegalArgumentException - if sourceIndex is negative or greater than the index of the last source.
NullPointerException - if destRect is null.
Overrides:
mapDestRect in class OpImage

computeTile

public java.awt.image.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. If the requested tile lies outside of the image's boundary, the created raster is returned with all of its pixels set to 0.

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.

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



Casa de Bender