|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.media.jai.RenderableOp
A node in a renderable imaging chain. This is the Java Advanced
Imaging version of the Java2D class RenderableImageOp
.
Instead of an explicit ContextualRenderedImageFactory
,
the indirection of the OperationRegistry
is used.
A RenderableOp
stores an operation name and a
ParameterBlock
containing sources and parameters. A set of
nodes may be joined together via the source Vector
s within
their respective ParameterBlock
s to form a directed
acyclic graph (DAG). The topology, i.e., connectivity, of
the graph may be altered by changing the node's sources. The operation
name and parameters may also be changed.
Such chains provide a framework for resolution- and rendering- independent imaging. They are useful in that a chain may be manipulated dynamically and rendered multiple times. Thus for example the same chain of operations may be applied to different images or the parameters of certain operations in a chain may be modified interactively.
A RenderableOp
may be constructed directly as, for example,
RenderableImage addend1;
RenderableImage addend2;
ParameterBlock pb =
(new ParameterBlock()).addSource(addend1).addSource(addend2);
RenderableOp node = new RenderableOp("add", pb);
or via the createRenderable()
or
createRenderableNS()
methods defined in the JAI
class. The difference between direct construction of a node and creation
via a convenience method is that in the latter case:
validateArguments()
method of the associated
OperationDescriptor
, the arguments (sources and parameters)
are validated as being compatible with the specified operation.RenderingHints
maintained by the JAI
instance are set on the RenderableOp
using
setRenderingHints()
. When a chain of nodes is rendered by any any of the
createRendering()
methods, a "parallel" chain of
RenderedImage
s is created. Each node in the chain of
RenderableOp
s corresponds to a node in the chain of
RenderedImage
s. A RenderedImage
associated
with a given node is referred to as a rendering of the node.
The translation between RenderableOp
chains and
RenderedImage
(usually OpImage
) chains makes
use of three levels of indirection provided by the
OperationRegistry
, ContextualRenderedImageFactory
,
(CRIF), and RenderedImageFactory
(RIF) facilities. First, the
OperationRegistry
is used to map the operation name into a
CRIF. This CRIF then constructs a RenderedImage
via its
create(RenderContext, ParameterBlock)
method. The third
level of indirection results from the operation name being mapped within
create()
into the optimum RIF which actually creates the
RenderedImage
. (Note that this third level of indirection is a
function of the CRIF implementation of the renderable create()
method: that provided by the convenience class CRIFImpl
provides this indirection.) If the RenderedImage
returned by
the CRIF create()
invocation is a RenderedOp
, it
is replaced with the rendering of the RenderedOp
(usually an
OpImage
).
RenderingHints
may be set on a RenderableOp
to provide a set of common hints to be used in all invocations of the
various createRendering()
methods on the node. These hints
are merged with any hints supplied to createRendering()
either explicitly or via a RenderContext
. Directly
supplied hints take precedence over the common hints.
RenderableOp
nodes may participate in Java Bean-style
events. The PropertyChangeEmitter
methods may be used
to register and unregister PropertyChangeListener
s.
Certain PropertyChangeEvent
s may be emitted by the
RenderableOp
. These include the
PropertyChangeEventJAI
s and
PropertySourceChangeEvent
s required by virtue of implementing
the OperationNode
interface.
RenderableOp
nodes are WritablePropertySource
s
and so manage a name-value database of image meta-data also known as image
properties. Properties may be set on and requested from a node. The
value of a property not explicitly set on the node (via
setProperty()
) is obtained from the property environment of
the node. When a property is derived from the property environment it is
cached locally to ensure synchronization, i.e., that properties do not
change spontaneously if for example the same property is modified upstream.
The property environment of the RenderableOp
is initially
derived from that of the corresponding OperationDescriptor
as maintained by the OperationRegistry
. It may be modified
locally by adding a PropertyGenerator
or by suppressing a
specific property. These modifications cannot be undone.
When a property value is requested an attempt will be made to derive it from the several entities in the following order of precedence:
PropertyGenerator
s, or
setProperty()
or due to caching of a
property derived from the property environment.
The properties of a RenderableOp
node are copied to each
rendering generated by any of the createRendering()
methods.
Properties already set on the rendering are not copied, i.e., those of the
rendering take precedence.
A RenderableOp
chain created on a client may be passed
to a server via a RemoteImage
. Any RenderedImage
sources which are not Serializable
will be wrapped in
SerializableRenderedImage
s for serialization. The tile
transmission parameters will be determined from the common
RenderingHints
of the node. All other non-serializable
objects will attempt to be serialized using
SerializerFactory
. If no Serializer
is
available for a particular object, a
java.io.NotSerializableException
may result. Image
properties (meta-data) are serialized insofar as they are serializable:
non-serializable components are simply eliminated from the local cache
of properties and from the property environment.
CRIFImpl
,
CollectionOp
,
OperationRegistry
,
RenderedOp
,
RenderingHints
,
ContextualRenderedImageFactory
,
RenderableImageOp
,
RenderContext
, Serialized FormField Summary | |
protected ContextualRenderedImageFactory |
crif
The ContextualRenderedImageFactory used to
generate renderings. |
protected PropertyChangeSupportJAI |
eventManager
A helper object to manage firing events. |
protected OperationNodeSupport |
nodeSupport
An object to assist in implementing OperationNode . |
protected WritablePropertySourceImpl |
properties
A helper object to manage the image properties. |
protected PropertySource |
thePropertySource
The PropertySource containing the combined properties
of all of the node's sources. |
Fields inherited from interface java.awt.image.renderable.RenderableImage |
HINTS_OBSERVED |
Constructor Summary | |
RenderableOp(OperationRegistry registry,
String opName,
ParameterBlock pb)
Constructs a RenderableOp given the name of the operation to be performed and a ParameterBlock containing RenderableImage sources and other parameters. |
|
RenderableOp(OperationRegistry registry,
String opName,
ParameterBlock pb,
RenderingHints hints)
Constructs a RenderableOp given the name of the operation to be performed and a ParameterBlock containing RenderableImage sources and other parameters. |
|
RenderableOp(String opName,
ParameterBlock pb)
Constructs a RenderableOp given the name of the operation to be performed and a ParameterBlock containing RenderableImage sources and other parameters. |
Method Summary | |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. |
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Add a PropertyChangeListener for a specific property. |
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. |
RenderedImage |
createDefaultRendering()
Returns a default rendering of this RenderableImage . |
RenderedImage |
createRendering(RenderContext renderContext)
Gets a RenderedImage that represents a rendering of this image using a given RenderContext. |
RenderedImage |
createScaledRendering(int w,
int h,
RenderingHints hints)
Gets a RenderedImage instance of this image with width w, and height h in pixels. |
byte |
getByteParameter(int index)
Returns one of the node's parameters, as a byte. |
char |
getCharParameter(int index)
Returns one of the node's parameters, as a char. |
double |
getDoubleParameter(int index)
Returns one of the node's parameters, as a double. |
Object |
getDynamicProperty(String name)
Returns the property associated with the specified property name, or java.awt.Image.UndefinedProperty if the specified
property is not set on the image. |
float |
getFloatParameter(int index)
Returns one of the node's parameters, as a float. |
float |
getHeight()
Return the rendering-independent height of the image. |
int |
getIntParameter(int index)
Returns one of the node's parameters, as an int. |
long |
getLongParameter(int index)
Returns one of the node's parameters, as a long. |
float |
getMinX()
Gets the minimum X coordinate of the rendering-independent image data. |
float |
getMinY()
Gets the minimum Y coordinate of the rendering-independent image data. |
Object |
getObjectParameter(int index)
Returns one of the node's parameters, as an Object. |
String |
getOperationName()
Returns the name of the operation this node represents as a String . |
ParameterBlock |
getParameterBlock()
Returns a clone of the ParameterBlock of this node. |
Object |
getProperty(String name)
Gets a property from the property set of this image. |
Class |
getPropertyClass(String name)
Returns the class expected to be returned by a request for the property with the specified name. |
String[] |
getPropertyNames()
Returns the names of properties available from this node. |
String[] |
getPropertyNames(String prefix)
Returns an array of String s recognized as names by
this property source that begin with the supplied prefix. |
OperationRegistry |
getRegistry()
Returns the OperationRegistry that is used
by this node. |
String |
getRegistryModeName()
Returns the name of the RegistryMode corresponding to
this RenderableOp . |
RenderingHints |
getRenderingHints()
Returns a clone of the common RenderingHints of this node
or null . |
short |
getShortParameter(int index)
Returns one of the node's parameters, as a short. |
Object |
getSource(int index)
Returns one of the node's sources as an Object. |
Vector |
getSources()
Returns a vector of RenderableImages that are the sources of image data for this RenderableImage. |
float |
getWidth()
Return the rendering-independent width of the image. |
boolean |
isDynamic()
Returns false, i.e., successive renderings with the same arguments will produce identical results. |
void |
removeProperty(String name)
Removes the named property from the local property set of the RenderableOp as well as from its property
environment. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. |
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Remove a PropertyChangeListener for a specific property. |
void |
removeSources()
Removes all the node's sources. |
void |
setOperationName(String opName)
Sets the name of the operation this node represents. |
void |
setParameter(byte param,
int index)
Sets one of the node's parameters to a byte. |
void |
setParameter(char param,
int index)
Sets one of the node's parameters to a char. |
void |
setParameter(double param,
int index)
Sets one of the node's parameters to a double. |
void |
setParameter(float param,
int index)
Sets one of the node's parameters to a float. |
void |
setParameter(int param,
int index)
Sets one of the node's parameters to an int. |
void |
setParameter(long param,
int index)
Sets one of the node's parameters to a long. |
void |
setParameter(Object param,
int index)
Sets one of the node's parameters to an Object. |
void |
setParameter(short param,
int index)
Sets one of the node's parameters to a short. |
void |
setParameterBlock(ParameterBlock pb)
Sets the ParameterBlock of this node. |
void |
setProperty(String name,
Object value)
Sets a local property on a node. |
void |
setRegistry(OperationRegistry registry)
Sets the OperationRegistry that is used by
this node. |
void |
setRenderingHints(RenderingHints hints)
Sets the common RenderingHints of this node. |
void |
setSource(Object source,
int index)
Sets one of the node's sources to an Object. |
void |
suppressProperty(String name)
Removes a named property from the property environment of this node. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected PropertyChangeSupportJAI eventManager
protected WritablePropertySourceImpl properties
protected OperationNodeSupport nodeSupport
OperationNode
.protected transient PropertySource thePropertySource
PropertySource
containing the combined properties
of all of the node's sources.protected transient ContextualRenderedImageFactory crif
ContextualRenderedImageFactory
used to
generate renderings.Constructor Detail |
public RenderableOp(OperationRegistry registry, String opName, ParameterBlock pb, RenderingHints hints)
The ParameterBlock
may include
DeferredData
parameters. These will not be evaluated
until their values are actually required, i.e., when a rendering of
the node is requested or the renderable dimensions are queried.
registry
- The OperationRegistry
to be used for
instantiation. if null
, the default registry
is used. Saved by reference.opName
- The operation name. Saved by reference.pb
- The sources and other parameters. If null
,
it is assumed that this node has no sources and parameters.
This parameter is cloned.hints
- The common node RenderingHints
to be set;
it may be null
.
This parameter is cloned.opName
is
null
.public RenderableOp(OperationRegistry registry, String opName, ParameterBlock pb)
The ParameterBlock
may include
DeferredData
parameters. These will not be evaluated
until their values are actually required, i.e., when a rendering of
the node is requested or the renderable dimensions are queried.
registry
- The OperationRegistry
to be used for
instantiation. if null
, the default registry
is used. Saved by reference.opName
- The operation name. Saved by reference.pb
- The sources and other parameters. If null
,
it is assumed that this node has no sources and parameters.
This parameter is cloned.opName
is
null
.public RenderableOp(String opName, ParameterBlock pb)
The ParameterBlock
may include
DeferredData
parameters. These will not be evaluated
until their values are actually required, i.e., when a rendering of
the node is requested or the renderable dimensions are queried.
opName
- The operation name. Saved by reference.pb
- The sources and other parameters. If null
,
it is assumed that this node has no sources and parameters.
This parameter is cloned.opName
is null
.Method Detail |
public String getRegistryModeName()
RegistryMode
corresponding to
this RenderableOp
. This method always returns the
String
"renderable".public OperationRegistry getRegistry()
OperationRegistry
that is used
by this node. If the registry had not been set, the default
registry is returned.public void setRegistry(OperationRegistry registry)
OperationRegistry
that is used by
this node. If the specified registry is null
, the
default registry is used.
If the supplied registry does not equal the current registry, a
PropertyChangeEventJAI
named "OperationRegistry"
will be fired
registry
- The new OperationRegistry
to be set;
it may be null
.public String getOperationName()
String
.public void setOperationName(String opName)
If the supplied name does not equal the current operation name, a
PropertyChangeEventJAI
named "OperationName"
will be fired.
opName
- The new operation name to be set.opName
is
null
.public ParameterBlock getParameterBlock()
ParameterBlock
of this node.public void setParameterBlock(ParameterBlock pb)
ParameterBlock
of this node.
If the specified new ParameterBlock
is null
,
it is assumed that this node has no input sources and parameters.
The supplied parameter is cloned.
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 this node represents; otherwise
some form of error or exception may occur at the time of rendering.
If the supplied ParameterBlock
does not equal the
current ParameterBlock
, a
PropertyChangeEventJAI
named "ParameterBlock", "Sources",
or "Parameters" will be fired.
The ParameterBlock
may include
DeferredData
parameters. These will not be evaluated
until their values are actually required, i.e., when a rendering of
the node is requested or the renderable dimensions are queried.
pb
- The new ParameterBlock
to be set;
it may be null
.public RenderingHints getRenderingHints()
RenderingHints
of this node
or null
.public void setRenderingHints(RenderingHints hints)
RenderingHints
of this node.
The supplied parameter is cloned if non-null
.
If the supplied RenderingHints
does not equal the
current RenderingHints
, a
PropertyChangeEventJAI
named "RenderingHints"
will be fired.
hints
- The new RenderingHints
to be set;
it may be null
.public Vector getSources()
public float getWidth()
public float getHeight()
public float getMinX()
public float getMinY()
public RenderedImage createDefaultRendering()
RenderableImage
.
In all cases the area of interest will equal the image bounds.
Any hints set on the node via setRenderingHints()
will
be used.
The dimensions of the created RenderedImage
are
determined in the following order of precedence:
JAI.KEY_DEFAULT_RENDERING_SIZE
hint is set on
the node it is used unless both its dimensions are non-positive.JAI.getDefaultRenderingSize()
is used unless it is null
.
JAI
instance may be non-positive in which case
the other dimension and the renderable aspect ratio will be used to
compute the rendered image size.
This method does not validate sources and parameters supplied
in the ParameterBlock
supplied at construction against
the specification of the operation this node represents. It is the
caller's responsibility to ensure that the data in the
ParameterBlock
are suitable for this operation.
Otherwise, some kind of exception or error will occur. Invoking this
method will cause any DeferredData
parameters to be
evaluated.
public RenderedImage createScaledRendering(int w, int h, RenderingHints hints)
setRenderingHints()
with the hints passed in taking
precedence.
If w == 0, it will be taken to equal Math.round(h*(getWidth()/getHeight())). Similarly, if h == 0, it will be taken to equal Math.round(w*(getHeight()/getWidth())). One of w or h must be non-zero or else an IllegalArgumentException will be thrown.
This method does not validate sources and parameters supplied
in the ParameterBlock
supplied at construction against
the specification of the operation this node represents. It is the
caller's responsibility to ensure that the data in the
ParameterBlock
are suitable for this operation.
Otherwise, some kind of exception or error will occur. Invoking this
method will cause any DeferredData
parameters to be
evaluated.
w
- the width of rendered image in pixels, or 0.h
- the height of rendered image in pixels, or 0.hints
- a RenderingHints object containg hints.public RenderedImage createRendering(RenderContext renderContext)
This method does not validate sources and parameters supplied
in the ParameterBlock
supplied at construction against
the specification of the operation this node represents. It is the
caller's responsibility to ensure that the data in the
ParameterBlock
are suitable for this operation.
Otherwise, some kind of exception or error will occur. Invoking this
method will cause any DeferredData
parameters to be
evaluated.
The RenderContext
may contain a Shape
that represents the area-of-interest (aoi). If the aoi is specifed,
it is still legal to return an image that's larger than this aoi.
Therefore, by default, the aoi, if specified, is ignored at the
rendering.
Any hints in the RenderContext
will be merged with any
set on the node via setRenderingHints()
with the hints
in the RenderContext
taking precedence.
renderContext
- the RenderContext to use to produce the rendering.public boolean isDynamic()
public String[] getPropertyNames()
String
s containing valid
property names or null
if there are none.public String[] getPropertyNames(String prefix)
String
s recognized as names by
this property source that begin with the supplied prefix. If
no property names match, null
will be returned.
The comparison is done in a case-independent manner.String
s giving the valid
property names.public Class getPropertyClass(String name)
null
will be returned.Class
expected to be return by a
request for the value of this property or null
.name
is null
.public Object getProperty(String name)
java.awt.Image.UndefinedProperty
will be returned.name
- the name of the property to get, as a String.name
is null
.public void setProperty(String name, Object value)
If the node is serialized then serializable properties will also be serialized but non-serializable properties will be lost.
name
- a String representing the property name.value
- the property's value, as an Object.name
or value
is null
.public void removeProperty(String name)
RenderableOp
as well as from its property
environment.name
is null
.public Object getDynamicProperty(String name)
java.awt.Image.UndefinedProperty
if the specified
property is not set on the image. This method is dynamic in the
sense that subsequent invocations of this method on the same object
may return different values as a function of changes in the property
environment of the node, e.g., a change in which
PropertyGenerator
s are registered or in the values
associated with properties of node sources. The case of the property
name passed to this method is ignored.name
- A String
naming the property.name
is null
.public void addPropertyGenerator(PropertyGenerator pg)
pg
- a PropertyGenerator to be added to this node's
property environment.public void copyPropertyFromSource(String propertyName, int sourceIndex)
propertyName
- the name of the property to be copied.sourceIndex
- the index of the from which to copy the property.propertyName
is
null
.public void suppressProperty(String name)
setProperty()
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()
. To delete the property from the
local property set of the node, removeProperty()
should
be used.name
- a String naming the property to be suppressed.IllegalArgumentException
- if
name
is null
.public void addPropertyChangeListener(PropertyChangeListener listener)
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
public void removePropertyChangeListener(PropertyChangeListener listener)
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
public Object getSource(int index)
index
- the index of the source.public void setSource(Object source, int index)
setParameterBlock()
and so adheres to the same event
firing behavior.source
- the source, as an Object.index
- the index of the source.source
is
null
.public void removeSources()
setParameterBlock()
and so adheres to the same event
firing behavior.public byte getByteParameter(int index)
index
- the index of the parameter.public char getCharParameter(int index)
index
- the index of the parameter.public short getShortParameter(int index)
index
- the index of the parameter.public int getIntParameter(int index)
index
- the index of the parameter.public long getLongParameter(int index)
index
- the index of the parameter.public float getFloatParameter(int index)
index
- the index of the parameter.public double getDoubleParameter(int index)
index
- the index of the parameter.public Object getObjectParameter(int index)
index
- the index of the parameter.public void setParameter(byte param, int index)
setParameter(Object,int)
and so adheres to the same event
firing behavior.param
- the parameter, as a byte.index
- the index of the parameter.public void setParameter(char param, int index)
setParameter(Object,int)
and so adheres to the same event
firing behavior.param
- the parameter, as a char.index
- the index of the parameter.public void setParameter(short param, int index)
setParameter(Object,int)
and so adheres to the same event
firing behavior.param
- the parameter, as a short.index
- the index of the parameter.public void setParameter(int param, int index)
setParameter(Object,int)
and so adheres to the same event
firing behavior.param
- the parameter, as an int.index
- the index of the parameter.public void setParameter(long param, int index)
setParameter(Object,int)
and so adheres to the same event
firing behavior.param
- the parameter, as a long.index
- the index of the parameter.public void setParameter(float param, int index)
setParameter(Object,int)
and so adheres to the same event
firing behavior.param
- the parameter, as a float.index
- the index of the parameter.public void setParameter(double param, int index)
setParameter(Object,int)
and so adheres to the same event
firing behavior.param
- the parameter, as a double.index
- the index of the parameter.public void setParameter(Object param, int index)
setParameterBlock()
and so adheres to the same event
firing behavior.
The Object
may be a
DeferredData
instance. It will not be evaluated
until its value is actually required, i.e., when a rendering of
the node is requested or the renderable dimensions are queried.
param
- the parameter, as an Object.index
- the index of the parameter.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |