Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Class java.awt.image.renderable.ParameterBlock

java.lang.Object
    |
    +----java.awt.image.renderable.ParameterBlock

public class ParameterBlock
extends Object
implements Cloneable, Serializable
A ParameterBlock encapsulates all the information about sources and parameters (expressed as base types or Objects) required by a RenderableImageOp and other future classes that manipulate chains of imaging operators.

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.

Note that all 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() and add() 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
Vector  parameters
A Vector of non-source parameters, stored as arbitrary Objects.
Vector  sources
A Vector of sources, stored as arbitrary Objects.
 

Constructor Summary
 ParameterBlock()
A dummy constructor.
 ParameterBlock(Vector sources)
Constructs a ParameterBlock with a given Vector of sources.
 ParameterBlock(Vector sources, Vector parameters)
Constructs a ParameterBlock with a given Vector of sources and Vector of parameters.
 

Method Summary
ParameterBlock  add(byte b)
Adds a byte to the list of parameters.
ParameterBlock  add(char c)
Adds a char to the list of parameters.
ParameterBlock  add(short s)
Adds a short to the list of parameters.
ParameterBlock  add(int i)
Adds a int to the list of parameters.
ParameterBlock  add(long l)
Adds a long to the list of parameters.
ParameterBlock  add(float f)
Adds a float to the list of parameters.
ParameterBlock  add(double d)
Adds a double to the list of parameters.
ParameterBlock  add(Object obj)
Adds an object to the list of parameters.
ParameterBlock  addSource(Object obj)
Adds an image to end of the list of sources.
Object  clone()
Creates a copy of a ParameterBlock.
byte  getByteParameter(int index)
A convenience class to return a parameter as a byte.
char  getCharParameter(int index)
A convenience class to return a parameter as a char.
double  getDoubleParameter(int index)
A convenience class to return a parameter as a double.
float  getFloatParameter(int index)
A convenience class to return a parameter as a float.
int  getIntParameter(int index)
A convenience class to return a parameter as an int.
long  getLongParameter(int index)
A convenience class to return a parameter as a long.
int  getNumParameters()
Returns the number of parameters (not including source images).
int  getNumSources()
Returns the number of source images.
Object  getObjectParameter(int index)
Gets a parameter as an object.
Class[]  getParamClasses()
Returns an array of Class objects describing the types of the parameters.
Vector  getParameters()
Returns the entire Vector of parameters.
RenderableImage  getRenderableSource(int index)
A convenience method to return a source as a RenderableImage.
RenderedImage  getRenderedSource(int index)
A convenience method to return a source as a RenderedImage.
short  getShortParameter(int index)
A convenience class to return a parameter as a short.
Object  getSource(int index)
Returns a source as a general Object.
Vector  getSources()
Returns the entire Vector of sources.
void  removeParameters()
Clears the list of parameters.
void  removeSources()
Clears the list of source images.
void  setParameters(Vector parameters)
Sets the entire Vector of parameters to a given Vector.
void  setSources(Vector sources)
Sets the entire Vector of sources to a given Vector.
Object  shallowClone()
Creates a shallow copy of a ParameterBlock.
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sources

protected Vector sources
A Vector of sources, stored as arbitrary Objects.

parameters

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

ParameterBlock

public ParameterBlock()
A dummy constructor.

ParameterBlock

public ParameterBlock(Vector sources)
Constructs a ParameterBlock with a given Vector of sources.

ParameterBlock

public ParameterBlock(Vector sources,
                      Vector parameters)
Constructs a ParameterBlock with a given Vector of sources and Vector of parameters.
Method Detail

shallowClone

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:
an Object clone of the ParameterBlock.

clone

public 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:
an Object clone of the ParameterBlock.
Overrides:
clone in class Object

addSource

public ParameterBlock addSource(Object obj)
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:
obj - an image object to be stored in the source list.

getSource

public Object getSource(int index)
Returns a source as a general Object. The caller must cast it into an appropriate type.
Parameters:
index - the index of the source to be returned.

getRenderedSource

public RenderedImage getRenderedSource(int index)
A convenience method to return a source as a RenderedImage. An exception will be thrown if the sources is not a RenderedImage.
Parameters:
index - the index of the source to be returned.

getRenderableSource

public RenderableImage getRenderableSource(int index)
A convenience method to return a source as a RenderableImage. An exception will be thrown if the sources is not a RenderableImage.
Parameters:
index - the index of the source to be returned.

getNumSources

public int getNumSources()
Returns the number of source images.

getSources

public Vector getSources()
Returns the entire Vector of sources.

setSources

public void setSources(Vector sources)
Sets the entire Vector of sources to a given Vector.

removeSources

public void removeSources()
Clears the list of source images.

getNumParameters

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

getParameters

public Vector getParameters()
Returns the entire Vector of parameters.

setParameters

public void setParameters(Vector parameters)
Sets the entire Vector of parameters to a given Vector.

removeParameters

public void removeParameters()
Clears the list of parameters.

add

public ParameterBlock add(byte b)
Adds a byte to the list of parameters.

add

public ParameterBlock add(char c)
Adds a char to the list of parameters.

add

public ParameterBlock add(short s)
Adds a short to the list of parameters.

add

public ParameterBlock add(int i)
Adds a int to the list of parameters.

add

public ParameterBlock add(long l)
Adds a long to the list of parameters.

add

public ParameterBlock add(float f)
Adds a float to the list of parameters.

add

public ParameterBlock add(double d)
Adds a double to the list of parameters.

add

public ParameterBlock add(Object obj)
Adds an object to the list of parameters.

getObjectParameter

public Object getObjectParameter(int index)
Gets a parameter as an object. Objects belonging to a base type (e.g., int) will be returned as a member of the corresponding class type (e.g., Integer).

getByteParameter

public byte getByteParameter(int index)
A convenience class to return a parameter as a byte. An exception will be thrown if the parameter is of a different type.
Parameters:
index - the index of the parameter to be returned.

getCharParameter

public char getCharParameter(int index)
A convenience class to return a parameter as a char. An exception will be thrown if the parameter is of a different type.
Parameters:
index - the index of the parameter to be returned.

getShortParameter

public short getShortParameter(int index)
A convenience class to return a parameter as a short. An exception will be thrown if the parameter is of a different type.
Parameters:
index - the index of the parameter to be returned.

getIntParameter

public int getIntParameter(int index)
A convenience class to return a parameter as an int. An exception will be thrown if the parameter is of a different type.
Parameters:
index - the index of the parameter to be returned.

getLongParameter

public long getLongParameter(int index)
A convenience class to return a parameter as a long. An exception will be thrown if the parameter is of a different type.
Parameters:
index - the index of the parameter to be returned.

getFloatParameter

public float getFloatParameter(int index)
A convenience class to return a parameter as a float. An exception will be thrown if the parameter is of a different type.
Parameters:
index - the index of the parameter to be returned.

getDoubleParameter

public double getDoubleParameter(int index)
A convenience class to return a parameter as a double. An exception will be thrown if the parameter is of a different type.
Parameters:
index - the index of the parameter to be returned.

getParamClasses

public Class[] getParamClasses()
Returns an array of Class objects describing the types of the parameters.

Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.