APIdia Launch Partner
Top Description Fields Constructors Methods
java.awt.image

public final Class DataBufferUShort

extends DataBuffer
Class Inheritance
Imports
java.util.Objects

This class extends DataBuffer and stores data internally as shorts. Values stored in the short array(s) of this DataBuffer are treated as unsigned values.

Note that some implementations may function more efficiently if they can maintain control over how the data for an image is stored. For example, optimizations such as caching an image in video memory require that the implementation track all modifications to that data. Other implementations may operate better if they can store the data in locations other than a Java array. To maintain optimum compatibility with various optimizations it is best to avoid constructors and methods which expose the underlying storage as a Java array as noted below in the documentation for those methods.

Field Summary

Modifier and TypeField and Description
pack-priv short[][]
bankdata

All data banks

pack-priv short[]
data

The default data bank.

Inherited from java.awt.image.DataBuffer:
banksdataTypeoffsetoffsetssizetheTrackableTYPE_BYTETYPE_DOUBLETYPE_FLOATTYPE_INTTYPE_SHORTTYPE_UNDEFINEDTYPE_USHORT

Constructor Summary

AccessConstructor and Description
public
DataBufferUShort(int
The size of the DataBuffer.
size
)

Constructs an unsigned-short based DataBuffer with a single bank and the specified size.

public
DataBufferUShort(int
The size of the banks in the DataBuffer.
size
,
int
The number of banks in the DataBuffer.
numBanks
)

Constructs an unsigned-short based DataBuffer with the specified number of banks, all of which are the specified size.

public
DataBufferUShort(short[]
The unsigned-short array for the DataBuffer.
dataArray
,
int
The size of the DataBuffer bank.
size
)

Constructs an unsigned-short based DataBuffer with a single bank using the specified array.

public
DataBufferUShort(short[]
The unsigned-short array for the DataBuffer.
dataArray
,
int
The size of the DataBuffer bank.
size
,
int
The offset into the dataArray.
offset
)

Constructs an unsigned-short based DataBuffer with a single bank using the specified array, size, and offset.

public
DataBufferUShort(short[][]
The unsigned-short arrays for the DataBuffer.
dataArray
,
int
The size of the banks in the DataBuffer.
size
)

Constructs an unsigned-short based DataBuffer with the specified arrays.

public
DataBufferUShort(short[][]
The unsigned-short arrays for the DataBuffer.
dataArray
,
int
The size of the banks in the DataBuffer.
size
,
int[]
The offsets into each array.
offsets
)

Constructs an unsigned-short based DataBuffer with specified arrays, size, and offsets.

Method Summary

Modifier and TypeMethod and Description
public short[][]

Returns:

All of the data arrays.
getBankData
()

Returns the data arrays for all banks.

public short[]

Returns:

The first unsigned-short data array.
getData
()

Returns the default (first) unsigned-short data array.

public short[]

Returns:

The data array for the specified bank.
getData
(int
The bank whose data array you want to get.
bank
)

Returns the data array for the specified bank.

public int

Returns:

The requested data array element as an integer.
getElem
(int
The data array element you want to get.
i
)

Overrides java.awt.image.DataBuffer.getElem.

Returns the requested data array element from the first (default) bank.

public int

Returns:

The requested data array element as an integer.
getElem
(int
The bank from which you want to get a data array element.
bank
,
int
The data array element you want to get.
i
)

Implements abstract java.awt.image.DataBuffer.getElem.

Returns the requested data array element from the specified bank.

public void
setElem(int
The data array element you want to set.
i
,
int
The integer value to which you want to set the data array element.
val
)

Overrides java.awt.image.DataBuffer.setElem.

Sets the requested data array element in the first (default) bank to the specified value.

public void
setElem(int
The bank in which you want to set the data array element.
bank
,
int
The data array element you want to set.
i
,
int
The integer value to which you want to set the specified data array element.
val
)

Implements abstract java.awt.image.DataBuffer.setElem.

Sets the requested data array element in the specified bank from the given integer.

Inherited from java.awt.image.DataBuffer:
checkArraySizecheckArraySizecheckBankcheckBankSizecheckIndexcheckIndexcheckNumBankscheckOffsetcheckSizegetDataTypegetDataTypeSizegetElemDoublegetElemDoublegetElemFloatgetElemFloatgetNumBanksgetOffsetgetOffsetsgetSizesetElemDoublesetElemDoublesetElemFloatsetElemFloattoIntArray

Field Detail

bankdataback to summary
pack-priv short[][] bankdata

All data banks

databack to summary
pack-priv short[] data

The default data bank.

Constructor Detail

DataBufferUShortback to summary
public DataBufferUShort(int size)

Constructs an unsigned-short based DataBuffer with a single bank and the specified size.

Parameters
size:int

The size of the DataBuffer.

Exceptions
IllegalArgumentException:
if size is less than or equal to zero.
DataBufferUShortback to summary
public DataBufferUShort(int size, int numBanks)

Constructs an unsigned-short based DataBuffer with the specified number of banks, all of which are the specified size.

Parameters
size:int

The size of the banks in the DataBuffer.

numBanks:int

The number of banks in the DataBuffer.

Exceptions
IllegalArgumentException:
if size or numBanks is less than or equal to zero.
DataBufferUShortback to summary
public DataBufferUShort(short[] dataArray, int size)

Constructs an unsigned-short based DataBuffer with a single bank using the specified array. Only the first size elements should be used by accessors of this DataBuffer. dataArray must be large enough to hold size elements.

Note that DataBuffer objects created by this constructor may be incompatible with performance optimizations used by some implementations (such as caching an associated image in video memory).

Parameters
dataArray:short[]

The unsigned-short array for the DataBuffer.

size:int

The size of the DataBuffer bank.

