This class extends Raster to provide pixel writing capabilities. Refer to the class comment for Raster for descriptions of how a Raster stores pixels.

The constructors of this class are protected. To instantiate a WritableRaster, use one of the createWritableRaster factory methods in the Raster class.

Creates a Raster based on a BandedSampleModel with the specified DataBuffer, width, height, scanline stride, bank indices, and band offsets. The number of bands is inferred from bankIndices.length and bandOffsets.length, which must be the same. The upper left corner of the Raster is given by the location argument. If location is null, (0, 0) will be used.
Parameters
dataBufferthe DataBuffer that contains the image data
wthe width in pixels of the image data
hthe height in pixels of the image data
scanlineStridethe line stride of the image data
bankIndicesthe bank indices for each band
bandOffsetsthe offsets of all bands
locationthe upper-left corner of the Raster
Return
a WritableRaster object with the specified DataBuffer, width, height, scanline stride, bank indices and band offsets.
Throws
RasterFormatExceptionif w or h is less than or equal to zero, or computing either location.x + w or location.y + h results in integer overflow
IllegalArgumentExceptionif dataType is not one of the supported data types, which are DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT or DataBuffer.TYPE_INT
NullPointerExceptionif dataBuffer is null
Creates a Raster based on a BandedSampleModel with the specified data type, width, height, scanline stride, bank indices and band offsets. The number of bands is inferred from bankIndices.length and bandOffsets.length, which must be the same.

The upper left corner of the Raster is given by the location argument. The dataType parameter should be one of the enumerated values defined in the DataBuffer class.

The only dataTypes supported currently are TYPE_BYTE, TYPE_USHORT, and TYPE_INT.

Parameters
dataTypethe data type for storing samples
wthe width in pixels of the image data
hthe height in pixels of the image data
scanlineStridethe line stride of the image data
bankIndicesthe bank indices for each band
bandOffsetsthe offsets of all bands
locationthe upper-left corner of the Raster
Return
a WritableRaster object with the specified data type, width, height, scanline stride, bank indices and band offsets.
Throws
RasterFormatExceptionif w or h is less than or equal to zero, or computing either location.x + w or location.y + h results in integer overflow
IllegalArgumentExceptionif dataType is not one of the supported data types, which are DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT or DataBuffer.TYPE_INT
ArrayIndexOutOfBoundsExceptionif bankIndices or bandOffsets is null
Creates a Raster based on a BandedSampleModel with the specified data type, width, height, and number of bands.

The upper left corner of the Raster is given by the location argument. If location is null, (0, 0) will be used. The dataType parameter should be one of the enumerated values defined in the DataBuffer class.

The only dataTypes supported currently are TYPE_BYTE, TYPE_USHORT, and TYPE_INT.

Parameters
dataTypethe data type for storing samples
wthe width in pixels of the image data
hthe height in pixels of the image data
bandsthe number of bands
locationthe upper-left corner of the Raster
Return
a WritableRaster object with the specified data type, width, height and number of bands.
Throws
RasterFormatExceptionif w or h is less than or equal to zero, or computing either location.x + w or location.y + h results in integer overflow
ArrayIndexOutOfBoundsExceptionif bands is less than 1
Returns a new Raster which shares all or part of this Raster's DataBuffer. The new Raster will possess a reference to the current Raster, accessible through its getParent() method.

The parentX, parentY, width and height parameters form a Rectangle in this Raster's coordinate space, indicating the area of pixels to be shared. An error will be thrown if this Rectangle is not contained with the bounds of the current Raster.

The new Raster may additionally be translated to a different coordinate system for the plane than that used by the current Raster. The childMinX and childMinY parameters give the new (x, y) coordinate of the upper-left pixel of the returned Raster; the coordinate (childMinX, childMinY) in the new Raster will map to the same pixel as the coordinate (parentX, parentY) in the current Raster.

The new Raster may be defined to contain only a subset of the bands of the current Raster, possibly reordered, by means of the bandList parameter. If bandList is null, it is taken to include all of the bands of the current Raster in their current order.

To create a new Raster that contains a subregion of the current Raster, but shares its coordinate system and bands, this method should be called with childMinX equal to parentX, childMinY equal to parentY, and bandList equal to null.

