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

public Class ShortComponentRaster

extends SunWritableRaster
Class Inheritance
Known Direct Subclasses
sun.awt.image.ShortInterleavedRaster
Imports
java.awt.image.Raster, .WritableRaster, .RasterFormatException, .SampleModel, .ComponentSampleModel, .SinglePixelPackedSampleModel, .DataBufferUShort, java.awt.Rectangle, .Point

This class defines a Raster with pixels consisting of one or more 16-bit data elements stored in close proximity to each other in a short integer array. The bit precision per data element is that of the data type (that is, the bit precision for this Raster is 16). There is only one pixel stride and one scanline stride for all bands. This type of Raster can be used with a ComponentColorModel if there are multiple bands, or a IndexColorModel if there is only one band.

For example, 5-6-5 RGB image data can be represented by a ShortComponentRaster using a SinglePixelPackedSampleModel and a ComponentColorModel.

Field Summary

Modifier and TypeField and Description
protected int
bandOffset

private band offset for use by native code

protected short[]
data

The image data array.

protected int[]
dataOffsets

Data offsets for each band of image data.

private int
maxX

A cached copy of minX + width for use in bounds checks.

private int
maxY

A cached copy of minY + height for use in bounds checks.

protected int
pixelStride

Pixel stride of the image data contained in this Raster.

protected int
scanlineStride

Scanline stride of the image data contained in this Raster.

pack-priv int

Constructor Summary

AccessConstructor and Description
public
ShortComponentRaster(SampleModel
The SampleModel that specifies the layout.
sampleModel
,
Point
The Point that specified the origin.
origin
)

Constructs a ShortComponentRaster with the given SampleModel.

public
ShortComponentRaster(SampleModel
The SampleModel that specifies the layout.
sampleModel
,
DataBufferUShort
The DataBufferUShort that contains the image data.
dataBuffer
,
Point
The Point that specifies the origin.
origin
)

Constructs a ShortComponentRaster with the given SampleModel and DataBuffer.

public
ShortComponentRaster(SampleModel
The SampleModel that specifies the layout.
sampleModel
,
DataBufferUShort
The DataBufferUShort that contains the image data.
dataBuffer
,
Rectangle
The Rectangle that specifies the image area.
aRegion
,
Point
The Point that specifies the origin.
origin
,
ShortComponentRaster
The parent (if any) of this raster.
parent
)

Constructs a ShortComponentRaster with the given SampleModel, DataBuffer, and parent.

Method Summary

Modifier and TypeMethod and Description
public Raster
createChild(int
X offset.
x
,
int
Y offset.
y
,
int
Width (in pixels) of the subraster.
width
,
int
Height (in pixels) of the subraster.
height
,
int
Translated X origin of the subraster.
x0
,
int
Translated Y origin of the subraster.
y0
,
int[]
Array of band indices.
bandList
)

Overrides java.awt.image.Raster.createChild.

Creates a subraster given a region of the raster.

public WritableRaster
createCompatibleWritableRaster(int w, int h)

Overrides java.awt.image.Raster.createCompatibleWritableRaster.

Creates a Raster with the same layout but using a different width and height, and with new zeroed data arrays.

public WritableRaster
createCompatibleWritableRaster()

Overrides java.awt.image.Raster.createCompatibleWritableRaster.

Creates a Raster with the same layout and the same width and height, and with new zeroed data arrays.

public WritableRaster
createWritableChild(int
X offset.
x
,
int
Y offset.
y
,
int
Width (in pixels) of the subraster.
width
,
int
Height (in pixels) of the subraster.
height
,
int
Translated X origin of the subraster.
x0
,
int
Translated Y origin of the subraster.
y0
,
int[]
Array of band indices.
bandList
)

Overrides java.awt.image.WritableRaster.createWritableChild.

Creates a Writable subRaster given a region of the Raster.

public Object

Returns:

An object reference to an array of type defined by getTransferType() with the request pixel data.
getDataElements
(int
The X coordinate of the pixel location.
x
,
int
The Y coordinate of the pixel location.
y
,
Object
An object reference to an array of type defined by getTransferType() and length getNumDataElements(). If null an array of appropriate type and size will be allocated.
obj
)

Overrides java.awt.image.Raster.getDataElements.

Returns the data elements for all bands at the specified location.

public Object

Returns:

