Package com.lowagie.text.html
Class WebColors
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<java.lang.String,int[]>
-
- com.lowagie.text.html.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 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static WebColors
NAMES
HashMap containing all the names and corresponding color values.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 int
getFromPercent(java.lang.String v, int max)
static java.awt.Color
getRGBColor(java.lang.String name)
Gives you a Color based on a name.private static java.awt.Color
getRGBFromHex(java.lang.String colorName)
private static java.awt.Color
getRGBFromHSL(java.lang.String colorName)
private static java.awt.Color
getRGBFromName(java.lang.String colorName)
private static java.awt.Color
getRGBFromRGB(java.lang.String colorName)
private static int[]
hsl2rgb(float hue, float saturation, float lightness)
Convert from hsl to rgbprivate static float
hue2rgb(float p, float q, float t)
private static double
toDegrees(java.lang.String hueString)
-
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
-
-
-
-
Field Detail
-
NAMES
public static final WebColors NAMES
HashMap containing all the names and corresponding color values.
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
getRGBColor
public static java.awt.Color getRGBColor(java.lang.String name) throws java.lang.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:
java.lang.IllegalArgumentException
- if the String isn't a know representation of a color.
-
getRGBFromHex
private static java.awt.Color getRGBFromHex(java.lang.String colorName)
-
getRGBFromRGB
private static java.awt.Color getRGBFromRGB(java.lang.String colorName)
-
getFromPercent
private static int getFromPercent(java.lang.String v, int max)
-
getRGBFromName
private static java.awt.Color getRGBFromName(java.lang.String colorName)
-
getRGBFromHSL
private static java.awt.Color getRGBFromHSL(java.lang.String colorName)
-
toDegrees
private static double toDegrees(java.lang.String hueString)
-
hsl2rgb
private static int[] hsl2rgb(float hue, float saturation, float lightness)
Convert from hsl to rgb- Parameters:
hue
- Hue angle in degreessaturation
- saturation (0 to 1)lightness
- lightness (0 to 1)- Returns:
- int[] rgb
-
hue2rgb
private static float hue2rgb(float p, float q, float t)
-
-