Parameters
parentX, parentYcoordinates of the upper-left corner in this Raster's coordinates
widthWidth of the region starting at (parentX, parentY)
heightHeight of the region starting at (parentX, parentY).
childMinX, childMinYcoordinates of the upper-left corner of the returned Raster
bandListArray of band indices, or null to use all bands
Return
a new Raster.
Throws
RasterFormatExceptionif the specified subregion is outside of the raster bounds.
RasterFormatExceptionif width or height is less than or equal to zero, or computing any of parentX + width, parentY + height, childMinX + width, or childMinY + height results in integer overflow
Create a compatible WritableRaster the same size as this Raster with the same SampleModel and a new initialized DataBuffer.
Return
a compatible WritableRaster with the same sample model and a new data buffer.
Create a compatible WritableRaster with the specified size, a new SampleModel, and a new initialized DataBuffer.
Parameters
wthe specified width of the new WritableRaster
hthe specified height of the new WritableRaster
Return
a compatible WritableRaster with the specified size and a new sample model and data buffer.
Throws
RasterFormatExceptionif the width or height is less than or equal to zero.
Create a compatible WritableRaster with the specified location (minX, minY) and size (width, height), a new SampleModel, and a new initialized DataBuffer.
Parameters
x, ythe coordinates of the upper-left corner of the WritableRaster
wthe specified width of the WritableRaster
hthe specified height of the WritableRaster
Return
a compatible WritableRaster with the specified size and location and a new sample model and data buffer.
Throws
RasterFormatExceptionif w or h is less than or equal to zero, or computing either x + w or y + h results in integer overflow
Create a compatible WritableRaster with location (minX, minY) and size (width, height) specified by rect, a new SampleModel, and a new initialized DataBuffer.
Parameters
recta Rectangle that specifies the size and location of the WritableRaster
Return
a compatible WritableRaster with the specified size and location and a new sample model and data buffer.
Throws
RasterFormatExceptionif rect has width or height less than or equal to zero, or computing either rect.x + rect.width or rect.y + rect.height results in integer overflow
NullPointerExceptionif rect is null
Creates a Raster based on a PixelInterleavedSampleModel with the specified DataBuffer, width, height, scanline stride, pixel stride, and band offsets. The number of bands is inferred from bandOffsets.length. The upper left corner of the Raster is given by the location argument. If location is null, (0, 0) will be used.

Note that interleaved DataBuffer.TYPE_INT Rasters are not supported. To create a 1-band Raster of type DataBuffer.TYPE_INT, use Raster.createPackedRaster().

Parameters
dataBufferthe DataBuffer that contains the image data
wthe width in pixels of the image data
hthe height in pixels of the image data
scanlineStridethe line stride of the image data
pixelStridethe pixel stride of the image data
bandOffsetsthe offsets of all bands
locationthe upper-left corner of the Raster
Return
a WritableRaster object with the specified DataBuffer, width, height, scanline stride, pixel stride and band offsets.
Throws
RasterFormatExceptionif w or h is less than or equal to zero, or computing either location.x + w or location.y + h results in integer overflow
IllegalArgumentExceptionif dataType is not one of the supported data types, which are DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT
RasterFormatExceptionif dataBuffer has more than one bank.
NullPointerExceptionif dataBuffer is null
Creates a Raster based on a PixelInterleavedSampleModel with the specified data type, width, height, scanline stride, pixel stride, and band offsets. The number of bands is inferred from bandOffsets.length.

The upper left corner of the Raster is given by the location argument. If location is null, (0, 0) will be used. The dataType parameter should be one of the enumerated values defined in the DataBuffer class.

Note that interleaved DataBuffer.TYPE_INT Rasters are not supported. To create a 1-band Raster of type DataBuffer.TYPE_INT, use Raster.createPackedRaster().

The only dataTypes supported currently are TYPE_BYTE and TYPE_USHORT.

Parameters
dataTypethe data type for storing samples
wthe width in pixels of the image data
hthe height in pixels of the image data
scanlineStridethe line stride of the image data
pixelStridethe pixel stride of the image data
bandOffsetsthe offsets of all bands
locationthe upper-left corner of the Raster
Return
a WritableRaster object with the specified data type, width, height, scanline stride, pixel stride and band offsets.
Throws
RasterFormatExceptionif w or h is less than or equal to zero, or computing either location.x + w or location.y + h results in integer overflow
IllegalArgumentExceptionif dataType is not one of the supported data types, which are DataBuffer.TYPE_BYTE, or DataBuffer.TYPE_USHORT.
Creates a Raster based on a PixelInterleavedSampleModel with the specified data type, width, height, and number of bands.

The upper left corner of the Raster is given by the location argument. If location is null, (0, 0) will be used. The dataType parameter should be one of the enumerated values defined in the DataBuffer class.

Note that interleaved DataBuffer.TYPE_INT Rasters are not supported. To create a 1-band Raster of type DataBuffer.TYPE_INT, use Raster.createPackedRaster().

