APIdia Launch Partner
Top Description Fields Constructors Methods
java.awt.image.renderable

public Class ParameterBlock

extends Object
implements Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable
Imports
java.awt.image.RenderedImage, java.io.Serial, .Serializable, java.util.Vector

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(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));

Field Summary

Modifier and TypeField and Description
protected Vector<Object>
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<Object>
sources

A Vector of sources, stored as arbitrary Objects.

Constructor Summary

AccessConstructor and Description
public
ParameterBlock()

A dummy constructor.

public
ParameterBlock(Vector<Object>
a Vector of source images
sources
)

Constructs a ParameterBlock with a given Vector of sources.

public
ParameterBlock(Vector<Object>
a Vector of source images
sources
,
Vector<Object>
a Vector of parameters to be used in the rendering operation
parameters
)

Constructs a ParameterBlock with a given Vector of sources and Vector of parameters.

Method Summary

Modifier and TypeMethod and Description
public ParameterBlock

Returns:

a new ParameterBlock containing the specified parameter.
add
(Object
the Object to add to the parameters Vector
obj
)

Adds an object to the list of parameters.

public ParameterBlock

Returns:

a new ParameterBlock containing the specified parameter.
add
(byte
the byte to add to the parameters Vector
b
)

Adds a Byte to the list of parameters.

public ParameterBlock

Returns:

a new ParameterBlock containing the specified parameter.
add
(char
the char to add to the parameters Vector
c
)

Adds a Character to the list of parameters.

public ParameterBlock

Returns:

a new ParameterBlock containing the specified parameter.
add
(short
the short to add to the parameters Vector
s
)

Adds a Short to the list of parameters.

public ParameterBlock

Returns:

a new ParameterBlock containing the specified parameter.
add
(int
the int to add to the parameters Vector
i
)

Adds a Integer to the list of parameters.

public ParameterBlock

Returns:

a new ParameterBlock containing the specified parameter.
add
(long
the long to add to the parameters Vector
l
)

Adds a Long to the list of parameters.

public ParameterBlock

Returns:

a new ParameterBlock containing the specified parameter.
add
(float
the float to add to the parameters Vector
f
)

Adds a Float to the list of parameters.

public ParameterBlock

Returns:

a new ParameterBlock containing the specified parameter.
add
(double
the double to add to the parameters Vector
d
)

Adds a Double to the list of parameters.

public ParameterBlock

Returns:

a new ParameterBlock containing the specified source.
addSource
(Object
an image object to be stored in the source list.
source
)

Adds an image to end of the list of sources.

public Object

Returns:

an Object clone of the ParameterBlock.
clone
()

Overrides java.lang.Object.clone.

Creates a copy of a ParameterBlock.

public byte

Returns:

