Class WebColors

java.lang.Object
java.util.AbstractMap<String,int[]>
java.util.HashMap<String,int[]>
com.lowagie.text.html.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 Color as value. (Source: Wikipedia http://en.wikipedia.org/wiki/Web_colors )

CSS4 Implementation based on: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value

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:
  • Constructor Details

    • WebColors

      public WebColors()
  • Method Details

    • getRGBColor

      public static Color getRGBColor(String name) throws IllegalArgumentException
      Gives you a Color based on a name.
      Parameters:
      name - the css color name to convert. You can use CSS4 color values
      • a name such as black, violet, cornflowerblue
      • #RGB, #RRGGBB, #RGBA or #RRGGBBAA
      • rgb(R, G, B) rgb(R,G,B,A) or rgba(R,G,B) or rgba(R,G,B,A)
      • hsl(H, S, L) hsl(H,S,L,A) or hslq(H,S,L) or hsla(H,S,L,A)
      Returns:
      the corresponding Color object
      Throws:
      IllegalArgumentException - if the String isn't a know representation of a color.
    • getRGBFromHex

      private static Color getRGBFromHex(String colorName)
    • getRGBFromRGB

      private static Color getRGBFromRGB(String colorName)
    • getFromPercent

      private static int getFromPercent(String v, int max)
    • getRGBFromName

      private static Color getRGBFromName(String colorName)
    • getRGBFromHSL

      private static Color getRGBFromHSL(String colorName)
    • toDegrees

      private static double toDegrees(String hueString)
    • hsl2rgb

      private static int[] hsl2rgb(float hue, float saturation, float lightness)
      Convert from hsl to rgb
      Parameters:
      hue - Hue angle in degrees
      saturation - saturation (0 to 1)
      lightness - lightness (0 to 1)
      Returns:
      int[] rgb
    • hue2rgb

      private static float hue2rgb(float p, float q, float t)