WritableRasterpublic class WritableRaster extends Raster The WritableRaster class provides functionality for writing samples and pixel
capabilities to the Raster. |
Constructors Summary |
---|
protected WritableRaster(SampleModel sampleModel, DataBuffer dataBuffer, Rectangle aRegion, Point sampleModelTranslate, WritableRaster parent)Instantiates a new WritableRaster object with the specified SampleModel,
DataBuffer, rectangular region and parent WritableRaster.
super(sampleModel, dataBuffer, aRegion, sampleModelTranslate, parent);
| protected WritableRaster(SampleModel sampleModel, DataBuffer dataBuffer, Point origin)Instantiates a new WritableRaster object with the specified SampleModel
which defines a layout of this WritableRaster and DataBuffer objects
which defines the image data.
this(sampleModel, dataBuffer, new Rectangle(origin.x, origin.y, sampleModel.width,
sampleModel.height), origin, null);
| protected WritableRaster(SampleModel sampleModel, Point origin)Instantiates a new WritableRaster with the specified SampleModel.
this(sampleModel, sampleModel.createDataBuffer(), new Rectangle(origin.x, origin.y,
sampleModel.width, sampleModel.height), origin, null);
|
Methods Summary |
---|
public java.awt.image.WritableRaster | createWritableChild(int parentX, int parentY, int w, int h, int childMinX, int childMinY, int[] bandList)Creates the child of this WritableRaster by sharing the specified
rectangular area in this WritableRaster. The parentX, parentY, width and
height parameters specify rectangular area to be shared.
if (w <= 0 || h <= 0) {
// awt.244=Width or Height of child Raster is less than or equal to
// zero
throw new RasterFormatException(Messages.getString("awt.244")); //$NON-NLS-1$
}
if (parentX < this.minX || parentX + w > this.minX + this.width) {
// awt.245=parentX disposes outside Raster
throw new RasterFormatException(Messages.getString("awt.245")); //$NON-NLS-1$
}
if (parentY < this.minY || parentY + h > this.minY + this.height) {
// awt.246=parentY disposes outside Raster
throw new RasterFormatException(Messages.getString("awt.246")); //$NON-NLS-1$
}
if ((long)parentX + w > Integer.MAX_VALUE) {
// awt.247=parentX + w results in integer overflow
throw new RasterFormatException(Messages.getString("awt.247")); //$NON-NLS-1$
}
if ((long)parentY + h > Integer.MAX_VALUE) {
// awt.248=parentY + h results in integer overflow
throw new RasterFormatException(Messages.getString("awt.248")); //$NON-NLS-1$
}
if ((long)childMinX + w > Integer.MAX_VALUE) {
// awt.249=childMinX + w results in integer overflow
throw new RasterFormatException(Messages.getString("awt.249")); //$NON-NLS-1$
}
if ((long)childMinY + h > Integer.MAX_VALUE) {
// awt.24A=childMinY + h results in integer overflow
throw new RasterFormatException(Messages.getString("awt.24A")); //$NON-NLS-1$
}
SampleModel childModel;
if (bandList == null) {
childModel = sampleModel;
} else {
childModel = sampleModel.createSubsetSampleModel(bandList);
}
int childTranslateX = childMinX - parentX;
int childTranslateY = childMinY - parentY;
return new WritableRaster(childModel, dataBuffer,
new Rectangle(childMinX, childMinY, w, h), new Point(childTranslateX
+ sampleModelTranslateX, childTranslateY + sampleModelTranslateY), this);
| public java.awt.image.WritableRaster | createWritableTranslatedChild(int childMinX, int childMinY)Creates the translated child of this WritableRaster. New WritableRaster
object is a reference to the this WritableRaster and with different
location.
return createWritableChild(minX, minY, width, height, childMinX, childMinY, null);
| public java.awt.image.WritableRaster | getWritableParent()Gets the parent WritableRaster for this WritableRaster object.
return (WritableRaster)parent;
| public void | setDataElements(int x, int y, java.awt.image.Raster inRaster)Sets the data for a rectangle of pixels from an input Raster to this
WritableRaster.
int dstX = x + inRaster.getMinX();
int dstY = y + inRaster.getMinY();
int w = inRaster.getWidth();
int h = inRaster.getHeight();
if (dstX < this.minX || dstX + w > this.minX + this.width || dstY < this.minY
|| dstY + h > this.minY + this.height) {
// awt.63=Coordinates are not in bounds
throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.63")); //$NON-NLS-1$
}
int srcX = inRaster.getMinX();
int srcY = inRaster.getMinY();
Object line = null;
for (int i = 0; i < h; i++) {
line = inRaster.getDataElements(srcX, srcY + i, w, 1, line);
setDataElements(dstX, dstY + i, w, 1, line);
}
| public void | setDataElements(int x, int y, java.lang.Object inData)Sets the data for a single pixel from an input Object which represents an
array of primitive types: DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT,
DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, or
DataBuffer.TYPE_DOUBLE.
sampleModel.setDataElements(x - sampleModelTranslateX, y - sampleModelTranslateY, inData,
dataBuffer);
| public void | setDataElements(int x, int y, int w, int h, java.lang.Object inData)Sets the data elements which represent pixel data to the specified
rectangle area as a primitive array. The following image data types are
supported: DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT,
DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, or
DataBuffer.TYPE_DOUBLE.
sampleModel.setDataElements(x - sampleModelTranslateX, y - sampleModelTranslateY, w, h,
inData, dataBuffer);
| public void | setPixel(int x, int y, int[] iArray)Sets an integer array of samples for the specified pixel in this
WritableRaster.
sampleModel.setPixel(x - sampleModelTranslateX, y - sampleModelTranslateY, iArray,
dataBuffer);
| public void | setPixel(int x, int y, float[] fArray)Sets a float array of samples for the specified pixel in this
WritableRaster.
sampleModel.setPixel(x - sampleModelTranslateX, y - sampleModelTranslateY, fArray,
dataBuffer);
| public void | setPixel(int x, int y, double[] dArray)Sets a double array of samples for the specified pixel in this
WritableRaster.
sampleModel.setPixel(x - sampleModelTranslateX, y - sampleModelTranslateY, dArray,
dataBuffer);
| public void | setPixels(int x, int y, int w, int h, int[] iArray)Sets a integer array of samples for the specified rectangular area of
pixels in this WritableRaster.
sampleModel.setPixels(x - sampleModelTranslateX, y - sampleModelTranslateY, w, h, iArray,
dataBuffer);
| public void | setPixels(int x, int y, int w, int h, float[] fArray)Sets a float array of samples for the specified rectangular area of
pixels in this WritableRaster.
sampleModel.setPixels(x - sampleModelTranslateX, y - sampleModelTranslateY, w, h, fArray,
dataBuffer);
| public void | setPixels(int x, int y, int w, int h, double[] dArray)Sets a double array of samples for the specified rectangular area of
pixels in this WritableRaster.
sampleModel.setPixels(x - sampleModelTranslateX, y - sampleModelTranslateY, w, h, dArray,
dataBuffer);
| public void | setRect(int dx, int dy, java.awt.image.Raster srcRaster)Sets pixels from the specified source Raster srcRaster to this
WritableRaster. Each pixel with (x, y) coordinates from the source Raster
is copied to pixel with (x+dx, y+dy) coordinates in this WritableRaster.
The pixels with (x+dx, y+dy) coordinates which are out the bounds of this
raster are ignored.
int w = srcRaster.getWidth();
int h = srcRaster.getHeight();
int srcX = srcRaster.getMinX();
int srcY = srcRaster.getMinY();
int dstX = srcX + dx;
int dstY = srcY + dy;
if (dstX < this.minX) {
int minOffX = this.minX - dstX;
w -= minOffX;
dstX = this.minX;
srcX += minOffX;
}
if (dstY < this.minY) {
int minOffY = this.minY - dstY;
h -= minOffY;
dstY = this.minY;
srcY += minOffY;
}
if (dstX + w > this.minX + this.width) {
int maxOffX = (dstX + w) - (this.minX + this.width);
w -= maxOffX;
}
if (dstY + h > this.minY + this.height) {
int maxOffY = (dstY + h) - (this.minY + this.height);
h -= maxOffY;
}
if (w <= 0 || h <= 0) {
return;
}
switch (sampleModel.getDataType()) {
case DataBuffer.TYPE_BYTE:
case DataBuffer.TYPE_SHORT:
case DataBuffer.TYPE_USHORT:
case DataBuffer.TYPE_INT:
int iPixelsLine[] = null;
for (int i = 0; i < h; i++) {
iPixelsLine = srcRaster.getPixels(srcX, srcY + i, w, 1, iPixelsLine);
setPixels(dstX, dstY + i, w, 1, iPixelsLine);
}
break;
case DataBuffer.TYPE_FLOAT:
float fPixelsLine[] = null;
for (int i = 0; i < h; i++) {
fPixelsLine = srcRaster.getPixels(srcX, srcY + i, w, 1, fPixelsLine);
setPixels(dstX, dstY + i, w, 1, fPixelsLine);
}
break;
case DataBuffer.TYPE_DOUBLE:
double dPixelsLine[] = null;
for (int i = 0; i < h; i++) {
dPixelsLine = srcRaster.getPixels(srcX, srcY + i, w, 1, dPixelsLine);
setPixels(dstX, dstY + i, w, 1, dPixelsLine);
}
break;
}
| public void | setRect(java.awt.image.Raster srcRaster)Sets pixels from the specified source Raster srcRaster to this
WritableRaster.
setRect(0, 0, srcRaster);
| public void | setSample(int x, int y, int b, int s)Sets the sample for the specified band and the specified pixel with an
integer sample.
sampleModel.setSample(x - sampleModelTranslateX, y - sampleModelTranslateY, b, s,
dataBuffer);
| public void | setSample(int x, int y, int b, float s)Sets the sample for the specified band and the specified pixel with a
float sample.
sampleModel.setSample(x - sampleModelTranslateX, y - sampleModelTranslateY, b, s,
dataBuffer);
| public void | setSample(int x, int y, int b, double s)Sets the sample for the specified band and the specified pixel with an
integer sample.
sampleModel.setSample(x - sampleModelTranslateX, y - sampleModelTranslateY, b, s,
dataBuffer);
| public void | setSamples(int x, int y, int w, int h, int b, int[] iArray)Sets the samples for the specified band and the specified rectangular
area of pixels with an integer array of samples.
sampleModel.setSamples(x - sampleModelTranslateX, y - sampleModelTranslateY, w, h, b,
iArray, dataBuffer);
| public void | setSamples(int x, int y, int w, int h, int b, float[] fArray)Sets the samples for the specified band and the specified rectangular
area of pixels with a float array of samples.
sampleModel.setSamples(x - sampleModelTranslateX, y - sampleModelTranslateY, w, h, b,
fArray, dataBuffer);
| public void | setSamples(int x, int y, int w, int h, int b, double[] dArray)Sets the samples for the specified band and the specified rectangular
area of pixels with a double array of samples.
sampleModel.setSamples(x - sampleModelTranslateX, y - sampleModelTranslateY, w, h, b,
dArray, dataBuffer);
|
|