|
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;
}
このコードは、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<Object> |
parameters
任意の Object として格納される、ソース以外のパラメータの Vector です。 |
protected Vector<Object> |
sources
任意の Object として格納される、ソースの Vector です。 |
| コンストラクタの概要 | |
|---|---|
ParameterBlock()
ダミーコンストラクタです。 |
|
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)
オブジェクトをパラメータのリストに追加します。 |
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)
パラメータのリストの 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<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 のシャローコピーを作成します。ソースおよびパラメータの Vector は参照でコピーされます。 追加や変更は両方のバージョンに対して可視になります。
ParameterBlock の Object の複製public Object clone()
ParameterBlock のコピーを作成します。ソースおよびパラメータの Vector は複製されますが、実際のソースおよびパラメータは参照でコピーされます。このため、複製でのソースおよびパラメータの順序と数の変更は、元の ParameterBlock からは不可視になります。一方、共有されるソースまたはパラメータ自体の変更は可視になります。
Object 内の cloneParameterBlock の Object の複製Cloneablepublic ParameterBlock addSource(Object source)
source - ソースリストに格納されるイメージオブジェクト
source を格納する新規の ParameterBlockpublic Object getSource(int index)
index - 返されるソースのインデックス
sources Vector 内の指定されたインデックスにあるソースを表す ObjectsetSource(Object, int)
public ParameterBlock setSource(Object source,
int index)
source - 指定されたソースイメージindex - 指定された source を挿入する sources Vector 内のインデックス
source を指定された index で格納する新規の ParameterBlockgetSource(int)public RenderedImage getRenderedSource(int index)
RenderedImage として返します。このメソッドは簡易メソッドです。ソースが RenderedImage でない場合、例外がスローされます。
index - 返されるソースのインデックス
sources Vector 内の指定されたインデックスにあるソースイメージを表す RenderedImagepublic RenderableImage getRenderableSource(int index)
index - 返されるソースのインデックス
sources Vector 内の指定されたインデックスにあるソースイメージを表す RenderableImagepublic int getNumSources()
sources Vector 内のソースイメージの数public Vector<Object> getSources()
sources VectorsetSources(Vector)public void setSources(Vector<Object> sources)
sources - ソースイメージの VectorgetSources()public void removeSources()
public int getNumParameters()
parameters Vector 内のパラメータの数public Vector<Object> getParameters()
parameters VectorsetParameters(Vector)public void setParameters(Vector<Object> parameters)
parameters - パラメータの指定された VectorgetParameters()public void removeParameters()
public ParameterBlock add(Object obj)
obj - parameters Vector に追加する Object
ParameterBlockpublic ParameterBlock add(byte b)
b - parameters Vector に追加する byte
ParameterBlockpublic ParameterBlock add(char c)
c - parameters Vector に追加する char
ParameterBlockpublic ParameterBlock add(short s)
s - parameters Vector に追加する short
ParameterBlockpublic ParameterBlock add(int i)
i - parameters Vector に追加する int
ParameterBlockpublic ParameterBlock add(long l)
l - parameters Vector に追加する long
ParameterBlockpublic ParameterBlock add(float f)
f - parameters Vector に追加する float
ParameterBlockpublic 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 - 指定されたパラメータに置き換えられるパラメータのインデックス
ParameterBlockpublic Object getObjectParameter(int index)
index - 取得するパラメータのインデックス
parameters Vector 内の指定されたインデックスにあるパラメータを表す Objectpublic 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 |
|||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
Copyright 2009 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Documentation Redistribution Policy も参照してください。