|
Java プラットフォーム 1.2 |
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
java.lang.Object | +--java.awt.image.renderable.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; }
このコードは、getSources オペレーションがソース Vector への参照を返したために、元の ParameterBlock を変更する副作用があります。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 メソッドは、こうした理由でソースとパラメータの両方の Vector の複製を実行するように定義されています。普通のシャロー複製では shallowClone が利用できます。
addSource、setSource、add、および set の各メソッドは、引数を追加したあとで this を返すように定義されます。そのため、次のような構文の使用が可能です。
ParameterBlock pb = new ParameterBlock(); op = new RenderableImageOp("operation", pb.add(arg1).add(arg2));
フィールドの概要 | |
protected Vector |
parameters
任意の Object として格納される、ソース以外のパラメータの Vector です。 |
protected Vector |
sources
任意の Object として格納される、ソースの Vector です。 |
コンストラクタの概要 | |
ParameterBlock()
ダミーコンストラクタです。 |
|
ParameterBlock(Vector sources)
指定された sources の Vector を使って ParameterBlock を構築します。 |
|
ParameterBlock(Vector sources,
Vector parameters)
指定された sources の Vector と parameters の 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)
オブジェクトをパラメータのリストに追加します。 |
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 |
getParameters()
パラメータの Vector 全体を返します。 |
RenderableImage |
getRenderableSource(int index)
ソースを RenderableImage として返す簡易メソッドです。 |
RenderedImage |
getRenderedSource(int index)
ソースを RenderedImage として返す簡易メソッドです。 |
short |
getShortParameter(int index)
パラメータを short として返す簡易メソッドです。 |
Object |
getSource(int index)
ソースを一般的な Object として返します。 |
Vector |
getSources()
ソースの Vector 全体を返します。 |
void |
removeParameters()
パラメータのリストをクリアします。 |
void |
removeSources()
ソースイメージのリストをクリアします。 |
ParameterBlock |
set(byte b,
int index)
パラメータのリストの Object を Byte に置き換えます。 |
ParameterBlock |
set(char c,
int index)
パラメータのリストの Object を Character に置き換えます。 |
ParameterBlock |
set(double d,
int index)
パラメータのリストの Object を Double に置き換えます。 |
ParameterBlock |
set(float f,
int index)
パラメータのリストの Object を Float に置き換えます。 |
ParameterBlock |
set(int i,
int index)
パラメータのリストの Object を Integer に置き換えます。 |
ParameterBlock |
set(long l,
int index)
パラメータのリストの Object を Long に置き換えます。 |
ParameterBlock |
set(Object obj,
int index)
パラメータのリストの Object を置き換えます。 |
ParameterBlock |
set(short s,
int index)
パラメータのリストの Object を Short に置き換えます。 |
void |
setParameters(Vector parameters)
指定された Vector にパラメータの Vector 全体を設定します。 |
ParameterBlock |
setSource(Object source,
int index)
ソースのリストのエントリを新しいソースに置き換えます。 |
void |
setSources(Vector sources)
指定された Vector にソースの Vector 全体を設定します。 |
Object |
shallowClone()
ParameterBlock のシャローコピーを作成します。 |
クラス java.lang.Object から継承したメソッド |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
フィールドの詳細 |
protected Vector sources
protected Vector parameters
コンストラクタの詳細 |
public ParameterBlock()
public ParameterBlock(Vector sources)
public ParameterBlock(Vector sources, Vector parameters)
メソッドの詳細 |
public Object shallowClone()
public Object clone()
public ParameterBlock addSource(Object source)
source
- ソースリストに格納されるイメージオブジェクトpublic Object getSource(int index)
index
- 返されるソースのインデックスpublic ParameterBlock setSource(Object source, int index)
public RenderedImage getRenderedSource(int index)
index
- 返されるソースのインデックスpublic RenderableImage getRenderableSource(int index)
index
- 返されるソースのインデックスpublic int getNumSources()
public Vector getSources()
public void setSources(Vector sources)
public void removeSources()
public int getNumParameters()
public Vector getParameters()
public void setParameters(Vector parameters)
public void removeParameters()
public ParameterBlock add(Object obj)
public ParameterBlock add(byte b)
public ParameterBlock add(char c)
public ParameterBlock add(short s)
public ParameterBlock add(int i)
public ParameterBlock add(long l)
public ParameterBlock add(float f)
public ParameterBlock add(double d)
public ParameterBlock set(Object obj, int index)
public ParameterBlock set(byte b, int index)
public ParameterBlock set(char c, int index)
public ParameterBlock set(short s, int index)
public ParameterBlock set(int i, int index)
public ParameterBlock set(long l, int index)
public ParameterBlock set(float f, int index)
public ParameterBlock set(double d, int index)
public Object getObjectParameter(int index)
public byte getByteParameter(int index)
index
- 返されるパラメータのインデックスpublic char getCharParameter(int index)
index
- 返されるパラメータのインデックスpublic short getShortParameter(int index)
index
- 返されるパラメータのインデックスpublic int getIntParameter(int index)
index
- 返されるパラメータのインデックスpublic long getLongParameter(int index)
index
- 返されるパラメータのインデックスpublic float getFloatParameter(int index)
index
- 返されるパラメータのインデックスpublic double getDoubleParameter(int index)
index
- 返されるパラメータのインデックスpublic Class[] getParamClasses()
|
Java プラットフォーム 1.2 |
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |