javax.media.jai
Class RenderedImageList

java.lang.Object
  extended byjavax.media.jai.CollectionImage
      extended byjavax.media.jai.RenderedImageList
All Implemented Interfaces:
Collection, ImageJAI, List, PropertyChangeEmitter, PropertySource, RenderedImage, Serializable, WritablePropertySource

public class RenderedImageList
extends CollectionImage
implements List, RenderedImage, Serializable

A CollectionImage which is also a RenderedImage. The underlying Collection in this case is required to be a List containing only RenderedImages.

Instances of this class may be returned from either a RenderedImageFactory or from a CollectionImageFactory. This class would be particularly useful for implementing operations the result of which includes a single primary image and one or more secondary or dependant images the data of which are less likely to be requested.

Invocations of RenderedImage methods on an instance of this class will be forwarded to the first RenderedImage in the underlying List, i.e., the image at index zero. This should be the index assigned to the primary image in the case alluded to above. If there are no images in the List when a RenderedImage method is invoked an IllegalStateException will be thrown.

One example of the use of this class is in generating a classmap image using a classification algorithm. A by-product image of such an operation is often an error image wherein the value of each pixel is some measure of the classification error at that pixel. In this case the classmap image would be stored at index zero in the internal list and the error image at the unity index. The error image would be an OpImage that has the classmap image as its source. The result is that a reference to the error image is always available with the classmap image but the computation of the error image pixel values may be deferred until such time as the data are needed, if ever.

Methods defined in the RenderedImage and List interfaces are not all commented in detail. The List methods merely forward the call in most cases directly to the underlying List; as previously stated, RenderedImage method invocations are forwarded to the RenderedImage at position zero in the List.

Since:
JAI 1.1
See Also:
CollectionImage, RenderedImage, List, Serialized Form

Field Summary
 
Fields inherited from class javax.media.jai.CollectionImage
eventManager, imageCollection, imageFactory, properties, sinks
 
Constructor Summary
protected RenderedImageList()
          Creates an empty RenderedImageList.
  RenderedImageList(List renderedImageList)
          Creates a RenderedImageList from the supplied List.
 
Method Summary
 void add(int index, Object element)
          Inserts the specified element at the specified position in this list.
 boolean add(Object o)
          Adds the specified object to this List.
 boolean addAll(Collection c)
          Adds to this List all elements in the specified Collection which are RenderedImages.
 boolean addAll(int index, Collection c)
          Inserts into this List at the indicated position all elements in the specified Collection which are RenderedImages.
 WritableRaster copyData(WritableRaster dest)
          Copies an arbitrary rectangular region of the primary image into a caller-supplied WritableRaster.
 Object get(int index)
          Returns the element at the given index in imageCollection.
 ColorModel getColorModel()
          Returns the ColorModel of the primary image.
 Raster getData()
          Returns the entire primary image in a single Raster.
 Raster getData(Rectangle bounds)
          Returns an arbitrary rectangular region of the primary image in a Raster.
 int getHeight()
          Returns the height of the primary image.
 int getMinTileX()
          Returns the horizontal index of the leftmost column of tiles of the primary image.
 int getMinTileY()
          Returns the vertical index of the uppermost row of tiles of the primary image.
 int getMinX()
          Returns the X coordinate of the leftmost column of the primary image.
 int getMinY()
          Returns the X coordinate of the uppermost row of the primary image.
 int getNumXTiles()
          Returns the number of tiles of the primary image along the tile grid in the horizontal direction.
 int getNumYTiles()
          Returns the number of tiles of the primary image along the tile grid in the vertical direction.
 RenderedImage getPrimaryImage()
          Returns the first image in the underlying list of RenderedImages.
 Object getProperty(String name)
          Gets a property from the property set of this image.
 String[] getPropertyNames()
          Returns a list of the properties recognized by this image.
 SampleModel getSampleModel()
          Returns the SampleModel of the primary image.
 Vector getSources()
          Returns a Vector containing the image sources.
 Raster getTile(int tileX, int tileY)
          Returns tile (tileX, tileY) of the primary image as a Raster.
 int getTileGridXOffset()
          Returns the X coordinate of the upper-left pixel of tile (0, 0) of the primary image.
 int getTileGridYOffset()
          Returns the Y coordinate of the upper-left pixel of tile (0, 0) of the primary image.
 int getTileHeight()
          Returns the height of a tile of the primary image.
 int getTileWidth()
          Returns the width of a tile of the primary image.
 int getWidth()
          Returns the width of the primary image.
 int indexOf(Object o)
           
 int lastIndexOf(Object o)
           
 ListIterator listIterator()
           
 ListIterator listIterator(int index)
           
 Object remove(int index)
           
 Object set(int index, Object element)
           
 List subList(int fromIndex, int toIndex)
           
 
