javax.media.jai
Class CollectionImage

java.lang.Object
  extended byjavax.media.jai.CollectionImage
All Implemented Interfaces:
Collection, ImageJAI, PropertyChangeEmitter, PropertySource, WritablePropertySource
Direct Known Subclasses:
AttributedImageCollection, CollectionOp, ImageSequence, ImageStack, RenderedImageList

public abstract class CollectionImage
extends Object
implements ImageJAI, Collection

An abstract superclass for classes representing a Collection of images. It may be a Collection of RenderedImages or RenderableImages, a Collection of Collections that include images. In other words, this class supports nested Collections, but at the very bottom, there must be images associated with the Collection objects.


Field Summary
protected  PropertyChangeSupportJAI eventManager
          A helper object to manage firing events.
protected  Collection imageCollection
          A Collection of objects.
protected  CollectionImageFactory imageFactory
          The CollectionImageFactory which created this CollectionImage; may be null which implies that the CollectionImage was not created by a CollectionImageFactory.
protected  WritablePropertySourceImpl properties
          A helper object to manage the image properties.
protected  Set sinks
          A Set of WeakReferences to the sinks of this CollectionImage.
 
Constructor Summary
protected CollectionImage()
          Default constructor.
  CollectionImage(Collection collection)
          Constructs a class that contains an image Collection.
 
Method Summary
 boolean add(Object o)
          Adds the specified object to this Collection.
 boolean addAll(Collection c)
          Adds all of the elements in the specified Collection to this Collection.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a PropertyChangeListener to the listener list.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Add a PropertyChangeListener for a specific property.
 boolean addSink(Object sink)
          Adds a sink to the set of sinks.
 void clear()
          Removes all of the elements from this Collection.
 boolean contains(Object o)
          Returns true if this Collection contains the specified object.
 boolean containsAll(Collection c)
          Returns true if this Collection contains all of the elements in the specified Collection.
 Object get(int index)
          Returns the element at the given index in imageCollection.
 CollectionImageFactory getImageFactory()
          If this CollectionImage was created by a CollectionImageFactory then return a reference to that factory; otherwise return null.
 Object getProperty(String name)
          Returns the specified property.
 Object getProperty(String name, Collection collection)
          Deprecated. as of JAI 1.1.
 Class getPropertyClass(String name)
          Returns the class expected to be returned by a request for the property with the specified name.
 String[] getPropertyNames()
          Returns an array of Strings recognized as names by this property source.
 String[] getPropertyNames(String prefix)
          Returns an array of Strings recognized as names by this property source that begin with the supplied prefix.
 Set getSinks()
          Retrieves the set of sinks or null if there are none.
 boolean isEmpty()
          Returns true if this Collection contains no elements.
 Iterator iterator()
          Returns an Iterator over the elements in this Collection.
 boolean remove(Object o)
          Removes the specified object from this Collection.
 boolean removeAll(Collection c)
          Removes all this collection's elements that are also contained in the specified Collection.
 void removeProperty(String name)
          Removes the named property from the CollectionImage.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a PropertyChangeListener from the listener list.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Remove a PropertyChangeListener for a specific property.
 boolean removeSink(Object sink)
          Removes a sink from the set of sinks.
 void removeSinks()
          Removes all sinks from the set of sinks.
 boolean retainAll(Collection c)
          Retains only the elements in this Collection that are contained in the specified Collection.
 void setImageFactory(CollectionImageFactory imageFactory)
          Sets the imageFactory instance variable to the supplied value.
 void setProperty(String name, Object value)
          Sets a property on a CollectionImage.
 int size()
          Returns the number of elements in this Collection.
 Object[] toArray()
          Returns an array containing all of the elements in this Collection.
 Object[] toArray(Object[] a)
          Returns an array containing all of the elements in this collection whose runtime type is that of the specified array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

imageCollection

protected Collection imageCollection
A Collection of objects. It may be a Collection of images of the same type, a Collection of objects of the same type, each containing an image, or a Collection of Collections whose leaf objects are images or objects that contain images.


imageFactory

protected CollectionImageFactory imageFactory
The CollectionImageFactory which created this CollectionImage; may be null which implies that the CollectionImage was not created by a CollectionImageFactory.

Since:
JAI 1.1

eventManager

protected PropertyChangeSupportJAI eventManager
A helper object to manage firing events.

Since:
JAI 1.1

properties

protected WritablePropertySourceImpl properties
A helper object to manage the image properties.

Since:
JAI 1.1

sinks

protected Set sinks
A Set of WeakReferences to the sinks of this CollectionImage.

Since:
JAI 1.1
Constructor Detail

CollectionImage

protected CollectionImage()
Default constructor. The imageCollection parameter is null. Subclasses that use this constructor must either set the imageCollection parameter themselves, or override the methods defined in the Collection interface. Otherwise, a NullPointerException may be thrown at a later time when methods which use to the imageCollection instance variable are invoked.


CollectionImage

public CollectionImage(Collection collection)
Constructs a class that contains an image Collection.

Parameters:
collection - A Collection of objects that include images.
Throws:
IllegalArgumentException - if collection is null.
Method Detail

get

public Object get(int index)
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().

Parameters:
index - The index of the desired element.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || indeximageCollection.size()).
Since:
JAI 1.1

setImageFactory

public void setImageFactory(CollectionImageFactory imageFactory)
Sets the imageFactory instance variable to the supplied value. The parameter may be null. It is recommended that this method be invoked as soon as the CollectionImage is constructed.

