Book Home Java Enterprise in a Nutshell Search this book

Chapter 10. The java.awt.color Package

The java.awt.color package includes the abstract ColorSpace class, which defines methods necessary for converting colors between arbitrary color spaces. The package also contains implementations of the ColorSpace class based on data contained in ICC profile files. (The ICC is the international color standards body.) Most applications do not need to use this package; it is required only for applications that perform sophisticated image processing or require extremely accurate device-independent color display. Figure 10-1 shows the class hierarchy of this package, which is new in Java 1.2.

This package does not contain classes for representing colors. See the java.awt.Color class instead.

figure

Figure 10-1. The java.awt.color package

CMMExceptionJava 1.2
java.awt.colorserializable unchecked

Signals that an error has occurred in the internal color space management code.

public class CMMException extends RuntimeException {
// Public Constructors
public CMMException (String s);
}

Hierarchy: Object-->Throwable(Serializable)-->Exception-->RuntimeException-->CMMException

ColorSpaceJava 1.2
java.awt.color

This abstract class encapsulates a color space: a system of representing colors using some number of floating-point color components. For examples, sRGB is a proposed standard color space that represents colors in terms of red, green, and blue components, while CIEXYZ is an international standard color space that represents colors in terms of three color components named X, Y, and Z. Typically, only applications that are doing image processing or are concerned with very precise color reproduction need to use this class.

ColorSpace does not have a public constructor. You can obtain an instance by calling the static getInstance() method and passing in one of the CS_ constants to specify the type of color space you want. Alternatively, implement and instantiate your own concrete subclass. Each ColorSpace object has methods to convert a color to and from the standard sRGB and CIEXYZ color spaces. This ensures that any color, regardless of its color space, can be converted to the red, green, and blue values used by computer display devices. It also ensures that a color represented in an arbitrary color space can be transformed to any other color space by first converting to an intermediate CIEXYZ representation.

public abstract class ColorSpace {
// Protected Constructors
protected ColorSpace (int type, int numcomponents);
// Public Constants
public static final int CS_CIEXYZ ; =1001
public static final int CS_GRAY ; =1003
public static final int CS_LINEAR_RGB ; =1004
public static final int CS_PYCC ; =1002
public static final int CS_sRGB ; =1000
public static final int TYPE_2CLR ; =12
public static final int TYPE_3CLR ; =13
public static final int TYPE_4CLR ; =14
public static final int TYPE_5CLR ; =15
public static final int TYPE_6CLR ; =16
public static final int TYPE_7CLR ; =17
public static final int TYPE_8CLR ; =18
public static final int TYPE_9CLR ; =19
public static final int TYPE_ACLR ; =20
public static final int TYPE_BCLR ; =21
public static final int TYPE_CCLR ; =22
public static final int TYPE_CMY ; =11
public static final int TYPE_CMYK ; =9
public static final int TYPE_DCLR ; =23
public static final int TYPE_ECLR ; =24
public static final int TYPE_FCLR ; =25
public static final int TYPE_GRAY ; =6
public static final int TYPE_HLS ; =8
public static final int TYPE_HSV ; =7
public static final int TYPE_Lab ; =1
public static final int TYPE_Luv ; =2
public static final int TYPE_RGB ; =5
public static final int TYPE_XYZ ; =0
public static final int TYPE_YCbCr ; =3
public static final int TYPE_Yxy ; =4
// Public Class Methods
public static ColorSpace getInstance (int colorspace);
// Public Instance Methods
public abstract float[ ] fromCIEXYZ (float[ ] colorvalue);
public abstract float[ ] fromRGB (float[ ] rgbvalue);
public String getName (int idx);
public int getNumComponents ();
public int getType ();
public boolean isCS_sRGB ();
public abstract float[ ] toCIEXYZ (float[ ] colorvalue);
public abstract float[ ] toRGB (float[ ] colorvalue);
}

Subclasses: ICC_ColorSpace

Passed To: Color.{Color(), getColorComponents(), getComponents()}, java.awt.image.ColorConvertOp.ColorConvertOp(), java.awt.image.ColorModel.ColorModel(), java.awt.image.ComponentColorModel.ComponentColorModel(), java.awt.image.DirectColorModel.DirectColorModel(), java.awt.image.PackedColorModel.PackedColorModel()

Returned By: Color.getColorSpace(), ColorSpace.getInstance(), java.awt.image.ColorModel.getColorSpace()

ICC_ColorSpaceJava 1.2
java.awt.color

This concrete subclass of ColorSpace defines a color space based on an ICC_Profile object that represents color space profile data in a format defined by the International Color Consortium (ICC). See http://www.color.org for information about ICC standards.

public class ICC_ColorSpace extends ColorSpace {
// Public Constructors
public ICC_ColorSpace (ICC_Profile profile);
// Public Instance Methods
public ICC_Profile getProfile ();
// Public Methods Overriding ColorSpace
public float[ ] fromCIEXYZ (float[ ] colorvalue);
public float[ ] fromRGB (float[ ] rgbvalue);
public float[ ] toCIEXYZ (float[ ] colorvalue);
public float[ ] toRGB (float[ ] colorvalue);
}

Hierarchy: Object-->ColorSpace-->ICC_ColorSpace

ICC_ProfileJava 1.2
java.awt.color

This class represents an International Color Consortium (ICC) color space profile. For details about the profile format, see the ICC Profile Format Specification, Version 3.4, at http://www.color.org. Only applications working with custom or specialized color spaces ever need to use this class.

ICC_Profile does not have a public constructor. Obtain an instance by calling the static getInstance() method. There are versions of this method that read profile data from a java.io.InputStream, a string, and an array of bytes. The fourth version of this method takes one of the CS_ constants defined by the ColorSpace class and reads a built-in profile for that color space. (In Sun's Java 1.2 implementation, the profile data for these built-in standard color spaces is in the directory jre/lib/cmm.)

public class ICC_Profile {
// No Constructor
// Public Constants
public static final int CLASS_ABSTRACT ; =5
public static final int CLASS_COLORSPACECONVERSION ; =4
public static final int CLASS_DEVICELINK ; =3
public static final int CLASS_DISPLAY ; =1
public static final int CLASS_INPUT ; =0
public static final int CLASS_NAMEDCOLOR ; =6
public static final int CLASS_OUTPUT ; =2
public static final int icAbsoluteColorimetric ; =3
public static final int icCurveCount ; =8
public static final int icCurveData ; =12
public static final int icHdrAttributes ; =56
public static final int icHdrCmmId ; =4
public static final int icHdrColorSpace ; =16
public static final int icHdrCreator ; =80
public static final int icHdrDate ; =24
public static final int icHdrDeviceClass ; =12
public static final int icHdrFlags ; =44
public static final int icHdrIlluminant ; =68
public static final int icHdrMagic ; =36
public static final int icHdrManufacturer ; =48
public static final int icHdrModel ; =52
public static final int icHdrPcs ; =20
public static final int icHdrPlatform ; =40
public static final int icHdrRenderingIntent ; =64
public static final int icHdrSize ; =0
public static final int icHdrVersion ; =8
public static final int icPerceptual ; =0
public static final int icRelativeColorimetric ; =1
public static final int icSaturation ; =2
public static final int icSigAbstractClass ; =1633842036
public static final int icSigAToB0Tag ; =1093812784
public static final int icSigAToB1Tag ; =1093812785
public static final int icSigAToB2Tag ; =1093812786
public static final int icSigBlueColorantTag ; =1649957210
public static final int icSigBlueTRCTag ; =1649693251
public static final int icSigBToA0Tag ; =1110589744
public static final int icSigBToA1Tag ; =1110589745
public static final int icSigBToA2Tag ; =1110589746
public static final int icSigCalibrationDateTimeTag ; =1667329140
public static final int icSigCharTargetTag ; =1952543335
public static final int icSigCmyData ; =1129142560
public static final int icSigCmykData ; =1129142603
public static final int icSigColorSpaceClass ; =1936744803
public static final int icSigCopyrightTag ; =1668313716
public static final int icSigDeviceMfgDescTag ; =1684893284
public static final int icSigDeviceModelDescTag ; =1684890724
public static final int icSigDisplayClass ; =1835955314
public static final int icSigGamutTag ; =1734438260
public static final int icSigGrayData ; =1196573017
public static final int icSigGrayTRCTag ; =1800688195
public static final int icSigGreenColorantTag ; =1733843290
public static final int icSigGreenTRCTag ; =1733579331
public static final int icSigHead ; =1751474532
public static final int icSigHlsData ; =1212961568
public static final int icSigHsvData ; =1213421088
public static final int icSigInputClass ; =1935896178
public static final int icSigLabData ; =1281450528
public static final int icSigLinkClass ; =1818848875
public static final int icSigLuminanceTag ; =1819635049
public static final int icSigLuvData ; =1282766368
public static final int icSigMeasurementTag ; =1835360627
public static final int icSigMediaBlackPointTag ; =1651208308
public static final int icSigMediaWhitePointTag ; =2004119668
public static final int icSigNamedColor2Tag ; =1852009522
public static final int icSigNamedColorClass ; =1852662636
public static final int icSigOutputClass ; =1886549106
public static final int icSigPreview0Tag ; =1886545200
public static final int icSigPreview1Tag ; =1886545201
public static final int icSigPreview2Tag ; =1886545202
public static final int icSigProfileDescriptionTag ; =1684370275
public static final int icSigProfileSequenceDescTag ; =1886610801
public static final int icSigPs2CRD0Tag ; =1886610480
public static final int icSigPs2CRD1Tag ; =1886610481
public static final int icSigPs2CRD2Tag ; =1886610482
public static final int icSigPs2CRD3Tag ; =1886610483
public static final int icSigPs2CSATag ; =1886597747
public static final int icSigPs2RenderingIntentTag ; =1886597737
public static final int icSigRedColorantTag ; =1918392666
public static final int icSigRedTRCTag ; =1918128707
public static final int icSigRgbData ; =1380401696
public static final int icSigScreeningDescTag ; =1935897188
public static final int icSigScreeningTag ; =1935897198
public static final int icSigSpace2CLR ; =843271250
public static final int icSigSpace3CLR ; =860048466
public static final int icSigSpace4CLR ; =876825682
public static final int icSigSpace5CLR ; =893602898
public static final int icSigSpace6CLR ; =910380114
public static final int icSigSpace7CLR ; =927157330
public static final int icSigSpace8CLR ; =943934546
public static final int icSigSpace9CLR ; =960711762
public static final int icSigSpaceACLR ; =1094929490
public static final int icSigSpaceBCLR ; =1111706706
public static final int icSigSpaceCCLR ; =1128483922
public static final int icSigSpaceDCLR ; =1145261138
public static final int icSigSpaceECLR ; =1162038354
public static final int icSigSpaceFCLR ; =1178815570
public static final int icSigTechnologyTag ; =1952801640
public static final int icSigUcrBgTag ; =1650877472
public static final int icSigViewingCondDescTag ; =1987405156
public static final int icSigViewingConditionsTag ; =1986618743
public static final int icSigXYZData ; =1482250784
public static final int icSigYCbCrData ; =1497588338
public static final int icSigYxyData ; =1501067552
public static final int icTagReserved ; =4
public static final int icTagType ; =0
public static final int icXYZNumberX ; =8
// Public Class Methods
public static ICC_Profile getInstance (java.io.InputStream s) throws java.io.IOException;
public static ICC_Profile getInstance (String fileName) throws java.io.IOException;
public static ICC_Profile getInstance (byte[ ] data);
public static ICC_Profile getInstance (int cspace);
// Property Accessor Methods (by property name)
public int getColorSpaceType ();
public byte[ ] getData ();
public byte[ ] getData (int tagSignature);
public int getMajorVersion ();
public int getMinorVersion ();
public int getNumComponents ();
public int getPCSType ();
public int getProfileClass ();
// Public Instance Methods
public void setData (int tagSignature, byte[ ] tagData);
public void write (String fileName) throws java.io.IOException;
public void write (java.io.OutputStream s) throws java.io.IOException;
// Protected Methods Overriding Object
protected void finalize ();
}

Subclasses: ICC_ProfileGray, ICC_ProfileRGB

Passed To: ICC_ColorSpace.ICC_ColorSpace(), java.awt.image.ColorConvertOp.ColorConvertOp()

Returned By: ICC_ColorSpace.getProfile(), ICC_Profile.getInstance(), java.awt.image.ColorConvertOp.getICC_Profiles()

ICC_ProfileGrayJava 1.2
java.awt.color

A specialized subclass of ICC_Profile that is used to represent certain grayscale color spaces that meet criteria that allow color space conversions to be optimized. Applications never need to use this class.

public class ICC_ProfileGray extends ICC_Profile {
// No Constructor
// Public Instance Methods
public float getGamma ();
public short[ ] getTRC ();
// Public Methods Overriding ICC_Profile
public float[ ] getMediaWhitePoint ();
}

Hierarchy: Object-->ICC_Profile-->ICC_ProfileGray

ICC_ProfileRGBJava 1.2
java.awt.color

A specialized subclass of ICC_Profile that is used to represent certain RGB color spaces that meet criteria that allow color space conversions to be optimized. Applications never need to use this class.

public class ICC_ProfileRGB extends ICC_Profile {
// No Constructor
// Public Constants
public static final int BLUECOMPONENT ; =2
public static final int GREENCOMPONENT ; =1
public static final int REDCOMPONENT ; =0
// Public Instance Methods
public float[ ][ ] getMatrix ();
// Public Methods Overriding ICC_Profile
public float getGamma (int component);
public float[ ] getMediaWhitePoint ();
public short[ ] getTRC (int component);
}

Hierarchy: Object-->ICC_Profile-->ICC_ProfileRGB

ProfileDataExceptionJava 1.2
java.awt.colorserializable unchecked

Signals that an error occurred while reading ICC profile data.

public class ProfileDataException extends RuntimeException {
// Public Constructors
public ProfileDataException (String s);
}

Hierarchy: Object-->Throwable(Serializable)-->Exception-->RuntimeException-->ProfileDataException



Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.