Class CIELabColorSpace
java.lang.Object
java.awt.color.ColorSpace
org.apache.xmlgraphics.java2d.color.CIELabColorSpace
- All Implemented Interfaces:
Serializable
This class defines the CIE L*a*b* (CIE 1976) color space. Valid values for L* are between 0
and 100, for a* and b* between -127 and +127.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final doubleprivate static final doubleprivate static final doubleprivate static final floatprivate static final floatprivate static final floatprivate static final floatprivate static final floatprivate static final floatprivate static final longprivate static final doubleprivate floatprivate floatprivate floatFields inherited from class java.awt.color.ColorSpace
CS_CIEXYZ, CS_GRAY, CS_LINEAR_RGB, CS_PYCC, CS_sRGB, TYPE_2CLR, TYPE_3CLR, TYPE_4CLR, TYPE_5CLR, TYPE_6CLR, TYPE_7CLR, TYPE_8CLR, TYPE_9CLR, TYPE_ACLR, TYPE_BCLR, TYPE_CCLR, TYPE_CMY, TYPE_CMYK, TYPE_DCLR, TYPE_ECLR, TYPE_FCLR, TYPE_GRAY, TYPE_HLS, TYPE_HSV, TYPE_Lab, TYPE_Luv, TYPE_RGB, TYPE_XYZ, TYPE_YCbCr, TYPE_Yxy -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor using the D65 white point.CIELabColorSpace(float[] whitePoint) CIE Lab space constructor which allows to give an arbitrary white point. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckNumComponents(float[] colorvalue) private voidcheckNumComponents(float[] colorvalue, int expected) private floatdenormalize(float value, int component) float[]fromCIEXYZ(float[] colorvalue) float[]fromRGB(float[] rgbvalue) static float[]Returns the D50 white point.static float[]Returns the D65 white point.floatgetMaxValue(int component) floatgetMinValue(int component) getName(int component) private floatgetNativeValueRange(int component) float[]Returns the configured white point.private floatnormalize(float value, int component) float[]toCIEXYZ(float[] colorvalue) float[]toCIEXYZNative(float l, float a, float b) Transforms a color value assumed to be in thisColorSpaceinto the CS_CIEXYZ conversion color space.toColor(float[] colorvalue, float alpha) Creates aColorinstance from color values usually used by the L*a*b* color space by scaling them to the 0.0..1.0 range expected by Color's constructor.toColor(float l, float a, float b, float alpha) Creates aColorinstance from color values usually used by the L*a*b* color space by scaling them to the 0.0..1.0 range expected by Color's constructor.float[]toNativeComponents(float[] comps) Converts normalized (0..1) color components to CIE L*a*b*'s native value range.float[]toRGB(float[] colorvalue) Methods inherited from class java.awt.color.ColorSpace
getInstance, getNumComponents, getType, isCS_sRGB
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
REF_X_D65
private static final float REF_X_D65- See Also:
-
REF_Y_D65
private static final float REF_Y_D65- See Also:
-
REF_Z_D65
private static final float REF_Z_D65- See Also:
-
REF_X_D50
private static final float REF_X_D50- See Also:
-
REF_Y_D50
private static final float REF_Y_D50- See Also:
-
REF_Z_D50
private static final float REF_Z_D50- See Also:
-
D
private static final double D- See Also:
-
REF_A
private static final double REF_A -
REF_B
private static final double REF_B- See Also:
-
T0
private static final double T0 -
wpX
private float wpX -
wpY
private float wpY -
wpZ
private float wpZ -
CIE_LAB_ONLY_HAS_3_COMPONENTS
- See Also:
-
-
Constructor Details
-
CIELabColorSpace
public CIELabColorSpace()Default constructor using the D65 white point. -
CIELabColorSpace
public CIELabColorSpace(float[] whitePoint) CIE Lab space constructor which allows to give an arbitrary white point.- Parameters:
whitePoint- the white point in XYZ coordinates (valid values: 0.0f to 1.0f, although values slightly larger than 1.0f are common)
-
-
Method Details
-
getD65WhitePoint
public static float[] getD65WhitePoint()Returns the D65 white point.- Returns:
- the D65 white point.
-
getD50WhitePoint
public static float[] getD50WhitePoint()Returns the D50 white point.- Returns:
- the D50 white point.
-
checkNumComponents
private void checkNumComponents(float[] colorvalue) -
checkNumComponents
private void checkNumComponents(float[] colorvalue, int expected) -
getWhitePoint
public float[] getWhitePoint()Returns the configured white point.- Returns:
- the white point in CIE XYZ coordinates
-
getMinValue
public float getMinValue(int component) - Overrides:
getMinValuein classColorSpace
-
getMaxValue
public float getMaxValue(int component) - Overrides:
getMaxValuein classColorSpace
-
getName
- Overrides:
getNamein classColorSpace
-
fromCIEXYZ
public float[] fromCIEXYZ(float[] colorvalue) - Specified by:
fromCIEXYZin classColorSpace
-
fromRGB
public float[] fromRGB(float[] rgbvalue) - Specified by:
fromRGBin classColorSpace
-
toCIEXYZ
public float[] toCIEXYZ(float[] colorvalue) - Specified by:
toCIEXYZin classColorSpace
-
toCIEXYZNative
public float[] toCIEXYZNative(float l, float a, float b) Transforms a color value assumed to be in thisColorSpaceinto the CS_CIEXYZ conversion color space. This method uses component values in CIE Lab's native color ranges rather than the normalized values between 0 and 1.- Parameters:
l- the L* component (values between 0 and 100)a- the a* component (usually between -128 and +128)b- the b* component (usually between -128 and +128)- Returns:
- the XYZ color values
- See Also:
-
toRGB
public float[] toRGB(float[] colorvalue) - Specified by:
toRGBin classColorSpace
-
getNativeValueRange
private float getNativeValueRange(int component) -
normalize
private float normalize(float value, int component) -
denormalize
private float denormalize(float value, int component) -
toNativeComponents
public float[] toNativeComponents(float[] comps) Converts normalized (0..1) color components to CIE L*a*b*'s native value range.- Parameters:
comps- the normalized components.- Returns:
- the denormalized components
-
toColor
Creates aColorinstance from color values usually used by the L*a*b* color space by scaling them to the 0.0..1.0 range expected by Color's constructor.- Parameters:
colorvalue- the original color values (native value range, i.e. not normalized to 0.0..1.0)alpha- the alpha component- Returns:
- the requested color instance
-
toColor
Creates aColorinstance from color values usually used by the L*a*b* color space by scaling them to the 0.0..1.0 range expected by Color's constructor.- Parameters:
l- the L* component (values between 0 and 100)a- the a* component (usually between -128 and +127)b- the b* component (usually between -128 and +127)alpha- the alpha component (values between 0 and 1)- Returns:
- the requested color instance
-