The only dataTypes supported currently are TYPE_BYTE and TYPE_USHORT.

Parameters
dataTypethe data type for storing samples
wthe width in pixels of the image data
hthe height in pixels of the image data
bandsthe number of bands
locationthe upper-left corner of the Raster
Return
a WritableRaster object with the specified data type, width, height and number of bands.
Throws
RasterFormatExceptionif w or h is less than or equal to zero, or computing either location.x + w or location.y + h results in integer overflow
Creates a Raster based on a SinglePixelPackedSampleModel with the specified DataBuffer, width, height, scanline stride, and band masks. The number of bands is inferred from bandMasks.length. The upper left corner of the Raster is given by the location argument. If location is null, (0, 0) will be used.
Parameters
dataBufferthe DataBuffer that contains the image data
wthe width in pixels of the image data
hthe height in pixels of the image data
scanlineStridethe line stride of the image data
bandMasksan array containing an entry for each band
locationthe upper-left corner of the Raster
Return
a WritableRaster object with the specified DataBuffer, width, height, scanline stride, and band masks.
Throws
RasterFormatExceptionif w or h is less than or equal to zero, or computing either location.x + w or location.y + h results in integer overflow
IllegalArgumentExceptionif dataType is not one of the supported data types, which are DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT or DataBuffer.TYPE_INT
RasterFormatExceptionif dataBuffer has more than one bank.
NullPointerExceptionif dataBuffer is null
Creates a Raster based on a MultiPixelPackedSampleModel with the specified DataBuffer, width, height, and bits per pixel. The upper left corner of the Raster is given by the location argument. If location is null, (0, 0) will be used.
Parameters
dataBufferthe DataBuffer that contains the image data
wthe width in pixels of the image data
hthe height in pixels of the image data
bitsPerPixelthe number of bits for each pixel
locationthe upper-left corner of the Raster
Return
a WritableRaster object with the specified DataBuffer, width, height, and bits per pixel.
Throws
RasterFormatExceptionif w or h is less than or equal to zero, or computing either location.x + w or location.y + h results in integer overflow
IllegalArgumentExceptionif dataType is not one of the supported data types, which are DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT or DataBuffer.TYPE_INT
RasterFormatExceptionif dataBuffer has more than one bank.
NullPointerExceptionif dataBuffer is null
Creates a Raster based on a SinglePixelPackedSampleModel with the specified data type, width, height, and band masks. The number of bands is inferred from bandMasks.length.

The upper left corner of the Raster is given by the location argument. If location is null, (0, 0) will be used. The dataType parameter should be one of the enumerated values defined in the DataBuffer class.

The only dataTypes supported currently are TYPE_BYTE, TYPE_USHORT, and TYPE_INT.

Parameters
dataTypethe data type for storing samples
wthe width in pixels of the image data
hthe height in pixels of the image data
bandMasksan array containing an entry for each band
locationthe upper-left corner of the Raster
Return
a WritableRaster object with the specified data type, width, height, and band masks.
Throws
RasterFormatExceptionif w or h is less than or equal to zero, or computing either location.x + w or location.y + h results in integer overflow
IllegalArgumentExceptionif dataType is not one of the supported data types, which are DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT or DataBuffer.TYPE_INT
Creates a Raster based on a packed SampleModel with the specified data type, width, height, number of bands, and bits per band. If the number of bands is one, the SampleModel will be a MultiPixelPackedSampleModel.

If the number of bands is more than one, the SampleModel will be a SinglePixelPackedSampleModel, with each band having bitsPerBand bits. In either case, the requirements on dataType and bitsPerBand imposed by the corresponding SampleModel must be met.

The upper left corner of the Raster is given by the location argument. If location is null, (0, 0) will be used. The dataType parameter should be one of the enumerated values defined in the DataBuffer class.

The only dataTypes supported currently are TYPE_BYTE, TYPE_USHORT, and TYPE_INT.