An object reference to an array of type defined by getTransferType() with the request pixel data.
getDataElements
(int
The X coordinate of the upper left pixel location.
x
,
int
The Y coordinate of the upper left pixel location.
y
,
int
Width of the pixel rectangle.
w
,
int
Height of the pixel rectangle.
h
,
Object
An object reference to an array of type defined by getTransferType() and length w*h*getNumDataElements(). If null an array of appropriate type and size will be allocated.
obj
)

Overrides java.awt.image.Raster.getDataElements.

Returns an array of data elements from the specified rectangular region.

public int
getDataOffset(int
The band whose offset is returned.
band
)

Returns the data offset for the specified band.

public int[]
getDataOffsets()

Returns a copy of the data offsets array.

public short[]
getDataStorage()

Returns a reference to the data array.

public int
getPixelStride()

Returns pixel stride -- the number of data array elements between two samples for the same band on the same scanline.

public int
getScanlineStride()

Returns the scanline stride -- the number of data array elements between a given sample and the same sample in the same column of the next row.

public short[]

Returns:

Data array with data elements for all bands.
getShortData
(int
The X coordinate of the upper left pixel location.
x
,
int
The Y coordinate of the upper left pixel location.
y
,
int
Width of the sample rectangle.
w
,
int
Height of the sample rectangle.
h
,
int
The band to return.
band
,
short[]
If non-null, data elements for all bands at the specified location are returned in this array.
outData
)

Returns a short integer array of data elements from the specified rectangular region.

public short[]

Returns:

Data array with data elements for all bands.
getShortData
(int
The X coordinate of the upper left pixel location.
x
,
int
The Y coordinate of the upper left pixel location.
y
,
int
Width of the pixel rectangle.
w
,
int
Height of the pixel rectangle.
h
,
short[]
If non-null, data elements for all bands at the specified location are returned in this array.
outData
)

Returns a short integer array of data elements from the specified rectangular region.

private static native void
public void
putShortData(int
The X coordinate of the upper left pixel location.
x
,
int
The Y coordinate of the upper left pixel location.
y
,
int
Width of the pixel rectangle.
w
,
int
Height of the pixel rectangle.
h
,
int
The band to set.
band
,
short[]
The data elements to be stored.
inData
)

Stores a short integer array of data elements into the specified rectangular region.

public void
putShortData(int
The X coordinate of the upper left pixel location.
x
,
int
The Y coordinate of the upper left pixel location.
y
,
int
Width of the pixel rectangle.
w
,
int
Height of the pixel rectangle.
h
,
short[]
The data elements to be stored.
inData
)

Stores a short integer array of data elements into the specified rectangular region.

public void
setDataElements(int
The X coordinate of the pixel location.
x
,
int
The Y coordinate of the pixel location.
y
,
Object
An object reference to an array of type defined by getTransferType() and length getNumDataElements() containing the pixel data to place at x,y.
obj
)

Overrides java.awt.image.WritableRaster.setDataElements.

Stores the data elements for all bands at the specified location.

public void
setDataElements(int
The X coordinate of the pixel location.
x
,
int
The Y coordinate of the pixel location.
y
,
Raster
Raster of data to place at x,y location.
inRaster
)

Overrides java.awt.image.WritableRaster.setDataElements.

Stores the Raster data at the specified location.

private void
setDataElements(int
The absolute X coordinate of the destination pixel that will receive a copy of the upper-left pixel of the inRaster
dstX
,
int
The absolute Y coordinate of the destination pixel that will receive a copy of the upper-left pixel of the inRaster
dstY
,
int
The number of pixels to store horizontally
width
,
int
The number of pixels to store vertically
height
,
Raster
Raster of data to place at x,y location.
inRaster
)

Stores the Raster data at the specified location.

public void
setDataElements(int
The X coordinate of the upper left pixel location.
x
,
int
The Y coordinate of the upper left pixel location.
y
,
int
Width of the pixel rectangle.
w
,
int
Height of the pixel rectangle.
h
,
Object
An object reference to an array of type defined by getTransferType() and length w*h*getNumDataElements() containing the pixel data to place between x,y and x+h, y+h.
obj
)

Overrides java.awt.image.WritableRaster.setDataElements.

Stores an array of data elements into the specified rectangular region.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

protected final void
verify()

Verify that the layout parameters are consistent with the data.

Inherited from sun.awt.image.SunWritableRaster:
makeTrackablemarkDirtymarkDirtymarkDirtymarkDirtysetDataStealersetTrackablestealDatastealDatastealDatastealTrackable

Field Detail

bandOffsetback to summary
protected int bandOffset

