- All Implemented Interfaces:
- Serializable,- Cloneable
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
 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));
 - See Also:
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionA dummy constructor.ParameterBlock(Vector<Object> sources) Constructs aParameterBlockwith a given Vector of sources.ParameterBlock(Vector<Object> sources, Vector<Object> parameters) Constructs aParameterBlockwith a given Vector of sources and Vector of parameters.
- 
Method SummaryModifier and TypeMethodDescriptionadd(byte b) Adds a Byte to the list of parameters.add(char c) Adds a Character to the list of parameters.add(double d) Adds a Double to the list of parameters.add(float f) Adds a Float to the list of parameters.add(int i) Adds a Integer to the list of parameters.add(long l) Adds a Long to the list of parameters.add(short s) Adds a Short to the list of parameters.Adds an object to the list of parameters.Adds an image to end of the list of sources.clone()Creates a copy of aParameterBlock.bytegetByteParameter(int index) A convenience method to return a parameter as a byte.chargetCharParameter(int index) A convenience method to return a parameter as a char.doublegetDoubleParameter(int index) A convenience method to return a parameter as a double.floatgetFloatParameter(int index) A convenience method to return a parameter as a float.intgetIntParameter(int index) A convenience method to return a parameter as an int.longgetLongParameter(int index) A convenience method to return a parameter as a long.intReturns the number of parameters (not including source images).intReturns the number of source images.getObjectParameter(int index) Gets a parameter as an object.Class<?>[]Returns an array of Class objects describing the types of the parameters.Returns the entire Vector of parameters.getRenderableSource(int index) Returns a source as a RenderableImage.getRenderedSource(int index) Returns a source as aRenderedImage.shortgetShortParameter(int index) A convenience method to return a parameter as a short.getSource(int index) Returns a source as a general Object.Returns the entire Vector of sources.voidClears the list of parameters.voidClears the list of source images.set(byte b, int index) Replaces an Object in the list of parameters with a Byte.set(char c, int index) Replaces an Object in the list of parameters with a Character.set(double d, int index) Replaces an Object in the list of parameters with a Double.set(float f, int index) Replaces an Object in the list of parameters with a Float.set(int i, int index) Replaces an Object in the list of parameters with an Integer.set(long l, int index) Replaces an Object in the list of parameters with a Long.set(short s, int index) Replaces an Object in the list of parameters with a Short.Replaces an Object in the list of parameters.voidsetParameters(Vector<Object> parameters) Sets the entire Vector of parameters to a given Vector.Replaces an entry in the list of source with a new source.voidsetSources(Vector<Object> sources) Sets the entire Vector of sources to a given Vector.Creates a shallow copy of aParameterBlock.
- 
Field Details- 
sourcesA Vector of sources, stored as arbitrary Objects.
- 
parametersA Vector of non-source parameters, stored as arbitrary Objects.
 
- 
- 
Constructor Details- 
ParameterBlockpublic ParameterBlock()A dummy constructor.
- 
ParameterBlockConstructs aParameterBlockwith a given Vector of sources.- Parameters:
- sources- a- Vectorof source images
 
- 
ParameterBlockConstructs aParameterBlockwith a given Vector of sources and Vector of parameters.- Parameters:
- sources- a- Vectorof source images
- parameters- a- Vectorof parameters to be used in the rendering operation
 
 
- 
- 
Method Details- 
shallowCloneCreates a shallow copy of aParameterBlock. 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.
 
- 
cloneCreates a copy of aParameterBlock. 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 originalParameterBlock. Changes to the shared sources or parameters themselves will still be visible.
- 
addSourceAdds 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- an image object to be stored in the source list.
- Returns:
- a new ParameterBlockcontaining the specifiedsource.
 
- 
getSourceReturns 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.
- Returns:
- an Objectthat represents the source located at the specified index in thesourcesVector.
- See Also:
 
- 
setSourceReplaces 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- the specified source image
- index- the index into the- sources- Vectorat which to insert the specified- source
- Returns:
- a new ParameterBlockthat contains the specifiedsourceat the specifiedindex.
- See Also:
 
- 
getRenderedSourceReturns a source as aRenderedImage. This method is a convenience method. An exception will be thrown if the source is not a RenderedImage.- Parameters:
- index- the index of the source to be returned
- Returns:
- a RenderedImagethat represents the source image that is at the specified index in thesources Vector.
 
- 
getRenderableSourceReturns 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- the index of the source to be returned
- Returns:
- a RenderableImagethat represents the source image that is at the specified index in thesources Vector.
 
- 
getNumSourcespublic int getNumSources()Returns the number of source images.- Returns:
- the number of source images in the sourcesVector.
 
- 
getSourcesReturns the entire Vector of sources.- Returns:
- the sources Vector.
- See Also:
 
- 
setSourcesSets the entire Vector of sources to a given Vector.- Parameters:
- sources- the- Vectorof source images
- See Also:
 
- 
removeSourcespublic void removeSources()Clears the list of source images.
- 
getNumParameterspublic int getNumParameters()Returns the number of parameters (not including source images).- Returns:
- the number of parameters in the parametersVector.
 
- 
getParametersReturns the entire Vector of parameters.- Returns:
- the parameters Vector.
- See Also:
 
- 
setParametersSets the entire Vector of parameters to a given Vector.- Parameters:
- parameters- the specified- Vectorof parameters
- See Also:
 