Parameters
dataTypethe data type for storing samples
wthe width in pixels of the image data
hthe height in pixels of the image data
bandsthe number of bands
bitsPerBandthe number of bits per band
locationthe upper-left corner of the Raster
Return
a WritableRaster object with the specified data type, width, height, number of bands, and bits per band.
Throws
RasterFormatExceptionif w or h is less than or equal to zero, or computing either location.x + w or location.y + h results in integer overflow
IllegalArgumentExceptionif the product of bitsPerBand and bands is greater than the number of bits held by dataType
IllegalArgumentExceptionif bitsPerBand or bands is not greater than zero
IllegalArgumentExceptionif dataType is not one of the supported data types, which are DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT or DataBuffer.TYPE_INT
Creates a Raster with the specified SampleModel and DataBuffer. The upper left corner of the Raster is given by the location argument. If location is null, (0, 0) will be used.
Parameters
smthe specified SampleModel
dbthe specified DataBuffer
locationthe upper-left corner of the Raster
Return
a Raster with the specified SampleModel, DataBuffer, and location.
Throws
RasterFormatExceptionif computing either location.x + sm.getWidth() or location.y + sm.getHeight() results in integer overflow
RasterFormatExceptionif dataBuffer has more than one bank and the sampleModel is PixelInterleavedSampleModel, SinglePixelPackedSampleModel, or MultiPixelPackedSampleModel.
NullPointerExceptionif either SampleModel or DataBuffer is null
Create a Raster with the same size, SampleModel and DataBuffer as this one, but with a different location. The new Raster will possess a reference to the current Raster, accessible through its getParent() method.
Parameters
childMinX, childMinYcoordinates of the upper-left corner of the new Raster
Return
a new Raster with the same size, SampleModel, and DataBuffer as this Raster, but with the specified location.
Throws
RasterFormatExceptionif computing either childMinX + this.getWidth() or childMinY + this.getHeight() results in integer overflow
Returns a new WritableRaster which shares all or part of this WritableRaster's DataBuffer. The new WritableRaster will possess a reference to the current WritableRaster, accessible through its getParent() and getWritableParent() methods.

The parentX, parentY, width and height parameters form a Rectangle in this WritableRaster's coordinate space, indicating the area of pixels to be shared. An error will be thrown if this Rectangle is not contained with the bounds of the current WritableRaster.

The new WritableRaster may additionally be translated to a different coordinate system for the plane than that used by the current WritableRaster. The childMinX and childMinY parameters give the new (x, y) coordinate of the upper-left pixel of the returned WritableRaster; the coordinate (childMinX, childMinY) in the new WritableRaster will map to the same pixel as the coordinate (parentX, parentY) in the current WritableRaster.

The new WritableRaster may be defined to contain only a subset of the bands of the current WritableRaster, possibly reordered, by means of the bandList parameter. If bandList is null, it is taken to include all of the bands of the current WritableRaster in their current order.

To create a new WritableRaster that contains a subregion of the current WritableRaster, but shares its coordinate system and bands, this method should be called with childMinX equal to parentX, childMinY equal to parentY, and bandList equal to null.

