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 String
private static final double
private static final double
private static final double
private static final float
private static final float
private static final float
private static final float
private static final float
private static final float
private static final long
private static final double
private float
private float
private float
Fields 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 void
checkNumComponents
(float[] colorvalue) private void
checkNumComponents
(float[] colorvalue, int expected) private float
denormalize
(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.float
getMaxValue
(int component) float
getMinValue
(int component) getName
(int component) private float
getNativeValueRange
(int component) float[]
Returns the configured white point.private float
normalize
(float value, int component) float[]
toCIEXYZ
(float[] colorvalue) float[]
toCIEXYZNative
(float l, float a, float b) Transforms a color value assumed to be in thisColorSpace
into the CS_CIEXYZ conversion color space.toColor
(float[] colorvalue, float alpha) Creates aColor
instance 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 aColor
instance 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:
getMinValue
in classColorSpace
-
getMaxValue
public float getMaxValue(int component) - Overrides:
getMaxValue
in classColorSpace
-
getName
- Overrides:
getName
in classColorSpace
-
fromCIEXYZ
public float[] fromCIEXYZ(float[] colorvalue) - Specified by:
fromCIEXYZ
in classColorSpace
-
fromRGB
public float[] fromRGB(float[] rgbvalue) - Specified by:
fromRGB
in classColorSpace
-
toCIEXYZ
public float[] toCIEXYZ(float[] colorvalue) - Specified by:
toCIEXYZ
in classColorSpace
-
toCIEXYZNative
public float[] toCIEXYZNative(float l, float a, float b) Transforms a color value assumed to be in thisColorSpace
into 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:
toRGB
in 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 aColor
instance 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 aColor
instance 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
-