javax.media.jai
Class RenderedImageAdapter

java.lang.Object
  extended byjavax.media.jai.PlanarImage
      extended byjavax.media.jai.RenderedImageAdapter
All Implemented Interfaces:
ImageJAI, PropertyChangeEmitter, PropertySource, RenderedImage, WritablePropertySource
Direct Known Subclasses:
AttributedImage, WritableRenderedImageAdapter

public class RenderedImageAdapter
extends PlanarImage

A PlanarImage wrapper for a non-writable RenderedImage. The tile layout, sample model, and so forth are preserved. Calls to getTile(), getData(), and copyData() are forwarded to the image being adapted.

The set of properties available on the image will be a combination of those defined locally via setProperty() and those defined on the source image with the local properties taking precedence. No PropertySourceChangeEvent will be generated as a result of changes to the property set of the source image.

From JAI's point of view, this image is a PlanarImage of unknown type, with no sources. The source image is assumed to be immutable. If the RenderedImage source implements WritableRenderedImage, a WritableRenderedImageAdapter should be used.

The methods are marked 'final' in order to allow dynamic inlining to take place. This should eliminate any performance penalty associated with the use of an adapter class.

Since the methods of this class all derive from PlanarImage, they are not commented in detail.

See Also:
PlanarImage, WritableRenderedImageAdapter, RenderedImage, WritableRenderedImage

Field Summary
protected  RenderedImage theImage
          The RenderedImage being adapted.
 
Fields inherited from class javax.media.jai.PlanarImage
colorModel, eventManager, height, minX, minY, properties, sampleModel, tileFactory, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, width
 
Constructor Summary
RenderedImageAdapter(RenderedImage im)
          Constructs a RenderedImageAdapter.
 
Method Summary
 WritableRaster copyData(WritableRaster raster)
          Forwards call to the true source.
 Raster getData()
          Forwards call to the true source.
 Raster getData(Rectangle rect)
          Forwards call to the true source.
 Object getProperty(String name)
          Retrieves the property from those set locally on the image or, if the property is not available locally, the call is forwarded to the true source.
 Class getPropertyClass(String name)
          Returns the class expected to be returned by a request for the property with the specified name.
 String[] getPropertyNames()
          Retrieves a list of property names recognized by this image.
 Raster getTile(int x, int y)
          Forwards call to the true source unless the specified tile indices refer to a tile which does not overlap the image bounds in which case null is returned.
 RenderedImage getWrappedImage()
          Returns the reference to the external RenderedImage originally supplied to the constructor.
 
Methods inherited from class javax.media.jai.PlanarImage
addPropertyChangeListener, addPropertyChangeListener, addSink, addSink, addSource, addTileComputationListener, cancelTiles, copyData, copyExtendedData, createColorModel, createSnapshot, createWritableRaster, dispose, finalize, getAsBufferedImage, getAsBufferedImage, getBounds, getColorModel, getDefaultColorModel, getExtendedData, getGraphics, getHeight, getImageID, getMaxTileX, getMaxTileY, getMaxX, getMaxY, getMinTileX, getMinTileY, getMinX, getMinY, getNumBands, getNumSources, getNumXTiles, getNumYTiles, getProperties, getPropertyNames, getSampleModel, getSinks, getSource, getSourceImage, getSourceObject, getSources, getSplits, getTileComputationListeners, getTileFactory, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileIndices, getTileRect, getTiles, getTiles, getTileWidth, getWidth, overlapsMultipleTiles, prefetchTiles, queueTiles, 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

theImage

protected RenderedImage theImage
The RenderedImage being adapted.

Constructor Detail

RenderedImageAdapter

public RenderedImageAdapter(RenderedImage im)
Constructs a RenderedImageAdapter.

Parameters:
im - a RenderedImage to be `wrapped' as a PlanarImage.
Throws:
IllegalArgumentException - if im is null.
Method Detail

getWrappedImage

public final RenderedImage getWrappedImage()
Returns the reference to the external RenderedImage originally supplied to the constructor.

Since:
JAI 1.1.2

getTile

public final Raster getTile(int x,
                            int y)
Forwards call to the true source unless the specified tile indices refer to a tile which does not overlap the image bounds in which case null is returned.

Specified by:
getTile in interface RenderedImage
Specified by:
getTile in class PlanarImage
Parameters:
x - The X index of the requested tile in the tile array.
y - The Y index of the requested tile in the tile array.

getData

public final Raster getData()
Forwards call to the true source.

Specified by:
getData in interface RenderedImage
Overrides:
getData in class PlanarImage
Returns:
A Raster containing the entire image data.

getData

public final Raster getData(Rectangle rect)
Forwards call to the true source.

Specified by:
getData in interface RenderedImage
Overrides:
getData in class PlanarImage
Parameters:
rect - The rectangular region of this image to be returned, or null.
Returns:
A Raster containing the specified image data.

copyData

public final WritableRaster copyData(WritableRaster raster)
Forwards call to the true source.

Specified by:
copyData in interface RenderedImage
Overrides:
copyData in class PlanarImage
Parameters:
raster - A WritableRaster to hold the copied pixel data of this image.
Returns:
A reference to the supplied WritableRaster, or to a new WritableRaster if the supplied one was null.

getPropertyNames

public final String[] getPropertyNames()
Retrieves a list of property names recognized by this image. The locally defined property names are combined with those derived from the true source.

Specified by:
getPropertyNames in interface PropertySource
Overrides:
getPropertyNames in class PlanarImage
Returns:
an array of Strings containing valid property names or null.

getProperty

public final Object getProperty(String name)
Retrieves the property from those set locally on the image or, if the property is not available locally, the call is forwarded to the true source.

Specified by:
getProperty in interface PropertySource
Overrides:
getProperty in class PlanarImage
Parameters:
name - the name of the property to get, as a String.
Returns:
A reference to the property Object, or the value java.awt.Image.UndefinedProperty.
Throws:
IllegalArgumentException - if name is null.

getPropertyClass

public final Class getPropertyClass(String name)
Returns the class expected to be returned by a request for the property with the specified name. If this information is unavailable, null will be returned.

Specified by:
getPropertyClass in interface PropertySource
Overrides:
getPropertyClass in class PlanarImage
Returns:
The Class expected to be return by a request for the value of this property or null.
Throws:
IllegalArgumentException - if name is null.
Since:
JAI 1.1