java.awt.image
public abstract class DataBuffer extends Object
Modifier and Type | Field and Description |
---|---|
protected int |
banks
The number of banks in this buffer.
|
protected int |
dataType
The type of the data elements stored in the data buffer.
|
protected int |
offset
Offset into the default (0'th) bank).
|
protected int[] |
offsets
Offset into each bank.
|
protected int |
size
The size of the banks.
|
static int |
TYPE_BYTE
A constant representing a data type that uses
byte primitives
as the storage unit. |
static int |
TYPE_DOUBLE
A constant representing a data type that uses
double
primitives as the storage unit. |
static int |
TYPE_FLOAT
A constant representing a data type that uses
float
primitives as the storage unit. |
static int |
TYPE_INT
A constant representing a data type that uses
int
primitives as the storage unit. |
static int |
TYPE_SHORT
A constant representing a data type that uses
short
primitives as the storage unit. |
static int |
TYPE_UNDEFINED
A constant representing an undefined data type.
|
static int |
TYPE_USHORT
A constant representing a data type that uses
short
primitives as the storage unit. |
Modifier | Constructor and Description |
---|---|
protected |
DataBuffer(int dataType,
int size)
Creates a new
DataBuffer with the specified data type and
size. |
protected |
DataBuffer(int dataType,
int size,
int numBanks)
Creates a new
DataBuffer with the specified data type,
size and number of banks. |
protected |
DataBuffer(int dataType,
int size,
int numBanks,
int offset)
Creates a new
DataBuffer with the specified data type,
size and number of banks. |
protected |
DataBuffer(int dataType,
int size,
int numBanks,
int[] offsets)
Creates a new
DataBuffer with the specified data type,
size and number of banks. |
Modifier and Type | Method and Description |
---|---|
int |
getDataType()
Returns the type of the data elements in the data buffer.
|
static int |
getDataTypeSize(int dataType)
Returns the size (number of bits) of the specified data type.
|
int |
getElem(int i)
Returns an element from the first data bank.
|
abstract int |
getElem(int bank,
int i)
Returns an element from a particular data bank.
|
double |
getElemDouble(int i)
Returns an element from the first data bank, converted to a
double . |
double |
getElemDouble(int bank,
int i)
Returns an element from a particular data bank, converted to a
double . |
float |
getElemFloat(int i)
Returns an element from the first data bank, converted to a
float . |
float |
getElemFloat(int bank,
int i)
Returns an element from a particular data bank, converted to a
float . |
int |
getNumBanks()
Returns the number of data banks for this
DataBuffer . |
int |
getOffset()
Returns the element offset for the first data bank.
|
int[] |
getOffsets()
Returns the offsets for all the data banks used by this
DataBuffer . |
int |
getSize()
Returns the size of the data buffer.
|
void |
setElem(int i,
int val)
Sets an element in the first data bank.
|
abstract void |
setElem(int bank,
int i,
int val)
Sets an element in a particular data bank.
|
void |
setElemDouble(int i,
double val)
Sets an element in the first data bank.
|
void |
setElemDouble(int bank,
int i,
double val)
Sets an element in a particular data bank.
|
void |
setElemFloat(int i,
float val)
Sets an element in the first data bank.
|
void |
setElemFloat(int bank,
int i,
float val)
Sets an element in a particular data bank.
|
public static final int TYPE_BYTE
byte
primitives
as the storage unit.public static final int TYPE_USHORT
short
primitives as the storage unit.public static final int TYPE_SHORT
short
primitives as the storage unit.public static final int TYPE_INT
int
primitives as the storage unit.public static final int TYPE_FLOAT
float
primitives as the storage unit.public static final int TYPE_DOUBLE
double
primitives as the storage unit.public static final int TYPE_UNDEFINED
protected int dataType
protected int banks
protected int offset
protected int size
protected int[] offsets
protected DataBuffer(int dataType, int size)
DataBuffer
with the specified data type and
size. The dataType
should be one of the constants
TYPE_BYTE
, TYPE_SHORT
, TYPE_USHORT
,
TYPE_INT
, TYPE_FLOAT
and TYPE_DOUBLE
.
The physical (array-based) storage is allocated by a subclass.
dataType
- the data type.size
- the number of elements in the buffer.protected DataBuffer(int dataType, int size, int numBanks)
DataBuffer
with the specified data type,
size and number of banks. The dataType
should be one of
the constants TYPE_BYTE
, TYPE_SHORT
,
TYPE_USHORT
, TYPE_INT
, TYPE_FLOAT
and
TYPE_DOUBLE
.
The physical (array-based) storage is allocated by a subclass.
dataType
- the data type.size
- the number of elements in the buffer.numBanks
- the number of data banks.protected DataBuffer(int dataType, int size, int numBanks, int offset)
DataBuffer
with the specified data type,
size and number of banks. An offset (which applies to all banks) is
also specified. The dataType
should be one of
the constants TYPE_BYTE
, TYPE_SHORT
,
TYPE_USHORT
, TYPE_INT
, TYPE_FLOAT
and
TYPE_DOUBLE
.
The physical (array-based) storage is allocated by a subclass.
dataType
- the data type.size
- the number of elements in the buffer.numBanks
- the number of data banks.offset
- the offset to the first element for all banks.protected DataBuffer(int dataType, int size, int numBanks, int[] offsets)
DataBuffer
with the specified data type,
size and number of banks. An offset (which applies to all banks) is
also specified. The dataType
should be one of
the constants TYPE_BYTE
, TYPE_SHORT
,
TYPE_USHORT
, TYPE_INT
, TYPE_FLOAT
and
TYPE_DOUBLE
.
The physical (array-based) storage is allocated by a subclass.
dataType
- the data type.size
- the number of elements in the buffer.numBanks
- the number of data banks.offsets
- the offsets to the first element for all banks.ArrayIndexOutOfBoundsException
- if
numBanks != offsets.length
.public static int getDataTypeSize(int dataType)
TYPE_BYTE
, TYPE_SHORT
,
TYPE_USHORT
, TYPE_INT
, TYPE_FLOAT
and
TYPE_DOUBLE
.dataType
- the data type.IllegalArgumentException
- if dataType < 0
or
dataType > TYPE_DOUBLE
.public int getDataType()
TYPE_BYTE
, TYPE_SHORT
,
TYPE_USHORT
, TYPE_INT
, TYPE_FLOAT
and
TYPE_DOUBLE
.public int getSize()
public int getOffset()
public int[] getOffsets()
DataBuffer
.public int getNumBanks()
DataBuffer
.public int getElem(int i)
i
before accessing the
underlying data array.i
- the element index.public abstract int getElem(int bank, int i)
i
before accessing the
underlying data array.bank
- the bank index.i
- the element index.public void setElem(int i, int val)
i
before updating the underlying
data array.i
- the element index.val
- the new element value.public abstract void setElem(int bank, int i, int val)
i
before updating the underlying
data array.bank
- the data bank index.i
- the element index.val
- the new element value.public float getElemFloat(int i)
float
. The offset (specified in the constructor) is added
to i
before accessing the underlying data array.i
- the element index.public float getElemFloat(int bank, int i)
float
. The offset (specified in the constructor) is
added to i
before accessing the underlying data array.bank
- the bank index.i
- the element index.public void setElemFloat(int i, float val)
i
before updating the underlying
data array.i
- the element index.val
- the new element value.public void setElemFloat(int bank, int i, float val)
i
before updating the underlying
data array.bank
- the data bank index.i
- the element index.val
- the new element value.public double getElemDouble(int i)
double
. The offset (specified in the constructor) is added
to i
before accessing the underlying data array.i
- the element index.public double getElemDouble(int bank, int i)
double
. The offset (specified in the constructor) is
added to i
before accessing the underlying data array.bank
- the bank index.i
- the element index.public void setElemDouble(int i, double val)
i
before updating the underlying
data array.i
- the element index.val
- the new element value.public void setElemDouble(int bank, int i, double val)
i
before updating the underlying
data array.bank
- the data bank index.i
- the element index.val
- the new element value.