Class WebColors

java.lang.Object
java.util.AbstractMap<String,int[]>
java.util.HashMap<String,int[]>
com.itextpdf.kernel.colors.WebColors
All Implemented Interfaces:
Serializable, Cloneable, Map<String,int[]>

public class WebColors extends HashMap<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:
  • Field Details

    • NAMES

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

      private static final long serialVersionUID
      See Also:
    • RGB_MAX_VAL

      private static final double RGB_MAX_VAL
      See Also:
  • Constructor Details

    • WebColors

      public WebColors()
  • Method Details

    • getRGBColor

      public static DeviceRgb getRGBColor(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(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(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(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, StringTokenizer tok)
    • parseCMYKColors

      private static void parseCMYKColors(float[] color, StringTokenizer tok)
    • missingHashColorFormat

      private static boolean missingHashColorFormat(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(String rgbChannel)
    • getCMYKChannelValue

      private static float getCMYKChannelValue(String cmykChannel)
    • getAlphaChannelValue

      private static float getAlphaChannelValue(String rgbChannel)
    • parsePercentValue

      private static float parsePercentValue(String rgbChannel)