Class WebColors

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,​int[]>

    public class WebColors
    extends java.util.HashMap<java.lang.String,​int[]>
    This class is a HashMap that contains the names of colors as a key and the corresponding RGB color as value. (Source: Wikipedia http://en.wikipedia.org/wiki/Web_colors )
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static WebColors NAMES
      HashMap containing all the names and corresponding color values.
      private static double RGB_MAX_VAL  
      private static long serialVersionUID  
    • Constructor Summary

      Constructors 
      Constructor Description
      WebColors()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static float getAlphaChannelValue​(java.lang.String rgbChannel)  
      static float[] getCMYKArray​(java.lang.String name)
      Gives an array of five floats that contain CMYK values and opacity, each value is between 0 and 1.
      private static float getCMYKChannelValue​(java.lang.String cmykChannel)  
      static DeviceCmyk getCMYKColor​(java.lang.String name)
      Gives you a DeviceCmyk based on a name.
      static float[] getRGBAColor​(java.lang.String name)
      Gives an array of four floats that contain RGBA values, each value is between 0 and 1.
      private static float getRGBChannelValue​(java.lang.String rgbChannel)  
      static DeviceRgb getRGBColor​(java.lang.String name)
      Gives you a DeviceRgb based on a name.
      private static boolean missingHashColorFormat​(java.lang.String colStr)
      A web color string without the leading # will be 3 or 6 characters long and all those characters will be hex digits.
      private static void parseCMYKColors​(float[] color, java.util.StringTokenizer tok)  
      private static float parsePercentValue​(java.lang.String rgbChannel)  
      private static void parseRGBColors​(float[] color, java.util.StringTokenizer tok)  
      • Methods inherited from class java.util.HashMap

        clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        equals, hashCode
    • Field Detail

      • NAMES

        public static final WebColors NAMES
        HashMap containing all the names and corresponding color values.
    • Constructor Detail

      • WebColors

        public WebColors()
    • Method Detail

      • getRGBColor

        public static DeviceRgb getRGBColor​(java.lang.String name)
        Gives you a DeviceRgb based on a name.
        Parameters:
        name - a name such as black, violet, cornflowerblue or #RGB or #RRGGBB or RGB or RRGGBB or rgb(R,G,B)
        Returns:
        the corresponding DeviceRgb object. Never returns null.
      • getCMYKColor

        public static DeviceCmyk getCMYKColor​(java.lang.String name)
        Gives you a DeviceCmyk based on a name.
        Parameters:
        name - 'device-cmyk(c, m, y, k)' structure
        Returns:
        the corresponding DeviceCmyk object. Never returns null.
      • getCMYKArray

        public static float[] getCMYKArray​(java.lang.String name)
        Gives an array of five floats that contain CMYK values and opacity, each value is between 0 and 1.
        Parameters:
        name - 'device-cmyk(c, m, y, k)' structure
        Returns:
        the corresponding array of five floats, or null if parsing failed.
      • getRGBAColor

        public static float[] getRGBAColor​(java.lang.String name)
        Gives an array of four floats that contain RGBA values, each value is between 0 and 1.
        Parameters:
        name - a name such as black, violet, cornflowerblue or #RGB or #RRGGBB or RGB or RRGGBB or rgb(R,G,B) or rgb(R,G,B,A)
        Returns:
        the corresponding array of four floats, or null if parsing failed.
      • parseRGBColors

        private static void parseRGBColors​(float[] color,
                                           java.util.StringTokenizer tok)
      • parseCMYKColors

        private static void parseCMYKColors​(float[] color,
                                            java.util.StringTokenizer tok)
      • missingHashColorFormat

        private static boolean missingHashColorFormat​(java.lang.String colStr)
        A web color string without the leading # will be 3 or 6 characters long and all those characters will be hex digits. NOTE: colStr must be all lower case or the current hex letter test will fail.
        Parameters:
        colStr - A non-null, lower case string that might describe an RGB color in hex.
        Returns:
        Is this a web color hex string without the leading #?
      • getRGBChannelValue

        private static float getRGBChannelValue​(java.lang.String rgbChannel)
      • getCMYKChannelValue

        private static float getCMYKChannelValue​(java.lang.String cmykChannel)
      • getAlphaChannelValue

        private static float getAlphaChannelValue​(java.lang.String rgbChannel)
      • parsePercentValue

        private static float parsePercentValue​(java.lang.String rgbChannel)