summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/java/awt/image/ComponentSampleModel.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/awt/image/ComponentSampleModel.java')
-rw-r--r--libjava/classpath/java/awt/image/ComponentSampleModel.java208
1 files changed, 104 insertions, 104 deletions
diff --git a/libjava/classpath/java/awt/image/ComponentSampleModel.java b/libjava/classpath/java/awt/image/ComponentSampleModel.java
index 73e7fb4d3d0..f32eae31965 100644
--- a/libjava/classpath/java/awt/image/ComponentSampleModel.java
+++ b/libjava/classpath/java/awt/image/ComponentSampleModel.java
@@ -60,65 +60,65 @@ public class ComponentSampleModel extends SampleModel
{
/** The offsets to the first sample for each band. */
protected int[] bandOffsets;
-
+
/** The indices of the bank used to store each band in a data buffer. */
protected int[] bankIndices;
-
- /**
+
+ /**
* The number of bands in the image.
* @specnote This field shadows the protected numBands in SampleModel.
*/
protected int numBands;
-
+
/** Used when creating data buffers. */
protected int numBanks;
- /**
- * The number of data elements between a sample in one row and the
+ /**
+ * The number of data elements between a sample in one row and the
* corresponding sample in the next row.
*/
protected int scanlineStride;
-
+
/**
- * The number of data elements between a sample for one pixel and the
+ * The number of data elements between a sample for one pixel and the
* corresponding sample for the next pixel in the same row.
*/
protected int pixelStride;
/**
- * Creates a new sample model that assumes that all bands are stored in a
+ * Creates a new sample model that assumes that all bands are stored in a
* single bank of the {@link DataBuffer}.
* <p>
* Note that the <code>bandOffsets</code> array is copied to internal storage
* to prevent subsequent changes to the array from affecting this object.
- *
+ *
* @param dataType the data type (one of {@link DataBuffer#TYPE_BYTE},
* {@link DataBuffer#TYPE_USHORT}, {@link DataBuffer#TYPE_SHORT},
- * {@link DataBuffer#TYPE_INT}, {@link DataBuffer#TYPE_FLOAT} or
+ * {@link DataBuffer#TYPE_INT}, {@link DataBuffer#TYPE_FLOAT} or
* {@link DataBuffer#TYPE_DOUBLE}).
* @param w the width in pixels.
* @param h the height in pixels.
* @param pixelStride the number of data elements in the step from a sample
* in one pixel to the corresponding sample in the next pixel.
- * @param scanlineStride the number of data elements in the step from a
+ * @param scanlineStride the number of data elements in the step from a
* sample in a pixel to the corresponding sample in the pixel in the next
* row.
- * @param bandOffsets the offset to the first element for each band, with
+ * @param bandOffsets the offset to the first element for each band, with
* the size of the array defining the number of bands (<code>null</code>
* not permitted).
- *
+ *
* @throws IllegalArgumentException if <code>dataType</code> is not one of
* the specified values.
* @throws IllegalArgumentException if <code>w</code> is less than or equal
* to zero.
- * @throws IllegalArgumentException if <code>h</code> is less than or equal
+ * @throws IllegalArgumentException if <code>h</code> is less than or equal
* to zero.
* @throws IllegalArgumentException if <code>w * h</code> exceeds
* {@link Integer#MAX_VALUE}.
* @throws IllegalArgumentException if <code>pixelStride</code> is negative.
- * @throws IllegalArgumentException if <code>scanlineStride</code> is less
+ * @throws IllegalArgumentException if <code>scanlineStride</code> is less
* than or equal to zero.
- * @throws IllegalArgumentException if <code>bandOffsets</code> has zero
+ * @throws IllegalArgumentException if <code>bandOffsets</code> has zero
* length.
*/
public ComponentSampleModel(int dataType,
@@ -130,43 +130,43 @@ public class ComponentSampleModel extends SampleModel
this(dataType, w, h, pixelStride, scanlineStride,
new int[bandOffsets.length], bandOffsets);
}
-
+
/**
- * Creates a new sample model that assumes that all bands are stored in a
+ * Creates a new sample model that assumes that all bands are stored in a
* single bank of the {@link DataBuffer}.
- *
+ *
* @param dataType the data type (one of {@link DataBuffer#TYPE_BYTE},
* {@link DataBuffer#TYPE_USHORT}, {@link DataBuffer#TYPE_SHORT},
- * {@link DataBuffer#TYPE_INT}, {@link DataBuffer#TYPE_FLOAT} or
+ * {@link DataBuffer#TYPE_INT}, {@link DataBuffer#TYPE_FLOAT} or
* {@link DataBuffer#TYPE_DOUBLE}).
* @param w the width in pixels.
* @param h the height in pixels.
* @param pixelStride the number of data elements in the step from a sample
* in one pixel to the corresponding sample in the next pixel.
- * @param scanlineStride the number of data elements in the step from a
+ * @param scanlineStride the number of data elements in the step from a
* sample in a pixel to the corresponding sample in the pixel in the next
* row.
- * @param bankIndices the index of the bank in which each band is stored
+ * @param bankIndices the index of the bank in which each band is stored
* (<code>null</code> not permitted). This array is copied to internal
- * storage so that subsequent updates to the array do not affect the sample
+ * storage so that subsequent updates to the array do not affect the sample
* model.
- * @param bandOffsets the offset to the first element for each band, with
+ * @param bandOffsets the offset to the first element for each band, with
* the size of the array defining the number of bands (<code>null</code>
- * not permitted). This array is copied to internal storage so that
+ * not permitted). This array is copied to internal storage so that
* subsequent updates to the array do not affect the sample model.
- *
+ *
* @throws IllegalArgumentException if <code>dataType</code> is not one of
* the specified values.
* @throws IllegalArgumentException if <code>w</code> is less than or equal
* to zero.
- * @throws IllegalArgumentException if <code>h</code> is less than or equal
+ * @throws IllegalArgumentException if <code>h</code> is less than or equal
* to zero.
* @throws IllegalArgumentException if <code>w * h</code> exceeds
* {@link Integer#MAX_VALUE}.
* @throws IllegalArgumentException if <code>pixelStride</code> is negative.
- * @throws IllegalArgumentException if <code>scanlineStride</code> is less
+ * @throws IllegalArgumentException if <code>scanlineStride</code> is less
* than or equal to zero.
- * @throws IllegalArgumentException if <code>bandOffsets</code> has zero
+ * @throws IllegalArgumentException if <code>bandOffsets</code> has zero
* length.
*/
public ComponentSampleModel(int dataType,
@@ -177,15 +177,15 @@ public class ComponentSampleModel extends SampleModel
int[] bandOffsets)
{
super(dataType, w, h, bandOffsets.length);
-
+
// super permits DataBuffer.TYPE_UNDEFINED but this class doesn't...
if (dataType == DataBuffer.TYPE_UNDEFINED)
throw new IllegalArgumentException("Unsupported dataType.");
-
- if ((pixelStride < 0) || (scanlineStride < 0) || (bandOffsets.length < 1)
+
+ if ((pixelStride < 0) || (scanlineStride < 0) || (bandOffsets.length < 1)
|| (bandOffsets.length != bankIndices.length))
throw new IllegalArgumentException();
-
+
this.bandOffsets = (int[]) bandOffsets.clone();
this.bankIndices = (int[]) bankIndices.clone();
this.numBands = bandOffsets.length;
@@ -197,15 +197,15 @@ public class ComponentSampleModel extends SampleModel
this.scanlineStride = scanlineStride;
this.pixelStride = pixelStride;
- }
+ }
/**
* Creates a new sample model that is compatible with this one, but with the
* specified dimensions.
- *
+ *
* @param w the width (must be greater than zero).
* @param h the height (must be greater than zero).
- *
+ *
* @return A new sample model.
*/
public SampleModel createCompatibleSampleModel(int w, int h)
@@ -218,15 +218,15 @@ public class ComponentSampleModel extends SampleModel
/**
* Creates a new sample model that provides access to a subset of the bands
* that this sample model supports.
- *
+ *
* @param bands the bands (<code>null</code> not permitted).
- *
+ *
* @return The new sample model.
*/
public SampleModel createSubsetSampleModel(int[] bands)
{
int numBands = bands.length;
-
+
int[] bankIndices = new int[numBands];
int[] bandOffsets = new int[numBands];
for (int b = 0; b < numBands; b++)
@@ -242,7 +242,7 @@ public class ComponentSampleModel extends SampleModel
/**
* Creates a new data buffer that is compatible with this sample model.
- *
+ *
* @return The new data buffer.
*/
public DataBuffer createDataBuffer()
@@ -250,8 +250,8 @@ public class ComponentSampleModel extends SampleModel
// Maybe this value should be precalculated in the constructor?
int highestOffset = 0;
for (int b = 0; b < numBands; b++)
- highestOffset = Math.max(highestOffset, bandOffsets[b]);
- int size = pixelStride * (width - 1) + scanlineStride * (height - 1)
+ highestOffset = Math.max(highestOffset, bandOffsets[b]);
+ int size = pixelStride * (width - 1) + scanlineStride * (height - 1)
+ highestOffset + 1;
DataBuffer buffer = null;
@@ -283,12 +283,12 @@ public class ComponentSampleModel extends SampleModel
* Returns the offset of the sample in band 0 for the pixel at location
* <code>(x, y)</code>. This offset can be used to read a sample value from
* a {@link DataBuffer}.
- *
+ *
* @param x the x-coordinate.
* @param y the y-coordinate.
- *
+ *
* @return The offset.
- *
+ *
* @see #getOffset(int, int, int)
*/
public int getOffset(int x, int y)
@@ -300,11 +300,11 @@ public class ComponentSampleModel extends SampleModel
* Returns the offset of the sample in band <code>b</code> for the pixel at
* location <code>(x, y)</code>. This offset can be used to read a sample
* value from a {@link DataBuffer}.
- *
+ *
* @param x the x-coordinate.
* @param y the y-coordinate.
* @param b the band index.
- *
+ *
* @return The offset.
*/
public int getOffset(int x, int y, int b)
@@ -316,9 +316,9 @@ public class ComponentSampleModel extends SampleModel
* Returns the size in bits for each sample (one per band). For this sample
* model, each band has the same sample size and this is determined by the
* data type for the sample model.
- *
+ *
* @return The sample sizes.
- *
+ *
* @see SampleModel#getDataType()
*/
public final int[] getSampleSize()
@@ -332,13 +332,13 @@ public class ComponentSampleModel extends SampleModel
/**
* Returns the size in bits for the samples in the specified band. In this
- * class, the sample size is the same for every band and is determined from
+ * class, the sample size is the same for every band and is determined from
* the data type for the model.
- *
+ *
* @param band the band index (ignored here).
- *
+ *
* @return The sample size in bits.
- *
+ *
* @see SampleModel#getDataType()
*/
public final int getSampleSize(int band)
@@ -347,10 +347,10 @@ public class ComponentSampleModel extends SampleModel
}
/**
- * Returns the indices of the bank(s) in the {@link DataBuffer} used to
+ * Returns the indices of the bank(s) in the {@link DataBuffer} used to
* store the samples for each band. The returned array is a copy, so that
* altering it will not impact the sample model.
- *
+ *
* @return The bank indices.
*/
public final int[] getBankIndices()
@@ -361,7 +361,7 @@ public class ComponentSampleModel extends SampleModel
/**
* Returns the offsets to the first sample in each band. The returned array
* is a copy, so that altering it will not impact the sample model.
- *
+ *
* @return The offsets.
*/
public final int[] getBandOffsets()
@@ -371,10 +371,10 @@ public class ComponentSampleModel extends SampleModel
/**
* Returns the distance (in terms of element indices) between the sample for
- * one pixel and the corresponding sample for the equivalent pixel in the
+ * one pixel and the corresponding sample for the equivalent pixel in the
* next row. This is used in the calculation of the element offset for
* retrieving samples from a {@link DataBuffer}.
- *
+ *
* @return The distance between pixel samples in consecutive rows.
*/
public final int getScanlineStride()
@@ -383,11 +383,11 @@ public class ComponentSampleModel extends SampleModel
}
/**
- * Returns the distance (in terms of element indices) between the sample for
- * one pixel and the corresponding sample for the next pixel in a row. This
- * is used in the calculation of the element offset for retrieving samples
+ * Returns the distance (in terms of element indices) between the sample for
+ * one pixel and the corresponding sample for the next pixel in a row. This
+ * is used in the calculation of the element offset for retrieving samples
* from a {@link DataBuffer}.
- *
+ *
* @return The distance between pixel samples in the same row.
*/
public final int getPixelStride()
@@ -396,10 +396,10 @@ public class ComponentSampleModel extends SampleModel
}
/**
- * Returns the number of data elements used to store the samples for one
+ * Returns the number of data elements used to store the samples for one
* pixel. In this model, this is the same as the number of bands.
- *
- * @return The number of data elements used to store the samples for one
+ *
+ * @return The number of data elements used to store the samples for one
* pixel.
*/
public final int getNumDataElements()
@@ -409,17 +409,17 @@ public class ComponentSampleModel extends SampleModel
/**
* Returns the samples for the pixel at location <code>(x, y)</code> in
- * a primitive array (the array type is determined by the data type for
+ * a primitive array (the array type is determined by the data type for
* this model). The <code>obj</code> argument provides an option to supply
* an existing array to hold the result, if this is <code>null</code> a new
* array will be allocated.
- *
+ *
* @param x the x-coordinate.
* @param y the y-coordinate.
- * @param obj a primitive array that, if not <code>null</code>, will be
+ * @param obj a primitive array that, if not <code>null</code>, will be
* used to store and return the sample values.
* @param data the data buffer (<code>null</code> not permitted).
- *
+ *
* @return An array of sample values for the specified pixel.
*/
public Object getDataElements(int x, int y, Object obj, DataBuffer data)
@@ -502,23 +502,23 @@ public class ComponentSampleModel extends SampleModel
/**
* Returns all the samples for the pixel at location <code>(x, y)</code>
* stored in the specified data buffer.
- *
+ *
* @param x the x-coordinate.
* @param y the y-coordinate.
* @param iArray an array that will be populated with the sample values and
- * returned as the result. The size of this array should be equal to the
+ * returned as the result. The size of this array should be equal to the
* number of bands in the model. If the array is <code>null</code>, a new
* array is created.
* @param data the data buffer (<code>null</code> not permitted).
- *
+ *
* @return The samples for the specified pixel.
- *
+ *
* @see #setPixel(int, int, int[], DataBuffer)
*/
public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
{
if (x < 0 || x >= width || y < 0 || y >= height)
- throw new ArrayIndexOutOfBoundsException("Pixel (" + x + ", " + y
+ throw new ArrayIndexOutOfBoundsException("Pixel (" + x + ", " + y
+ ") is out of bounds.");
int offset = pixelStride * x + scanlineStride * y;
if (iArray == null)
@@ -532,22 +532,22 @@ public class ComponentSampleModel extends SampleModel
/**
* Returns the samples for all the pixels in a rectangular region.
- *
+ *
* @param x the x-coordinate.
* @param y the y-coordinate.
* @param w the width.
* @param h the height.
- * @param iArray an array that if non-<code>null</code> will be populated
+ * @param iArray an array that if non-<code>null</code> will be populated
* with the sample values and returned as the result.
* @param data the data buffer (<code>null</code> not permitted).
- *
+ *
* @return The samples for all the pixels in the rectangle.
*/
public int[] getPixels(int x, int y, int w, int h, int[] iArray,
DataBuffer data)
{
int offset = pixelStride * x + scanlineStride * y;
- if (iArray == null)
+ if (iArray == null)
iArray = new int[numBands * w * h];
int outOffset = 0;
for (y = 0; y < h; y++)
@@ -557,7 +557,7 @@ public class ComponentSampleModel extends SampleModel
{
for (int b = 0; b < numBands; b++)
{
- iArray[outOffset++]
+ iArray[outOffset++]
= data.getElem(bankIndices[b], lineOffset+bandOffsets[b]);
}
lineOffset += pixelStride;
@@ -566,41 +566,41 @@ public class ComponentSampleModel extends SampleModel
}
return iArray;
}
-
+
/**
- * Returns the sample for band <code>b</code> of the pixel at
+ * Returns the sample for band <code>b</code> of the pixel at
* <code>(x, y)</code> that is stored in the specified data buffer.
- *
+ *
* @param x the x-coordinate.
* @param y the y-coordinate.
* @param b the band index.
* @param data the data buffer (<code>null</code> not permitted).
- *
+ *
* @return The sample value.
- *
- * @throws ArrayIndexOutOfBoundsException if <code>(x, y)</code> is outside
+ *
+ * @throws ArrayIndexOutOfBoundsException if <code>(x, y)</code> is outside
* the bounds <code>[0, 0, width, height]</code>.
- *
+ *
* @see #setSample(int, int, int, int, DataBuffer)
*/
public int getSample(int x, int y, int b, DataBuffer data)
{
if (x < 0 || x >= width || y < 0 || y >= height)
- throw new ArrayIndexOutOfBoundsException("Sample (" + x + ", " + y
+ throw new ArrayIndexOutOfBoundsException("Sample (" + x + ", " + y
+ ") is out of bounds.");
return data.getElem(bankIndices[b], getOffset(x, y, b));
}
/**
- * Sets the samples for the pixel at location <code>(x, y)</code> from the
- * supplied primitive array (the array type must be consistent with the data
+ * Sets the samples for the pixel at location <code>(x, y)</code> from the
+ * supplied primitive array (the array type must be consistent with the data
* type for this model).
- *
+ *
* @param x the x-coordinate.
* @param y the y-coordinate.
* @param obj a primitive array containing the pixel's sample values.
* @param data the data buffer (<code>null</code> not permitted).
- *
+ *
* @see #setDataElements(int, int, Object, DataBuffer)
*/
public void setDataElements(int x, int y, Object obj, DataBuffer data)
@@ -652,16 +652,16 @@ public class ComponentSampleModel extends SampleModel
break;
}
}
-
+
/**
* Sets the sample values for the pixel at location <code>(x, y)</code>
* stored in the specified data buffer.
- *
+ *
* @param x the x-coordinate.
* @param y the y-coordinate.
* @param iArray the pixel sample values (<code>null</code> not permitted).
* @param data the data buffer (<code>null</code> not permitted).
- *
+ *
* @see #getPixel(int, int, int[], DataBuffer)
*/
public void setPixel(int x, int y, int[] iArray, DataBuffer data)
@@ -670,24 +670,24 @@ public class ComponentSampleModel extends SampleModel
for (int b = 0; b < numBands; b++)
data.setElem(bankIndices[b], offset + bandOffsets[b], iArray[b]);
}
-
+
/**
* Sets the sample value for band <code>b</code> of the pixel at location
* <code>(x, y)</code> in the specified data buffer.
- *
+ *
* @param x the x-coordinate.
* @param y the y-coordinate.
* @param b the band index.
* @param s the sample value.
* @param data the data buffer (<code>null</code> not permitted).
- *
+ *
* @see #getSample(int, int, int, DataBuffer)
*/
public void setSample(int x, int y, int b, int s, DataBuffer data)
{
data.setElem(bankIndices[b], getOffset(x, y, b), s);
}
-
+
/**
* Tests this sample model for equality with an arbitrary object. Returns
* <code>true</code> if and only if:
@@ -700,10 +700,10 @@ public class ComponentSampleModel extends SampleModel
* <code>scanlineStride</code>, <code>bandOffsets</code> and
* <code>bankIndices</code> fields.</li>
* </ul>
- *
+ *
* @param obj the object to test (<code>null</code> permitted).
- *
- * @return <code>true</code> if this sample model is equal to
+ *
+ * @return <code>true</code> if this sample model is equal to
* <code>obj</code>, and <code>false</code> otherwise.
*/
public boolean equals(Object obj)
@@ -730,10 +730,10 @@ public class ComponentSampleModel extends SampleModel
// couldn't find any difference, so...
return true;
}
-
+
/**
* Returns a hash code for this sample model.
- *
+ *
* @return The hash code.
*/
public int hashCode()
OpenPOWER on IntegriCloud