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(Short.valueOf(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));
| Modifier and Type | Field and Description |
|---|---|
| protected Vector | parameters
A Vector of non-source parameters, stored as arbitrary Objects. |
| private static final long | serialVersionUID
Use serialVersionUID from JDK 9 for interoperability. |
| protected Vector | sources
A Vector of sources, stored as arbitrary Objects. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | ParameterBlock(Vector<Object>
a sources)Vector of source imagesConstructs a |
| public | ParameterBlock(Vector<Object>
a sources, Vector<Object> Vector of source imagesa parameters)Vector of parameters to be used in the
rendering operationConstructs a |
| Modifier and Type | Method and Description |
|---|---|
| public ParameterBlock | |
| public ParameterBlock | Returns: a newParameterBlock containing
the specified parameter.the byte to add to the
b)parameters VectorAdds a Byte to the list of parameters. |
| public ParameterBlock | Returns: a newParameterBlock containing
the specified parameter.the char to add to the
c)parameters VectorAdds a Character to the list of parameters. |
| public ParameterBlock | Returns: a newParameterBlock containing
the specified parameter.the short to add to the
s)parameters VectorAdds a Short to the list of parameters. |
| public ParameterBlock | Returns: a newParameterBlock containing
the specified parameter.the int to add to the
i)parameters VectorAdds a Integer to the list of parameters. |
| public ParameterBlock | Returns: a newParameterBlock containing
the specified parameter.the long to add to the
l)parameters VectorAdds a Long to the list of parameters. |
| public ParameterBlock | Returns: a newParameterBlock containing
the specified parameter.the float to add to the
f)parameters VectorAdds a Float to the list of parameters. |
| public ParameterBlock | Returns: a newParameterBlock containing
the specified parameter.the double to add to the
d)parameters VectorAdds a Double to the list of parameters. |
| public ParameterBlock | |
| public Object | Returns: an Object clone of theParameterBlock.Overrides java. Creates a copy of a |
| public byte | Returns: the parameter at the specified index as abyte value.the index of the parameter to be returned. index)A convenience method to return a parameter as a byte. |
| public char | Returns: the parameter at the specified index as achar value.the index of the parameter to be returned. index)A convenience method to return a parameter as a char. |
| public double | Returns: the parameter at the specified index as adouble value.the index of the parameter to be returned. index)A convenience method to return a parameter as a double. |
| public float | Returns: the parameter at the specified index as afloat value.the index of the parameter to be returned. index)A convenience method to return a parameter as a float. |
| public int | Returns: the parameter at the specified index as anint value.the index of the parameter to be returned. index)A convenience method to return a parameter as an int. |
| public long | Returns: the parameter at the specified index as along value.the index of the parameter to be returned. index)A convenience method to return a parameter as a long. |
| public int | Returns: the number of parameters in theparameters
Vector.Returns the number of parameters (not including source images). |
| public int | Returns: the number of source images in thesources
Vector.Returns the number of source images. |
| public Object | Returns: anObject representing the
the parameter at the specified index
into the parameters
Vector.the index of the parameter to get index)Gets a parameter as an object. |
| public Class | Returns: an array ofClass objects.Returns an array of Class objects describing the types of the parameters. |
| public Vector | |
| public RenderableImage | Returns: aRenderableImage that represents the source
image that is at the specified index in the
sources Vector.the index of the source to be returned index)Returns a source as a RenderableImage. |
| public RenderedImage | Returns: aRenderedImage that represents the source
image that is at the specified index in the
sources Vector.the index of the source to be returned index)Returns a source as a |
| public short | Returns: the parameter at the specified index as ashort value.the index of the parameter to be returned. index)A convenience method to return a parameter as a short. |
| public Object | Returns: anObject that represents the source located
at the specified index in the sources
Vector.the index of the source to be returned. index)Returns a source as a general Object. |
| public Vector | |
| public void | |
| public void | |
| public ParameterBlock | |
| public ParameterBlock | Returns: a newParameterBlock containing
the specified parameter.the parameter that replaces the
parameter at the specified index in the
b, int parameters Vectorthe index of the parameter to be
replaced with the specified parameter index)Replaces an Object in the list of parameters with a Byte. |
| public ParameterBlock | Returns: a newParameterBlock containing
the specified parameter.the parameter that replaces the
parameter at the specified index in the
c, int parameters Vectorthe index of the parameter to be
replaced with the specified parameter index)Replaces an Object in the list of parameters with a Character. |
| public ParameterBlock | Returns: a newParameterBlock containing
the specified parameter.the parameter that replaces the
parameter at the specified index in the
s, int parameters Vectorthe index of the parameter to be
replaced with the specified parameter index)Replaces an Object in the list of parameters with a Short. |
| public ParameterBlock | Returns: a newParameterBlock containing
the specified parameter.the parameter that replaces the
parameter at the specified index in the
i, int parameters Vectorthe index of the parameter to be
replaced with the specified parameter index)Replaces an Object in the list of parameters with an Integer. |
| public ParameterBlock | Returns: a newParameterBlock containing
the specified parameter.the parameter that replaces the
parameter at the specified index in the
l, int parameters Vectorthe index of the parameter to be
replaced with the specified parameter index)Replaces an Object in the list of parameters with a Long. |
| public ParameterBlock | Returns: a newParameterBlock containing
the specified parameter.the parameter that replaces the
parameter at the specified index in the
f, int parameters Vectorthe index of the parameter to be
replaced with the specified parameter index)Replaces an Object in the list of parameters with a Float. |
| public ParameterBlock | Returns: a newParameterBlock containing
the specified parameter.the parameter that replaces the
parameter at the specified index in the
d, int parameters Vectorthe index of the parameter to be
replaced with the specified parameter index)Replaces an Object in the list of parameters with a Double. |
| public void | setParameters(Vector<Object>
the specified parameters)Vector of
parametersSets the entire Vector of parameters to a given Vector. |
| public ParameterBlock | |
| public void | setSources(Vector<Object>
the sources)Vector of source imagesSets the entire Vector of sources to a given Vector. |
| public Object | Returns: an Object clone of theParameterBlock.Creates a shallow copy of a |
| parameters | back to summary |
|---|---|
| protected Vector<Object> parameters A Vector of non-source parameters, stored as arbitrary Objects. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Use serialVersionUID from JDK 9 for interoperability. | |
| sources | back to summary |
|---|---|
| protected Vector<Object> sources A Vector of sources, stored as arbitrary Objects. | |
| ParameterBlock | back to summary |
|---|---|
| public ParameterBlock() A dummy constructor. | |
| ParameterBlock | back to summary |
|---|---|
| public ParameterBlock(Vector<Object> sources) Constructs a | |
| ParameterBlock | back to summary |
|---|---|
| public ParameterBlock(Vector<Object> sources, Vector<Object> parameters) Constructs a | |
| add | back to summary |
|---|---|
| public ParameterBlock add(Object obj) Adds an object to the list of parameters.
| |
| add | back to summary |
|---|---|
| public ParameterBlock add(byte b) Adds a Byte to the list of parameters.
| |
| add | back to summary |
|---|---|
| public ParameterBlock add(char c) Adds a Character to the list of parameters.
| |
| add | back to summary |
|---|---|
| public ParameterBlock add(short s) Adds a Short to the list of parameters.
| |
| add | back to summary |
|---|---|
| public ParameterBlock add(int i) Adds a Integer to the list of parameters.
| |
| add | back to summary |
|---|---|
| public ParameterBlock add(long l) Adds a Long to the list of parameters.
| |
| add | back to summary |
|---|---|
| public ParameterBlock add(float f) Adds a Float to the list of parameters.
| |
| add | back to summary |
|---|---|
| public ParameterBlock add(double d) Adds a Double to the list of parameters.
| |
| addSource | back to summary |
|---|---|
| public ParameterBlock addSource(Object source) 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.
| |
| clone | back to summary |
|---|---|
| public Object clone() Overrides java. Creates a copy of a
| |
| getByteParameter | back to summary |
|---|---|
| public byte getByteParameter(int index) A convenience method to return a parameter as a byte. An
exception is thrown if the parameter is
| |
| getCharParameter | back to summary |
|---|---|
| public char getCharParameter(int index) A convenience method to return a parameter as a char. An
exception is thrown if the parameter is
| |
| getDoubleParameter | back to summary |
|---|---|
| public double getDoubleParameter(int index) A convenience method to return a parameter as a double. An
exception is thrown if the parameter is
| |
| getFloatParameter | back to summary |
|---|---|
| public float getFloatParameter(int index) A convenience method to return a parameter as a float. An
exception is thrown if the parameter is
| |
| getIntParameter | back to summary |
|---|---|
| public int getIntParameter(int index) A convenience method to return a parameter as an int. An
exception is thrown if the parameter is
| |
| getLongParameter | back to summary |
|---|---|
| public long getLongParameter(int index) A convenience method to return a parameter as a long. An
exception is thrown if the parameter is
| |
| getNumParameters | back to summary |
|---|---|
| public int getNumParameters() Returns the number of parameters (not including source images).
| |
| getNumSources | back to summary |
|---|---|
| public int getNumSources() Returns the number of source images.
| |
| getObjectParameter | back to summary |
|---|---|
| public Object getObjectParameter(int index) Gets a parameter as an object.
| |
| getParamClasses | back to summary |
|---|---|
| public Class Returns an array of Class objects describing the types of the parameters.
| |
| getParameters | back to summary |
|---|---|
| public Vector Returns the entire Vector of parameters.
| |
| getRenderableSource | back to summary |
|---|---|
| public RenderableImage getRenderableSource(int index) Returns a source as a RenderableImage. This method is a convenience method. An exception will be thrown if the sources is not a RenderableImage.
| |
| getRenderedSource | back to summary |
|---|---|
| public RenderedImage getRenderedSource(int index) Returns a source as a
| |
| getShortParameter | back to summary |
|---|---|
| public short getShortParameter(int index) A convenience method to return a parameter as a short. An
exception is thrown if the parameter is
| |
| getSource | back to summary |
|---|---|
| public Object getSource(int index) Returns a source as a general Object. The caller must cast it into an appropriate type.
| |
| getSources | back to summary |
|---|---|
| public Vector Returns the entire Vector of sources.
| |
| removeParameters | back to summary |
|---|---|
| public void removeParameters() Clears the list of parameters. | |
| removeSources | back to summary |
|---|---|
| public void removeSources() Clears the list of source images. | |
| set | back to summary |
|---|---|
| public ParameterBlock set(Object obj, int index) 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.
| |
| set | back to summary |
|---|---|
| public ParameterBlock set(byte b, int index) 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.
| |
| set | back to summary |
|---|---|
| public ParameterBlock set(char c, int index) 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.
| |
| set | back to summary |
|---|---|
| public ParameterBlock set(short s, int index) 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.
| |
| set | back to summary |
|---|---|
| public ParameterBlock set(int i, int index) 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.
| |
| set | back to summary |
|---|---|
| public ParameterBlock set(long l, int index) 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.
| |
| set | back to summary |
|---|---|
| public ParameterBlock set(float f, int index) 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.
| |
| set | back to summary |
|---|---|
| public ParameterBlock set(double d, int index) 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.
| |
| setParameters | back to summary |
|---|---|
| public void setParameters(Vector<Object> parameters) Sets the entire Vector of parameters to a given Vector.
| |
| setSource | back to summary |
|---|---|
| public ParameterBlock setSource(Object source, int index) 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.
| |
| setSources | back to summary |
|---|---|
| public void setSources(Vector<Object> sources) Sets the entire Vector of sources to a given Vector.
| |
| shallowClone | back to summary |
|---|---|
| public Object shallowClone() Creates a shallow copy of a
| |