Exceptions
NullPointerException:
if dataArray is null.
IllegalArgumentException:
if size is less than or equal to zero, or is greater than the length of dataArray.
DataBufferUShortback to summary
public DataBufferUShort(short[] dataArray, int size, int offset)

Constructs an unsigned-short based DataBuffer with a single bank using the specified array, size, and offset. dataArray must have at least offset + size elements. Only elements offset through offset + size - 1 should be used by accessors of this DataBuffer.

Note that DataBuffer objects created by this constructor may be incompatible with performance optimizations used by some implementations (such as caching an associated image in video memory).

Parameters
dataArray:short[]

The unsigned-short array for the DataBuffer.

size:int

The size of the DataBuffer bank.

offset:int

The offset into the dataArray.

Exceptions
NullPointerException:
if dataArray is null.
IllegalArgumentException:
if size is less than or equal to zero, or offset is less than zero, or (offset + size) is greater than the length of dataArray.
DataBufferUShortback to summary
public DataBufferUShort(short[][] dataArray, int size)

Constructs an unsigned-short based DataBuffer with the specified arrays. The number of banks will be equal to dataArray.length. Only the first size elements of each array should be used by accessors of this DataBuffer.

Note that DataBuffer objects created by this constructor may be incompatible with performance optimizations used by some implementations (such as caching an associated image in video memory).

Parameters
dataArray:short[][]

The unsigned-short arrays for the DataBuffer.

size:int

The size of the banks in the DataBuffer.

Exceptions
NullPointerException:
  • if dataArray is null.
  • if any bank of dataArray is null.
IllegalArgumentException:
  • if size is less than or equal to zero.
  • if dataArray does not have at least one bank.
  • if the length of any bank of dataArray is less than size.
DataBufferUShortback to summary
public DataBufferUShort(short[][] dataArray, int size, int[] offsets)

Constructs an unsigned-short based DataBuffer with specified arrays, size, and offsets. The number of banks is equal to dataArray.length. Each array must be at least as large as size + the corresponding offset. There must be an entry in the offset array for each dataArray entry. For each bank, only elements offset through offset + size - 1 should be used by accessors of this DataBuffer.

Note that DataBuffer objects created by this constructor may be incompatible with performance optimizations used by some implementations (such as caching an associated image in video memory).

Parameters
dataArray:short[][]

The unsigned-short arrays for the DataBuffer.

size:int

The size of the banks in the DataBuffer.

offsets:int[]

The offsets into each array.

Exceptions
IllegalArgumentException:
  • if size is less than or equal to zero.
  • if dataArray does not have at least one bank.
  • if any element of offsets is less than zero.
  • if the length of any bank of dataArray is less than (size + offsets[bankIndex]).
NullPointerException:
  • if dataArray is null.
  • if any bank of dataArray is null.
  • if offsets is null.
ArrayIndexOutOfBoundsException:
if the lengths of dataArray and offsets differ.

Method Detail

getBankDataback to summary
public short[][] getBankData()

Returns the data arrays for all banks.

Note that calling this method may cause this DataBuffer object to be incompatible with performance optimizations used by some implementations (such as caching an associated image in video memory).

Returns:short[][]

All of the data arrays.

getDataback to summary
public short[] getData()

Returns the default (first) unsigned-short data array.

Note that calling this method may cause this DataBuffer object to be incompatible with performance optimizations used by some implementations (such as caching an associated image in video memory).

Returns:short[]

The first unsigned-short data array.

getDataback to summary
public short[] getData(int bank)

Returns the data array for the specified bank.

Note that calling this method may cause this DataBuffer object to be incompatible with performance optimizations used by some implementations (such as caching an associated image in video memory).

Parameters
bank:int

The bank whose data array you want to get.

Returns:short[]

The data array for the specified bank.

Exceptions
ArrayIndexOutOfBoundsException:
if bank is not a valid bank index.
getElemback to summary
public int getElem(int i)

Overrides java.awt.image.DataBuffer.getElem.

Returns the requested data array element from the first (default) bank.

Parameters
i:int

The data array element you want to get.

Returns:int

The requested data array element as an integer.

Exceptions
ArrayIndexOutOfBoundsException:
if (i + getOffset()) is not a valid index.
See Also
setElem(int, int), setElem(int, int, int)
getElemback to summary
public int getElem(int bank, int i)

Implements abstract java.awt.image.DataBuffer.getElem.

Returns the requested data array element from the specified bank.

Parameters
bank:int

The bank from which you want to get a data array element.

i:int

The data array element you want to get.

Returns:int

The requested data array element as an integer.

Exceptions
ArrayIndexOutOfBoundsException:
if bank is not a valid bank index, or (i + getOffsets()[bank]) is not a valid index into the bank.
See Also
setElem(int, int), setElem(int, int, int)
setElemback to summary
public void setElem(int i, int val)

Overrides java.awt.image.DataBuffer.setElem.

Sets the requested data array element in the first (default) bank to the specified value.

Parameters
i:int

The data array element you want to set.

val:int

The integer value to which you want to set the data array element.

Exceptions
ArrayIndexOutOfBoundsException:
if (i + getOffset()) is not a valid index.
See Also
getElem(int), getElem(int, int)
setElemback to summary
public void setElem(int bank, int i, int val)

Implements abstract java.awt.image.DataBuffer.setElem.

Sets the requested data array element in the specified bank from the given integer.

Parameters
bank:int

The bank in which you want to set the data array element.

i:int

The data array element you want to set.

val:int

The integer value to which you want to set the specified data array element.

Exceptions
ArrayIndexOutOfBoundsException:
if bank is not a valid bank index, or (i + getOffsets()[bank]) is not a valid index into the bank.
See Also
getElem(int), getElem(int, int)