- 
removeParameterspublic void removeParameters()Clears the list of parameters.
- 
addAdds an object to the list of parameters.- Parameters:
- obj- the- Objectto add to the- parameters Vector
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
addAdds a Byte to the list of parameters.- Parameters:
- b- the byte to add to the- parameters Vector
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
addAdds a Character to the list of parameters.- Parameters:
- c- the char to add to the- parameters Vector
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
addAdds a Short to the list of parameters.- Parameters:
- s- the short to add to the- parameters Vector
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
addAdds a Integer to the list of parameters.- Parameters:
- i- the int to add to the- parameters Vector
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
addAdds a Long to the list of parameters.- Parameters:
- l- the long to add to the- parameters Vector
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
addAdds a Float to the list of parameters.- Parameters:
- f- the float to add to the- parameters Vector
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
addAdds a Double to the list of parameters.- Parameters:
- d- the double to add to the- parameters Vector
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
setReplaces 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- 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
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
setReplaces 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- 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
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
setReplaces 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- 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
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
setReplaces 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- 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
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
setReplaces 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- 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
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
setReplaces 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- 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
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
setReplaces 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- 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
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
setReplaces 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- 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
- Returns:
- a new ParameterBlockcontaining the specified parameter.
 
- 
getObjectParameterGets a parameter as an object.- Parameters:
- index- the index of the parameter to get
- Returns:
- an Objectrepresenting the the parameter at the specified index into theparametersVector.
 
- 
getByteParameterpublic byte getByteParameter(int index) A convenience method to return a parameter as a byte. An exception is thrown if the parameter isnullor not aByte.- Parameters:
- index- the index of the parameter to be returned.
- Returns:
- the parameter at the specified index
         as a bytevalue.
- Throws:
- ClassCastException- if the parameter at the specified index is not a- Byte
- NullPointerException- if the parameter at the specified index is- null
- ArrayIndexOutOfBoundsException- if- indexis negative or not less than the current size of this- ParameterBlockobject
 
- 
getCharParameterpublic char getCharParameter(int index) A convenience method to return a parameter as a char. An exception is thrown if the parameter isnullor not aCharacter.- Parameters:
- index- the index of the parameter to be returned.
- Returns:
- the parameter at the specified index
         as a charvalue.
- Throws:
- ClassCastException- if the parameter at the specified index is not a- Character
- NullPointerException- if the parameter at the specified index is- null
- ArrayIndexOutOfBoundsException- if- indexis negative or not less than the current size of this- ParameterBlockobject
 
- 
getShortParameterpublic short getShortParameter(int index) A convenience method to return a parameter as a short. An exception is thrown if the parameter isnullor not aShort.- Parameters:
- index- the index of the parameter to be returned.
- Returns:
- the parameter at the specified index
         as a shortvalue.
- Throws:
- ClassCastException- if the parameter at the specified index is not a- Short
- NullPointerException- if the parameter at the specified index is- null
- ArrayIndexOutOfBoundsException- if- indexis negative or not less than the current size of this- ParameterBlockobject
 
- 
getIntParameterpublic int getIntParameter(int index) A convenience method to return a parameter as an int. An exception is thrown if the parameter isnullor not anInteger.- Parameters:
- index- the index of the parameter to be returned.
- Returns:
- the parameter at the specified index
         as an intvalue.
- Throws:
- ClassCastException- if the parameter at the specified index is not an- Integer
- NullPointerException- if the parameter at the specified index is- null
- ArrayIndexOutOfBoundsException- if- indexis negative or not less than the current size of this- ParameterBlockobject
 
- 
getLongParameterpublic long getLongParameter(int index) A convenience method to return a parameter as a long. An exception is thrown if the parameter isnullor not aLong.- Parameters:
- index- the index of the parameter to be returned.
- Returns:
- the parameter at the specified index
         as a longvalue.
- Throws:
- ClassCastException- if the parameter at the specified index is not a- Long
- NullPointerException- if the parameter at the specified index is- null
- ArrayIndexOutOfBoundsException- if- indexis negative or not less than the current size of this- ParameterBlockobject
 
- 
getFloatParameterpublic float getFloatParameter(int index) A convenience method to return a parameter as a float. An exception is thrown if the parameter isnullor not aFloat.- Parameters:
- index- the index of the parameter to be returned.
- Returns:
- the parameter at the specified index
         as a floatvalue.
- Throws:
- ClassCastException- if the parameter at the specified index is not a- Float
- NullPointerException- if the parameter at the specified index is- null
- ArrayIndexOutOfBoundsException- if- indexis negative or not less than the current size of this- ParameterBlockobject
 
- 
getDoubleParameterpublic double getDoubleParameter(int index) A convenience method to return a parameter as a double. An exception is thrown if the parameter isnullor not aDouble.- Parameters:
- index- the index of the parameter to be returned.
- Returns:
- the parameter at the specified index
         as a doublevalue.
- Throws:
- ClassCastException- if the parameter at the specified index is not a- Double
- NullPointerException- if the parameter at the specified index is- null
- ArrayIndexOutOfBoundsException- if- indexis negative or not less than the current size of this- ParameterBlockobject
 
- 
getParamClassesReturns an array of Class objects describing the types of the parameters.- Returns:
- an array of Classobjects.
 
 
-