Parameters
parentXX coordinate of the upper left corner in this WritableRaster's coordinates.
parentYY coordinate of the upper left corner in this WritableRaster's coordinates.
wWidth of the region starting at (parentX, parentY).
hHeight of the region starting at (parentX, parentY).
childMinXX coordinate of the upper left corner of the returned WritableRaster.
childMinYY coordinate of the upper left corner of the returned WritableRaster.
bandListArray of band indices, or null to use all bands.
Return
a WritableRaster sharing all or part of the DataBuffer of this WritableRaster.
Throws
RasterFormatExceptionif the subregion is outside of the raster bounds.
RasterFormatExceptionif w or h is less than or equal to zero, or computing any of parentX + w, parentY + h, childMinX + w, or childMinY + h results in integer overflow
Creates a WritableRaster with the specified SampleModel and DataBuffer. The upper left corner of the Raster is given by the location argument. If location is null, (0, 0) will be used.
Parameters
smthe specified SampleModel
dbthe specified DataBuffer
locationthe upper-left corner of the WritableRaster
Return
a WritableRaster with the specified SampleModel, DataBuffer, and location.
Throws
RasterFormatExceptionif computing either location.x + sm.getWidth() or location.y + sm.getHeight() results in integer overflow
RasterFormatExceptionif dataBuffer has more than one bank and the sampleModel is PixelInterleavedSampleModel, SinglePixelPackedSampleModel, or MultiPixelPackedSampleModel.
NullPointerExceptionif either SampleModel or DataBuffer is null
Creates a WritableRaster with the specified SampleModel. The upper left corner of the Raster is given by the location argument. If location is null, (0, 0) will be used.
Parameters
smthe specified SampleModel
locationthe upper-left corner of the WritableRaster
Return
a WritableRaster with the specified SampleModel and location.
Throws
RasterFormatExceptionif computing either location.x + sm.getWidth() or location.y + sm.getHeight() results in integer overflow
Create a WritableRaster with the same size, SampleModel and DataBuffer as this one, but with a different location. The new WritableRaster will possess a reference to the current WritableRaster, accessible through its getParent() and getWritableParent() methods.
Parameters
childMinXX coord of the upper left corner of the new Raster.
childMinYY coord of the upper left corner of the new Raster.
Return
a WritableRaster the same as this one except for the specified location.
Throws
RasterFormatExceptionif computing either childMinX + this.getWidth() or childMinY + this.getHeight() results in integer overflow
Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Parameters
objthe reference object with which to compare.
Return
true if this object is the same as the obj argument; false otherwise.
Returns the bounding Rectangle of this Raster. This function returns the same information as getMinX/MinY/Width/Height.
Return
the bounding box of this Raster.
Returns the runtime class of an object. That Class object is the object that is locked by static synchronized methods of the represented class.
Return
The java.lang.Class object that represents the runtime class of the object. The result is of type {@code Class} where X is the erasure of the static type of the expression on which getClass is called.
Returns the DataBuffer associated with this Raster.
Return
the DataBuffer of this Raster.
Returns the pixel data for the specified rectangle of pixels in a primitive array of type TransferType. For image data supported by the Java 2D API, this will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE. Data may be returned in a packed format, thus increasing efficiency for data transfers. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed. A ClassCastException will be thrown if the input object is non null and references anything other than an array of TransferType.
Parameters
x, ythe coordinates of the upper-left pixel location
wWidth of the pixel rectangle
hHeight of the pixel rectangle
outDataAn 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.
Return
An object reference to an array of type defined by getTransferType() with the requested pixel data.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if outData is too small to hold the output.
Returns data for a single pixel in a primitive array of type TransferType. For image data supported by the Java 2D(tm) API, this will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE. Data may be returned in a packed format, thus increasing efficiency for data transfers. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed. A ClassCastException will be thrown if the input object is non null and references anything other than an array of TransferType.
Parameters
x, ythe coordinates of the pixel location
outDataAn 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
Return
An object reference to an array of type defined by getTransferType() with the requested pixel data.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if outData is too small to hold the output.
Returns the height in pixels of the Raster.
Return
the height of this Raster.
Returns the minimum valid X coordinate of the Raster.
Return
the minimum x coordinate of this Raster.
Returns the minimum valid Y coordinate of the Raster.
Return
the minimum y coordinate of this Raster.
Returns the number of bands (samples per pixel) in this Raster.
Return
the number of bands of this Raster.
Returns the number of data elements needed to transfer one pixel via the getDataElements and setDataElements methods. When pixels are transferred via these methods, they may be transferred in a packed or unpacked format, depending on the implementation of the underlying SampleModel. Using these methods, pixels are transferred as an array of getNumDataElements() elements of a primitive type given by getTransferType(). The TransferType may or may not be the same as the storage data type of the DataBuffer.
Return
the number of data elements.
Returns the parent Raster (if any) of this Raster or null.
Return
the parent Raster or null.
Returns the samples in an array of double for the specified pixel. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
x, ythe coordinates of the pixel location
dArrayAn optionally preallocated double array
Return
the samples for the specified pixel.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if dArray is too small to hold the output.
Returns the samples in an array of float for the specified pixel. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
x, ythe coordinates of the pixel location
fArrayAn optionally preallocated float array
Return
the samples for the specified pixel.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if fArray is too small to hold the output.
Returns the samples in an array of int for the specified pixel. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
x, ythe coordinates of the pixel location
iArrayAn optionally preallocated int array
Return
the samples for the specified pixel.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if iArray is too small to hold the output.
Returns a double array containing all samples for a rectangle of pixels, one sample per array element. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
x, ythe coordinates of the upper-left pixel location
wWidth of the pixel rectangle
hHeight of the pixel rectangle
dArrayAn optionally pre-allocated double array
Return
the samples for the specified rectangle of pixels.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if dArray is too small to hold the output.
Returns a float array containing all samples for a rectangle of pixels, one sample per array element. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
x, ythe coordinates of the pixel location
wWidth of the pixel rectangle
hHeight of the pixel rectangle
fArrayAn optionally pre-allocated float array
Return
the samples for the specified rectangle of pixels.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if fArray is too small to hold the output.
Returns an int array containing all samples for a rectangle of pixels, one sample per array element. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
x, ythe coordinates of the upper-left pixel location
wWidth of the pixel rectangle
hHeight of the pixel rectangle
iArrayAn optionally pre-allocated int array
Return
the samples for the specified rectangle of pixels.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if iArray is too small to hold the output.
Returns the sample in a specified band for the pixel located at (x,y) as an int. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
x, ythe coordinates of the pixel location
bThe band to return
Return
the sample in the specified band for the pixel at the specified coordinate.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates or the band index are not in bounds.
Returns the sample in a specified band for a pixel located at (x,y) as a double. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
x, ythe coordinates of the pixel location
bThe band to return
Return
the sample in the specified band for the pixel at the specified coordinate.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates or the band index are not in bounds.
Returns the sample in a specified band for the pixel located at (x,y) as a float. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
x, ythe coordinates of the pixel location
bThe band to return
Return
the sample in the specified band for the pixel at the specified coordinate.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates or the band index are not in bounds.
Returns the SampleModel that describes the layout of the image data.
Return
the SampleModel of this Raster.
Returns the X translation from the coordinate system of the SampleModel to that of the Raster. To convert a pixel's X coordinate from the Raster coordinate system to the SampleModel coordinate system, this value must be subtracted.
Return
the X translation from the coordinate space of the Raster's SampleModel to that of the Raster.
Returns the Y translation from the coordinate system of the SampleModel to that of the Raster. To convert a pixel's Y coordinate from the Raster coordinate system to the SampleModel coordinate system, this value must be subtracted.
Return
the Y translation from the coordinate space of the Raster's SampleModel to that of the Raster.
Returns the samples for a specified band for a specified rectangle of pixels in a double array, one sample per array element. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
x, ythe coordinates of the upper-left pixel location
wWidth of the pixel rectangle
hHeight of the pixel rectangle
bThe band to return
dArrayAn optionally pre-allocated double array
Return
the samples for the specified band for the specified rectangle of pixels.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates or the band index are not in bounds, or if dArray is too small to hold the output.
Returns the samples for a specified band for the specified rectangle of pixels in a float array, one sample per array element. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
x, ythe coordinates of the upper-left pixel location
wWidth of the pixel rectangle
hHeight of the pixel rectangle
bThe band to return
fArrayAn optionally pre-allocated float array
Return
the samples for the specified band for the specified rectangle of pixels.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates or the band index are not in bounds, or if fArray is too small to hold the output.
Returns the samples for a specified band for the specified rectangle of pixels in an int array, one sample per array element. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
x, ythe coordinates of the upper-left pixel location
wWidth of the pixel rectangle
hHeight of the pixel rectangle
bThe band to return
iArrayAn optionally pre-allocated int array
Return
the samples for the specified band for the specified rectangle of pixels.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates or the band index are not in bounds, or if iArray is too small to hold the output.
Returns the TransferType used to transfer pixels via the getDataElements and setDataElements methods. When pixels are transferred via these methods, they may be transferred in a packed or unpacked format, depending on the implementation of the underlying SampleModel. Using these methods, pixels are transferred as an array of getNumDataElements() elements of a primitive type given by getTransferType(). The TransferType may or may not be the same as the storage data type of the DataBuffer. The TransferType will be one of the types defined in DataBuffer.
Return
this transfer type.
Returns the width in pixels of the Raster.
Return
the width of this Raster.
Returns the parent WritableRaster (if any) of this WritableRaster, or else null.
Return
the parent of this WritableRaster, or null.
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Return
a hash code value for this object.
Wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. A thread waits on an object's monitor by calling one of the wait methods.

The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:

  • By executing a synchronized instance method of that object.
  • By executing the body of a synchronized statement that synchronizes on the object.
  • For objects of type Class, by executing a synchronized static method of that class.

Only one thread at a time can own an object's monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.

The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Sets the data for a rectangle of pixels from a primitive array of type TransferType. For image data supported by the Java 2D API, this will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE. Data in the array may be in a packed format, thus increasing efficiency for data transfers. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds, or if inData is not large enough to hold the pixel data. However, explicit bounds checking is not guaranteed. A ClassCastException will be thrown if the input object is not null and references anything other than an array of TransferType.
Parameters
xThe X coordinate of the upper left pixel location.
yThe Y coordinate of the upper left pixel location.
wWidth of the pixel rectangle.
hHeight of the pixel rectangle.
inDataAn 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+w-1, y+h-1.
Throws
NullPointerExceptionif inData is null.
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if inData is too small to hold the input.
Sets the data for a single pixel from a primitive array of type TransferType. For image data supported by the Java 2D(tm) API, this will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE. Data in the array may be in a packed format, thus increasing efficiency for data transfers. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds, or if inData is not large enough to hold the pixel data. However, explicit bounds checking is not guaranteed. A ClassCastException will be thrown if the input object is not null and references anything other than an array of TransferType.
Parameters
xThe X coordinate of the pixel location.
yThe Y coordinate of the pixel location.
inDataAn object reference to an array of type defined by getTransferType() and length getNumDataElements() containing the pixel data to place at x,y.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if inData is too small to hold the input.
Sets the data for a rectangle of pixels from an input Raster. The input Raster must be compatible with this WritableRaster in that they must have the same number of bands, corresponding bands must have the same number of bits per sample, the TransferTypes and NumDataElements must be the same, and the packing used by the getDataElements/setDataElements must be identical. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
xThe X coordinate of the pixel location.
yThe Y coordinate of the pixel location.
inRasterRaster containing data to place at x,y.
Throws
NullPointerExceptionif inRaster is null.
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds.
Sets a pixel in the DataBuffer using a double array of samples for input. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
xThe X coordinate of the pixel location.
yThe Y coordinate of the pixel location.
dArrayThe input samples in a double array.
Throws
NullPointerExceptionif dArray is null.
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if dArray is too small to hold the input.
Sets a pixel in the DataBuffer using a float array of samples for input. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
xThe X coordinate of the pixel location.
yThe Y coordinate of the pixel location.
fArrayThe input samples in a float array.
Throws
NullPointerExceptionif fArray is null.
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if fArray is too small to hold the input.
Sets a pixel in the DataBuffer using an int array of samples for input. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
xThe X coordinate of the pixel location.
yThe Y coordinate of the pixel location.
iArrayThe input samples in a int array.
Throws
NullPointerExceptionif iArray is null.
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if iArray is too small to hold the input.
Sets all samples for a rectangle of pixels from a double array containing one sample per array element. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
xThe X coordinate of the upper left pixel location.
yThe Y coordinate of the upper left pixel location.
wWidth of the pixel rectangle.
hHeight of the pixel rectangle.
dArrayThe input double pixel array.
Throws
NullPointerExceptionif dArray is null.
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if dArray is too small to hold the input.
Sets all samples for a rectangle of pixels from a float array containing one sample per array element. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
xThe X coordinate of the upper left pixel location.
yThe Y coordinate of the upper left pixel location.
wWidth of the pixel rectangle.
hHeight of the pixel rectangle.
fArrayThe input float pixel array.
Throws
NullPointerExceptionif fArray is null.
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if fArray is too small to hold the input.
Sets all samples for a rectangle of pixels from an int array containing one sample per array element. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
xThe X coordinate of the upper left pixel location.
yThe Y coordinate of the upper left pixel location.
wWidth of the pixel rectangle.
hHeight of the pixel rectangle.
iArrayThe input int pixel array.
Throws
NullPointerExceptionif iArray is null.
ArrayIndexOutOfBoundsExceptionif the coordinates are not in bounds, or if iArray is too small to hold the input.
Copies pixels from Raster srcRaster to this WritableRaster. For each (x, y) address in srcRaster, the corresponding pixel is copied to address (x+dx, y+dy) in this WritableRaster, unless (x+dx, y+dy) falls outside the bounds of this raster. srcRaster must have the same number of bands as this WritableRaster. The copy is a simple copy of source samples to the corresponding destination samples. For details, see .
Parameters
dxThe X translation factor from src space to dst space of the copy.
dyThe Y translation factor from src space to dst space of the copy.
srcRasterThe Raster from which to copy pixels.
Throws
NullPointerExceptionif srcRaster is null.
Copies pixels from Raster srcRaster to this WritableRaster. Each pixel in srcRaster is copied to the same x,y address in this raster, unless the address falls outside the bounds of this raster. srcRaster must have the same number of bands as this WritableRaster. The copy is a simple copy of source samples to the corresponding destination samples.

