Methods Summary |
---|
public java.awt.image.ColorModel | coerceData(java.awt.image.WritableRaster raster, boolean isAlphaPremultiplied)Creates a new color model by coercing the data in the writable raster in
accordance with the alpha strategy of this color model.
throw new UnsupportedOperationException("This method is not " + //$NON-NLS-1$
"supported by this ColorModel"); //$NON-NLS-1$
|
private int | constructPixel(java.lang.Object obj)Construct pixel.
int pixel = 0;
switch (getTransferType()) {
case DataBuffer.TYPE_BYTE:
byte[] bPixel = (byte[])obj;
if (bPixel.length > 1) {
// awt.275=This pixel representation is not suuported by tis
// Color Model
throw new UnsupportedOperationException(Messages.getString("awt.275")); //$NON-NLS-1$
}
pixel = bPixel[0] & 0xff;
break;
case DataBuffer.TYPE_USHORT:
short[] sPixel = (short[])obj;
if (sPixel.length > 1) {
// awt.275=This pixel representation is not suuported by tis
// Color Model
throw new UnsupportedOperationException(Messages.getString("awt.275")); //$NON-NLS-1$
}
pixel = sPixel[0] & 0xffff;
break;
case DataBuffer.TYPE_INT:
int[] iPixel = (int[])obj;
if (iPixel.length > 1) {
// awt.275=This pixel representation is not suuported by tis
// Color Model
throw new UnsupportedOperationException(Messages.getString("awt.275")); //$NON-NLS-1$
}
pixel = iPixel[0];
break;
default:
// awt.22D=This transferType ( {0} ) is not supported by this
// color model
throw new UnsupportedOperationException(Messages.getString("awt.22D", //$NON-NLS-1$
transferType));
}
return pixel;
|
public java.awt.image.SampleModel | createCompatibleSampleModel(int w, int h)Creates the compatible sample model.
throw new UnsupportedOperationException("This method is not " + //$NON-NLS-1$
"supported by this ColorModel"); //$NON-NLS-1$
|
public java.awt.image.WritableRaster | createCompatibleWritableRaster(int w, int h)Creates a compatible writable raster.
throw new UnsupportedOperationException("This method is not " + //$NON-NLS-1$
"supported by this ColorModel"); //$NON-NLS-1$
|
public boolean | equals(java.lang.Object obj)
if (!(obj instanceof ColorModel)) {
return false;
}
ColorModel cm = (ColorModel)obj;
return (pixel_bits == cm.getPixelSize() && transferType == cm.getTransferType()
&& cs.getType() == cm.getColorSpace().getType() && hasAlpha == cm.hasAlpha()
&& isAlphaPremultiplied == cm.isAlphaPremultiplied()
&& transparency == cm.getTransparency()
&& numColorComponents == cm.getNumColorComponents()
&& numComponents == cm.getNumComponents() && Arrays.equals(bits, cm
.getComponentSize()));
|
public void | finalize()
// This method is added for the API compatibility
// Don't need to call super since Object's finalize is always empty
|
public int | getAlpha(java.lang.Object inData)Gets the alpha component of the pixel defined by the data array.
return getAlpha(constructPixel(inData));
|
public abstract int | getAlpha(int pixel)Gets the alpha component of the pixel determined by the pixel data.
|
public java.awt.image.WritableRaster | getAlphaRaster(java.awt.image.WritableRaster raster)Gets the child raster corresponding to the alpha channel of the specified
writable raster, or null if alpha is not supported.
return null;
|
public int | getBlue(java.lang.Object inData)Gets the blue component of the pixel defined by the data array.
return getBlue(constructPixel(inData));
|
public abstract int | getBlue(int pixel)Gets the blue component of the pixel determined by the pixel data.
|
public final java.awt.color.ColorSpace | getColorSpace()Gets the color space of this color model.
return cs;
|
public int | getComponentSize(int componentIdx)Gets the size of the desired component of this color model.
if (bits == null) {
// awt.26C=bits is null
throw new NullPointerException(Messages.getString("awt.26C")); //$NON-NLS-1$
}
if (componentIdx < 0 || componentIdx >= bits.length) {
// awt.274=componentIdx is greater than the number of components or
// less than zero
throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.274")); //$NON-NLS-1$
}
return bits[componentIdx];
|
public int[] | getComponentSize()Gets the array of sizes of the different components.
if (bits != null) {
return bits.clone();
}
return null;
|
public int[] | getComponents(int pixel, int[] components, int offset)Takes a pixel whose data is defined by an integer, and writes the
corresponding components into the components array, starting from the
index offset.
throw new UnsupportedOperationException("This method is not " + //$NON-NLS-1$
"supported by this ColorModel"); //$NON-NLS-1$
|
public int[] | getComponents(java.lang.Object pixel, int[] components, int offset)Gets the components of the pixel determined by the data array.
throw new UnsupportedOperationException("This method is not " + //$NON-NLS-1$
"supported by this ColorModel"); //$NON-NLS-1$
|
public int | getDataElement(int[] components, int offset)Gets the data element corresponding to the unnormalized components.
throw new UnsupportedOperationException("This method is not " + //$NON-NLS-1$
"supported by this ColorModel"); //$NON-NLS-1$
|
public int | getDataElement(float[] normComponents, int normOffset)Gets the data element corresponding to the normalized components.
int unnormComponents[] = getUnnormalizedComponents(normComponents, normOffset, null, 0);
return getDataElement(unnormComponents, 0);
|
public java.lang.Object | getDataElements(int[] components, int offset, java.lang.Object obj)Gets the data elements from the specified component array, transforming
them according to rules of the color model.
throw new UnsupportedOperationException("This method is not " + //$NON-NLS-1$
"supported by this ColorModel"); //$NON-NLS-1$
|
public java.lang.Object | getDataElements(float[] normComponents, int normOffset, java.lang.Object obj)Gets the data elements from the specified array of normalized components.
int unnormComponents[] = getUnnormalizedComponents(normComponents, normOffset, null, 0);
return getDataElements(unnormComponents, 0, obj);
|
public java.lang.Object | getDataElements(int rgb, java.lang.Object pixel)Gets the data elements corresponding to the pixel determined by the RGB
data.
throw new UnsupportedOperationException("This method is not " + //$NON-NLS-1$
"supported by this ColorModel"); //$NON-NLS-1$
|
public int | getGreen(java.lang.Object inData)Gets the green component of the pixel defined by the data array.
return getGreen(constructPixel(inData));
|
public abstract int | getGreen(int pixel)Gets the green component of the pixel determined by the pixel data.
|
public float[] | getNormalizedComponents(java.lang.Object pixel, float[] normComponents, int normOffset)Gets the normalized components of the pixel determined by the data array.
if (pixel == null) {
// awt.294=pixel is null
throw new NullPointerException(Messages.getString("awt.294")); //$NON-NLS-1$
}
int unnormComponents[] = getComponents(pixel, null, 0);
return getNormalizedComponents(unnormComponents, 0, normComponents, normOffset);
|
public float[] | getNormalizedComponents(int[] components, int offset, float[] normComponents, int normOffset)Gets the normalized components corresponding to the specified
unnormalized components.
if (bits == null) {
// awt.26C=bits is null
throw new UnsupportedOperationException(Messages.getString("awt.26C")); //$NON-NLS-1$
}
if (normComponents == null) {
normComponents = new float[numComponents + normOffset];
}
if (hasAlpha && isAlphaPremultiplied) {
float normAlpha = (float)components[offset + numColorComponents]
/ maxValues[numColorComponents];
if (normAlpha != 0.0f) {
for (int i = 0; i < numColorComponents; i++) {
normComponents[normOffset + i] = components[offset + i]
/ (normAlpha * maxValues[i]);
}
normComponents[normOffset + numColorComponents] = normAlpha;
} else {
for (int i = 0; i < numComponents; i++) {
normComponents[normOffset + i] = 0.0f;
}
}
} else {
for (int i = 0; i < numComponents; i++) {
normComponents[normOffset + i] = (float)components[offset + i] / maxValues[i];
}
}
return normComponents;
|
public int | getNumColorComponents()Gets the number of color components of this color model.
return numColorComponents;
|
public int | getNumComponents()Gets the number of components of this color model.
return numComponents;
|
public int | getPixelSize()Gets the pixel size in bits.
return pixel_bits;
|
public int | getRGB(java.lang.Object inData)Gets the RGB integer value corresponding to the pixel defined by the data
array.
return (getAlpha(inData) << 24 | getRed(inData) << 16 | getGreen(inData) << 8 | getBlue(inData));
|
public int | getRGB(int pixel)Takes the pixel data and returns the integer value corresponding to the
pixel's color in RGB format.
return (getAlpha(pixel) << 24 | getRed(pixel) << 16 | getGreen(pixel) << 8 | getBlue(pixel));
|
public static java.awt.image.ColorModel | getRGBdefault()Gets the default RGB color model.
if (RGBdefault == null) {
RGBdefault = new DirectColorModel(32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
}
return RGBdefault;
|
public int | getRed(java.lang.Object inData)Gets the red component of the pixel determined by the data array.
return getRed(constructPixel(inData));
|
public abstract int | getRed(int pixel)Gets the red component of the pixel determined by the pixel data.
|
public final int | getTransferType()Gets the transfer type, which is the type of Java primitive value that
corresponds to the bit length per pixel: either
{@link DataBuffer#TYPE_BYTE}, {@link DataBuffer#TYPE_USHORT},
{@link DataBuffer#TYPE_INT}, or {@link DataBuffer#TYPE_UNDEFINED}.
return transferType;
|
static int | getTransferType(int bits)Gets the transfer type, which is the type of Java primitive value that
corresponds to the bit length per pixel: either
{@link DataBuffer#TYPE_BYTE}, {@link DataBuffer#TYPE_USHORT},
{@link DataBuffer#TYPE_INT}, or {@link DataBuffer#TYPE_UNDEFINED}.
if (bits <= 8) {
return DataBuffer.TYPE_BYTE;
} else if (bits <= 16) {
return DataBuffer.TYPE_USHORT;
} else if (bits <= 32) {
return DataBuffer.TYPE_INT;
} else {
return DataBuffer.TYPE_UNDEFINED;
}
|
public int | getTransparency()
return transparency;
|
public int[] | getUnnormalizedComponents(float[] normComponents, int normOffset, int[] components, int offset)Gets the unnormalized components corresponding to the specified
normalized components.
if (bits == null) {
// awt.26C=bits is null
throw new UnsupportedOperationException(Messages.getString("awt.26C")); //$NON-NLS-1$
}
if (normComponents.length - normOffset < numComponents) {
// awt.273=The length of normComponents minus normOffset is less
// than numComponents
throw new IllegalArgumentException(Messages.getString("awt.273")); //$NON-NLS-1$
}
if (components == null) {
components = new int[numComponents + offset];
} else {
if (components.length - offset < numComponents) {
// awt.272=The length of components minus offset is less than
// numComponents
throw new IllegalArgumentException(Messages.getString("awt.272")); //$NON-NLS-1$
}
}
if (hasAlpha && isAlphaPremultiplied) {
float alpha = normComponents[normOffset + numColorComponents];
for (int i = 0; i < numColorComponents; i++) {
components[offset + i] = (int)(normComponents[normOffset + i] * maxValues[i]
* alpha + 0.5f);
}
components[offset + numColorComponents] = (int)(normComponents[normOffset
+ numColorComponents]
* maxValues[numColorComponents] + 0.5f);
} else {
for (int i = 0; i < numComponents; i++) {
components[offset + i] = (int)(normComponents[normOffset + i] * maxValues[i] + 0.5f);
}
}
return components;
|
public final boolean | hasAlpha()Checks whether this color model supports alpha.
return hasAlpha;
|
public int | hashCode()
int hash = 0;
int tmp;
if (hasAlpha) {
hash ^= 1;
hash <<= 8;
}
if (isAlphaPremultiplied) {
hash ^= 1;
hash <<= 8;
}
tmp = hash >>> 24;
hash ^= numColorComponents;
hash <<= 8;
hash |= tmp;
tmp = hash >>> 24;
hash ^= transparency;
hash <<= 8;
hash |= tmp;
tmp = hash >>> 24;
hash ^= cs.getType();
hash <<= 8;
hash |= tmp;
tmp = hash >>> 24;
hash ^= pixel_bits;
hash <<= 8;
hash |= tmp;
tmp = hash >>> 24;
hash ^= transferType;
hash <<= 8;
hash |= tmp;
if (bits != null) {
for (int element : bits) {
tmp = hash >>> 24;
hash ^= element;
hash <<= 8;
hash |= tmp;
}
}
return hash;
|
public final boolean | isAlphaPremultiplied()Checks if the alpha component is pre-multiplied.
return isAlphaPremultiplied;
|
public boolean | isCompatibleRaster(java.awt.image.Raster raster)Checks if the specified raster is compatible with this color model.
throw new UnsupportedOperationException("This method is not " + //$NON-NLS-1$
"supported by this ColorModel"); //$NON-NLS-1$
|
public boolean | isCompatibleSampleModel(java.awt.image.SampleModel sm)Checks if the sample model is compatible with this color model.
throw new UnsupportedOperationException("This method is not " + //$NON-NLS-1$
"supported by this ColorModel"); //$NON-NLS-1$
|
public java.lang.String | toString()
// The output format based on 1.5 release behavior.
// It could be reveled such way:
// ColorModel cm = new
// ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB,
// false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
// System.out.println(cm.toString());
return "ColorModel: Color Space = " + cs.toString() + "; has alpha = " //$NON-NLS-1$ //$NON-NLS-2$
+ hasAlpha + "; is alpha premultipied = " //$NON-NLS-1$
+ isAlphaPremultiplied + "; transparency = " + transparency //$NON-NLS-1$
+ "; number color components = " + numColorComponents //$NON-NLS-1$
+ "; pixel bits = " + pixel_bits + "; transfer type = " //$NON-NLS-1$ //$NON-NLS-2$
+ transferType;
|