Methods inherited from class javax.media.jai.CollectionImage
addPropertyChangeListener, addPropertyChangeListener, addSink, clear, contains, containsAll, getImageFactory, getProperty, getPropertyClass, getPropertyNames, getSinks, isEmpty, iterator, remove, removeAll, removeProperty, removePropertyChangeListener, removePropertyChangeListener, removeSink, removeSinks, retainAll, setImageFactory, setProperty, size, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.List
clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

RenderedImageList

protected RenderedImageList()
Creates an empty RenderedImageList.


RenderedImageList

public RenderedImageList(List renderedImageList)
Creates a RenderedImageList from the supplied List.

Throws:
IllegalArgumentException - if any objects in the List are not RenderedImages.
IllegalArgumentException - if the List is empty.
IllegalArgumentException - if the List parameter is null.
Method Detail

getPrimaryImage

public RenderedImage getPrimaryImage()
Returns the first image in the underlying list of RenderedImages. The call is forwarded to the first image in the List.


getMinX

public int getMinX()
Returns the X coordinate of the leftmost column of the primary image. The call is forwarded to the first image in the List.

Specified by:
getMinX in interface RenderedImage

getMinY

public int getMinY()
Returns the X coordinate of the uppermost row of the primary image. The call is forwarded to the first image in the List.

Specified by:
getMinY in interface RenderedImage

getWidth

public int getWidth()
Returns the width of the primary image. The call is forwarded to the first image in the List.

Specified by:
getWidth in interface RenderedImage

getHeight

public int getHeight()
Returns the height of the primary image. The call is forwarded to the first image in the List.

Specified by:
getHeight in interface RenderedImage

getTileWidth

public int getTileWidth()
Returns the width of a tile of the primary image. The call is forwarded to the first image in the List.

Specified by:
getTileWidth in interface RenderedImage

getTileHeight

public int getTileHeight()
Returns the height of a tile of the primary image. The call is forwarded to the first image in the List.

Specified by:
getTileHeight in interface RenderedImage

getTileGridXOffset

public int getTileGridXOffset()
Returns the X coordinate of the upper-left pixel of tile (0, 0) of the primary image. The call is forwarded to the first image in the List.

Specified by:
getTileGridXOffset in interface RenderedImage

getTileGridYOffset

public int getTileGridYOffset()
Returns the Y coordinate of the upper-left pixel of tile (0, 0) of the primary image. The call is forwarded to the first image in the List.

Specified by:
getTileGridYOffset in interface RenderedImage

getMinTileX

public int getMinTileX()
Returns the horizontal index of the leftmost column of tiles of the primary image. The call is forwarded to the first image in the List.

Specified by:
getMinTileX in interface RenderedImage

getNumXTiles

public int getNumXTiles()
Returns the number of tiles of the primary image along the tile grid in the horizontal direction. The call is forwarded to the first image in the List.

Specified by:
getNumXTiles in interface RenderedImage

getMinTileY

public int getMinTileY()
Returns the vertical index of the uppermost row of tiles of the primary image. The call is forwarded to the first image in the List.

Specified by:
getMinTileY in interface RenderedImage

getNumYTiles

public int getNumYTiles()
Returns the number of tiles of the primary image along the tile grid in the vertical direction. The call is forwarded to the first image in the List.

Specified by:
getNumYTiles in interface RenderedImage

getSampleModel

public SampleModel getSampleModel()
Returns the SampleModel of the primary image. The call is forwarded to the first image in the List.

Specified by:
getSampleModel in interface RenderedImage

getColorModel

public ColorModel getColorModel()
Returns the ColorModel of the primary image. The call is forwarded to the first image in the List.

Specified by:
getColorModel in interface RenderedImage

getProperty

