java.lang.Object
io.sf.carte.doc.style.css.property.StyleValue
io.sf.carte.doc.style.css.property.PrimitiveValue
io.sf.carte.doc.style.css.property.TypedValue
io.sf.carte.doc.style.css.property.ColorValue
- All Implemented Interfaces:
CSSColorValue
,CSSPrimitiveValue
,CSSTypedValue
,CSSValue
,Serializable
,Cloneable
- Direct Known Subclasses:
HSLColorValue
,HWBColorValue
,LABColorValue
,LCHColorValue
,RGBColorValue
Color value.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.sf.carte.doc.style.css.CSSColorValue
CSSColorValue.ColorModel
Nested classes/interfaces inherited from interface io.sf.carte.doc.style.css.CSSValue
CSSValue.CssType, CSSValue.Type
-
Method Summary
Modifier and TypeMethodDescriptionabstract ColorValue
clone()
Creates and returns a copy of this object.float
deltaE2000
(CSSColorValue color) Compute the difference to the given color, according to CIE Delta E 2000.abstract PrimitiveValue
getComponent
(int index) Get the color component atindex
.int
Get the number of components of this value.Get a string representation of the current value.getMinifiedCssText
(String propertyName) Gives a minified version of the css text of the property.boolean
Is this value a wildcard for a system-dependent default?void
setComponent
(int index, StyleValue component) If this value has components, set the component atindex
.void
setCssText
(String cssText) Attempts to change this value to match the supplied css text.void
Convert this value to aHSLColorValue
, if possible.Convert this value to aLABColorValue
, if possible.Convert this value to aLCHColorValue
, if possible.void
writeCssText
(SimpleWriter wri) Serialize this value to aSimpleWriter
.Methods inherited from class io.sf.carte.doc.style.css.property.TypedValue
getCssValueType, getFloatValue, getStringValue, isCalculatedNumber, isNumberZero, setFloatValue, setStringValue, toRGBColor
Methods inherited from class io.sf.carte.doc.style.css.property.PrimitiveValue
equals, getPrimitiveType, hashCode, isPrimitiveValue, isSubproperty, setExpectInteger, setSubproperty
Methods inherited from class io.sf.carte.doc.style.css.property.StyleValue
matches, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.sf.carte.doc.style.css.CSSColorValue
getColor, getColorModel, toRGBColor
Methods inherited from interface io.sf.carte.doc.style.css.CSSPrimitiveValue
getUnitType, isNegativeNumber, isPrimitiveValue, 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
getCssValueType, getMinifiedCssText, getPrimitiveType, matches
-
Method Details
-
setSystemDefault
public void setSystemDefault() -
isSystemDefault
public boolean isSystemDefault()Description copied from class:StyleValue
Is this value a wildcard for a system-dependent default?If that is the case, it cannot be used to compute values.
- Overrides:
isSystemDefault
in classStyleValue
- Returns:
true
if this is a placeholder for a system-dependent default,false
otherwise.
-
setCssText
Description copied from class:StyleValue
Attempts to change this value to match the supplied css text.In css4j, it is not recommended to set property values using this method.
- Specified by:
setCssText
in interfaceCSSValue
- Overrides:
setCssText
in classStyleValue
- Parameters:
cssText
- the text value.- Throws:
DOMException
- SYNTAX_ERR: Raised if the specified CSS string value has a syntax error (according to the attached property) or is unparsable.
INVALID_MODIFICATION_ERR: Raised if the specified CSS string value represents a different type of values than the values allowed by the CSS property.
NO_MODIFICATION_ALLOWED_ERR: Raised if this value is read-only.
-
getCssText
Description copied from class:StyleValue
Get a string representation of the current value.- Specified by:
getCssText
in interfaceCSSValue
- Specified by:
getCssText
in classStyleValue
- Returns:
- the css text representing the value of this property.
-
getMinifiedCssText
Description copied from interface:CSSValue
Gives a minified version of the css text of the property.It may be customized for the given property name.
- Specified by:
getMinifiedCssText
in interfaceCSSValue
- Overrides:
getMinifiedCssText
in classStyleValue
- Parameters:
propertyName
- the property name.- Returns:
- the minified css text.
-
writeCssText
Description copied from interface:CSSValue
Serialize this value to aSimpleWriter
.- Specified by:
writeCssText
in interfaceCSSValue
- Parameters:
wri
- the SimpleWriter.- Throws:
IOException
- if an error happened while writing.
-
deltaE2000
Description copied from interface:CSSColorValue
Compute the difference to the given color, according to CIE Delta E 2000.- Specified by:
deltaE2000
in interfaceCSSColorValue
- Parameters:
color
- the color to compute the delta from.- Returns:
- the CIE Delta E 2000.
-
setComponent
Description copied from class:TypedValue
If this value has components, set the component atindex
.This method allows to access the components regardless of them being formally indexed or not. It is convenient to perform common tasks at the components (like when computing values).
- Overrides:
setComponent
in classTypedValue
- Parameters:
index
- the index. For colors, index0
is always the alpha channel. Setting a component at an index that does not exist has no effect.component
- the new component. Cannot be aKEYWORD
nor aSHORTHAND
. For colors, must be a primitive value (that is, eitherTYPED
or aPROXY
).
-
getComponent
Get the color component atindex
.This method allows to access the color components like if they were indexed. It is convenient to perform common tasks at the components (like when computing values).
- Overrides:
getComponent
in classTypedValue
- Parameters:
index
- the index. Index0
is always the alpha channel.- Returns:
- the color component, or
null
if the index is incorrect.
-
getComponentCount
public int getComponentCount()Description copied from class:TypedValue
Get the number of components of this value.- Overrides:
getComponentCount
in classTypedValue
- Returns:
- the number of components,
0
if none.
-
clone
Description copied from class:TypedValue
Creates and returns a copy of this object.The object will be the same except for the
subproperty
flag, that will be disabled in the clone object.- Specified by:
clone
in interfaceCSSColorValue
- Specified by:
clone
in interfaceCSSTypedValue
- Specified by:
clone
in interfaceCSSValue
- Specified by:
clone
in classTypedValue
- Returns:
- a copy of this object.
-
toHSLColorValue
Convert this value to aHSLColorValue
, if possible.- Returns:
- the converted
HSLColorValue
. - Throws:
DOMException
- INVALID_STATE_ERR if the components cannot be converted.
-
toLABColorValue
Convert this value to aLABColorValue
, if possible.- Specified by:
toLABColorValue
in interfaceCSSColorValue
- Returns:
- the converted
LABColorValue
. - Throws:
DOMException
- INVALID_STATE_ERR if the components cannot be converted.
-
toLCHColorValue
Description copied from interface:CSSColorValue
Convert this value to aLCHColorValue
, if possible.- Specified by:
toLCHColorValue
in interfaceCSSColorValue
- Returns:
- the converted
LCHColorValue
. - Throws:
DOMException
- INVALID_STATE_ERR if the components cannot be converted.
-