|
JavaTM 2 Platform Std. Ed. v1.3 |
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
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)
指定されたソースの Vector を使って ParameterBlock を構築します。 |
|
ParameterBlock(Vector sources,
Vector 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)
オブジェクトをパラメータのリストに追加します。 |
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)
ParameterBlock
を構築します。public ParameterBlock(Vector sources, Vector parameters)
ParameterBlock
を構築します。メソッドの詳細 |
public Object shallowClone()
ParameterBlock
のシャローコピーを作成します。ソースおよびパラメータの Vector は参照でコピーされます。追加や変更は両方のバージョンに対して可視になります。ParameterBlock
の Object の複製public Object clone()
ParameterBlock
のコピーを作成します。ソースおよびパラメータの Vector は複製されますが、実際のソースおよびパラメータは参照がコピーされます。このため、複製でのソースおよびパラメータの順序と数の変更は、元の ParameterBlock
からは不可視になります。一方、共有されるソースまたはパラメータでの変更は可視になります。Object
内の clone
ParameterBlock
の Object の複製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)
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()
|
JavaTM 2 Platform Std. Ed. v1.3 |
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
Java、Java 2D、JDBC は、米国およびその他の国における米国 Sun Microsystems, Inc. の商標もしくは登録商標です。
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.