javax.media.jai
Class OperationNodeSupport

java.lang.Object
  extended byjavax.media.jai.OperationNodeSupport
All Implemented Interfaces:
Serializable

public class OperationNodeSupport
extends Object
implements Serializable

This is a utility class that can be used by OperationNodes to consolidate common functionality. An instance of this class may be used as a member field of the OperationNode and some of the OperationNode's work delegated to it.

Since:
JAI 1.1
See Also:
Serialized Form

Constructor Summary
OperationNodeSupport(String registryModeName, String opName, OperationRegistry registry, ParameterBlock pb, RenderingHints hints, PropertyChangeSupportJAI eventManager)
          Constructs an OperationNodeSupport instance.
 
Method Summary
 void addPropertyGenerator(PropertyGenerator pg)
          Adds a PropertyGenerator to the node.
 void copyPropertyFromSource(String propertyName, int sourceIndex)
          Forces a property to be copied from the specified source node.
 String getOperationName()
          Returns the name of the operation the associated node represents.
 ParameterBlock getParameterBlock()
          Returns the ParameterBlock of the associated node by reference.
 PropertySource getPropertySource(OperationNode opNode, PropertySource defaultPS)
          Constructs and returns a PropertySource suitable for use by the specified OperationNode.
 OperationRegistry getRegistry()
          Returns the OperationRegistry used by the associated node.
 String getRegistryModeName()
          Returns the name of RegistryMode corresponding to this OperationNode.
 RenderingHints getRenderingHints()
          Returns the RenderingHints of the associated node by reference.
 void resetPropertyEnvironment(boolean resetLocalEnvironment)
          Resets the property environment.
 void setOperationName(String opName)
          Sets the name of the operation the associated node represents.
 void setParameterBlock(ParameterBlock pb)
          Sets the ParameterBlock of the associated node by reference.
 void setRegistry(OperationRegistry registry)
          Sets the OperationRegistry that is used by the associated node.
 void setRenderingHints(RenderingHints hints)
          Sets the RenderingHints of the associated node.
 void suppressProperty(String name)
          Removes a named property from the property environment of the associated node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperationNodeSupport

public OperationNodeSupport(String registryModeName,
                            String opName,
                            OperationRegistry registry,
                            ParameterBlock pb,
                            RenderingHints hints,
                            PropertyChangeSupportJAI eventManager)
Constructs an OperationNodeSupport instance. All parameters except opName may be null. If non-null the PropertyChangeSupportJAI should have been created with the node as its event source (note that this cannot be verified).

The ParameterBlock may include DeferredData parameters. These will not be evaluated until their values are actually required, i.e., when the node is rendered. Any Observable events generated by such DeferredData parameters will be trapped by the node, converted to a PropertyChangeEventJAI named "parameters", and forwarded to any listeners registered with the supplied. eventManager. The old and new values of the event object so generated will be the previous and current values, respectively, of the data object wrapped by the DeferredData parameter, and thus will be instances of the class returned by the getDataClass() method of the DeferredData parameter.

Parameters:
registryModeName - The name of the registry mode concerned.
opName - The operation name to set.
registry - The OperationRegistry to set; it may be null in which case the registry will be set to the default JAI registry.
pb - The ParameterBlock to set; it may be null.
hints - The new RenderingHints to be set; it may be null.
eventManager - The event helper object. The property change event source of this object should be the OperationNode which is using the constructed OperationNodeSupport instance. If null no events will be fired.
Throws:
IllegalArgumentException - if registryModeName or opName is null.
Method Detail

getRegistryModeName

public String getRegistryModeName()
Returns the name of RegistryMode corresponding to this OperationNode. This value shoud be immutable for a given node. The value is returned by reference.


getOperationName

public String getOperationName()
Returns the name of the operation the associated node represents. The value is returned by reference.


setOperationName

public void setOperationName(String opName)
Sets the name of the operation the associated node represents. The value is set by reference.

If the operation name changes as a result of calling this method according to a case-insensitive comparison by equals() of the old and new names, a PropertyChangeEventJAI named "OperationName" will be fired by the event helper object with old and new values set to the old and new values of the operation name, respectively.

Parameters:
opName - The new operation name to be set.
Throws:
IllegalArgumentException - if opName is null.

getRegistry

public OperationRegistry getRegistry()
Returns the OperationRegistry used by the associated node. The value is returned by reference.


setRegistry

public void setRegistry(OperationRegistry registry)
Sets the OperationRegistry that is used by the associated node. If the specified registry is null, the registry will be set to the default JAI registry. The value is set by reference.

If the registry changes according to a direct comparison of the old and new registry references, a PropertyChangeEventJAI named "OperationRegistry" will be fired by the event helper object with old and new values set to the old and new values of the registry, respectively.

Parameters:
registry - The new OperationRegistry to be set; it may be null.

getParameterBlock

