|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjava.awt.image.renderable.ParameterBlock
public class ParameterBlock
ParameterBlock 封装有关 RenderableImageOp 所需的源和参数 (Object) 的所有信息,或者其他处理图像的类。
尽管可以将任意对象放入源 Vector,但此类的用户可能会强加一些语义限制,如要求所有源都作为 RenderedImages 或 RenderableImage。ParameterBlock 本身只是一个容器,而且不对源或参数类型执行检查。
ParameterBlock 中的所有参数都是对象;可以使用便捷的 add 和 set 方法,这些方法带基本类型的参数并构建 Number(Integer 或 Float)的适当子类。相应的 get 方法执行向下强制转换并拥有基本类型的返回值;如果存储的值没有正确的类型,则会抛出异常。无法区分 "short s; add(s)" 和 "add(new Short(s))" 之间的结果。
注意,get 和 set 方法对引用进行操作。因此,需要小心的是,在不适当的时候一定不要共享 ParameterBlock 之间的引用。例如,要创建一个与旧 ParameterBlock(除了添加的源之外)相等的新 ParameterBlock,有人可能会尝试编写以下程序:
ParameterBlock addSource(ParameterBlock pb, RenderableImage im) {
ParameterBlock pb1 = new ParameterBlock(pb.getSources());
pb1.addSource(im);
return pb1;
}
这段代码具有替换原来 ParameterBlock 的负作用,因为 getSources 操作返回一个对其源 Vector 的引用。pb 和 pb1 同时共享其源 Vector,而且对其中之一的更改相对于两者来说都是可见的。
编写 addSource 函数的正确方法是复制源 Vector:
ParameterBlock addSource (ParameterBlock pb, RenderableImage im) {
ParameterBlock pb1 = new ParameterBlock(pb.getSources().clone());
pb1.addSource(im);
return pb1;
}
因此,定义了 ParameterBlock 的 clone 方法,以执行源和参数 Vectors 的副本。可以使用标准的浅表副本 shallowClone。
定义了 addSource、setSource、add 和 set 方法,以在添加其参数后返回 'this'。这允许使用类似以下的语法:
ParameterBlock pb = new ParameterBlock();
op = new RenderableImageOp("operation", pb.add(arg1).add(arg2));
| 字段摘要 | |
|---|---|
protected Vector<Object> |
parameters
一个非源参数的 Vector,存储为任意 Object。 |
protected Vector<Object> |
sources
源的 Vector,存储为任意 Objects。 |
| 构造方法摘要 | |
|---|---|
ParameterBlock()
一个 dummy 构造方法。 |
|
ParameterBlock(Vector<Object> sources)
使用源的给定 Vector 构造一个 ParameterBlock。 |
|
ParameterBlock(Vector<Object> sources,
Vector<Object> parameters)
使用源的给定 Vector 和参数的 Vector 构造一个 ParameterBlock。 |
|
| 方法摘要 | |
|---|---|
ParameterBlock |
add(byte b)
将一个 Byte 添加到此参数列表。 |
ParameterBlock |
add(char c)
将一个 Character 添加到此参数列表。 |
ParameterBlock |
add(double d)
将一个 Double 添加到此参数列表。 |
ParameterBlock |
add(float f)
将一个 Float 添加到此参数列表。 |
ParameterBlock |
add(int i)
将一个 Integer 添加到此参数列表。 |
ParameterBlock |
add(long l)
将一个 Long 添加到此参数列表。 |
ParameterBlock |
add(Object obj)
将一个 Object 添加到此参数列表。 |
ParameterBlock |
add(short s)
将一个 Short 添加到此参数列表。 |
ParameterBlock |
addSource(Object source)
将一个图像添加到源列表的末尾。 |
Object |
clone()
创建 ParameterBlock 的一个副本。 |
byte |
getByteParameter(int index)
作为 byte 返回参数的便捷方法。 |
char |
getCharParameter(int index)
作为 char 返回参数的便捷方法。 |
double |
getDoubleParameter(int index)
作为 double 返回参数的便捷方法。 |
float |
getFloatParameter(int index)
作为 float 返回参数的便捷方法。 |
int |
getIntParameter(int index)
作为 int 返回参数的便捷方法。 |
long |
getLongParameter(int index)
作为 long 返回参数的便捷方法。 |
int |
getNumParameters()
返回参数的数量(不包括源图像)。 |
int |
getNumSources()
返回源图像的数量。 |
Object |
getObjectParameter(int index)
获取作为对象的参数。 |
Class[] |
getParamClasses()
返回描述该参数的 Class 对象的数组。 |
Vector<Object> |
getParameters()
返回参数的整个 Vector。 |
RenderableImage |
getRenderableSource(int index)
返回作为 RenderableImage 的源。 |
RenderedImage |
getRenderedSource(int index)
返回作为 RenderedImage 的源。 |
short |
getShortParameter(int index)
作为 short 返回参数的便捷方法。 |
Object |
getSource(int index)
返回作为通用 Object 的源。 |
Vector<Object> |
getSources()
返回源的整个 Vector。 |
void |
removeParameters()
清除参数列表。 |
void |
removeSources()
清除源图像的列表。 |
ParameterBlock |
set(byte b,
int index)
使用 Byte 替换参数列表中的一个 Object。 |
ParameterBlock |
set(char c,
int index)
使用 Character 替换参数列表中的一个 Object。 |
ParameterBlock |
set(double d,
int index)
使用 Double 替换参数列表中的一个 Object。 |
ParameterBlock |
set(float f,
int index)
使用 Float 替换参数列表中的一个 Object。 |
ParameterBlock |
set(int i,
int index)
使用 Integer 替换参数列表中的一个 Object。 |
ParameterBlock |
set(long l,
int index)
使用 Long 替换参数列表中的一个 Object。 |
ParameterBlock |
set(Object obj,
int index)
替换此参数列表中的一个 Object。 |
ParameterBlock |
set(short s,
int index)
使用 Short 替换参数列表中的一个 Object。 |
void |
setParameters(Vector<Object> parameters)
将参数的整个 Vector 设置为给定 Vector。 |
ParameterBlock |
setSource(Object source,
int index)
将源列表中的某个项替换为一个新源。 |
void |
setSources(Vector<Object> sources)
将源的整个 Vector 设置为给定 Vector。 |
Object |
shallowClone()
创建 ParameterBlock 的一个浅表副本。 |
| 从类 java.lang.Object 继承的方法 |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
protected Vector<Object> sources
protected Vector<Object> parameters
| 构造方法详细信息 |
|---|
public ParameterBlock()
public ParameterBlock(Vector<Object> sources)
ParameterBlock。
sources - 源映像的 Vector
public ParameterBlock(Vector<Object> sources,
Vector<Object> parameters)
ParameterBlock。
sources - 源映像的 Vectorparameters - 要在呈现操作中使用的参数的 Vector| 方法详细信息 |
|---|
public Object shallowClone()
ParameterBlock 的一个浅表副本。按引用复制源和参数 Vectors,添加或更改将对两个版本都可见。
ParameterBlock 的 Object 副本。public Object clone()
ParameterBlock 的一个副本。复制源和参数 Vector,但实际源和参数按引用复制。这允许对副本中源和参数的顺序和数量的更改在初始 ParameterBlock 中可见。对共享源或参数本身的更改仍将可见。
Object 中的 cloneParameterBlock 的 Object 副本。Cloneablepublic ParameterBlock addSource(Object source)
source - 将存储到源列表中的图像对象。
source 的新 ParameterBlock。public Object getSource(int index)
index - 要返回的源的索引。
sources Vector 中指定索引处的源的 Object。setSource(Object, int)
public ParameterBlock setSource(Object source,
int index)
source - 指定的源图像index - 指向 sources Vector 索引,在该处将插入指定的 source
index 处的指定 source 的新 ParameterBlock。getSource(int)public RenderedImage getRenderedSource(int index)
RenderedImage 的源。这是一种便捷方法。如果源不是 RenderedImage,则会抛出异常。
index - 要返回的源的索引
sources Vector 中指定索引处的源图像的 RenderedImage。public RenderableImage getRenderableSource(int index)
index - 要返回的源的索引
sources Vector 中指定索引处的源图像的 RenderableImage。public int getNumSources()
sources Vector 中源图像的数量。public Vector<Object> getSources()
sources Vector。setSources(Vector)public void setSources(Vector<Object> sources)
sources - 源图像的 VectorgetSources()public void removeSources()
public int getNumParameters()
parameters Vector 中的参数数量。public Vector<Object> getParameters()
parameters Vector。setParameters(Vector)public void setParameters(Vector<Object> parameters)
parameters - 参数的指定 VectorgetParameters()public void removeParameters()
public ParameterBlock add(Object obj)
obj - 要添加到此 parameters Vector 的 Object
ParameterBlock。public ParameterBlock add(byte b)
b - 要添加到此 parameters Vector 的 Byte
ParameterBlock。public ParameterBlock add(char c)
c - 要添加到此 parameters Vector 的 char
ParameterBlock。public ParameterBlock add(short s)
s - 要添加到此 parameters Vector 的 short
ParameterBlock。public ParameterBlock add(int i)
i - 要添加到此 parameters Vector 的 int
ParameterBlock。public ParameterBlock add(long l)
l - 要添加到此 parameters Vector 的 long
ParameterBlock。public ParameterBlock add(float f)
f - 要添加到此 parameters Vector 的 float
ParameterBlock。public ParameterBlock add(double d)
d - 要添加到此 parameters Vector 的 double
ParameterBlock。
public ParameterBlock set(Object obj,
int index)
obj - 替换 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 中指定索引处参数的参数index - 要使用指定参数替换的参数索引
ParameterBlock。
public ParameterBlock set(short s,
int index)
s - 替换 parameters Vector 中指定索引处参数的参数index - 要使用指定参数替换的参数索引
ParameterBlock。
public ParameterBlock set(int i,
int index)
i - 替换 parameters Vector 中指定索引处参数的参数index - 要使用指定参数替换的参数索引
ParameterBlock。
public ParameterBlock set(long l,
int index)
l - 替换 parameters Vector 中指定索引处参数的参数index - 要使用指定参数替换的参数索引
ParameterBlock。
public ParameterBlock set(float f,
int index)
f - 替换 parameters Vector 中指定索引处参数的参数index - 要使用指定参数替换的参数索引
ParameterBlock。
public ParameterBlock set(double d,
int index)
d - 替换 parameters Vector 中指定索引处参数的参数index - 要使用指定参数替换的参数索引
ParameterBlock。public Object getObjectParameter(int index)
index - 要获取的参数的索引
parameters Vector 中指定索引处参数的 Object。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 Class[] getParamClasses()
Class 对象的数组。
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。