Class Color

    • Field Detail

      • AQUA

        public static final Color AQUA
        The color aqua in sRGB space.
      • BLACK

        public static final Color BLACK
        The color black in sRGB space.
      • BLUE

        public static final Color BLUE
        The color blue in sRGB space.
      • FUCHSIA

        public static final Color FUCHSIA
        The color fuchsia in sRGB space.
      • GRAY

        public static final Color GRAY
        The color gray in sRGB space.
      • GREEN

        public static final Color GREEN
        The color green in sRGB space.
      • LIME

        public static final Color LIME
        The color lime in sRGB space.
      • MAROON

        public static final Color MAROON
        The color maroon in sRGB space.
      • NAVY

        public static final Color NAVY
        The color navy in sRGB space.
      • OLIVE

        public static final Color OLIVE
        The color olive in sRGB space.
      • ORANGE

        public static final Color ORANGE
        The color orange in sRGB space.
      • PURPLE

        public static final Color PURPLE
        The color purple in sRGB space.
      • RED

        public static final Color RED
        The color red in sRGB space.
      • SILVER

        public static final Color SILVER
        The color silver in sRGB space.
      • TEAL

        public static final Color TEAL
        The color teal in sRGB space.
      • WHITE

        public static final Color WHITE
        The color white in sRGB space.
      • YELLOW

        public static final Color YELLOW
        The color yellow in sRGB space.
    • Constructor Detail

      • Color

        public Color​(String color)
        Construct Color by the parsing the given string. The string should be observed sRGB color standard which starts with "#" and following with six numbers or three numbers in Hex format. For example, "#FFFFFF" is a valid argument and white color will be constructed.

        For further information on sRGB, see http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html .

        Parameters:
        color - represented using the 3 or 6 HEX sRGB notation.
        Throws:
        IllegalArgumentException - if the given argument is not a valid Color in sRGB HEX notation.
      • Color

        public Color​(int red,
                     int green,
                     int blue)
        Construct Color using the specified red, green and blue values in the range (0 - 255).
        Parameters:
        red - the red component.
        green - the green component.
        blue - the blue component.
        Throws:
        IllegalArgumentException - if red, green or blue are outside of the range 0 to 255, inclusive.
      • Color

        public Color​(float red,
                     float green,
                     float blue)
        Construct Color using the specified red, green, and blue values in the range (0.0 - 1.0).
        Parameters:
        red - the red component
        green - the green component
        blue - the blue component
        Throws:
        IllegalArgumentException - if red, green or blue are outside of the range 0.0 to 1.0, inclusive.
    • Method Detail

      • toString

        public String toString()
        Returns the Color in six HEX sRGB notation. format.
        Overrides:
        toString in class Object
        Returns:
        a six number hexadecimal string representation of the Color
      • valueOf

        public static Color valueOf​(String colorValue)
        Returns a Color instance representing the specified String value.
        Parameters:
        colorValue - a six (or three) number hexadecimal string representation of the Color
        Returns:
        return a Color instance representing stringValue.
        Throws:
        IllegalArgumentException - if the given argument is not a valid Color.
      • isValid

        public static boolean isValid​(String colorValue)
        Check if the specified String is a valid color data type.
        Parameters:
        colorValue - a six (or three) number hexadecimal string representation of the Color
        Returns:
        true if the value of argument is valid forcolor data type false otherwise.
      • toSixDigitHexRGB

        public static String toSixDigitHexRGB​(String colorValue)
        Convert RGB color formats to six-digit hex RGB format.

        The RGB mapping works as follows: rgb(110%, 0%, 0%)----clipped to rgb(100%,0%,0%), return #ff0000 maroon----one of the seventeen fixed labeled numbers, return #800000 #ff0000----six-digit notation #rrggbb, returns the input #f00----three-digit notation #rgb, return #ff0000 rgb(255,0,0)----integer range 0 - 255, return #ff0000 rgb(300,0,0)----clipped to rgb(255,0,0), return #ff0000 rgb(255,-10,0)----clipped to rgb(255,0,0), return #ff0000

        Parameters:
        colorValue - The sRGB color value to be converted.
        Returns:
        the converted color.
      • mapColorToAWTColor

        public static Color mapColorToAWTColor​(Color color)
        Map a Color data type to java.awt.Color.
        Parameters:
        color - The color data type to be mapped..
        Returns:
        the converted java.awt.Color instance.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object