public class ComponentSampleModel extends SampleModel
DataBuffer.TYPE_BYTE
、DataBuffer.TYPE_USHORT
、またはDataBuffer.TYPE_INT
を使用)で格納できる符号なし整数値を各サンプルに持つイメージ・データ、16ビット(DataBuffer.TYPE_SHORT
を使用)で格納できる符号付き整数値を各サンプルに持つデータ、または符号付きfloat型またはdouble型の数値(それぞれDataBuffer.TYPE_FLOAT
またはDataBuffer.TYPE_DOUBLE
を使用)を各サンプルに持つデータを表すことができます。このとき、指定されたComponentSampleModelのすべてのサンプルも、同じ精度で格納されます。すべてのストライド、およびオフセットは、負でない数値とする必要があります。このクラスは、TYPE_BYTE
、TYPE_USHORT
、TYPE_SHORT
、TYPE_INT
、TYPE_FLOAT
、およびTYPE_DOUBLE
をサポートします。修飾子と型 | フィールドと説明 |
---|---|
protected int[] |
bandOffsets
データ配列要素にあるすべてのバンドのオフセットです。
|
protected int[] |
bankIndices
イメージ・データのバンドを格納する各バンクのインデックスです。
|
protected int |
numBands
この
ComponentSampleModel 内のバンド数です。 |
protected int |
numBanks
この
ComponentSampleModel 内のバンク数です。 |
protected int |
pixelStride
このComponentSampleModelで記述されるイメージ・データ領域(データ配列要素)のピクセル・ストライドです。
|
protected int |
scanlineStride
このComponentSampleModelで記述されるイメージ・データ領域(データ配列要素)の走査線ストライドです。
|
dataType, height, width
コンストラクタと説明 |
---|
ComponentSampleModel(int dataType, int w, int h, int pixelStride, int scanlineStride, int[] bandOffsets)
指定されたパラメータで、ComponentSampleModelを構築します。
|
ComponentSampleModel(int dataType, int w, int h, int pixelStride, int scanlineStride, int[] bankIndices, int[] bandOffsets)
指定されたパラメータで、ComponentSampleModelを構築します。
|
修飾子と型 | メソッドと説明 |
---|---|
SampleModel |
createCompatibleSampleModel(int w, int h)
指定された幅と高さを持つ新しい
ComponentSampleModel を作成します。 |
DataBuffer |
createDataBuffer()
この
ComponentSampleModel に対応するDataBuffer を構築します。 |
SampleModel |
createSubsetSampleModel(int[] bands)
このComponentSampleModelのサブセットを持つ、新しいComponentSampleModelを構築します。
|
boolean |
equals(Object o)
このオブジェクトと他のオブジェクトが等しいかどうかを示します。
|
int[] |
getBandOffsets()
すべてのバンドについて、バンドのオフセットを返します。
|
int[] |
getBankIndices()
すべてのバンクについて、バンクのインデックスを返します。
|
Object |
getDataElements(int x, int y, Object obj, DataBuffer data)
TransferType 型のプリミティブ配列内の1つのピクセルのデータを返します。 |
int |
getNumDataElements()
getDataElements(int, int, Object, DataBuffer) メソッドおよびsetDataElements(int, int, Object, DataBuffer) メソッドを使って1ピクセル転送するのに必要なデータ要素の数を返します。 |
int |
getOffset(int x, int y)
ピクセル(x, y)の最初のバンドのオフセットを返します。
|
int |
getOffset(int x, int y, int b)
ピクセル(x, y)のバンドbのオフセットを返します。
|
int[] |
getPixel(int x, int y, int[] iArray, DataBuffer data)
指定されたピクセルのすべてのサンプルをint配列として返します。配列要素にサンプル1個が対応します。
|
int[] |
getPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
int配列の指定されたピクセルの矩形のすべてのサンプルを返します。配列要素ごとに1つのサンプルが返されます。
|
int |
getPixelStride()
このComponentSampleModelのピクセル・ストライドを返します。
|
int |
getSample(int x, int y, int b, DataBuffer data)
(x, y)に位置するピクセルの、指定されたバンド内のサンプルをintとして返します。
|
double |
getSampleDouble(int x, int y, int b, DataBuffer data)
(x, y)に位置するピクセルの指定されたバンド内のサンプルをdoubleとして返します。
|
float |
getSampleFloat(int x, int y, int b, DataBuffer data)
(x, y)に位置するピクセルの指定されたバンド内のサンプルをfloatとして返します。
|
int[] |
getSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
指定されたピクセル矩形に使う、指定されたバンド内のサンプルをint配列として返します。データ配列要素にサンプル1個が対応します。
|
int[] |
getSampleSize()
すべてのバンドのサンプルあたりのビット数を返します。
|
int |
getSampleSize(int band)
指定されたバンドのサンプルあたりのビット数を返します。
|
int |
getScanlineStride()
このComponentSampleModelの走査線ストライドを返します。
|
int |
hashCode()
オブジェクトのハッシュ・コード値を返します。
|
void |
setDataElements(int x, int y, Object obj, DataBuffer data)
指定された
DataBuffer の1つのピクセルのデータを、TransferType 型のプリミティブ配列から設定します。 |
void |
setPixel(int x, int y, int[] iArray, DataBuffer data)
サンプルのint配列を入力として使って
DataBuffer 内のピクセルを設定します。 |
void |
setPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
矩形のピクセルのサンプルすべてを、配列要素ごとに1つのサンプルが格納されているint配列から設定します。
|
void |
setSample(int x, int y, int b, double s, DataBuffer data)
doubleを入力として使用し、
DataBuffer 内の(x, y)に位置するピクセルの、指定されたバンド内のサンプルを設定します。 |
void |
setSample(int x, int y, int b, float s, DataBuffer data)
floatを入力として使用し、
DataBuffer 内の(x, y)に位置するピクセルの、指定されたバンド内のサンプルを設定します。 |
void |
setSample(int x, int y, int b, int s, DataBuffer data)
intを入力とし、
DataBuffer の(x,y)に位置するピクセルの、指定されたバンドのサンプルを設定します。 |
void |
setSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
データ配列要素あたり1個のサンプルを格納しているint配列から、指定されたピクセル矩形の、指定されたバンドにサンプルを設定します。
|
getDataElements, getDataType, getHeight, getNumBands, getPixel, getPixel, getPixels, getPixels, getSamples, getSamples, getTransferType, getWidth, setDataElements, setPixel, setPixel, setPixels, setPixels, setSamples, setSamples
protected int[] bandOffsets
protected int[] bankIndices
protected int numBands
ComponentSampleModel
内のバンド数です。protected int numBanks
ComponentSampleModel
内のバンク数です。protected int scanlineStride
protected int pixelStride
public ComponentSampleModel(int dataType, int w, int h, int pixelStride, int scanlineStride, int[] bandOffsets)
dataType
- サンプル格納用のデータ形式w
- 記述されたイメージ・データの領域の幅(単位はピクセル)h
- 記述されたイメージ・データの領域の高さ(単位はピクセル)pixelStride
- 記述されるイメージ・データの領域のピクセル・ストライドscanlineStride
- 記述されるイメージ・データの領域のライン・ストライドbandOffsets
- すべてのバンドのオフセットIllegalArgumentException
- w
またはh
が0以下である場合IllegalArgumentException
- pixelStride
が0より小さい場合IllegalArgumentException
- scanlineStride
が0より小さい場合IllegalArgumentException
- numBands
が1より小さい場合IllegalArgumentException
- w
とh
の積がInteger.MAX_VALUE
より大きい場合IllegalArgumentException
- dataType
がサポートされているデータ型でない場合public ComponentSampleModel(int dataType, int w, int h, int pixelStride, int scanlineStride, int[] bankIndices, int[] bandOffsets)
dataType
- サンプル格納用のデータ形式w
- 記述されたイメージ・データの領域の幅(単位はピクセル)h
- 記述されたイメージ・データの領域の高さ(単位はピクセル)pixelStride
- 記述されるイメージ・データの領域のピクセル・ストライドscanlineStride
- 記述されるイメージ・データの領域のライン・ストライドbankIndices
- すべてのバンドのバンク・インデックスbandOffsets
- すべてのバンドのバンド・オフセットIllegalArgumentException
- w
またはh
が0以下である場合IllegalArgumentException
- pixelStride
が0より小さい場合IllegalArgumentException
- scanlineStride
が0より小さい場合IllegalArgumentException
- bankIndices
の長さがbankOffsets
の長さと等しくない場合IllegalArgumentException
- bandIndices
のバンク・インデックスのいずれかが0より小さい場合IllegalArgumentException
- dataType
がサポートされているデータ型でない場合public SampleModel createCompatibleSampleModel(int w, int h)
ComponentSampleModel
を作成します。新しいSampleModel
は、このSampleModel
と同じ数のバンド、ストレージ・データ型、インタリーブ化方式、およびピクセル・ストライドを持ちます。createCompatibleSampleModel
、クラス: SampleModel
w
- 結果として得られるSampleModel
の幅h
- 結果として得られるSampleModel
の高さComponentSampleModel
IllegalArgumentException
- w
またはh
が0以下である場合public SampleModel createSubsetSampleModel(int[] bands)
createSubsetSampleModel
、クラス: SampleModel
bands
- このComponentSampleModel
のバンドのサブセットComponentSampleModel
のバンドのサブセットで作成されたComponentSampleModel
。public DataBuffer createDataBuffer()
ComponentSampleModel
に対応するDataBuffer
を構築します。DataBuffer
のデータ型、バンク数、およびサイズは、このComponentSampleModel
と矛盾しません。createDataBuffer
、クラス: SampleModel
ComponentSampleModel
とデータ型、バンク数、およびサイズが同じDataBuffer
。public int getOffset(int x, int y)
DataBuffer
data
から、ComponentSampleModel
csm
を使って次のようにして取得できます。
data.getElem(csm.getOffset(x, y));
x
- ピクセルのX位置y
- ピクセルのY位置public int getOffset(int x, int y, int b)
b
のサンプルは、DataBuffer
data
から、ComponentSampleModel
csm
を使って次のようにして取得できます。
data.getElem(csm.getOffset(x, y, b));
x
- 指定されたピクセルのX位置y
- 指定されたピクセルのY位置b
- 指定されたバンドpublic final int[] getSampleSize()
getSampleSize
、クラス: SampleModel
public final int getSampleSize(int band)
getSampleSize
、クラス: SampleModel
band
- 指定されたバンドpublic final int[] getBankIndices()
public final int[] getBandOffsets()
public final int getScanlineStride()
ComponentSampleModel
の走査線ストライド。public final int getPixelStride()
ComponentSampleModel
のピクセル・ストライド。public final int getNumDataElements()
getDataElements(int, int, Object, DataBuffer)
メソッドおよびsetDataElements(int, int, Object, DataBuffer)
メソッドを使って1ピクセル転送するのに必要なデータ要素の数を返します。ComponentSampleModel
では、これはバンド数と等しくなります。getNumDataElements
、クラス: SampleModel
getDataElements
メソッドとsetDataElements
メソッドで1ピクセルを転送するために必要なデータ要素の数。SampleModel.getNumDataElements()
, SampleModel.getNumBands()
public Object getDataElements(int x, int y, Object obj, DataBuffer data)
TransferType
型のプリミティブ配列内の1つのピクセルのデータを返します。ComponentSampleModel
では、これはデータ型と等しくなり、サンプルが配列要素ごとに1個ずつ返されます。通常は、Object
が自動的に作成され、正しい基本データ型になるように、obj
にはnull
が渡されます。
次のコードは、ComponentSampleModel
csm1
によってストレージ・レイアウトが記述されているDataBuffer
db1
から、ComponentSampleModel
csm2
によってストレージ・レイアウトが記述されているDataBuffer
db2
へ、1ピクセルのデータを転送する例です。この転送方法は、getPixel
およびsetPixel
を使う方法よりも通常効率的です。
ComponentSampleModel csm1, csm2; DataBufferInt db1, db2; csm2.setDataElements(x, y, csm1.getDataElements(x, y, null, db1), db2);
SampleModel
オブジェクトのバンド数が同じで、対応するバンドのサンプルあたりのビット数が同じで、TransferType
が同じである場合、2つのDataBuffer/SampleModel
ペア間の転送には、getDataElements
およびsetDataElements
を使用するのが適切です。
obj
がnull
でない場合は、TransferType
型のプリミティブ配列になります。そうでない場合は、ClassCastException
がスローされます。座標が境界内にない場合や、obj
がnull
でなく、ピクセル・データを格納するために十分な大きさでない場合は、ArrayIndexOutOfBoundsException
がスローされます。
getDataElements
、クラス: SampleModel
x
- ピクセル位置のX座標y
- ピクセル位置のY座標obj
- null
でない場合は、ピクセル・データが返されるプリミティブ配列data
- イメージ・データを格納するDataBuffer
NullPointerException
- dataがnullの場合。ArrayIndexOutOfBoundsException
- 座標が境界内に存在しない場合、またはobjが小さすぎて出力を保持できない場合。setDataElements(int, int, Object, DataBuffer)
public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
ArrayIndexOutOfBoundsException
がスローされることがあります。getPixel
、クラス: SampleModel
x
- ピクセル位置のX座標y
- ピクセル位置のY座標iArray
- nullでない場合、この配列内のサンプルを返しますdata
- イメージ・データを格納するDataBufferNullPointerException
- dataがnullの場合。ArrayIndexOutOfBoundsException
- 座標が境界内に存在しない場合、またはiArrayが小さすぎて出力を保持できない場合。setPixel(int, int, int[], DataBuffer)
public int[] getPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
ArrayIndexOutOfBoundsException
がスローされることがあります。getPixels
、クラス: SampleModel
x
- 左上のピクセル位置のX座標y
- 左上のピクセル位置のY座標w
- ピクセル矩形の幅h
- ピクセル矩形の高さiArray
- nullでない場合、この配列内のサンプルを返しますdata
- イメージ・データを格納するDataBuffersetPixels(int, int, int, int, int[], DataBuffer)
public int getSample(int x, int y, int b, DataBuffer data)
ArrayIndexOutOfBoundsException
がスローされることがあります。getSample
、クラス: SampleModel
x
- ピクセル位置のX座標y
- ピクセル位置のY座標b
- 返されるバンドdata
- イメージ・データを格納するDataBuffer
setSample(int, int, int, int, DataBuffer)
public float getSampleFloat(int x, int y, int b, DataBuffer data)
ArrayIndexOutOfBoundsException
がスローされることがあります。getSampleFloat
、クラス: SampleModel
x
- ピクセル位置のX座標y
- ピクセル位置のY座標b
- 返されるバンドdata
- イメージ・データを格納するDataBufferpublic double getSampleDouble(int x, int y, int b, DataBuffer data)
ArrayIndexOutOfBoundsException
がスローされることがあります。getSampleDouble
、クラス: SampleModel
x
- ピクセル位置のX座標y
- ピクセル位置のY座標b
- 返されるバンドdata
- イメージ・データを格納するDataBufferpublic int[] getSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
ArrayIndexOutOfBoundsException
がスローされることがあります。getSamples
、クラス: SampleModel
x
- 左上のピクセル位置のX座標y
- 左上のピクセル位置のY座標w
- ピクセル矩形の幅h
- ピクセル矩形の高さb
- 返されるバンドiArray
- null
でない場合、この配列内のサンプルを返すdata
- イメージ・データを格納するDataBuffer
setSamples(int, int, int, int, int, int[], DataBuffer)
public void setDataElements(int x, int y, Object obj, DataBuffer data)
DataBuffer
の1つのピクセルのデータを、TransferType
型のプリミティブ配列から設定します。ComponentSampleModel
では、これはデータ型と同じになり、サンプルは各配列要素に1個ずつ転送されます。
次のコードは、ComponentSampleModel
csm1
によってストレージ・レイアウトが記述されているDataBuffer
db1
から、ComponentSampleModel
csm2
によってストレージ・レイアウトが記述されているDataBuffer
db2
へ、1ピクセルのデータを転送する例です。この転送方法は、getPixel
およびsetPixel
を使う方法よりも通常効率的です。
ComponentSampleModel csm1, csm2; DataBufferInt db1, db2; csm2.setDataElements(x, y, csm1.getDataElements(x, y, null, db1), db2);
SampleModel
オブジェクトのバンド数が同じで、対応するバンドのサンプルあたりのビット数が同じで、TransferType
が同じである場合、2つのDataBuffer/SampleModel
ペア間の転送には、getDataElements
およびsetDataElements
を使用するのが適切です。
obj
がTransferType
型のプリミティブ配列でない場合は、ClassCastException
がスローされます。座標が境界内にない場合や、obj
がピクセル・データを格納するために十分な大きさでない場合は、ArrayIndexOutOfBoundsException
がスローされます。
setDataElements
、クラス: SampleModel
x
- ピクセル位置のX座標y
- ピクセル位置のY座標obj
- ピクセル・データを格納するプリミティブ配列data
- イメージ・データを格納するDataBuffergetDataElements(int, int, Object, DataBuffer)
public void setPixel(int x, int y, int[] iArray, DataBuffer data)
DataBuffer
内のピクセルを設定します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException
がスローされることがあります。setPixel
、クラス: SampleModel
x
- ピクセル位置のX座標y
- ピクセル位置のY座標iArray
- int配列形式の入力サンプルdata
- イメージ・データを格納するDataBuffergetPixel(int, int, int[], DataBuffer)
public void setPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
ArrayIndexOutOfBoundsException
がスローされることがあります。setPixels
、クラス: SampleModel
x
- 左上のピクセル位置のX座標y
- 左上のピクセル位置のY座標w
- ピクセル矩形の幅h
- ピクセル矩形の高さiArray
- int配列形式の入力サンプルdata
- イメージ・データを格納するDataBuffergetPixels(int, int, int, int, int[], DataBuffer)
public void setSample(int x, int y, int b, int s, DataBuffer data)
DataBuffer
の(x,y)に位置するピクセルの、指定されたバンドのサンプルを設定します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException
がスローされることがあります。setSample
、クラス: SampleModel
x
- ピクセル位置のX座標y
- ピクセル位置のY座標b
- 設定されるバンドs
- intの入力サンプルdata
- イメージ・データを格納するDataBuffergetSample(int, int, int, DataBuffer)
public void setSample(int x, int y, int b, float s, DataBuffer data)
DataBuffer
内の(x, y)に位置するピクセルの、指定されたバンド内のサンプルを設定します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException
がスローされることがあります。setSample
、クラス: SampleModel
x
- ピクセル位置のX座標y
- ピクセル位置のY座標b
- 設定されるバンドs
- floatでの入力サンプルdata
- イメージ・データを格納するDataBuffergetSample(int, int, int, DataBuffer)
public void setSample(int x, int y, int b, double s, DataBuffer data)
DataBuffer
内の(x, y)に位置するピクセルの、指定されたバンド内のサンプルを設定します。座標が境界内にない場合は、ArrayIndexOutOfBoundsException
がスローされることがあります。setSample
、クラス: SampleModel
x
- ピクセル位置のX座標y
- ピクセル位置のY座標b
- 設定されるバンドs
- doubleでの入力サンプルdata
- イメージ・データを格納するDataBuffergetSample(int, int, int, DataBuffer)
public void setSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
ArrayIndexOutOfBoundsException
がスローされることがあります。setSamples
、クラス: SampleModel
x
- 左上のピクセル位置のX座標y
- 左上のピクセル位置のY座標w
- ピクセル矩形の幅h
- ピクセル矩形の高さb
- 設定されるバンドiArray
- int配列形式の入力サンプルdata
- イメージ・データを格納するDataBuffergetSamples(int, int, int, int, int, int[], DataBuffer)
public boolean equals(Object o)
Object
equals
メソッドは、null以外のオブジェクト参照での同値関係を実装します。
x
について、x.equals(x)
はtrue
を返します。
x
およびy
について、y.equals(x)
がtrue
を返す場合に限り、x.equals(y)
はtrue
を返します。
x
、y
、およびz
について、x.equals(y)
がtrue
を返し、y.equals(z)
がtrue
を返す場合、x.equals(z)
はtrue
を返します。
x
およびy
について、x.equals(y)
の複数の呼出しは、このオブジェクトに対するequals
による比較で使われた情報が変更されていなければ、一貫してtrue
を返すか、一貫してfalse
を返します。
x
について、x.equals(null)
はfalse
を返します。
Object
クラスのequals
メソッドは、もっとも比較しやすいオブジェクトの同値関係を実装します。つまり、null以外の参照値x
とy
について、このメソッドはx
とy
が同じオブジェクトを参照する(x == y
がtrue
)場合にだけtrue
を返します。
通常、このメソッドをオーバーライドする場合は、hashCode
メソッドを常にオーバーライドして、「等価なオブジェクトは等価なハッシュ・コードを保持する必要がある」というhashCode
メソッドの汎用規約に従う必要があることに留意してください。
equals
、クラス: Object
o
- 比較対象の参照オブジェクト。true
、それ以外の場合はfalse
。Object.hashCode()
、HashMap
public int hashCode()
Object
HashMap
によって提供されるハッシュ表などの、ハッシュ表の利点のためにサポートされています。
hashCode
の一般的な規則は次のとおりです。
equals
の比較で使用される情報が変更されていなければ、hashCode
メソッドは常に同じ整数を返す必要があります。ただし、この整数は同じアプリケーションの実行ごとに同じである必要はありません。
equals(Object)
メソッドに従って2つのオブジェクトが等しい場合は、2つの各オブジェクトに対するhashCode
メソッドの呼出しによって同じ整数の結果が生成される必要があります。
Object.equals(java.lang.Object)
メソッドに従って2つのオブジェクトが等しくない場合は、2つの各オブジェクトに対するhashCode
メソッドの呼出しによって異なる整数の結果が生成される必要はありません。ただし、プログラマは、等しくないオブジェクトに対して異なる整数の結果を生成すると、ハッシュ表のパフォーマンスが向上する可能性があることに注意するようにしてください。
クラスObject
によって定義されたhashCodeメソッドは、可能なかぎり、異なるオブジェクトに対して異なる整数を返します。(これは通常、オブジェクトの内部アドレスを整数に変換することによって実装されますが、この実装テクニックはJava™プログラミング言語では必要ありません。)
hashCode
、クラス: Object
Object.equals(java.lang.Object)
, System.identityHashCode(java.lang.Object)
バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2016, Oracle and/or its affiliates. All rights reserved.Use is subject to license termsDocumentation Redistribution Policyも参照してください。