private band offset for use by native code

databack to summary
protected short[] data

The image data array.

dataOffsetsback to summary
protected int[] dataOffsets

Data offsets for each band of image data.

maxXback to summary
private int maxX

A cached copy of minX + width for use in bounds checks.

maxYback to summary
private int maxY

A cached copy of minY + height for use in bounds checks.

pixelStrideback to summary
protected int pixelStride

Pixel stride of the image data contained in this Raster.

scanlineStrideback to summary
protected int scanlineStride

Scanline stride of the image data contained in this Raster.

typeback to summary
pack-priv int type

Constructor Detail

ShortComponentRasterback to summary
public ShortComponentRaster(SampleModel sampleModel, Point origin)

Constructs a ShortComponentRaster with the given SampleModel. The Raster's upper left corner is origin and it is the same size as the SampleModel. A DataBuffer large enough to describe the Raster is automatically created. SampleModel must be of type ComponentSampleModel or SinglePixelPackedSampleModel.

Parameters
sampleModel:SampleModel

The SampleModel that specifies the layout.

origin:Point

The Point that specified the origin.

ShortComponentRasterback to summary
public ShortComponentRaster(SampleModel sampleModel, DataBufferUShort dataBuffer, Point origin)

Constructs a ShortComponentRaster with the given SampleModel and DataBuffer. The Raster's upper left corner is origin and it is the same sizes the SampleModel. The DataBuffer is not initialized and must be a DataBufferUShort compatible with SampleModel. SampleModel must be of type ComponentSampleModel or SinglePixelPackedSampleModel.

Parameters
sampleModel:SampleModel

The SampleModel that specifies the layout.

dataBuffer:DataBufferUShort

The DataBufferUShort that contains the image data.

origin:Point

The Point that specifies the origin.

ShortComponentRasterback to summary
public ShortComponentRaster(SampleModel sampleModel, DataBufferUShort dataBuffer, Rectangle aRegion, Point origin, ShortComponentRaster parent)

