javax.media.jai
Class SourcelessOpImage

java.lang.Object
  |
  +--javax.media.jai.PlanarImage
        |
        +--javax.media.jai.OpImage
              |
              +--javax.media.jai.SourcelessOpImage
All Implemented Interfaces:
ImageJAI, PropertyChangeEmitter, PropertySource, RenderedImage, WritablePropertySource

public abstract class SourcelessOpImage
extends OpImage

An abstract base class for image operators that have no image sources.

SourcelessOpImage is intended as a convenient superclass for OpImages that have no source image. Some examples are constant color images, file readers, protocol-based network readers, and mathematically-defined imagery such as fractals.

The computeTile method of this class will call the computeRect(PlanarImage[], WritableRaster, Rectangle) method of the subclass to perform the computation. The first argument will be null as there are no source images.

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
SourcelessOpImage(ImageLayout layout, Map configuration, SampleModel sampleModel, int minX, int minY, int width, int height)
          Constructs a SourcelessOpImage.
 
Method Summary
 boolean computesUniqueTiles()
          Returns false as SourcelessOpImages often return Rasters via computeTile() tile that are internally cached.
 Raster computeTile(int tileX, int tileY)
          Computes a tile.
 Rectangle mapDestRect(Rectangle destRect, int sourceIndex)
          Throws an IllegalArgumentException since the image has no image sources.
 Rectangle mapSourceRect(Rectangle sourceRect, int sourceIndex)
          Throws an IllegalArgumentException since the image has no image sources.
 
Methods inherited from class javax.media.jai.OpImage
addTileToCache, cancelTiles, computeRect, computeRect, createTile, dispose, 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

SourcelessOpImage

public SourcelessOpImage(ImageLayout layout,
                         Map configuration,
                         SampleModel sampleModel,
                         int minX,
                         int minY,
                         int width,
                         int height)
Constructs a SourcelessOpImage. The image bounds and SampleModel are set explicitly; other layout parameters may be set using the layout parameter. The min X, min Y, width, height, and SampleModel fields of the layout parameter are ignored.

If sampleModel is null, no exceptions will be thrown. However, the caller must be sure to set the sampleModel instance variable before construction terminates. This feature allows subclasses that require external computation such as file loading to defer the determination of their SampleModel until after the call to super.

Similarly, minX, minY, width, and height may be dummy values if care is taken to manually set all values that depend on them, namely the tile grid offset, tile size, and SampleModel width and height.

The tile dimensions, tile grid X and Y offsets, and ColorModel of the output will be set in the standard way by the OpImage constructor.

Parameters:
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.
layout - an ImageLayout describing the layout.
Since:
JAI 1.1
Method Detail

computesUniqueTiles

public boolean computesUniqueTiles()
Returns false as SourcelessOpImages often return Rasters via computeTile() tile that are internally cached. Some subclasses may want to override this method and return true.
Overrides:
computesUniqueTiles in class OpImage

computeTile

public Raster computeTile(int tileX,
                          int tileY)
Computes a tile. Since the operation has no sources, there is no need to worry about cobbling.

Subclasses should implement the computeRect(PlanarImage[], WritableRaster, Rectangle) method to perform the actual computation.

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

mapSourceRect

public Rectangle mapSourceRect(Rectangle sourceRect,
                               int sourceIndex)
Throws an IllegalArgumentException since the image has no image sources.
Overrides:
mapSourceRect in class OpImage
Parameters:
sourceRect - ignored.
sourceIndex - ignored.
Throws:
IllegalArgumentException - since the image has no sources.

mapDestRect

public Rectangle mapDestRect(Rectangle destRect,
                             int sourceIndex)
Throws an IllegalArgumentException since the image has no image sources.
Overrides:
mapDestRect in class OpImage
Parameters:
destRect - ignored.
sourceIndex - ignored.
Throws:
IllegalArgumentException - since the image has no sources.