public class ParameterBlock extends Object implements Cloneable, Serializable
ParameterBlock封装了所有关于RenderableImageOp或处理图像的其他类所需的源和参数(Objects)的信息。
虽然可以在源向量中放置任意对象,但此类的用户可能会强加语义约束,例如要求所有源都是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));
| Modifier and Type | Field and Description |
|---|---|
protected Vector<Object> |
parameters
非源参数向量,存储为任意对象。
|
protected Vector<Object> |
sources
源的矢量,存储为任意对象。
|
| Constructor and Description |
|---|
ParameterBlock()
一个虚拟构造函数。
|
ParameterBlock(Vector<Object> sources)
构造一个
ParameterBlock与给定的源的向量。
|
ParameterBlock(Vector<Object> sources, Vector<Object> parameters)
构造一个
ParameterBlock与给定矢量的源和参数矢量。
|
| Modifier and Type | Method and Description |
|---|---|
ParameterBlock |
add(byte b)
将一个字节添加到参数列表中。
|
ParameterBlock |
add(char c)
在参数列表中添加一个字符。
|
ParameterBlock |
add(double d)
向参数列表中添加一个Double。
|
ParameterBlock |
add(float f)
将浮点数添加到参数列表中。
|
ParameterBlock |
add(int i)
将一个整数添加到参数列表中。
|
ParameterBlock |
add(long l)
在参数列表中添加一个Long。
|
ParameterBlock |
add(Object obj)
将对象添加到参数列表中。
|
ParameterBlock |
add(short s)
在参数列表中添加一个Short。
|
ParameterBlock |
addSource(Object source)
将图像添加到源列表的末尾。
|
Object |
clone()
创建一个
ParameterBlock的副本。
|
byte |
getByteParameter(int index)
一个方便的方法返回一个参数作为一个字节。
|
char |
getCharParameter(int index)
一个方便的方法返回参数作为一个char。
|
double |
getDoubleParameter(int index)
将参数返回为双精度的方便方法。
|
float |
getFloatParameter(int index)
将参数返回为浮点数的方便方法。
|
int |
getIntParameter(int index)
以int形式返回参数的方便方法。
|
long |
getLongParameter(int index)
一个方便返回参数的方法。
|
int |
getNumParameters()
返回参数数量(不包括源图像)。
|
int |
getNumSources()
返回源图像的数量。
|
Object |
getObjectParameter(int index)
获取参数作为对象。
|
类[] |
getParamClasses()
返回描述参数类型的Class对象数组。
|
Vector<Object> |
getParameters()
返回整个参数向量。
|
RenderableImage |
getRenderableSource(int index)
作为RenderableImage返回一个源。
|
RenderedImage |
getRenderedSource(int index)
返回一个来源为
RenderedImage 。
|
short |
getShortParameter(int index)
一个简单的方法返回一个参数。
|
Object |
getSource(int index)
将源作为一般对象返回。
|
Vector<Object> |
getSources()
返回整个Vector的Vector。
|
void |
removeParameters()
清除参数列表。
|
void |
removeSources()
清除源图像列表。
|
ParameterBlock |
set(byte b, int index)
使用字节替换参数列表中的对象。
|
ParameterBlock |
set(char c, int index)
用Character替换参数列表中的Object。
|
ParameterBlock |
set(double d, int index)
用Double替换参数列表中的对象。
|
ParameterBlock |
set(float f, int index)
用Float替换参数列表中的对象。
|
ParameterBlock |
set(int i, int index)
用Integer替换参数列表中的对象。
|
ParameterBlock |
set(long l, int index)
用Long替换参数列表中的对象。
|
ParameterBlock |
set(Object obj, int index)
替换参数列表中的对象。
|
ParameterBlock |
set(short s, int index)
用Short替换参数列表中的对象。
|
void |
setParameters(Vector<Object> parameters)
将参数的整个Vector设置为给定的Vector。
|
ParameterBlock |
setSource(Object source, int index)
用源代替源列表中的条目。
|
void |
setSources(Vector<Object> sources)
将整个Vector矢量设置为给定的Vector。
|
Object |
shallowClone()
创建一个
ParameterBlock的浅拷贝。
|
public ParameterBlock()
public ParameterBlock(Vector<Object> sources)
ParameterBlock与给定的源的向量。
sources - 一幅
Vector的源图像
public Object shallowClone()
ParameterBlock的浅拷贝。
源和参数向量将被引用复制 - 对这两个版本都可以看到添加或更改。
ParameterBlock 。
public Object clone()
ParameterBlock的副本。
源和参数向量被克隆,但实际的源和参数是通过引用复制的。
这允许修改克隆中的源和参数的顺序和数量对原始ParameterBlock 。
对共享源或参数本身的更改仍将可见。
public ParameterBlock addSource(Object source)
source - 要存储在源列表中的图像对象。
ParameterBlock包含指定的
source 。
public Object getSource(int index)
index - 要返回的源的索引。
Object代表位于指定索引的
sources
Vector中的
Vector 。
setSource(Object, int)
public ParameterBlock setSource(Object source, int index)
source - 指定的源图像
index - 索引入
sources
Vector ,在其中插入指定的
source
ParameterBlock包含指定的
source在指定的
index 。
getSource(int)
public RenderedImage getRenderedSource(int index)
RenderedImage 。
这种方法是一种方便的方法。
如果源不是RenderedImage,将抛出异常。
index - 要返回的源的索引
RenderedImage表示源图像是在指定索引处
sources
Vector 。
public RenderableImage getRenderableSource(int index)
index - 要返回的源的索引
RenderableImage表示源图像是在指定索引处
sources
Vector 。
public int getNumSources()
sources
Vector 。
public Vector<Object> getSources()
sources
Vector 。
setSources(Vector)
public void setSources(Vector<Object> sources)
sources - 源图像的
Vector
getSources()
public void removeSources()
public int getNumParameters()
parameters
Vector 。
public Vector<Object> getParameters()
parameters
Vector 。
setParameters(Vector)
public void setParameters(Vector<Object> parameters)
parameters -
Vector的参数Vector
getParameters()
public void removeParameters()
public ParameterBlock add(Object obj)
obj -
Object加到
parameters
Vector
ParameterBlock包含指定的参数。
public ParameterBlock add(byte b)
b - 要添加到
parameters的字节
Vector
ParameterBlock包含指定的参数。
public ParameterBlock add(char c)
c - 添加到
parameters
Vector
ParameterBlock包含指定的参数。
public ParameterBlock add(short s)
s - 短加到
parameters
Vector
ParameterBlock包含指定的参数。
public ParameterBlock add(int i)
i - 将int加到
parameters
Vector
ParameterBlock包含指定的参数。
public ParameterBlock add(long l)
l - 长期加入
parameters
Vector
ParameterBlock包含指定的参数。
public ParameterBlock add(float f)
f - 浮动添加到
parameters
Vector
ParameterBlock包含指定的参数。
public ParameterBlock add(double d)
d - 双加到
parameters
Vector
ParameterBlock包含指定的参数。
public ParameterBlock set(Object obj, int index)
obj - 在parameters Vector中替换指定索引处的
parameters
Vector
index - 用指定参数替换参数的索引
ParameterBlock包含指定的参数。
public ParameterBlock set(byte b, int index)
b - 用于替换指定索引中的
parameters
Vector
index - 用指定参数替换参数的索引
ParameterBlock包含指定的参数。
public ParameterBlock set(char c, int index)
c - 在parameters Vector中指定的索引处替换
parameters
Vector
index - 用指定参数替换参数的索引
ParameterBlock包含指定的参数。
public ParameterBlock set(short s, int index)
s - 在parameters Vector中替换指定索引处的
parameters
Vector
index - 用指定参数替换参数的索引
ParameterBlock包含指定的参数。
public ParameterBlock set(int i, int index)
i - 在parameters Vector中指定索引处替换
parameters
Vector
index - 用指定参数替换参数的索引
ParameterBlock包含指定的参数。
public ParameterBlock set(long l, int index)
l - 在parameters Vector中的指定索引处替换
parameters
Vector
index - 用指定参数替换参数的索引
ParameterBlock包含指定的参数。
public ParameterBlock set(float f, int index)
f - 在parameters Vector中的指定索引处替换
parameters
Vector
index - 用指定参数替换参数的索引
ParameterBlock包含指定的参数。
public ParameterBlock set(double d, int index)
d - 在parameters Vector中指定的索引处替换
parameters
Vector
index - 用指定参数替换参数的索引
ParameterBlock包含指定的参数。
public Object getObjectParameter(int index)
index - 要获取的参数的索引
Object表示在指定的指数中的
parameters
Vector 。
public byte getByteParameter(int index)
null或不Byte 。
index - 要返回的参数的索引。
byte值。
ClassCastException - 如果指定索引处的参数不是
Byte
NullPointerException - 如果指定索引处的参数为
null
ArrayIndexOutOfBoundsException - 如果
index为负数或不低于此
ParameterBlock对象的当前大小
public char getCharParameter(int index)
null或不Character 。
index - 要返回的参数的索引。
char值。
ClassCastException - 如果指定索引处的参数不是
Character
NullPointerException - 如果指定索引处的参数为
null
ArrayIndexOutOfBoundsException - 如果
index为负数或不小于此
ParameterBlock对象的当前大小
public short getShortParameter(int index)
null或不Short 。
index - 要返回的参数的索引。
short值。
ClassCastException - 如果指定索引处的参数不是
Short
NullPointerException - 如果指定索引处的参数为
null
ArrayIndexOutOfBoundsException - 如果
index为负数或不小于此
ParameterBlock对象的当前大小
public int getIntParameter(int index)
null或不是Integer 。
index - 要返回的参数的索引。
int值。
ClassCastException - 如果指定索引处的参数不是
Integer
NullPointerException - 如果指定索引处的参数为
null
ArrayIndexOutOfBoundsException - 如果
index为负数或不小于此
ParameterBlock对象的当前大小
public long getLongParameter(int index)
null或不Long 。
index - 要返回的参数的索引。
long 。
ClassCastException - 如果指定索引处的参数不是
Long
NullPointerException - 如果指定索引处的参数为
null
ArrayIndexOutOfBoundsException - 如果
index为负数或不小于此
ParameterBlock对象的当前大小
public float getFloatParameter(int index)
null或不Float 。
index - 要返回的参数的索引。
float值。
ClassCastException - 如果指定索引处的参数不是
Float
NullPointerException - 如果指定索引处的参数为
null
ArrayIndexOutOfBoundsException - 如果
index为负数或不小于此
ParameterBlock对象的当前大小
public double getDoubleParameter(int index)
null或不Double 。
index - 要返回的参数的索引。
double值。
ClassCastException - 如果指定索引处的参数不是
Double
NullPointerException - 如果指定索引处的参数为
null
ArrayIndexOutOfBoundsException - 如果
index为负数或不小于此
ParameterBlock对象的当前大小
public 类[] getParamClasses()
类对象。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.