Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |
java.lang.Object | +----java.awt.image.renderable.ParameterBlock
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
|
Vector | sources
|
Constructor Summary | |
ParameterBlock()
|
|
ParameterBlock(Vector sources)
|
|
ParameterBlock(Vector sources,
Vector parameters)
|
Method Summary | |
ParameterBlock | add(byte b)
|
ParameterBlock | add(char c)
|
ParameterBlock | add(short s)
|
ParameterBlock | add(int i)
|
ParameterBlock | add(long l)
|
ParameterBlock | add(float f)
|
ParameterBlock | add(double d)
|
ParameterBlock | add(Object obj)
|
ParameterBlock | addSource(Object obj)
|
Object | clone()
|
byte | getByteParameter(int index)
|
char | getCharParameter(int index)
|
double | getDoubleParameter(int index)
|
float | getFloatParameter(int index)
|
int | getIntParameter(int index)
|
long | getLongParameter(int index)
|
int | getNumParameters()
|
int | getNumSources()
|
Object | getObjectParameter(int index)
|
Class[] | getParamClasses()
|
Vector | getParameters()
|
RenderableImage | getRenderableSource(int index)
|
RenderedImage | getRenderedSource(int index)
|
short | getShortParameter(int index)
|
Object | getSource(int index)
|
Vector | getSources()
|
void | removeParameters()
|
void | removeSources()
|
void | setParameters(Vector parameters)
|
void | setSources(Vector sources)
|
Object | shallowClone()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Vector sources
protected Vector parameters
Constructor Detail |
public ParameterBlock()
public ParameterBlock(Vector sources)
public ParameterBlock(Vector sources, Vector parameters)
Method Detail |
public Object shallowClone()
public Object clone()
public ParameterBlock addSource(Object obj)
obj
- an image object to be stored in the source list.
public Object getSource(int index)
index
- the index of the source to be returned.
public RenderedImage getRenderedSource(int index)
index
- the index of the source to be returned.
public RenderableImage getRenderableSource(int index)
index
- the index of the source to be returned.
public int getNumSources()
public Vector getSources()
public void setSources(Vector sources)
public void removeSources()
public int getNumParameters()
public Vector getParameters()
public void setParameters(Vector parameters)
public void removeParameters()
public ParameterBlock add(byte b)
public ParameterBlock add(char c)
public ParameterBlock add(short s)
public ParameterBlock add(int i)
public ParameterBlock add(long l)
public ParameterBlock add(float f)
public ParameterBlock add(double d)
public ParameterBlock add(Object obj)
public Object getObjectParameter(int index)
public byte getByteParameter(int index)
index
- the index of the parameter to be returned.
public char getCharParameter(int index)
index
- the index of the parameter to be returned.
public short getShortParameter(int index)
index
- the index of the parameter to be returned.
public int getIntParameter(int index)
index
- the index of the parameter to be returned.
public long getLongParameter(int index)
index
- the index of the parameter to be returned.
public float getFloatParameter(int index)
index
- the index of the parameter to be returned.
public double getDoubleParameter(int index)
index
- the index of the parameter to be returned.
public Class[] getParamClasses()
Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |