javax.media.jai
Class DeferredProperty

java.lang.Object
  |
  +--java.util.Observable
        |
        +--javax.media.jai.DeferredData
              |
              +--javax.media.jai.DeferredProperty
All Implemented Interfaces:
EventListener, PropertyChangeListener, Serializable

public class DeferredProperty
extends DeferredData
implements PropertyChangeListener

A subclass of DeferredData to be used to wrap JAI property values which will be computed at a later time. For example, an instance of this class could be used to wrap a property emitted by an operation node so that the actual computation of the property value was deferred until it was actually needed.

Since:
JAI 1.1
See Also:
DeferredData, RenderedOp, Serialized Form

Field Summary
protected  String propertyName
          The name of the property the value of which is to be obtained.
protected  PropertySource propertySource
          The PropertySource from which the value of the named property is to be drawn.
 
Fields inherited from class javax.media.jai.DeferredData
data, dataClass
 
Constructor Summary
DeferredProperty(PropertySource propertySource, String propertyName, Class propertyClass)
          Creates a DeferredProperty.
 
Method Summary
protected  Object computeData()
          Returns the value of the image property associated with the image and property name specified at construction.
 boolean equals(Object obj)
          Tests whether the parameter equals this object.
 String getPropertyName()
          Returns the name of the property the value of which is to be obtained.
 PropertySource getPropertySource()
          Returns the PropertySource of the property value.
 int hashCode()
          Returns a hash code value for the object.
 void propertyChange(PropertyChangeEvent evt)
          The implementation of PropertyChangeListener.
 
Methods inherited from class javax.media.jai.DeferredData
getData, getDataClass, isValid, setData
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propertySource

protected transient PropertySource propertySource
The PropertySource from which the value of the named property is to be drawn.

propertyName

protected String propertyName
The name of the property the value of which is to be obtained.
Constructor Detail

DeferredProperty

public DeferredProperty(PropertySource propertySource,
                        String propertyName,
                        Class propertyClass)
Creates a DeferredProperty. If the specified PropertySource is a PropertyChangeEmitter, then this DeferredProperty object is registered as a PropertyChangeListener of the PropertySource.
Throws:
IllegalArgumentException - if a parameter is null or if the propertyName is not among those emitted by the PropertySource.
Method Detail

getPropertySource

public PropertySource getPropertySource()
Returns the PropertySource of the property value.

getPropertyName

public String getPropertyName()
Returns the name of the property the value of which is to be obtained.

computeData

protected Object computeData()
Returns the value of the image property associated with the image and property name specified at construction.
Overrides:
computeData in class DeferredData

equals

public boolean equals(Object obj)
Tests whether the parameter equals this object. Equality obtains if the parameter object is a DeferredProperty and the respective propertySource and dataClass variables are equal according to their respective equals() methods and the propertyNames are equal ignoring case. The wrapped data object is not tested unless the isValid() of both objects returns true because requesting it via getData() may provoke computation of a deferred quantity.
Overrides:
equals in class Object

hashCode

public int hashCode()
Returns a hash code value for the object.
Overrides:
hashCode in class Object

propertyChange

public void propertyChange(PropertyChangeEvent evt)
The implementation of PropertyChangeListener. This method responds to certain PropertyChangeEvents generated by the PropertySource used to construct this object.

If the PropertyChangeEvent is named "Rendering" and is an instance of javax.media.jai.RenderingChangeEvent, then the source of the event is checked to determine whether it equals the PropertySource used to construct this object. If this test is passed then the PropertySource is a RenderedOp the rendering of which has changed. Therefore setData() will be invoked with a null argument. This will indicate to any registered observers that the property data should be re-requested by invoking getData() on this object.

If the PropertyChangeEvent was generated by the PropertySource used to construct this object, has name equal to the name of the deferred property, and is an instance of PropertySourceChangeEvent, then the value returned by the getNewValue() method of the event object will be passed to setData() unless getNewValue() returns java.awt.Image.UndefinedProperty in which case null will be passed to setData(). Registered observers will be notified according to the specification of setData().

Specified by:
propertyChange in interface PropertyChangeListener