- java.lang.Object
-
- java.awt.image.renderable.ParameterBlock
-
- All Implemented Interfaces:
-
Serializable,Cloneable
public class ParameterBlock extends Object implements Cloneable, Serializable
AParameterBlock封装了所有关于RenderableImageOp或处理图像的其他类所需的源和参数(对象)的信息。虽然可以在源向量中放置任意对象,但此类的用户可能会强加语义约束,例如要求所有源都是RenderedImages或RenderableImage。
ParameterBlock本身只是一个容器,不会对源或参数类型进行检查。ParameterBlock中的所有参数都是对象; 可以使用方便的添加和设置方法来获取基类型的参数,并构造适当的Number子类(如Integer或Float)。 相应的get方法执行向下转换并具有基本类型的返回值; 如果存储的值没有正确的类型,将抛出异常。 没有办法区分“short s; add(s)”和“add(new Short(s))”的结果。请注意,get和set方法对引用进行操作。 因此,当这不合适时,必须小心不要在
ParameterBlock之间共享引用。 例如,要创建一个新的ParameterBlock等于一个旧的,除了一个添加的源,可能会诱惑写:ParameterBlock addSource(ParameterBlock pb, RenderableImage im) { ParameterBlock pb1 = new ParameterBlock(pb.getSources()); pb1.addSource(im); return pb1; }此代码将具有更改原始
ParameterBlock,因为getSources操作返回对其源向量的引用。 pb和pb1都共享它们的源向量,并且两者中的更改都可见。编写addSource函数的正确方法是克隆源Vector:
ParameterBlock addSource (ParameterBlock pb, RenderableImage im) { ParameterBlock pb1 = new ParameterBlock(pb.getSources().clone()); pb1.addSource(im); return pb1; }ParameterBlock,已经定义了ParameterBlock的克隆方法来执行源和参数向量的克隆。 一个标准的浅克隆可用作shallowClone。addSource,setSource,add和set方法被定义为在添加参数后返回'this'。 这允许使用如下语法:
ParameterBlock pb = new ParameterBlock(); op = new RenderableImageOp("operation", pb.add(arg1).add(arg2));- 另请参见:
- Serialized Form
-
-
构造方法摘要
构造方法 Constructor 描述 ParameterBlock()一个虚拟构造函数。ParameterBlock(Vector<Object> sources)构造一个具有给ParameterBlock向量的ParameterBlock。ParameterBlock(Vector<Object> sources, Vector<Object> parameters)构造一个ParameterBlock与给定的矢量矢量和参数矢量。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 ParameterBlockadd(byte b)将一个字节添加到参数列表中。ParameterBlockadd(char c)在参数列表中添加一个字符。ParameterBlockadd(double d)向参数列表中添加一个Double。ParameterBlockadd(float f)将浮点数添加到参数列表中。ParameterBlockadd(int i)将一个整数添加到参数列表中。ParameterBlockadd(long l)在参数列表中添加一个Long。ParameterBlockadd(short s)在参数列表中添加一个Short。ParameterBlockadd(Object obj)将对象添加到参数列表中。ParameterBlockaddSource(Object source)将图像添加到源列表的末尾。Objectclone()创建一个ParameterBlock的副本。bytegetByteParameter(int index)一个方便的方法返回一个参数作为一个字节。chargetCharParameter(int index)一个方便的方法返回参数作为一个char。doublegetDoubleParameter(int index)将参数返回为双精度的方便方法。floatgetFloatParameter(int index)将参数返回为浮点数的方便方法。intgetIntParameter(int index)以int形式返回参数的方便方法。longgetLongParameter(int index)一个方便返回参数的方法。intgetNumParameters()返回参数数量(不包括源图像)。intgetNumSources()返回源图像的数量。ObjectgetObjectParameter(int index)获取参数作为对象。Class<?>[]getParamClasses()返回描述参数类型的Class对象数组。Vector<Object>getParameters()返回整个参数向量。RenderableImagegetRenderableSource(int index)作为RenderableImage返回一个源。RenderedImagegetRenderedSource(int index)作为一个RenderedImage返回一个源。shortgetShortParameter(int index)一个简单的方法返回一个参数。ObjectgetSource(int index)将源作为一般对象返回。Vector<Object>getSources()返回整个Vector的Vector。voidremoveParameters()清除参数列表。voidremoveSources()清除源图像列表。ParameterBlockset(byte b, int index)使用字节替换参数列表中的对象。ParameterBlockset(char c, int index)用Character替换参数列表中的Object。ParameterBlockset(double d, int index)用Double替换参数列表中的对象。ParameterBlockset(float f, int index)用Float替换参数列表中的对象。ParameterBlockset(int i, int index)用Integer替换参数列表中的Object。ParameterBlockset(long l, int index)用Long替换参数列表中的对象。ParameterBlockset(short s, int index)用Short替换参数列表中的对象。ParameterBlockset(Object obj, int index)替换参数列表中的对象。voidsetParameters(Vector<Object> parameters)将参数的整个Vector设置为给定的Vector。ParameterBlocksetSource(Object source, int index)用源代替源列表中的条目。voidsetSources(Vector<Object> sources)将整个Vector矢量设置为给定的Vector。ObjectshallowClone()创建一个ParameterBlock的浅拷贝。
-
-
-
方法详细信息
-
shallowClone
public Object shallowClone()
创建一个ParameterBlock的浅拷贝。 源和参数向量将被引用复制 - 对这两个版本都可以看到添加或更改。- 结果
-
一个对象克隆的
ParameterBlock。
-
clone
public Object clone()
创建一个ParameterBlock的副本。 源和参数向量被克隆,但实际的源和参数是通过引用复制的。 这允许修改克隆中的源和参数的顺序和数量对于原始的ParameterBlock是不可见的。 对共享源或参数本身的更改仍将可见。
-
addSource
public ParameterBlock addSource(Object source)
将图像添加到源列表的末尾。 图像被存储为对象,以便将来允许新的节点类型。- 参数
-
source- 要存储在源列表中的图像对象。 - 结果
-
一个新的
ParameterBlock包含指定的source。
-
getSource
public Object getSource(int index)
将源作为一般对象返回。 来电者必须将其投入适当的类型。- 参数
-
index- 要返回的源的索引。 - 结果
-
一个
Object,代表位于sourcesVector指定索引的源。 - 另请参见:
-
setSource(Object, int)
-
setSource
public ParameterBlock setSource(Object source, int index)
用源代替源列表中的条目。 如果索引超出当前源列表,则列表将根据需要扩展为null。- 参数
-
source- 指定的源图像 -
index- 索引入sourcesVector,其中插入指定的source - 结果
-
一个新的
ParameterBlock,其中包含指定的source指定的index。 - 另请参见:
-
getSource(int)
-
getRenderedSource
public RenderedImage getRenderedSource(int index)
返回一个源为RenderedImage。 这种方法是一种方便的方法。 如果源不是RenderedImage,将抛出异常。- 参数
-
index- 要返回的源的索引 - 结果
-
一个
RenderedImage表示源图像是在指定索引处sources Vector。
-
getRenderableSource
public RenderableImage getRenderableSource(int index)
作为RenderableImage返回一个源。 这种方法是一种方便的方法。 如果源不是RenderableImage,将抛出异常。- 参数
-
index- 要返回的源的索引 - 结果
-
一个
RenderableImage表示源图像是在指定索引处sources Vector。
-
getNumSources
public int getNumSources()
返回源图像的数量。- 结果
-
源图像的数量在
sourcesVector。
-
getSources
public Vector<Object> getSources()
返回整个Vector的Vector。- 结果
-
sources Vector。 - 另请参见:
-
setSources(Vector)
-
setSources
public void setSources(Vector<Object> sources)
将整个Vector矢量设置为给定的Vector。- 参数
-
sources- 源图像的Vector - 另请参见:
-
getSources()
-
removeSources
public void removeSources()
清除源图像列表。
-
getNumParameters
public int getNumParameters()
返回参数数量(不包括源图像)。- 结果
-
参数的数量在
parametersVector。
-
getParameters
public Vector<Object> getParameters()
返回整个参数向量。- 结果
-
parameters Vector。 - 另请参见:
-
setParameters(Vector)
-
setParameters
public void setParameters(Vector<Object> parameters)
将参数的整个Vector设置为给定的Vector。- 参数
-
parameters- 指定的参数Vector - 另请参见:
-
getParameters()
-
removeParameters
public void removeParameters()
清除参数列表。
-
add
public ParameterBlock add(Object obj)
将对象添加到参数列表中。- 参数
-
obj-Object加到parameters Vector - 结果
-
一个包含指定参数的新的
ParameterBlock。
-
add
public ParameterBlock add(byte b)
将一个字节添加到参数列表中。- 参数
-
b- 要添加到parameters Vector的字节 - 结果
-
一个新的
ParameterBlock包含指定的参数。
-
add
public ParameterBlock add(char c)
在参数列表中添加一个字符。- 参数
-
c- 要添加到parameters Vector的字符 - 结果
-
一个包含指定参数的新的
ParameterBlock。
-
add
public ParameterBlock add(short s)
在参数列表中添加一个Short。- 参数
-
s- 短加到parameters Vector - 结果
-
一个包含指定参数的新的
ParameterBlock。
-
add
public ParameterBlock add(int i)
将一个整数添加到参数列表中。- 参数
-
i- 要添加到parameters Vector的int - 结果
-
一个包含指定参数的新的
ParameterBlock。
-
add
public ParameterBlock add(long l)
在参数列表中添加一个Long。- 参数
-
l- 长期添加到parameters Vector - 结果
-
一个包含指定参数的新的
ParameterBlock。
-
add
public ParameterBlock add(float f)
将浮点数添加到参数列表中。- 参数
-
f- 要添加到parameters Vector - 结果
-
一个包含指定参数的新的
ParameterBlock。
-
add
public ParameterBlock add(double d)
向参数列表中添加一个Double。- 参数
-
d- 双加到parameters Vector - 结果
-
一个包含指定参数的新的
ParameterBlock。
-
set
public ParameterBlock set(Object obj, int index)
替换参数列表中的对象。 如果索引超出当前源列表,则列表将根据需要扩展为null。- 参数
-
obj- 替换parameters Vector指定索引处的参数的参数 -
index- 用指定参数替换参数的索引 - 结果
-
一个新的
ParameterBlock包含指定的参数。
-
set
public ParameterBlock set(byte b, int index)
使用字节替换参数列表中的对象。 如果索引超出当前源列表,则列表将根据需要扩展为null。- 参数
-
b- 用于替换parameters Vector指定索引处的参数的参数 -
index- 要用指定参数替换的参数的索引 - 结果
-
一个包含指定参数的新的
ParameterBlock。
-
set
public ParameterBlock set(char c, int index)
用Character替换参数列表中的Object。 如果索引超出当前源列表,则列表将根据需要扩展为null。- 参数
-
c- 用于替换parameters Vector指定索引处的参数的参数 -
index- 用指定参数替换参数的索引 - 结果
-
一个包含指定参数的新的
ParameterBlock。
-
set
public ParameterBlock set(short s, int index)
用Short替换参数列表中的对象。 如果索引超出当前源列表,则列表将根据需要扩展为null。- 参数
-
s- 替换parameters Vector指定索引处的参数的参数 -
index- 用指定参数替换参数的索引 - 结果
-
一个包含指定参数的新的
ParameterBlock。
-
set
public ParameterBlock set(int i, int index)
用Integer替换参数列表中的Object。 如果索引超出当前源列表,则列表将根据需要扩展为null。- 参数
-
i- 用于替换parameters Vector指定索引处的参数的参数 -
index- 要用指定参数替换的参数的索引 - 结果
-
一个包含指定参数的新的
ParameterBlock。
-
set
public ParameterBlock set(long l, int index)
用Long替换参数列表中的对象。 如果索引超出当前源列表,则列表将根据需要扩展为null。- 参数
-
l- 用于替换parameters Vector指定索引处的参数的参数 -
index- 用指定参数替换参数的索引 - 结果
-
一个包含指定参数的新的
ParameterBlock。
-
set
public ParameterBlock set(float f, int index)
用Float替换参数列表中的对象。 如果索引超出当前源列表,则列表将根据需要扩展为null。- 参数
-
f- 用于替换parameters Vector指定索引处的参数的参数 -
index- 用指定参数替换参数的索引 - 结果
-
一个包含指定参数的新的
ParameterBlock。
-
set
public ParameterBlock set(double d, int index)
用Double替换参数列表中的对象。 如果索引超出当前源列表,则列表将根据需要扩展为null。- 参数
-
d- 用于替换parameters Vector指定索引处的参数的参数 -
index- 用指定参数替换参数的索引 - 结果
-
一个包含指定参数的新的
ParameterBlock。
-
getObjectParameter
public Object getObjectParameter(int index)
获取参数作为对象。- 参数
-
index- 要获取的参数的索引 - 结果
-
一个
Object表示参数在指定的指数parametersVector。
-
getByteParameter
public byte getByteParameter(int index)
一个方便的方法返回一个参数作为一个字节。 如果参数为null或不是Byte则抛出异常。- 参数
-
index- 要返回的参数的索引。 - 结果
-
指定索引处的参数为
byte值。 - 异常
-
ClassCastException- 如果指定索引处的参数不是Byte -
NullPointerException- 如果指定索引处的参数为null -
ArrayIndexOutOfBoundsException- 如果index为负数或不低于此ParameterBlock对象的当前大小
-
getCharParameter
public char getCharParameter(int index)
一个方便的方法返回参数作为一个char。 如果参数为null或不是Character则抛出异常。- 参数
-
index- 要返回的参数的索引。 - 结果
-
指定索引处的参数为
char值。 - 异常
-
ClassCastException- 如果指定索引处的参数不是Character -
NullPointerException- 如果指定索引处的参数为null -
ArrayIndexOutOfBoundsException- 如果index为负数或不小于此ParameterBlock对象的当前大小
-
getShortParameter
public short getShortParameter(int index)
一个简单的方法返回一个参数。 如果参数为null或不是Short则抛出异常。- 参数
-
index- 要返回的参数的索引。 - 结果
-
指定索引处的参数为
short值。 - 异常
-
ClassCastException- 如果指定索引处的参数不是Short -
NullPointerException- 如果指定索引处的参数为null -
ArrayIndexOutOfBoundsException- 如果index为负数或不低于此ParameterBlock对象的当前大小
-
getIntParameter
public int getIntParameter(int index)
以int形式返回参数的方便方法。 如果参数为null或不是Integer则抛出异常。- 参数
-
index- 要返回的参数的索引。 - 结果
-
指定索引处的参数为
int值。 - 异常
-
ClassCastException- 如果指定索引处的参数不是Integer -
NullPointerException- 如果指定索引处的参数为null -
ArrayIndexOutOfBoundsException- 如果index为负数或不小于此ParameterBlock对象的当前大小
-
getLongParameter
public long getLongParameter(int index)
一个方便返回参数的方法。 如果参数为null或不是Long则抛出异常。- 参数
-
index- 要返回的参数的索引。 - 结果
-
指定索引处的参数为
long值。 - 异常
-
ClassCastException- 如果指定索引处的参数不是Long -
NullPointerException- 如果指定索引处的参数为null -
ArrayIndexOutOfBoundsException- 如果index为负数或不低于此ParameterBlock对象的当前大小
-
getFloatParameter
public float getFloatParameter(int index)
将参数返回为浮点数的方便方法。 如果参数为null或不是Float则抛出异常。- 参数
-
index- 要返回的参数的索引。 - 结果
-
指定索引处的参数为
float。 - 异常
-
ClassCastException- 如果指定索引处的参数不是Float -
NullPointerException- 如果指定索引处的参数为null -
ArrayIndexOutOfBoundsException- 如果index为负数或不小于此ParameterBlock对象的当前大小
-
getDoubleParameter
public double getDoubleParameter(int index)
将参数返回为双精度的方便方法。 如果参数为null或不是Double则抛出异常。- 参数
-
index- 要返回的参数的索引。 - 结果
-
指定索引处的参数为
double值。 - 异常
-
ClassCastException- 如果指定索引处的参数不是Double -
NullPointerException- 如果指定索引处的参数为null -
ArrayIndexOutOfBoundsException- 如果index为负数或不小于此ParameterBlock对象的当前大小
-
getParamClasses
public Class<?>[] getParamClasses()
返回描述参数类型的Class对象数组。- 结果
-
一个
Class对象的数组。
-
-