public ParameterBlock getParameterBlock()
Returns the ParameterBlock of the associated node by reference. Nodes desirous of maintaining a consistent state for their ParameterBlock may prefer to clone the value returned by this method.


setParameterBlock

public void setParameterBlock(ParameterBlock pb)
Sets the ParameterBlock of the associated node by reference. If the specified ParameterBlock is null, it is assumed that the associated node has neither input sources nor parameters. Nodes desirous of maintaining a consistent state for their ParameterBlock may prefer to clone any user-supplied ParameterBlock before passing it to this method.

This method does not validate the content of the supplied ParameterBlock. The caller should ensure that the sources and parameters in the ParameterBlock are suitable for the operation the associated node represents; otherwise some form of error or exception may occur at the time of rendering.

If the ParameterBlock changes according to a comparison of the sources and parameters Vectors of the old and new ParameterBlocks using equals(), a PropertyChangeEventJAI named "ParameterBlock" will be fired by the event helper object with old and new values set to the old and new values of the ParameterBlock, respectively. A PropertyChangeEventJAI named "Sources" or "Parameters" will instead be fired if it can be determined that the ParameterBlock modification has affected only the sources or parameters of the node, respectively.

The ParameterBlock may include DeferredData parameters. These will not be evaluated until their values are actually required, i.e., when the node is rendered. Any Observable events generated by such DeferredData parameters will be trapped by the node, converted to a PropertyChangeEventJAI named "parameters", and forwarded to any listeners registered with the supplied. eventManager. The old and new values of the event object so generated will be the previous and current values, respectively, of the data object wrapped by the DeferredData parameter, and thus will be instances of the class returned by the getDataClass() method of the DeferredData parameter.

Parameters:
pb - The new ParameterBlock to be set; it may be null.

getRenderingHints

public RenderingHints getRenderingHints()
Returns the RenderingHints of the associated node by reference. Nodes desirous of maintaining a consistent state for their RenderingHints may prefer to clone the value returned by this method.


setRenderingHints

public void setRenderingHints(RenderingHints hints)
Sets the RenderingHints of the associated node. It is legal for nodes to ignore RenderingHints set on them by this mechanism. Nodes desirous of maintaining a consistent state for their RenderingHints may prefer to clone any user-supplied RenderingHints before passing it to this method.

If the RenderingHints changes according to a comparison by equals() of the old and new hints, a PropertyChangeEventJAI named "RenderingHints" will be fired by the event helper object with old and new values set to the old and new values of the RenderingHints, respectively.

Parameters:
hints - The new RenderingHints to be set; it may be null.

addPropertyGenerator

public void addPropertyGenerator(PropertyGenerator pg)
Adds a PropertyGenerator to the node. The property values emitted by this property generator override any previous definitions.

Parameters:
pg - A PropertyGenerator to be added to the associated node's property environment.
Throws:
IllegalArgumentException - if pg is null.

copyPropertyFromSource

public void copyPropertyFromSource(String propertyName,
                                   int sourceIndex)
Forces a property to be copied from the specified source node. By default, a property is copied from the first source node that that emits it. The result of specifying an invalid source is undefined.

Parameters:
propertyName - the name of the property to be copied.
sourceIndex - the index of the source to copy the property from.
Throws:
IllegalArgumentException - if propertyName is null.

suppressProperty

public void suppressProperty(String name)
Removes a named property from the property environment of the associated node. Unless the property is stored locally either due to having been set explicitly or to having been cached for property synchronization purposes, subsequent calls to getProperty(name) will return java.awt.Image.UndefinedProperty, and name will not appear on the list of properties emitted by getPropertyNames().

Parameters:
name - A String naming the property to be suppressed.
Throws:
IllegalArgumentException - if name is null.

getPropertySource

public PropertySource getPropertySource(OperationNode opNode,
                                        PropertySource defaultPS)
Constructs and returns a PropertySource suitable for use by the specified OperationNode. If the registry mode identified by getRegistryModeName() supports properties, i.e., the statement
 Registry.getMode(getRegistryModeName()).arePropertiesSupported()
 
evaluates to true, then the PropertySource will include the global property environment as managed by the OperationRegistry for the corresponding operation. Prior and subsequent modifications to the local property environment made via this object will be reflected in the returned PropertySource.

Parameters:
opNode - the OperationNode requesting its PropertySource.
defaultPS - a PropertySource to be used to derive property values if and only if they would otherwise be derived by inheritance from a source rather than from a a PropertyGenerator or a copy-from-source directive.
Returns:
A PropertySource including the local and, if applicable, the global property environment for the operation.
Throws:
IllegalArgumentException - if opNode is null.
See Also:
RegistryMode, OperationRegistry.getPropertySource(OperationNode op)

resetPropertyEnvironment

public void resetPropertyEnvironment(boolean resetLocalEnvironment)
Resets the property environment. The list of local property environment modifications made directly on this object is reset if and only if the parameter is true.

Parameters:
resetLocalEnvironment - Whether to clear the list of property environment changes made directly on this object.