javax.media.jai
Class PointOpImage

java.lang.Object
  |
  +--javax.media.jai.PlanarImage
        |
        +--javax.media.jai.OpImage
              |
              +--javax.media.jai.PointOpImage
All Implemented Interfaces:
ImageJAI, PropertyChangeEmitter, PropertySource, RenderedImage, WritablePropertySource
Direct Known Subclasses:
ColormapOpImage, NullOpImage

public abstract class PointOpImage
extends OpImage

An abstract base class for image operators that require only the (x, y) pixel from each source image in order to compute the destination pixel (x, y).

PointOpImage is intended as a convenient superclass for OpImages that only need to look at each destination pixel's corresponding source pixels. Some examples are lookup, contrast adjustment, pixel arithmetic, and color space conversion.

See Also:
OpImage

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
PointOpImage(RenderedImage source, ImageLayout layout, Map configuration, boolean cobbleSources)
          Constructs a PointOpImage with one source image.
PointOpImage(RenderedImage source0, RenderedImage source1, ImageLayout layout, Map configuration, boolean cobbleSources)
          Constructs a PointOpImage with two source images.
PointOpImage(RenderedImage source0, RenderedImage source1, RenderedImage source2, ImageLayout layout, Map configuration, boolean cobbleSources)
          Constructs a PointOpImage with three source images.
PointOpImage(Vector sources, ImageLayout layout, Map configuration, boolean cobbleSources)
          Constructor.
 
Method Summary
 Raster computeTile(int tileX, int tileY)
          Computes a tile.
 void dispose()
          Disposes of any remaining tiles in the TileCache.
