Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Class java.awt.image.DataBuffer

java.lang.Object
    |
    +----java.awt.image.DataBuffer
Subclasses:
DataBufferByte, DataBufferInt, DataBufferShort

public abstract class DataBuffer
extends Object
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 without bank specifiers 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. The size + offset fields for a given bank should never be longer than the array length of the associatied data array. Generally, an object of class DataBuffer will be cast down to one of it's subclasses for improved speed.


Field Summary
int  banks
The number of banks (or arrays in this DataBuffer).
static int  BYTE_DATA
Tag for byte data.
int  dataType
The datatype of this DataBuffer.
static int  DOUBLE_DATA
Tag for byte data.
static int  FLOAT_DATA
Tag for byte data.
static int  INT_DATA
Tag for int data.
static int  LONG_DATA
Tag for long data.
int  offset
Offset into default (first) bank from which to get the first element.
int[]  offsets
Offsets into all banks.
static int  SHORT_DATA
Tag for short data.
int  size
Usable size of the a bank.
 

Constructor Summary
 DataBuffer(int dataType, int size)
Constructs a DataBuffer containing one bank of the specified data type and size.
 DataBuffer(int dataType, int size, int numBanks)
Constructs a DataBuffer containing the specified number of banks.
 DataBuffer(int dataType, int size, int numBanks, int offset)
Constructs a DataBuffer which contains the specified number of banks.
 DataBuffer(int dataType, int size, int numBanks, int[] offsets)
Constructs a DataBuffer which contains the specified number of banks.
 

Method Summary
int  getDataType()
This returns the data type of this DataBuffer.
int  getElem(int i)
Returns the requested data array element from the first (default) bank as an integer.
int  getElem(int bank, int i)
Returns the requested data array element from the specified bank as an integer.
double  getElemDouble(int i)
Returns the requested data array element from the first (default) bank as a double.
double  getElemDouble(int bank, int i)
Returns the requested data array element from the specified bank as a double.
float  getElemFloat(int i)
Returns the requested data array element from the first (default) bank as a float.
float  getElemFloat(int bank, int i)
Returns the requested data array element from the specified bank as a float.
int  getNumBanks()
Returns the number of banks in this DataBuffer.
int  getOffset()
Returns the offset of the default bank in array elements.
int[]  getOffsets()
Returns the offsets of all the banks in array elements.
int  getSize()
Returns the size of the default bank in array elements.
void  setElem(int i, int val)
Sets the requested data array element in the first (default) bank from the given integer.
void  setElem(int bank, int i, int val)
Sets the requested data array element in the specified bank from the given integer.
void  setElemDouble(int i, double val)
Sets the requested data array element in the first (default) bank from the given double.
void  setElemDouble(int bank, int i, double val)
Sets the requested data array element in the specified bank from the given double.
void  setElemFloat(int i, float val)
Sets the requested data array element in the first (default) bank from the given float.
void  setElemFloat(int bank, int i, float val)
Sets the requested data array element in the specified bank from the given float.
static int  sizeOf(int type)
Size of the data type, given a datatype tag.
static int[]  toIntArray(Object obj)
Converts an input array of some primitive datatype (byte/short/int) into an integer array.
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BYTE_DATA

public static final int BYTE_DATA
Tag for byte data.

SHORT_DATA

public static final int SHORT_DATA
Tag for short data.

INT_DATA

public static final int INT_DATA
Tag for int data.

LONG_DATA

public static final int LONG_DATA
Tag for long data.

FLOAT_DATA

public static final int FLOAT_DATA
Tag for byte data.

DOUBLE_DATA

public static final int DOUBLE_DATA
Tag for byte data.

dataType

protected int dataType
The datatype of this DataBuffer.

banks

protected int banks
The number of banks (or arrays in this DataBuffer).

offset

protected int offset
Offset into default (first) bank from which to get the first element.

size

protected int size
Usable size of the a bank.

offsets

protected int[] offsets
Offsets into all banks.
Constructor Detail

DataBuffer

protected DataBuffer(int dataType,
                     int size)
Constructs a DataBuffer containing one bank of the specified data type and size.

DataBuffer

protected DataBuffer(int dataType,
                     int size,
                     int numBanks)
Constructs a DataBuffer containing the specified number of banks. Each bank has the specified size and an offset of 0.

DataBuffer

protected DataBuffer(int dataType,
                     int size,
                     int numBanks,
                     int offset)
Constructs a DataBuffer which contains the specified number of banks. Each bank has the specified datatype, size and offset.

DataBuffer

protected DataBuffer(int dataType,
                     int size,
                     int numBanks,
                     int[] offsets)
Constructs a DataBuffer which contains the specified number of banks. Each bank has the specified datatype and size. The offset for each bank corresponds to it's respective entry in the offsets array.
Method Detail

sizeOf

public static int sizeOf(int type)
Size of the data type, given a datatype tag.

toIntArray

public static int[] toIntArray(Object obj)
Converts an input array of some primitive datatype (byte/short/int) into an integer array. If the input array is of type int[], it will be returned as is. Otherwise, an integer array will be created and elements promoted to ints and copied. Masks will be used to prevent sign extension on byte values. Returns null if obj is not of type byte[], short[] or int[].

getDataType

public int getDataType()
This returns the data type of this DataBuffer.

getSize

public int getSize()
Returns the size of the default bank in array elements.

getOffset

public int getOffset()
Returns the offset of the default bank in array elements.

getOffsets

public int[] getOffsets()
Returns the offsets of all the banks in array elements.

getNumBanks

public int getNumBanks()
Returns the number of banks in this DataBuffer.

getElem

public int getElem(int i)
Returns the requested data array element from the first (default) bank as an integer.

getElem

public abstract int getElem(int bank,
                            int i)
Returns the requested data array element from the specified bank as an integer.

setElem

public void setElem(int i,
                    int val)
Sets the requested data array element in the first (default) bank from the given integer.

setElem

public abstract void setElem(int bank,
                             int i,
                             int val)
Sets the requested data array element in the specified bank from the given integer.

getElemFloat

public float getElemFloat(int i)
Returns the requested data array element from the first (default) bank as a float.

getElemFloat

public float getElemFloat(int bank,
                          int i)
Returns the requested data array element from the specified bank as a float.

setElemFloat

public void setElemFloat(int i,
                         float val)
Sets the requested data array element in the first (default) bank from the given float.

setElemFloat

public void setElemFloat(int bank,
                         int i,
                         float val)
Sets the requested data array element in the specified bank from the given float.

getElemDouble

public double getElemDouble(int i)
Returns the requested data array element from the first (default) bank as a double.

getElemDouble

public double getElemDouble(int bank,
                            int i)
Returns the requested data array element from the specified bank as a double.

setElemDouble

public void setElemDouble(int i,
                          double val)
Sets the requested data array element in the first (default) bank from the given double.

setElemDouble

public void setElemDouble(int bank,
                          int i,
                          double val)
Sets the requested data array element in the specified bank from the given double.

Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.