Package io.sf.carte.doc.style.css
Interface CSSColorValue
- All Superinterfaces:
Cloneable
,CSSPrimitiveValue
,CSSTypedValue
,CSSValue
- All Known Subinterfaces:
HSLColorValue
,HWBColorValue
,LABColorValue
,LCHColorValue
,RGBColorValue
- All Known Implementing Classes:
ColorValue
,HSLColorValue
,HWBColorValue
,LABColorValue
,LCHColorValue
,RGBColorValue
Represents a color value (not including color identifiers).
When the value is a COLOR
, cast it to this
interface, obtain the color with getColor()
and cast it to the
appropriate sub-interface (like RGBAColor
or LABColor
)
according to the color model given by getColorModel()
.
For any color model, you can access the color components also through the
base CSSColor
interface, without the need to cast it to any
sub-interface (and there is no sub-interface for PROFILE
colors, so in that case you must use the base interface).
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Enumeration of color models.Nested classes/interfaces inherited from interface io.sf.carte.doc.style.css.CSSValue
CSSValue.CssType, CSSValue.Type
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Creates and returns a copy of this value.float
deltaE2000
(CSSColorValue color) Compute the difference to the given color, according to CIE Delta E 2000.getColor()
Get the color represented by this value.Get the color model with which this value was set.Convert this value to aLABColorValue
, if possible.Convert this value to aLCHColorValue
, if possible.default RGBAColor
toRGBColor
(boolean clamp) Get the RGB(A) color representation of this value.Methods inherited from interface io.sf.carte.doc.style.css.CSSPrimitiveValue
getUnitType, isNegativeNumber, setExpectInteger
Methods inherited from interface io.sf.carte.doc.style.css.CSSTypedValue
getFloatValue, getStringValue, isCalculatedNumber, isNumberZero, setFloatValue, setStringValue, toRGBColor, toRGBColorValue
Methods inherited from interface io.sf.carte.doc.style.css.CSSValue
getCssText, getCssValueType, getMinifiedCssText, getPrimitiveType, matches, setCssText, writeCssText
-
Method Details
-
getColor
CSSColor getColor()Get the color represented by this value.- Returns:
- the color.
-
getColorModel
CSSColorValue.ColorModel getColorModel()Get the color model with which this value was set.- Returns:
- the color model.
-
deltaE2000
Compute the difference to the given color, according to CIE Delta E 2000.- Parameters:
color
- the color to compute the delta from.- Returns:
- the CIE Delta E 2000.
-
toLABColorValue
Convert this value to aLABColorValue
, if possible.- Returns:
- the converted
LABColorValue
. - Throws:
DOMException
- INVALID_STATE_ERR if the components cannot be converted.
-
toLCHColorValue
Convert this value to aLCHColorValue
, if possible.- Returns:
- the converted
LCHColorValue
. - Throws:
DOMException
- INVALID_STATE_ERR if the components cannot be converted.
-
toRGBColor
Get the RGB(A) color representation of this value.The returned value is implicitly in the sRGB color space, unless stated otherwise.
- Parameters:
clamp
-true
if the converted value has to be clamped when it does not fall into the sRGB color gamut.- Returns:
- the RGBA color value.
- Throws:
DOMException
- INVALID_ACCESS_ERR: if this value can't return a RGB color value (either is not aCOLOR
, not a typed value, orclamp
is false and the color does not map into the -implicit- sRGB color space).
NOT_SUPPORTED_ERR: if the conversion needs device color space information to be performed accurately.
-
clone
CSSColorValue clone()Description copied from interface:CSSValue
Creates and returns a copy of this value.
-