the parameter at the specified index as a byte value.
getByteParameter
(int
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 a char value.
getCharParameter
(int
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 a double value.
getDoubleParameter
(int
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 a float value.
getFloatParameter
(int
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 an int value.
getIntParameter
(int
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 a long value.
getLongParameter
(int
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 the parameters Vector.
getNumParameters
()

Returns the number of parameters (not including source images).

public int

Returns:

the number of source images in the sources Vector.
getNumSources
()

Returns the number of source images.

public Object

Returns:

an Object representing the the parameter at the specified index into the parameters Vector.
getObjectParameter
(int
the index of the parameter to get
index
)

Gets a parameter as an object.

public Class<?>[]

Returns:

an array of Class objects.
getParamClasses
()

Returns an array of Class objects describing the types of the parameters.

public Vector<Object>

Returns:

the parameters Vector.
getParameters
()

Returns the entire Vector of parameters.

public RenderableImage

Returns:

a RenderableImage that represents the source image that is at the specified index in the sources Vector.
getRenderableSource
(int
the index of the source to be returned
index
)

Returns a source as a RenderableImage.

public RenderedImage

Returns:

a RenderedImage that represents the source image that is at the specified index in the sources Vector.
getRenderedSource
(int
the index of the source to be returned
index
)

Returns a source as a RenderedImage.

public short

Returns:

the parameter at the specified index as a short value.
getShortParameter
(int
the index of the parameter to be returned.
index
)

A convenience method to return a parameter as a short.

public Object

Returns:

an Object that represents the source located at the specified index in the sources Vector.
getSource
(int
the index of the source to be returned.
index
)

Returns a source as a general Object.

public Vector<Object>

Returns:

the sources Vector.
getSources
()

Returns the entire Vector of sources.

public void
removeParameters()

Clears the list of parameters.

public void
removeSources()

Clears the list of source images.

public ParameterBlock

Returns:

a new ParameterBlock containing the specified parameter.
set
(Object
the parameter that replaces the parameter at the specified index in the parameters Vector
obj
,
int
the index of the parameter to be replaced with the specified parameter
index
)

Replaces an Object in the list of parameters.

public ParameterBlock

Returns:

a new ParameterBlock containing the specified parameter.
set
(byte
the parameter that replaces the parameter at the specified index in the parameters Vector
b
,
int
the 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 new ParameterBlock containing the specified parameter.
set
(char
the parameter that replaces the parameter at the specified index in the parameters Vector
c
,
int
the 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 new ParameterBlock containing the specified parameter.
set
(short
the parameter that replaces the parameter at the specified index in the parameters Vector
s
,
int
the 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 new ParameterBlock containing the specified parameter.
set
(int
the parameter that replaces the parameter at the specified index in the parameters Vector
i
,
int
the 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 new ParameterBlock containing the specified parameter.
set
(long
the parameter that replaces the parameter at the specified index in the parameters Vector
l
,
int
the 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 new ParameterBlock containing the specified parameter.
set
(float
the parameter that replaces the parameter at the specified index in the parameters Vector
f
,
int
the 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 new ParameterBlock containing the specified parameter.
set
(double
the parameter that replaces the parameter at the specified index in the parameters Vector
d
,
int
the 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 Vector of parameters
parameters
)

Sets the entire Vector of parameters to a given Vector.

public ParameterBlock

Returns:

a new ParameterBlock that contains the specified source at the specified index.
setSource
(Object
the specified source image
source
,
int
the index into the sources Vector at which to insert the specified source
index
)

Replaces an entry in the list of source with a new source.

public void
setSources(Vector<Object>
the Vector of source images
sources
)

Sets the entire Vector of sources to a given Vector.

public Object

Returns:

an Object clone of the ParameterBlock.
shallowClone
()

Creates a shallow copy of a ParameterBlock.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

parametersback to summary
protected Vector<Object> parameters

A Vector of non-source parameters, stored as arbitrary Objects.

serialVersionUIDback to summary
private static final long serialVersionUID

Use serialVersionUID from JDK 9 for interoperability.

Annotations
@Serial
sourcesback to summary
protected Vector<Object> sources

A Vector of sources, stored as arbitrary Objects.

Constructor Detail

ParameterBlockback to summary
public ParameterBlock()

A dummy constructor.

ParameterBlockback to summary
public ParameterBlock(Vector<Object> sources)

Constructs a ParameterBlock with a given Vector of sources.

Parameters
sources:Vector<Object>

a Vector of source images

ParameterBlockback to summary
public ParameterBlock(Vector<Object> sources, Vector<Object> parameters)

Constructs a ParameterBlock with a given Vector of sources and Vector of parameters.

Parameters
sources:Vector<Object>

a Vector of source images

parameters:Vector<Object>

a Vector of parameters to be used in the rendering operation

Method Detail

addback to summary
public ParameterBlock add(Object obj)

Adds an object to the list of parameters.

Parameters
obj:Object

the Object to add to the parameters Vector

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

addback to summary
public ParameterBlock add(byte b)

Adds a Byte to the list of parameters.

Parameters
b:byte

the byte to add to the parameters Vector

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

addback to summary
public ParameterBlock add(char c)

Adds a Character to the list of parameters.

Parameters
c:char

the char to add to the parameters Vector

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

addback to summary
public ParameterBlock add(short s)

Adds a Short to the list of parameters.

Parameters
s:short

the short to add to the parameters Vector

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

addback to summary
public ParameterBlock add(int i)

Adds a Integer to the list of parameters.

Parameters
i:int

the int to add to the parameters Vector

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

addback to summary
public ParameterBlock add(long l)

Adds a Long to the list of parameters.

Parameters
l:long

the long to add to the parameters Vector

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

addback to summary
public ParameterBlock add(float f)

Adds a Float to the list of parameters.

Parameters
f:float

the float to add to the parameters Vector

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

addback to summary
public ParameterBlock add(double d)

Adds a Double to the list of parameters.

Parameters
d:double

the double to add to the parameters Vector

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

addSourceback 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.

Parameters
source:Object

an image object to be stored in the source list.

Returns:ParameterBlock

a new ParameterBlock containing the specified source.

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

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.

Returns:Object

an Object clone of the ParameterBlock.

Annotations
@SuppressWarnings:unchecked
getByteParameterback 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 null or not a Byte.

Parameters
index:int

the index of the parameter to be returned.

Returns:byte

the parameter at the specified index as a byte value.

Exceptions
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
getCharParameterback 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 null or not a Character.

Parameters
index:int

the index of the parameter to be returned.

Returns:char

the parameter at the specified index as a char value.

Exceptions
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
getDoubleParameterback 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 null or not a Double.

Parameters
index:int

the index of the parameter to be returned.

Returns:double

the parameter at the specified index as a double value.

Exceptions
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
getFloatParameterback 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 null or not a Float.

Parameters
index:int

the index of the parameter to be returned.

Returns:float

the parameter at the specified index as a float value.

Exceptions
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
getIntParameterback 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 null or not an Integer.

Parameters
index:int

the index of the parameter to be returned.

Returns:int

the parameter at the specified index as an int value.

Exceptions
ClassCastException:
if the parameter at the specified index is not an 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
getLongParameterback 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 null or not a Long.

Parameters
index:int

the index of the parameter to be returned.

Returns:long

the parameter at the specified index as a long value.

Exceptions
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
getNumParametersback to summary
public int getNumParameters()

Returns the number of parameters (not including source images).

Returns:int

the number of parameters in the parameters Vector.

getNumSourcesback to summary
public int getNumSources()

Returns the number of source images.

Returns:int

the number of source images in the sources Vector.

getObjectParameterback to summary
public Object getObjectParameter(int index)

Gets a parameter as an object.

Parameters
index:int

the index of the parameter to get

Returns:Object

an Object representing the the parameter at the specified index into the parameters Vector.

getParamClassesback to summary
public Class<?>[] getParamClasses()

Returns an array of Class objects describing the types of the parameters.

Returns:Class<?>[]

an array of Class objects.

getParametersback to summary
public Vector<Object> getParameters()

Returns the entire Vector of parameters.

Returns:Vector<Object>

the parameters Vector.

See Also
setParameters(Vector)
getRenderableSourceback 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.

Parameters
index:int

the index of the source to be returned

Returns:RenderableImage

a RenderableImage that represents the source image that is at the specified index in the sources Vector.

getRenderedSourceback to summary
public RenderedImage getRenderedSource(int index)

Returns a source as a RenderedImage. This method is a convenience method. An exception will be thrown if the source is not a RenderedImage.

Parameters
index:int

the index of the source to be returned

Returns:RenderedImage

a RenderedImage that represents the source image that is at the specified index in the sources Vector.

getShortParameterback 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 null or not a Short.

Parameters
index:int

the index of the parameter to be returned.

Returns:short

the parameter at the specified index as a short value.

Exceptions
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
getSourceback to summary
public Object getSource(int index)

Returns a source as a general Object. The caller must cast it into an appropriate type.

Parameters
index:int

the index of the source to be returned.

Returns:Object

an Object that represents the source located at the specified index in the sources Vector.

See Also
setSource(Object, int)
getSourcesback to summary
public Vector<Object> getSources()

Returns the entire Vector of sources.

Returns:Vector<Object>

the sources Vector.

See Also
setSources(Vector)
removeParametersback to summary
public void removeParameters()

Clears the list of parameters.

removeSourcesback to summary
public void removeSources()

Clears the list of source images.

setback 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.

Parameters
obj:Object

the parameter that replaces the parameter at the specified index in the parameters Vector

index:int

the index of the parameter to be replaced with the specified parameter

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

setback 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.

Parameters
b:byte

the parameter that replaces the parameter at the specified index in the parameters Vector

index:int

the index of the parameter to be replaced with the specified parameter

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

setback 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.

Parameters
c:char

the parameter that replaces the parameter at the specified index in the parameters Vector

index:int

the index of the parameter to be replaced with the specified parameter

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

setback 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.

Parameters
s:short

the parameter that replaces the parameter at the specified index in the parameters Vector

index:int

the index of the parameter to be replaced with the specified parameter

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

setback 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.

Parameters
i:int

the parameter that replaces the parameter at the specified index in the parameters Vector

index:int

the index of the parameter to be replaced with the specified parameter

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

setback 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.

Parameters
l:long

the parameter that replaces the parameter at the specified index in the parameters Vector

index:int

the index of the parameter to be replaced with the specified parameter

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

setback 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.

Parameters
f:float

the parameter that replaces the parameter at the specified index in the parameters Vector

index:int

the index of the parameter to be replaced with the specified parameter

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

setback 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.

Parameters
d:double

the parameter that replaces the parameter at the specified index in the parameters Vector

index:int

the index of the parameter to be replaced with the specified parameter

Returns:ParameterBlock

a new ParameterBlock containing the specified parameter.

setParametersback to summary
public void setParameters(Vector<Object> parameters)

Sets the entire Vector of parameters to a given Vector.

Parameters
parameters:Vector<Object>

the specified Vector of parameters

See Also
getParameters
setSourceback 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.

Parameters
source:Object

the specified source image

index:int

the index into the sources Vector at which to insert the specified source

Returns:ParameterBlock

a new ParameterBlock that contains the specified source at the specified index.

See Also
getSource(int)
setSourcesback to summary
public void setSources(Vector<Object> sources)

Sets the entire Vector of sources to a given Vector.

Parameters
sources:Vector<Object>

the Vector of source images

See Also
getSources
shallowCloneback to summary
public Object shallowClone()

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.

Returns:Object

an Object clone of the ParameterBlock.