Class AbstractModeledColor<C extends java.lang.Enum<C> & ModeledColor.Component>

    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractModeledColor​(double... values)
      Constructs a color with the given components.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected static double checkComponentValue​(double value)
      Checks the range of a given color component.
      boolean equals​(java.lang.Object object)
      long getAbsoluteComponent​(C component, int bitDepth)
      Determines the absolute value of the given color component with the given bit depth.
      double getComponent​(C component)
      Determines the value of the given color component.
      double[] getValues()  
      int hashCode()  
      static Color valueOf​(java.lang.CharSequence charSequence)
      Creates a color from a string representation.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractModeledColor

        public AbstractModeledColor​(double... values)
        Constructs a color with the given components.
        Parameters:
        values - The values of components of the color in the correct color space, each within the range (0.0-1.0), in the order of the component ordinals.
        Throws:
        java.lang.NullPointerException - if the components is null. TODO fix @throws IllegalArgumentException if the number of component values do not equal the number of components.
    • Method Detail

      • getValues

        public double[] getValues()
        Returns:
        The color component values, each within the range (0.0-1.0).
      • checkComponentValue

        protected static double checkComponentValue​(double value)
        Checks the range of a given color component.
        Parameters:
        value - The value to check.
        Returns:
        The checked value.
        Throws:
        java.lang.IllegalArgumentException - if the given component is outside the range (0.0-1.0).
      • getComponent

        public double getComponent​(C component)
        Description copied from interface: ModeledColor
        Determines the value of the given color component.
        Specified by:
        getComponent in interface ModeledColor<C extends java.lang.Enum<C> & ModeledColor.Component>
        Parameters:
        component - The color component for which a value should be retrieved.
        Returns:
        The value of the requested color component.
      • getAbsoluteComponent

        public long getAbsoluteComponent​(C component,
                                         int bitDepth)
        Description copied from interface: ModeledColor
        Determines the absolute value of the given color component with the given bit depth. For example, retrieving a component with value 0.5 and a bit depth of 16 would produce 128 or 0x80.
        Specified by:
        getAbsoluteComponent in interface ModeledColor<C extends java.lang.Enum<C> & ModeledColor.Component>
        Parameters:
        component - The color component for which a value should be retrieved.
        bitDepth - The number of bits to use for the given color component.
        Returns:
        The absolute value of the requested color component at the given bit depth.
        See Also:
        ModeledColor.getComponent(Enum)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object object)

        This implementation returns whether the objects are of the same class with identical color component values.

        Overrides:
        equals in class java.lang.Object
      • valueOf

        public static Color valueOf​(java.lang.CharSequence charSequence)
        Creates a color from a string representation. This representation can be in one of the following forms:
        • colorname, one of the HTML color names, which must be in all lowercase without delimiters, such as "aliceblue".
        • #rgb, with hexadecimal representation of RGB color components without regard to case.
        • #rrggbb, with hexadecimal representation of RGB color components without regard to case.
        • rgb(red,green,blue), with decimal representation with a depth of eight bits (0-255).
        • rgb(red%,green%,blue%), with decimal component values multiplied by 100 (0.0-100.0%).
        • rgba(red,green,blue,alpha), with decimal representation with a depth of eight bits (0-255).
        • rgba(red%,green%,blue%,alpha%), with decimal component values multiplied by 100 (0.0%-100.0%).
        • hsl(hue,saturation,lightness), with decimal representation with a depth of eight bits (0-255).
        • hsl(hue%,saturation%,lightness%), with decimal component values multiplied by 100 (0.0-100.0%).
        This method also recognizes the transparent color name as equivalent to rgba(0, 0, 0, 0), or black with zero alpha.
        Parameters:
        charSequence - The character sequence representation of a color.
        Returns:
        A color object representing the color represented by the given string.
        Throws:
        java.lang.NullPointerException - if the given string is null.
        java.lang.IllegalArgumentException - if a color cannot be determined from the given string.
        See Also:
        HSLColor.valueOf(CharSequence), RGBColor.valueOf(CharSequence)