protected  boolean isColormapOperation()
          Indicates whether the operation is being effected directly on the associated colormap.
 Rectangle mapDestRect(Rectangle destRect, int sourceIndex)
          Returns a conservative estimate of the region of a specific source that is required in order to compute the pixels of a given destination rectangle.
 Rectangle mapSourceRect(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.
protected  void permitInPlaceOperation()
          Causes a flag to be set to indicate that in-place operation should be permitted if the image bounds, tile grid offset, tile dimensions, and SampleModels of the source and destination images are compatible.
 
Methods inherited from class javax.media.jai.OpImage
addTileToCache, cancelTiles, computeRect, computeRect, computesUniqueTiles, createTile, getExpandedNumBands, getFormatTags, getOperationComputeType, getTile, getTileCache, getTileCacheMetric, getTileDependencies, getTileFromCache, getTileRecycler, getTiles, hasExtender, mapDestPoint, mapSourcePoint, 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
 

Constructor Detail

PointOpImage

public PointOpImage(Vector sources,
                    ImageLayout layout,
                    Map configuration,
                    boolean cobbleSources)
Constructor.

There must be at least one valid source supplied via the sources argument. However, there is no upper limit on the number of sources this image may have.

The image's layout is encapsulated in the layout argument. If the image bounds are supplied they must be contained within the intersected source bounds which must be non-empty. If the bounds are not supplied, they are calculated to be the intersection of the bounds of all sources.

If no SampleModel is specified in the layout, a new SampleModel will be created. This SampleModel will have a number of bands equal to the minimum band count of all sources and a depth which can accomodate the data of all sources. The band count of sources which have an IndexColorModel will be set to the number of components of the IndexColorModel instead of to the number of bands of the SampleModel.

In all cases, the layout is forwarded to the OpImage constructor which sets the default layout values in the standard way.

Parameters:
layout - The layout parameters of the destination image.
sources - The source images.
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 - true if computeRect() expects contiguous sources.
Throws:
IllegalArgumentException - If sources or any object in sources is null.
IllegalArgumentException - if sources does not contain at least one element.
ClassCastException - If any object in sources is not a RenderedImage.
IllegalArgumentException - If combining the intersected source bounds with the user-specified bounds, if any, yields an empty rectangle, or the user-specified image bounds extends beyond the intersection of all the source bounds.
Since:
JAI 1.1

PointOpImage

public PointOpImage(RenderedImage source,
                    ImageLayout layout,
                    Map configuration,
                    boolean cobbleSources)
Constructs a PointOpImage with one source image. The image layout is computed as described in the constructor taking a Vector of sources.
Parameters:
layout - The layout parameters of the destination image.
source - The source image.
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 - Indicates whether computeRect() expects contiguous sources.
Throws:
IllegalArgumentException - if source is null.
Since:
JAI 1.1

PointOpImage

public PointOpImage(RenderedImage source0,
                    RenderedImage source1,
                    ImageLayout layout,
                    Map configuration,
                    boolean cobbleSources)
Constructs a PointOpImage with two source images. The image layout is computed as described in the constructor taking a Vector of sources.
Parameters:
layout - The layout parameters of the destination image.
source0 - The first source image.
source1 - The second source image.
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 - Indicates whether computeRect() expects contiguous sources.
Throws:
IllegalArgumentException - if source0 or source1 is null.
Since:
JAI 1.1

PointOpImage

public PointOpImage(RenderedImage source0,
                    RenderedImage source1,
                    RenderedImage source2,
                    ImageLayout layout,
                    Map configuration,
                    boolean cobbleSources)
Constructs a PointOpImage with three source images. The image layout is computed as described in the constructor taking a Vector of sources.
Parameters:
layout - The layout parameters of the destination image.
source0 - The first source image.
source1 - The second source image.
source2 - The third source image.
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 - Indicates whether computeRect() expects contiguous sources.
Throws:
IllegalArgumentException - if source0 or source1 or source2 is null.
Since:
JAI 1.1
Method Detail

permitInPlaceOperation

protected void permitInPlaceOperation()
Causes a flag to be set to indicate that in-place operation should be permitted if the image bounds, tile grid offset, tile dimensions, and SampleModels of the source and destination images are compatible. This method should be invoked in the constructor of the implementation of a given operation only if that implementation is amenable to in-place computation. Invocation of this method is a necessary but not a sufficient condition for in-place computation actually to occur. If the system property "javax.media.jai.PointOpImage.InPlace" is equal to the string "false" in a case-insensitive fashion then in-place operation will not be permitted.

isColormapOperation

protected boolean isColormapOperation()
Indicates whether the operation is being effected directly on the associated colormap. This method will in general return true if the image is the destination of a unary, shift-invariant operation with an IndexColorModel equal to that of its unique source.

When this method returns true the computeTile() method in this class will return either a copy of the corresponding region of the first source image or, if the operation is being performed in place, the corresponding tile of the first source image.

The implementation in this class always returns false.

Since:
JAI 1.1

computeTile

public Raster computeTile(int tileX,
                          int tileY)
Computes a tile. If source cobbling was requested at construction time, the source tile boundaries are overlayed onto the destination and computeRect(Raster[], WritableRaster, Rectangle) is called for each of the resulting regions. Otherwise, computeRect(PlanarImage[], WritableRaster, Rectangle) is called once to compute the entire active area of the tile.

The image bounds may be larger than the bounds of the source image. In this case, samples for which there are no corresponding sources are set to zero.

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

mapSourceRect

public final Rectangle mapSourceRect(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. The resulting Rectangle is not clipped to the destination image bounds.
Overrides:
mapSourceRect in class OpImage
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:
IllegalArgumentException - if sourceIndex is negative or greater than the index of the last source.
IllegalArgumentException - if sourceRect is null.

mapDestRect

public final Rectangle mapDestRect(Rectangle destRect,
                                   int sourceIndex)
Returns a conservative estimate of the region of a specific source that is required in order to compute the pixels of a given destination rectangle. The resulting Rectangle is not clipped to the source image bounds.
Overrides:
mapDestRect in class OpImage
Parameters:
destRect - the Rectangle in source coordinates.
sourceIndex - the index of the source image.
Returns:
a Rectangle indicating the potentially affected destination region.
Throws:
IllegalArgumentException - if sourceIndex is negative or greater than the index of the last source.
IllegalArgumentException - if destRect is null.

dispose

public void dispose()
Disposes of any remaining tiles in the TileCache.

If cache is non-null, in place operation is enabled, and tileRecycler is non-null, then all tiles owned by this specific image are removed from the cache. Subsequent to this super.dispose() is invoked.

Overrides:
dispose in class OpImage
Since:
JAI 1.1.2