Class LCHColorValue

All Implemented Interfaces:
CSSColorValue, CSSPrimitiveValue, CSSTypedValue, CSSValue, LCHColorValue, Serializable, Cloneable

public class LCHColorValue extends ColorValue implements LCHColorValue
LCh color value.
See Also:
  • Constructor Details

    • LCHColorValue

      public LCHColorValue()
  • Method Details

    • getColorModel

      public CSSColorValue.ColorModel getColorModel()
      Description copied from interface: CSSColorValue
      Get the color model with which this value was set.
      Specified by:
      getColorModel in interface CSSColorValue
      Returns:
      the color model.
    • getCssText

      public String getCssText()
      Description copied from class: StyleValue
      Get a string representation of the current value.
      Specified by:
      getCssText in interface CSSValue
      Overrides:
      getCssText in class ColorValue
      Returns:
      the css text representing the value of this property.
    • getMinifiedCssText

      public String getMinifiedCssText(String propertyValue)
      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 interface CSSValue
      Overrides:
      getMinifiedCssText in class ColorValue
      Parameters:
      propertyValue - the property name.
      Returns:
      the minified css text.
    • writeCssText

      public void writeCssText(io.sf.carte.util.SimpleWriter wri) throws IOException
      Description copied from interface: CSSValue
      Serialize this value to a SimpleWriter.
      Specified by:
      writeCssText in interface CSSValue
      Overrides:
      writeCssText in class ColorValue
      Parameters:
      wri - the SimpleWriter.
      Throws:
      IOException - if an error happened while writing.
    • getComponent

      public PrimitiveValue getComponent(int index)
      Description copied from class: ColorValue
      Get the color component at index.

      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).

      Specified by:
      getComponent in class ColorValue
      Parameters:
      index - the index. Index 0 is always the alpha channel.
      Returns:
      the color component, or null if the index is incorrect.
    • setComponent

      public void setComponent(int index, StyleValue component)
      Description copied from class: ColorValue
      Set the color component at index.

      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 class ColorValue
      Parameters:
      index - the index. For colors, index 0 is always the alpha channel. Setting a component at an index that does not exist has no effect.
      component - the new color component. Must be a primitive value (that is, either TYPED or a PROXY).
    • toRGBColor

      public RGBAColor toRGBColor() throws DOMException
      Description copied from interface: CSSTypedValue
      If this value represents a color, get it or transform to a RGB color.

      If the color does not map into the sRGB gamut, it is clamped.

      Specified by:
      toRGBColor in interface CSSTypedValue
      Overrides:
      toRGBColor in class TypedValue
      Returns:
      the RGBA color.
      Throws:
      DOMException - INVALID_ACCESS_ERR: if this value can't return a RGB color value (either is not a COLOR or not a typed value).
      NOT_SUPPORTED_ERR: if the conversion needs device color space information to be performed accurately.
    • toRGBColor

      public RGBAColor toRGBColor(boolean clamp) throws DOMException
      Description copied from interface: CSSColorValue
      Get the RGB(A) color representation of this value.

      The returned value is implicitly in the sRGB color space, unless stated otherwise.

      Specified by:
      toRGBColor in interface CSSColorValue
      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 a COLOR, not a typed value, or clamp 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.
    • toLABColorValue

      public LABColorValue toLABColorValue() throws DOMException
      Description copied from class: ColorValue
      Convert this value to a LABColorValue, if possible.
      Specified by:
      toLABColorValue in interface CSSColorValue
      Overrides:
      toLABColorValue in class ColorValue
      Returns:
      the converted LABColorValue.
      Throws:
      DOMException - INVALID_STATE_ERR if the components cannot be converted.
    • toLCHColorValue

      public LCHColorValue toLCHColorValue() throws DOMException
      Description copied from interface: CSSColorValue
      Convert this value to a LCHColorValue, if possible.
      Specified by:
      toLCHColorValue in interface CSSColorValue
      Overrides:
      toLCHColorValue in class ColorValue
      Returns:
      the converted LCHColorValue.
      Throws:
      DOMException - INVALID_STATE_ERR if the components cannot be converted.
    • getColor

      public LCHColor getColor()
      Description copied from interface: LCHColorValue
      Get the lch() or oklch() color represented by this value.
      Specified by:
      getColor in interface CSSColorValue
      Specified by:
      getColor in interface LCHColorValue
      Returns:
      the lch() or oklch() color.
    • deltaE2000

      public float deltaE2000(CSSColorValue color)
      Description copied from interface: CSSColorValue
      Compute the difference to the given color, according to CIE Delta E 2000.
      Specified by:
      deltaE2000 in interface CSSColorValue
      Overrides:
      deltaE2000 in class ColorValue
      Parameters:
      color - the color to compute the delta from.
      Returns:
      the CIE Delta E 2000.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class PrimitiveValue
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class PrimitiveValue
    • clone

      public LCHColorValue 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 interface CSSColorValue
      Specified by:
      clone in interface CSSValue
      Specified by:
      clone in interface LCHColorValue
      Specified by:
      clone in class ColorValue
      Returns:
      a copy of this object.