Parameters:
imageFactory - The creating CollectionImageFactory or null
Throws:
IllegalStateException - if the corresponding instance variable was already set.
Since:
JAI 1.1

getImageFactory

public CollectionImageFactory getImageFactory()
If this CollectionImage was created by a CollectionImageFactory then return a reference to that factory; otherwise return null.

Since:
JAI 1.1

addSink

public boolean addSink(Object sink)
Adds a sink to the set of sinks.

Since:
JAI 1.1

removeSink

public boolean removeSink(Object sink)
Removes a sink from the set of sinks.

Returns:
true if and only if the set of sinks changed as a result of the call.
Since:
JAI 1.1

getSinks

public Set getSinks()
Retrieves the set of sinks or null if there are none.

Since:
JAI 1.1

removeSinks

public void removeSinks()
Removes all sinks from the set of sinks.

Since:
JAI 1.1

getPropertyNames

public String[] getPropertyNames()
Returns an array of Strings recognized as names by this property source. If no property names match, null will be returned.

Specified by:
getPropertyNames in interface PropertySource
Returns:
An array of Strings which are the valid property names or null if there are none.

getPropertyNames

public String[] getPropertyNames(String prefix)
Returns an array of Strings recognized as names by this property source that begin with the supplied prefix. If no property names are recognized, or no property names match, null will be returned. The comparison is done in a case-independent manner.

The default implementation calls getPropertyNames() and searches the list of names for matches.

Specified by:
getPropertyNames in interface PropertySource
Returns:
An array of Strings giving the valid property names or null if there are none.
Throws:
IllegalArgumentException - if prefix is null.

getPropertyClass

public 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
Parameters:
name - the name of the property, as a String.
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

getProperty

public Object getProperty(String name)
Returns the specified property. The default implementation returns java.awt.Image.UndefinedProperty.

Specified by:
getProperty in interface PropertySource
Parameters:
name - the name of the property, as a String.
Returns:
the value of the property, as an Object, or the value java.awt.Image.UndefinedProperty.
Throws:
IllegalArgumentException - if name is null.

getProperty

public Object getProperty(String name,
                          Collection collection)
Deprecated. as of JAI 1.1.

Returns the specified property. The default implementation returns java.awt.Image.UndefinedProperty.

Throws:
IllegalArgumentException - if name is null.

setProperty

public void setProperty(String name,
                        Object value)
Sets a property on a CollectionImage. Some CollectionImage subclasses may ignore attempts to set properties.

Specified by:
setProperty in interface WritablePropertySource
Parameters:
name - a String containing the property's name.
value - the property, as a general Object.
Throws:
IllegalArgumentException - If name or value is null.
Since:
JAI 1.1

removeProperty

public void removeProperty(String name)
Removes the named property from the CollectionImage. Some CollectionImage subclasses may ignore attempts to remove properties.

Specified by:
removeProperty in interface WritablePropertySource
Parameters:
name - the name of the property, as a String.
Since:
JAI 1.1

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. The listener is registered for all properties.

Specified by:
addPropertyChangeListener in interface PropertyChangeEmitter
Since:
JAI 1.1

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Add a PropertyChangeListener for a specific property. The listener will be invoked only when a call on firePropertyChange names that specific property. The case of the name is ignored.

Specified by:
addPropertyChangeListener in interface PropertyChangeEmitter
Since:
JAI 1.1

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.

Specified by:
removePropertyChangeListener in interface PropertyChangeEmitter
Since:
JAI 1.1

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Remove a PropertyChangeListener for a specific property. The case of the name is ignored.

Specified by:
removePropertyChangeListener in interface PropertyChangeEmitter
Since:
JAI 1.1

size

public int size()
Returns the number of elements in this Collection.

Specified by:
size in interface Collection

isEmpty

public boolean isEmpty()
Returns true if this Collection contains no elements.

Specified by:
isEmpty in interface Collection

contains

public boolean contains(Object o)
Returns true if this Collection contains the specified object.

Specified by:
contains in interface Collection

iterator

public Iterator iterator()
Returns an Iterator over the elements in this Collection.

Specified by:
iterator in interface Collection

toArray

public Object[] toArray()
Returns an array containing all of the elements in this Collection.

Specified by:
toArray in interface Collection

toArray

public Object[] toArray(Object[] a)
Returns an array containing all of the elements in this collection whose runtime type is that of the specified array.

Specified by:
toArray in interface Collection
Throws:
ArrayStoreException - if the runtime type of the specified array is not a supertype of the runtime type of every element in this Collection.

add

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

Specified by:
add in interface Collection
Returns:
true if and only if the parameter is added to the Collection.

remove

public boolean remove(Object o)
Removes the specified object from this Collection.

Specified by:
remove in interface Collection
Returns:
true if and only if the parameter is removed from the Collection.

containsAll

public boolean containsAll(Collection c)
Returns true if this Collection contains all of the elements in the specified Collection.

Specified by:
containsAll in interface Collection

addAll

public boolean addAll(Collection c)
Adds all of the elements in the specified Collection to this Collection.

Specified by:
addAll in interface Collection
Returns:
true if this Collection changed as a result of the call.

removeAll

public boolean removeAll(Collection c)
Removes all this collection's elements that are also contained in the specified Collection.

Specified by:
removeAll in interface Collection
Returns:
true if this Collection changed as a result of the call.

retainAll

public boolean retainAll(Collection c)
Retains only the elements in this Collection that are contained in the specified Collection.

Specified by:
retainAll in interface Collection
Returns:
true if this Collection changed as a result of the call.

clear

public void clear()
Removes all of the elements from this Collection.

Specified by:
clear in interface Collection