public Object getProperty(String name)
Gets a property from the property set of this image. If the property name is not recognized, java.awt.Image.UndefinedProperty will be returned. The call is forwarded to the first image in the List.

Specified by:
getProperty in interface RenderedImage
Overrides:
getProperty in class CollectionImage
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.

getPropertyNames

public String[] getPropertyNames()
Returns a list of the properties recognized by this image. If no properties are available, null will be returned. The call is forwarded to the first image in the List.

Specified by:
getPropertyNames in interface RenderedImage
Overrides:
getPropertyNames in class CollectionImage
Returns:
an array of Strings representing valid property names.

getSources

public Vector getSources()
Returns a Vector containing the image sources. The call is forwarded to the first image in the List.

Specified by:
getSources in interface RenderedImage

getTile

public Raster getTile(int tileX,
                      int tileY)
Returns tile (tileX, tileY) of the primary image as a Raster. Note that tileX and tileY are indices into the tile array, not pixel locations. The call is forwarded to the first image in the List.

Specified by:
getTile in interface RenderedImage
Parameters:
tileX - The X index of the requested tile in the tile array.
tileY - The Y index of the requested tile in the tile array.

getData

public Raster getData()
Returns the entire primary image in a single Raster. For images with multiple tiles this will require making a copy. The returned Raster is semantically a copy. The call is forwarded to the first image in the List.

Specified by:
getData in interface RenderedImage
Returns:
a Raster containing a copy of this image's data.

getData

public Raster getData(Rectangle bounds)
Returns an arbitrary rectangular region of the primary image in a Raster. The returned Raster is semantically a copy. The call is forwarded to the first image in the List.

Specified by:
getData in interface RenderedImage
Parameters:
bounds - the region of the RenderedImage to be returned.

copyData

public WritableRaster copyData(WritableRaster dest)
Copies an arbitrary rectangular region of the primary image into a caller-supplied WritableRaster. The region to be computed is determined by clipping the bounds of the supplied WritableRaster against the bounds of the image. The supplied WritableRaster must have a SampleModel that is compatible with that of the image.

If the raster argument is null, the entire image will be copied into a newly-created WritableRaster with a SampleModel that is compatible with that of the image. The call is forwarded to the first image in the List.

Specified by:
copyData in interface RenderedImage
Parameters:
dest - a WritableRaster to hold the returned portion of the image.
Returns:
a reference to the supplied WritableRaster, or to a new WritableRaster if the supplied one was null.

add

public void add(int index,
                Object element)
Inserts the specified element at the specified position in this list.

Specified by:
add in interface List
Throws:
IllegalArgumentException - if the specified element is not a RenderedImage.
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

addAll

public boolean addAll(int index,
                      Collection c)
Inserts into this List at the indicated position all elements in the specified Collection which are RenderedImages.

Specified by:
addAll in interface List
Returns:
true if this List changed as a result of the call.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

get

public Object get(int index)
Description copied from class: CollectionImage
Returns the element at the given index in imageCollection. If imageCollection is a List then the call is forwarded to imageCollection; otherwise an array is created by applying toArray() to imageCollection and the indicated element of that array is returned. Note that in the latter case no guarantee as to element ordering beyond that stated in the specification of Collection.toArray().

Specified by:
get in interface List
Overrides:
get in class CollectionImage
Parameters:
index - index of element to return.
Returns:
the RenderedImage object at the specified index.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List

listIterator

public ListIterator listIterator()
Specified by:
listIterator in interface List

listIterator

public ListIterator listIterator(int index)
Specified by:
listIterator in interface List

remove

public Object remove(int index)
Specified by:
remove in interface List

set

public Object set(int index,
                  Object element)
Specified by:
set in interface List

subList

public List subList(int fromIndex,
                    int toIndex)
Specified by:
subList in interface List

add

public boolean add(Object o)
Adds the specified object to this List.

Specified by:
add in interface List
Overrides:
add in class CollectionImage
Returns:
true if and only if the parameter is added to the List.
Throws:
IllegalArgumentException - if o is null or is not an RenderedImage.

addAll

public boolean addAll(Collection c)
Adds to this List all elements in the specified Collection which are RenderedImages.

Specified by:
addAll in interface List
Overrides:
addAll in class CollectionImage
Returns:
true if this List changed as a result of the call.