java.lang.Objectjava.awt.image.renderable.ParameterBlock
All Implemented Interfaces:
Cloneable, Serializable
ParameterBlock encapsulates all the information about sources and
parameters (Objects) required by a RenderableImageOp, or other
classes that process images.
Although it is possible to place arbitrary objects in the
source Vector, users of this class may impose semantic constraints
such as requiring all sources to be RenderedImages or
RenderableImage. ParameterBlock itself is merely a container and
performs no checking on source or parameter types.
All parameters in a ParameterBlock are objects; convenience
add and set methods are available that take arguments of base type and
construct the appropriate subclass of Number (such as
Integer or Float). Corresponding get methods perform a
downward cast and have return values of base type; an exception
will be thrown if the stored values do not have the correct type.
There is no way to distinguish between the results of
"short s; add(s)" and "add(new Short(s))".
Note that the get and set methods operate on references.
Therefore, one must be careful not to share references between
ParameterBlocks when this is inappropriate. For example, to create
a new ParameterBlock that is equal to an old one except for an
added source, one might be tempted to write:
ParameterBlock addSource(ParameterBlock pb, RenderableImage im) {
ParameterBlock pb1 = new ParameterBlock(pb.getSources());
pb1.addSource(im);
return pb1;
}
This code will have the side effect of altering the original
ParameterBlock, since the getSources operation returned a reference
to its source Vector. Both pb and pb1 share their source Vector,
and a change in either is visible to both.
A correct way to write the addSource function is to clone the source Vector:
ParameterBlock addSource (ParameterBlock pb, RenderableImage im) {
ParameterBlock pb1 = new ParameterBlock(pb.getSources().clone());
pb1.addSource(im);
return pb1;
}
The clone method of ParameterBlock has been defined to
perform a clone of both the source and parameter Vectors for
this reason. A standard, shallow clone is available as
shallowClone.
The addSource, setSource, add, and set methods are defined to return 'this' after adding their argument. This allows use of syntax like:
ParameterBlock pb = new ParameterBlock();
op = new RenderableImageOp("operation", pb.add(arg1).add(arg2));
| Field Summary | ||
|---|---|---|
| protected Vector | sources | A Vector of sources, stored as arbitrary Objects. |
| protected Vector | parameters | A Vector of non-source parameters, stored as arbitrary Objects. |
| Constructor: |
|---|
|
ParameterBlock with a given Vector
of sources.
|
ParameterBlock with a given Vector of sources and
Vector of parameters.
|
| Method from java.awt.image.renderable.ParameterBlock Summary: |
|---|
| add, add, add, add, add, add, add, add, addSource, clone, getByteParameter, getCharParameter, getDoubleParameter, getFloatParameter, getIntParameter, getLongParameter, getNumParameters, getNumSources, getObjectParameter, getParamClasses, getParameters, getRenderableSource, getRenderedSource, getShortParameter, getSource, getSources, removeParameters, removeSources, set, set, set, set, set, set, set, set, setParameters, setSource, setSources, shallowClone |
| Methods from java.lang.Object: |
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from java.awt.image.renderable.ParameterBlock Detail: |
|---|
|
|
|
|
|
|
|
|
|
ParameterBlock. The source and parameter
Vectors are cloned, but the actual sources and parameters are
copied by reference. This allows modifications to the order
and number of sources and parameters in the clone to be invisible
to the original ParameterBlock. Changes to the shared sources or
parameters themselves will still be visible. |
null or not a Byte. |
null or not a Character. |
null or not a Double. |
null or not a Float. |
null or not an Integer. |
null or not a Long. |
|
|
|
|
|
|
RenderedImage. This method is
a convenience method.
An exception will be thrown if the source is not a RenderedImage. |
null or not a Short. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParameterBlock. The source and
parameter Vectors are copied by reference -- additions or
changes will be visible to both versions. |