java.lang.Object | |
↳ | java.awt.image.renderable.ParameterBlock |
A 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
ParameterBlock
s 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));
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
parameters | A Vector of non-source parameters, stored as arbitrary Objects. | ||||||||||
sources | A Vector of sources, stored as arbitrary Objects. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
A dummy constructor.
| |||||||||||
Constructs a
ParameterBlock with a given Vector
of sources. | |||||||||||
Constructs a
ParameterBlock with a given Vector of sources and
Vector of parameters. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a Double to the list of parameters.
| |||||||||||
Adds an object to the list of parameters.
| |||||||||||
Adds a Long to the list of parameters.
| |||||||||||
Adds a Integer to the list of parameters.
| |||||||||||
Adds a Character to the list of parameters.
| |||||||||||
Adds a Byte to the list of parameters.
| |||||||||||
Adds a Short to the list of parameters.
| |||||||||||
Adds a Float to the list of parameters.
| |||||||||||
Adds an image to end of the list of sources.
| |||||||||||
Creates a copy of a
ParameterBlock . | |||||||||||
A convenience method to return a parameter as a byte.
| |||||||||||
A convenience method to return a parameter as a char.
| |||||||||||
A convenience method to return a parameter as a double.
| |||||||||||
A convenience method to return a parameter as a float.
| |||||||||||
A convenience method to return a parameter as an int.
| |||||||||||
A convenience method to return a parameter as a long.
| |||||||||||
Returns the number of parameters (not including source images).
| |||||||||||
Returns the number of source images.
| |||||||||||
Gets a parameter as an object.
| |||||||||||
Returns an array of Class objects describing the types
of the parameters.
| |||||||||||
Returns the entire Vector of parameters.
| |||||||||||
Returns a source as a RenderableImage.
| |||||||||||
Returns a source as a
RenderedImage . | |||||||||||
A convenience method to return a parameter as a short.
| |||||||||||
Returns a source as a general Object.
| |||||||||||
Returns the entire Vector of sources.
| |||||||||||
Clears the list of parameters.
| |||||||||||
Clears the list of source images.
| |||||||||||
Replaces an Object in the list of parameters with a Double.
| |||||||||||
Replaces an Object in the list of parameters with a Character.
| |||||||||||
Replaces an Object in the list of parameters with an Integer.
| |||||||||||
Replaces an Object in the list of parameters with a Byte.
| |||||||||||
Replaces an Object in the list of parameters.
| |||||||||||
Replaces an Object in the list of parameters with a Float.
| |||||||||||
Replaces an Object in the list of parameters with a Long.
| |||||||||||
Replaces an Object in the list of parameters with a Short.
| |||||||||||
Sets the entire Vector of parameters to a given Vector.
| |||||||||||
Replaces an entry in the list of source with a new source.
| |||||||||||
Sets the entire Vector of sources to a given Vector.
| |||||||||||
Creates a shallow copy of a
ParameterBlock . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
A dummy constructor.
Constructs a ParameterBlock
with a given Vector
of sources.
sources | a Vector of source images
|
---|
Constructs a ParameterBlock
with a given Vector of sources and
Vector of parameters.
sources | a Vector of source images |
---|---|
parameters | a Vector of parameters to be used in the
rendering operation
|
Adds a Double to the list of parameters.
d | the double to add to the
parameters Vector |
---|
ParameterBlock
containing
the specified parameter.
Adds an object to the list of parameters.
obj | the Object to add to the
parameters Vector |
---|
ParameterBlock
containing
the specified parameter.
Adds a Long to the list of parameters.
l | the long to add to the
parameters Vector |
---|
ParameterBlock
containing
the specified parameter.
Adds a Integer to the list of parameters.
i | the int to add to the
parameters Vector |
---|
ParameterBlock
containing
the specified parameter.
Adds a Character to the list of parameters.
c | the char to add to the
parameters Vector |
---|
ParameterBlock
containing
the specified parameter.
Adds a Byte to the list of parameters.
b | the byte to add to the
parameters Vector |
---|
ParameterBlock
containing
the specified parameter.
Adds a Short to the list of parameters.
s | the short to add to the
parameters Vector |
---|
ParameterBlock
containing
the specified parameter.
Adds a Float to the list of parameters.
f | the float to add to the
parameters Vector |
---|
ParameterBlock
containing
the specified parameter.
Adds an image to end of the list of sources. The image is stored as an object in order to allow new node types in the future.
source | an image object to be stored in the source list. |
---|
ParameterBlock
containing the specified
source
.
Creates a copy of a 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.
ParameterBlock
.
A convenience method to return a parameter as a byte. An
exception is thrown if the parameter is
null
or not a Byte
.
index | the index of the parameter to be returned. |
---|
byte
value.ClassCastException | if the parameter at the
specified index is not a Byte |
---|---|
NullPointerException | if the parameter at the specified
index is null |
ArrayIndexOutOfBoundsException | if index
is negative or not less than the current size of this
ParameterBlock object
|
A convenience method to return a parameter as a char. An
exception is thrown if the parameter is
null
or not a Character
.
index | the index of the parameter to be returned. |
---|
char
value.ClassCastException | if the parameter at the
specified index is not a Character |
---|---|
NullPointerException | if the parameter at the specified
index is null |
ArrayIndexOutOfBoundsException | if index
is negative or not less than the current size of this
ParameterBlock object
|
A convenience method to return a parameter as a double. An
exception is thrown if the parameter is
null
or not a Double
.
index | the index of the parameter to be returned. |
---|
double
value.ClassCastException | if the parameter at the
specified index is not a Double |
---|---|
NullPointerException | if the parameter at the specified
index is null |
ArrayIndexOutOfBoundsException | if index
is negative or not less than the current size of this
ParameterBlock object
|
A convenience method to return a parameter as a float. An
exception is thrown if the parameter is
null
or not a Float
.
index | the index of the parameter to be returned. |
---|
float
value.ClassCastException | if the parameter at the
specified index is not a Float |
---|---|
NullPointerException | if the parameter at the specified
index is null |
ArrayIndexOutOfBoundsException | if index
is negative or not less than the current size of this
ParameterBlock object
|
A convenience method to return a parameter as an int. An
exception is thrown if the parameter is
null
or not an Integer
.
index | the index of the parameter to be returned. |
---|
int
value.ClassCastException | if the parameter at the
specified index is not a Integer |
---|---|
NullPointerException | if the parameter at the specified
index is null |
ArrayIndexOutOfBoundsException | if index
is negative or not less than the current size of this
ParameterBlock object
|
A convenience method to return a parameter as a long. An
exception is thrown if the parameter is
null
or not a Long
.
index | the index of the parameter to be returned. |
---|
long
value.ClassCastException | if the parameter at the
specified index is not a Long |
---|---|
NullPointerException | if the parameter at the specified
index is null |
ArrayIndexOutOfBoundsException | if index
is negative or not less than the current size of this
ParameterBlock object
|
Returns the number of parameters (not including source images).
parameters
Vector
.
Returns the number of source images.
sources
Vector
.
Gets a parameter as an object.
index | the index of the parameter to get |
---|
Object
representing the
the parameter at the specified index
into the parameters
Vector
.
Returns an array of Class objects describing the types of the parameters.
Class
objects.
Returns the entire Vector of parameters.
parameters
Vector
.Returns a source as a RenderableImage. This method is a convenience method. An exception will be thrown if the sources is not a RenderableImage.
index | the index of the source to be returned |
---|
RenderableImage
that represents the source
image that is at the specified index in the
sources
Vector
.
Returns a source as a RenderedImage
. This method is
a convenience method.
An exception will be thrown if the source is not a RenderedImage.
index | the index of the source to be returned |
---|
RenderedImage
that represents the source
image that is at the specified index in the
sources
Vector
.
A convenience method to return a parameter as a short. An
exception is thrown if the parameter is
null
or not a Short
.
index | the index of the parameter to be returned. |
---|
short
value.ClassCastException | if the parameter at the
specified index is not a Short |
---|---|
NullPointerException | if the parameter at the specified
index is null |
ArrayIndexOutOfBoundsException | if index
is negative or not less than the current size of this
ParameterBlock object
|
Returns a source as a general Object. The caller must cast it into an appropriate type.
index | the index of the source to be returned. |
---|
Object
that represents the source located
at the specified index in the sources
Vector
.Clears the list of parameters.
Clears the list of source images.
Replaces an Object in the list of parameters with a Double. If the index lies beyond the current source list, the list is extended with nulls as needed.
d | the parameter that replaces the
parameter at the specified index in the
parameters Vector |
---|---|
index | the index of the parameter to be replaced with the specified parameter |
ParameterBlock
containing
the specified parameter.
Replaces an Object in the list of parameters with a Character. If the index lies beyond the current source list, the list is extended with nulls as needed.
c | the parameter that replaces the
parameter at the specified index in the
parameters Vector |
---|---|
index | the index of the parameter to be replaced with the specified parameter |
ParameterBlock
containing
the specified parameter.
Replaces an Object in the list of parameters with an Integer. If the index lies beyond the current source list, the list is extended with nulls as needed.
i | the parameter that replaces the
parameter at the specified index in the
parameters Vector |
---|---|
index | the index of the parameter to be replaced with the specified parameter |
ParameterBlock
containing
the specified parameter.
Replaces an Object in the list of parameters with a Byte. If the index lies beyond the current source list, the list is extended with nulls as needed.
b | the parameter that replaces the
parameter at the specified index in the
parameters Vector |
---|---|
index | the index of the parameter to be replaced with the specified parameter |
ParameterBlock
containing
the specified parameter.
Replaces an Object in the list of parameters. If the index lies beyond the current source list, the list is extended with nulls as needed.
obj | the parameter that replaces the
parameter at the specified index in the
parameters Vector |
---|---|
index | the index of the parameter to be replaced with the specified parameter |
ParameterBlock
containing
the specified parameter.
Replaces an Object in the list of parameters with a Float. If the index lies beyond the current source list, the list is extended with nulls as needed.
f | the parameter that replaces the
parameter at the specified index in the
parameters Vector |
---|---|
index | the index of the parameter to be replaced with the specified parameter |
ParameterBlock
containing
the specified parameter.
Replaces an Object in the list of parameters with a Long. If the index lies beyond the current source list, the list is extended with nulls as needed.
l | the parameter that replaces the
parameter at the specified index in the
parameters Vector |
---|---|
index | the index of the parameter to be replaced with the specified parameter |
ParameterBlock
containing
the specified parameter.
Replaces an Object in the list of parameters with a Short. If the index lies beyond the current source list, the list is extended with nulls as needed.
s | the parameter that replaces the
parameter at the specified index in the
parameters Vector |
---|---|
index | the index of the parameter to be replaced with the specified parameter |
ParameterBlock
containing
the specified parameter.
Sets the entire Vector of parameters to a given Vector.
parameters | the specified Vector of
parameters |
---|
Replaces an entry in the list of source with a new source. If the index lies beyond the current source list, the list is extended with nulls as needed.
source | the specified source image |
---|---|
index | the index into the sources
Vector at which to
insert the specified source |
ParameterBlock
that contains the
specified source
at the specified
index
.Sets the entire Vector of sources to a given Vector.
sources | the Vector of source images |
---|
Creates a shallow copy of a ParameterBlock
. The source and
parameter Vectors are copied by reference -- additions or
changes will be visible to both versions.
ParameterBlock
.