If all samples of both source and destination Rasters are of integral type and less than or equal to 32 bits in size, then calling this method is equivalent to executing the following code for all x,y addresses valid in both Rasters.

       Raster srcRaster;
       WritableRaster dstRaster;
       for (int b = 0; b < srcRaster.getNumBands(); b++) {
           dstRaster.setSample(x, y, b, srcRaster.getSample(x, y, b));
       }
 
Thus, when copying an integral type source to an integral type destination, if the source sample size is greater than the destination sample size for a particular band, the high order bits of the source sample are truncated. If the source sample size is less than the destination size for a particular band, the high order bits of the destination are zero-extended or sign-extended depending on whether srcRaster's SampleModel treats the sample as a signed or unsigned quantity.

When copying a float or double source to an integral type destination, each source sample is cast to the destination type. When copying an integral type source to a float or double destination, the source is first converted to a 32-bit int (if necessary), using the above rules for integral types, and then the int is cast to float or double.

Parameters
srcRasterThe Raster from which to copy pixels.
Throws
NullPointerExceptionif srcRaster is null.
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using a double for input. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
xThe X coordinate of the pixel location.
yThe Y coordinate of the pixel location.
bThe band to set.
sThe input sample as a double.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates or the band index are not in bounds.
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using a float for input. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
xThe X coordinate of the pixel location.
yThe Y coordinate of the pixel location.
bThe band to set.
sThe input sample as a float.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates or the band index are not in bounds.
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using an int for input. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
xThe X coordinate of the pixel location.
yThe Y coordinate of the pixel location.
bThe band to set.
sThe input sample.
Throws
ArrayIndexOutOfBoundsExceptionif the coordinates or the band index are not in bounds.
Sets the samples in the specified band for the specified rectangle of pixels from a double array containing one sample per array element. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
xThe X coordinate of the upper left pixel location.
yThe Y coordinate of the upper left pixel location.
wWidth of the pixel rectangle.
hHeight of the pixel rectangle.
bThe band to set.
dArrayThe input double sample array.
Throws
NullPointerExceptionif dArray is null.
ArrayIndexOutOfBoundsExceptionif the coordinates or the band index are not in bounds, or if dArray is too small to hold the input.
Sets the samples in the specified band for the specified rectangle of pixels from a float array containing one sample per array element. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
xThe X coordinate of the upper left pixel location.
yThe Y coordinate of the upper left pixel location.
wWidth of the pixel rectangle.
hHeight of the pixel rectangle.
bThe band to set.
fArrayThe input float sample array.
Throws
NullPointerExceptionif fArray is null.
ArrayIndexOutOfBoundsExceptionif the coordinates or the band index are not in bounds, or if fArray is too small to hold the input.
Sets the samples in the specified band for the specified rectangle of pixels from an int array containing one sample per array element. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
Parameters
xThe X coordinate of the upper left pixel location.
yThe Y coordinate of the upper left pixel location.
wWidth of the pixel rectangle.
hHeight of the pixel rectangle.
bThe band to set.
iArrayThe input int sample array.
Throws
NullPointerExceptionif iArray is null.
ArrayIndexOutOfBoundsExceptionif the coordinates or the band index are not in bounds, or if iArray is too small to hold the input.
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 
Return
a string representation of the object.
Causes current thread to wait until another thread invokes the method or the method for this object. In other words, this method behaves exactly as if it simply performs the call wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait();
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Throws
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.