Constructs a ShortComponentRaster with the given SampleModel, DataBuffer, and parent. DataBuffer must be a DataBufferUShort and SampleModel must be of type ComponentSampleModel or SinglePixelPackedSampleModel. When translated into the base Raster's coordinate system, aRegion must be contained by the base Raster. Origin is the coordinate in the new Raster's coordinate system of the origin of the base Raster. (The base Raster is the Raster's ancestor which has no parent.) Note that this constructor should generally be called by other constructors or create methods, it should not be used directly.

Parameters
sampleModel:SampleModel

The SampleModel that specifies the layout.

dataBuffer:DataBufferUShort

The DataBufferUShort that contains the image data.

aRegion:Rectangle

The Rectangle that specifies the image area.

origin:Point

The Point that specifies the origin.

parent:ShortComponentRaster

The parent (if any) of this raster.

Method Detail

createChildback to summary
public Raster createChild(int x, int y, int width, int height, int x0, int y0, int[] bandList)

Overrides java.awt.image.Raster.createChild.

Creates a subraster given a region of the raster. The x and y coordinates specify the horizontal and vertical offsets from the upper-left corner of this raster to the upper-left corner of the subraster. A subset of the bands of the parent Raster may be specified. If this is null, then all the bands are present in the subRaster. A translation to the subRaster may also be specified. Note that the subraster will reference the same band objects as the parent raster, but using different offsets.

Parameters
x:int

X offset.

y:int

Y offset.

width:int

Width (in pixels) of the subraster.

height:int

Height (in pixels) of the subraster.

x0:int

Translated X origin of the subraster.

y0:int

Translated Y origin of the subraster.

bandList:int[]

Array of band indices.

Exceptions
RasterFormatException:
if the specified bounding box is outside of the parent raster.
createCompatibleWritableRasterback to summary
public WritableRaster createCompatibleWritableRaster(int w, int h)

Overrides java.awt.image.Raster.createCompatibleWritableRaster.

Creates a Raster with the same layout but using a different width and height, and with new zeroed data arrays.

createCompatibleWritableRasterback to summary
public WritableRaster createCompatibleWritableRaster()

Overrides java.awt.image.Raster.createCompatibleWritableRaster.

Creates a Raster with the same layout and the same width and height, and with new zeroed data arrays. If the Raster is a subRaster, this will call createCompatibleRaster(width, height).

createWritableChildback to summary
public WritableRaster createWritableChild(int x, int y, int width, int height, int x0, int y0, int[] bandList)

Overrides java.awt.image.WritableRaster.createWritableChild.

Creates a Writable subRaster given a region of the Raster. The x and y coordinates specify the horizontal and vertical offsets from the upper-left corner of this Raster to the upper-left corner of the subRaster. A subset of the bands of the parent Raster may be specified. If this is null, then all the bands are present in the subRaster. A translation to the subRaster may also be specified. Note that the subRaster will reference the same DataBuffers as the parent Raster, but using different offsets.

Parameters
x:int

X offset.

y:int

Y offset.

width:int

Width (in pixels) of the subraster.

height:int

Height (in pixels) of the subraster.

x0:int

Translated X origin of the subraster.

y0:int

Translated Y origin of the subraster.

bandList:int[]

Array of band indices.

Exceptions
RasterFormatException:
if the specified bounding box is outside of the parent Raster.
getDataElementsback to summary
public Object getDataElements(int x, int y, Object obj)

Overrides java.awt.image.Raster.getDataElements.

Returns the data elements for all bands at the specified location. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinate is out of bounds. A ClassCastException will be thrown if the input object is non null and references anything other than an array of transferType.

Parameters
x:int

The X coordinate of the pixel location.

y:int

The Y coordinate of the pixel location.

obj:Object

An object reference to an array of type defined by getTransferType() and length getNumDataElements(). If null an array of appropriate type and size will be allocated.

Returns:Object

An object reference to an array of type defined by getTransferType() with the request pixel data.

getDataElementsback to summary
public Object getDataElements(int x, int y, int w, int h, Object obj)

Overrides java.awt.image.Raster.getDataElements.

Returns an array of data elements from the specified rectangular region. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinates are out of bounds. A ClassCastException will be thrown if the input object is non null and references anything other than an array of transferType.

      short[] bandData = (short[])Raster.getDataElements(x, y, w, h, null);
      int numDataElements = Raster.getBands();
      short[] pixel = new short[numDataElements];
      // To find the data element at location (x2, y2)
      System.arraycopy(bandData, ((y2-y)*w + (x2-x))*numDataElements,
                       pixel, 0, numDataElements);
Parameters
x:int

The X coordinate of the upper left pixel location.

y:int

The Y coordinate of the upper left pixel location.

w:int

Width of the pixel rectangle.

h:int

Height of the pixel rectangle.

obj:Object

An object reference to an array of type defined by getTransferType() and length w*h*getNumDataElements(). If null an array of appropriate type and size will be allocated.

Returns:Object

An object reference to an array of type defined by getTransferType() with the request pixel data.

getDataOffsetback to summary
public int getDataOffset(int band)

Returns the data offset for the specified band. The data offset is the index into the data array in which the first sample of the first scanline is stored.

Parameters
band:int

The band whose offset is returned.

getDataOffsetsback to summary
public int[] getDataOffsets()

Returns a copy of the data offsets array. For each band the data offset is the index into the band's data array, of the first sample of the band.

getDataStorageback to summary
public short[] getDataStorage()

Returns a reference to the data array.

getPixelStrideback to summary
public int getPixelStride()

Returns pixel stride -- the number of data array elements between two samples for the same band on the same scanline.

getScanlineStrideback to summary
public int getScanlineStride()

Returns the scanline stride -- the number of data array elements between a given sample and the same sample in the same column of the next row.

getShortDataback to summary
public short[] getShortData(int x, int y, int w, int h, int band, short[] outData)

Returns a short integer array of data elements from the specified rectangular region. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinates are out of bounds.

      short[] bandData = Raster.getShortData(x, y, w, h, null);
      // To find the data element at location (x2, y2)
      short dataElenent = bandData[((y2-y)*w + (x2-x))];
Parameters
x:int

The X coordinate of the upper left pixel location.

y:int

The Y coordinate of the upper left pixel location.

w:int

Width of the sample rectangle.

h:int

Height of the sample rectangle.

band:int

The band to return.

outData:short[]

If non-null, data elements for all bands at the specified location are returned in this array.

Returns:short[]

Data array with data elements for all bands.

getShortDataback to summary
public short[] getShortData(int x, int y, int w, int h, short[] outData)

Returns a short integer array of data elements from the specified rectangular region. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinates are out of bounds.

      short[] bandData = Raster.getShortData(x, y, w, h, null);
      int numDataElements = Raster.getNumBands();
      short[] pixel = new short[numDataElements];
      // To find the data element at location (x2, y2)
      System.arraycopy(bandData, ((y2-y)*w + (x2-x))*numDataElements,
                       pixel, 0, numDataElements);
Parameters
x:int

The X coordinate of the upper left pixel location.

y:int

The Y coordinate of the upper left pixel location.

w:int

Width of the pixel rectangle.

h:int

Height of the pixel rectangle.

outData:short[]

If non-null, data elements for all bands at the specified location are returned in this array.

Returns:short[]

Data array with data elements for all bands.

initIDsback to summary
private static native void initIDs()

Hides java.awt.image.Raster.initIDs.

putShortDataback to summary
public void putShortData(int x, int y, int w, int h, int band, short[] inData)

Stores a short integer array of data elements into the specified rectangular region. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinates are out of bounds. The data elements in the data array are assumed to be packed. That is, a data element at location (x2, y2) would be found at:

     inData[((y2-y)*w + (x2-x))]
Parameters
x:int

The X coordinate of the upper left pixel location.

y:int

The Y coordinate of the upper left pixel location.

w:int

Width of the pixel rectangle.

h:int

Height of the pixel rectangle.

band:int

The band to set.

inData:short[]

The data elements to be stored.

putShortDataback to summary
public void putShortData(int x, int y, int w, int h, short[] inData)

Stores a short integer array of data elements into the specified rectangular region. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinates are out of bounds. The data elements in the data array are assumed to be packed. That is, a data element for the nth band at location (x2, y2) would be found at:

     inData[((y2-y)*w + (x2-x))*numDataElements + n]
Parameters
x:int

The X coordinate of the upper left pixel location.

y:int

The Y coordinate of the upper left pixel location.

w:int

Width of the pixel rectangle.

h:int

Height of the pixel rectangle.

inData:short[]

The data elements to be stored.

setDataElementsback to summary
public void setDataElements(int x, int y, Object obj)

Overrides java.awt.image.WritableRaster.setDataElements.

Stores the data elements for all bands at the specified location. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinate is out of bounds. A ClassCastException will be thrown if the input object is non null and references anything other than an array of transferType.

Parameters
x:int

The X coordinate of the pixel location.

y:int

The Y coordinate of the pixel location.

obj:Object

An object reference to an array of type defined by getTransferType() and length getNumDataElements() containing the pixel data to place at x,y.

setDataElementsback to summary
public void setDataElements(int x, int y, Raster inRaster)

Overrides java.awt.image.WritableRaster.setDataElements.

Stores the Raster data at the specified location. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinates are out of bounds.

Parameters
x:int

The X coordinate of the pixel location.

y:int

The Y coordinate of the pixel location.

inRaster:Raster

Raster of data to place at x,y location.

setDataElementsback to summary
private void setDataElements(int dstX, int dstY, int width, int height, Raster inRaster)

Stores the Raster data at the specified location.

Parameters
dstX:int

The absolute X coordinate of the destination pixel that will receive a copy of the upper-left pixel of the inRaster

dstY:int

The absolute Y coordinate of the destination pixel that will receive a copy of the upper-left pixel of the inRaster

width:int

The number of pixels to store horizontally

height:int

The number of pixels to store vertically

inRaster:Raster

Raster of data to place at x,y location.

setDataElementsback to summary
public void setDataElements(int x, int y, int w, int h, Object obj)

Overrides java.awt.image.WritableRaster.setDataElements.

Stores an array of data elements into the specified rectangular region. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinates are out of bounds. A ClassCastException will be thrown if the input object is non null and references anything other than an array of transferType. The data elements in the data array are assumed to be packed. That is, a data element for the nth band at location (x2, y2) would be found at:

     inData[((y2-y)*w + (x2-x))*numDataElements + n]
Parameters
x:int

The X coordinate of the upper left pixel location.

y:int

The Y coordinate of the upper left pixel location.

w:int

Width of the pixel rectangle.

h:int

Height of the pixel rectangle.

obj:Object

An object reference to an array of type defined by getTransferType() and length w*h*getNumDataElements() containing the pixel data to place between x,y and x+h, y+h.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

verifyback to summary
protected final void verify()

Verify that the layout parameters are consistent with the data. The method verifies whether scanline stride and pixel stride do not cause an integer overflow during calculation of a position of the pixel in data buffer. It also verifies whether the data buffer has enough data to correspond the raster layout attributes.

Exceptions
RasterFormatException:
if an integer overflow is detected, or if data buffer has not enough capacity.