java.lang.Object | |
↳ | java.awt.image.DataBuffer |
Known Direct Subclasses |
This class exists to wrap one or more data arrays. Each data array in the DataBuffer is referred to as a bank. Accessor methods for getting and setting elements of the DataBuffer's banks exist with and without a bank specifier. The methods without a bank specifier use the default 0th bank. The DataBuffer can optionally take an offset per bank, so that data in an existing array can be used even if the interesting data doesn't start at array location zero. Getting or setting the 0th element of a bank, uses the (0+offset)th element of the array. The size field specifies how much of the data array is available for use. Size + offset for a given bank should never be greater than the length of the associated data array. The data type of a data buffer indicates the type of the data array(s) and may also indicate additional semantics, e.g. storing unsigned 8-bit data in elements of a byte array. The data type may be TYPE_UNDEFINED or one of the types defined below. Other types may be added in the future. Generally, an object of class DataBuffer will be cast down to one of its data type specific subclasses to access data type specific methods for improved performance. Currently, the Java 2D(tm) API image classes use TYPE_BYTE, TYPE_USHORT, TYPE_INT, TYPE_SHORT, TYPE_FLOAT, and TYPE_DOUBLE DataBuffers to store image data.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | TYPE_BYTE | Tag for unsigned byte data. | |||||||||
int | TYPE_DOUBLE | Tag for double data. | |||||||||
int | TYPE_FLOAT | Tag for float data. | |||||||||
int | TYPE_INT | Tag for int data. | |||||||||
int | TYPE_SHORT | Tag for signed short data. | |||||||||
int | TYPE_UNDEFINED | Tag for undefined data. | |||||||||
int | TYPE_USHORT | Tag for unsigned short data. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
banks | The number of banks in this DataBuffer. | ||||||||||
dataType | The data type of this DataBuffer. | ||||||||||
offset | Offset into default (first) bank from which to get the first element. | ||||||||||
offsets | Offsets into all banks. | ||||||||||
size | Usable size of all banks. |
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a DataBuffer containing one bank of the specified
data type and size.
| |||||||||||
Constructs a DataBuffer containing the specified number of
banks.
| |||||||||||
Constructs a DataBuffer that contains the specified number
of banks.
| |||||||||||
Constructs a DataBuffer which contains the specified number
of banks.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the data type of this DataBuffer.
| |||||||||||
Returns the size (in bits) of the data type, given a datatype tag.
| |||||||||||
Returns the requested data array element from the specified bank
as an integer.
| |||||||||||
Returns the requested data array element from the first (default) bank
as an integer.
| |||||||||||
Returns the requested data array element from the specified bank as
a double.
| |||||||||||
Returns the requested data array element from the first (default) bank
as a double.
| |||||||||||
Returns the requested data array element from the first (default) bank
as a float.
| |||||||||||
Returns the requested data array element from the specified bank
as a float.
| |||||||||||
Returns the number of banks in this DataBuffer.
| |||||||||||
Returns the offset of the default bank in array elements.
| |||||||||||
Returns the offsets (in array elements) of all the banks.
| |||||||||||
Returns the size (in array elements) of all banks.
| |||||||||||
Sets the requested data array element in the first (default) bank
from the given integer.
| |||||||||||
Sets the requested data array element in the specified bank
from the given integer.
| |||||||||||
Sets the requested data array element in the first (default) bank
from the given double.
| |||||||||||
Sets the requested data array element in the specified bank
from the given double.
| |||||||||||
Sets the requested data array element in the first (default) bank
from the given float.
| |||||||||||
Sets the requested data array element in the specified bank
from the given float.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Tag for unsigned byte data.
Tag for double data. Placeholder for future use.
Tag for float data. Placeholder for future use.
Tag for int data.
Tag for signed short data. Placeholder for future use.
Tag for undefined data.
Tag for unsigned short data.
The number of banks in this DataBuffer.
The data type of this DataBuffer.
Offset into default (first) bank from which to get the first element.
Offsets into all banks.
Usable size of all banks.
Constructs a DataBuffer containing one bank of the specified data type and size.
dataType | the data type of this DataBuffer |
---|---|
size | the size of the banks |
Constructs a DataBuffer containing the specified number of banks. Each bank has the specified size and an offset of 0.
dataType | the data type of this DataBuffer |
---|---|
size | the size of the banks |
numBanks | the number of banks in this
DataBuffer
|
Constructs a DataBuffer that contains the specified number of banks. Each bank has the specified datatype, size and offset.
dataType | the data type of this DataBuffer |
---|---|
size | the size of the banks |
numBanks | the number of banks in this
DataBuffer |
offset | the offset for each bank |
Constructs a DataBuffer which contains the specified number of banks. Each bank has the specified datatype and size. The offset for each bank is specified by its respective entry in the offsets array.
dataType | the data type of this DataBuffer |
---|---|
size | the size of the banks |
numBanks | the number of banks in this
DataBuffer |
offsets | an array containing an offset for each bank. |
ArrayIndexOutOfBoundsException | if numBanks
does not equal the length of offsets
|
---|
Returns the data type of this DataBuffer.
DataBuffer
.
Returns the size (in bits) of the data type, given a datatype tag.
type | the value of one of the defined datatype tags |
---|
IllegalArgumentException | if type is less than
zero or greater than TYPE_DOUBLE
|
---|
Returns the requested data array element from the specified bank as an integer.
bank | the specified bank |
---|---|
i | the index of the requested data array element |
Returns the requested data array element from the first (default) bank as an integer.
i | the index of the requested data array element |
---|
Returns the requested data array element from the specified bank as a double. The implementation in this class is to cast getElem(bank, i) to a double. Subclasses may override this method if another implementation is needed.
bank | the specified bank |
---|---|
i | the specified index |
Returns the requested data array element from the first (default) bank
as a double. The implementation in this class is to cast
getElem(int)
to a double. Subclasses can override this method if another
implementation is needed.
i | the specified index |
---|
Returns the requested data array element from the first (default) bank as a float. The implementation in this class is to cast getElem(i) to a float. Subclasses may override this method if another implementation is needed.
i | the index of the requested data array element |
---|
Returns the requested data array element from the specified bank
as a float. The implementation in this class is to cast
getElem(int, int)
to a float. Subclasses can override this method if another
implementation is needed.
bank | the specified bank |
---|---|
i | the index of the requested data array element |
Returns the number of banks in this DataBuffer.
Returns the offset of the default bank in array elements.
Returns the offsets (in array elements) of all the banks.
Returns the size (in array elements) of all banks.
Sets the requested data array element in the first (default) bank from the given integer.
i | the specified index into the data array |
---|---|
val | the data to set the element at the specified index in the data array |
Sets the requested data array element in the specified bank from the given integer.
bank | the specified bank |
---|---|
i | the specified index into the data array |
val | the data to set the element in the specified bank at the specified index in the data array |
Sets the requested data array element in the first (default) bank
from the given double. The implementation in this class is to cast
val to an int and call setElem(int, int)
. Subclasses can
override this method if another implementation is needed.
i | the specified index |
---|---|
val | the value to set the element at the specified index in the data array |
Sets the requested data array element in the specified bank
from the given double. The implementation in this class is to cast
val to an int and call setElem(int, int)
. Subclasses can
override this method if another implementation is needed.
bank | the specified bank |
---|---|
i | the specified index |
val | the value to set the element in the specified bank at the specified index of the data array |
Sets the requested data array element in the first (default) bank
from the given float. The implementation in this class is to cast
val to an int and call setElem(int, int)
. Subclasses
can override this method if another implementation is needed.
i | the specified index |
---|---|
val | the value to set the element at the specified index in the data array |
Sets the requested data array element in the specified bank
from the given float. The implementation in this class is to cast
val to an int and call setElem(int, int)
. Subclasses can
override this method if another implementation is needed.
bank | the specified bank |
---|---|
i | the specified index |
val | the value to set the element in the specified bank at the specified index in the data array |