The current thread must own this object's monitor.

This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

  • Some other thread invokes the notify method for this object and thread T happens to be arbitrarily chosen as the thread to be awakened.
  • Some other thread invokes the notifyAll method for this object.
  • Some other thread interrupts thread T.
  • The specified amount of real time has elapsed, more or less. If timeout is zero, however, then real time is not taken into consideration and the thread simply waits until notified.
The thread T is then removed from the wait set for this object and re-enabled for thread scheduling. It then competes in the usual manner with other threads for the right to synchronize on the object; once it has gained control of the object, all its synchronization claims on the object are restored to the status quo ante - that is, to the situation as of the time that the wait method was invoked. Thread T then returns from the invocation of the wait method. Thus, on return from the wait method, the synchronization state of the object and of thread T is exactly as it was when the wait method was invoked.

A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout);
         ... // Perform action appropriate to condition
     }
 
(For more information on this topic, see Section 3.2.3 in Doug Lea's "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 2000), or Item 50 in Joshua Bloch's "Effective Java Programming Language Guide" (Addison-Wesley, 2001).

If the current thread is interrupted by another thread while it is waiting, then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.

Note that the wait method, as it places the current thread into the wait set for this object, unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Parameters
timeoutthe maximum time to wait in milliseconds.
Throws
IllegalArgumentExceptionif the value of timeout is negative.
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

This method is similar to the wait method of one argument, but it allows finer control over the amount of time to wait for a notification before giving up. The amount of real time, measured in nanoseconds, is given by:

 1000000*timeout+nanos

In all other respects, this method does the same thing as the method of one argument. In particular, wait(0, 0) means the same thing as wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:

  • Another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method.
  • The timeout period, specified by timeout milliseconds plus nanos nanoseconds arguments, has elapsed.

The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout, nanos);
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Parameters
timeoutthe maximum time to wait in milliseconds.
nanosadditional time, in nanoseconds range 0-999999.
Throws
IllegalArgumentExceptionif the value of timeout is negative or the value of nanos is not in the range 0-999999.
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.