|
JavaTM 2 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 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。