Package org.mapfish.print.map.style.json
Class ColorParser
- java.lang.Object
-
- org.mapfish.print.map.style.json.ColorParser
-
public final class ColorParser extends java.lang.Object
Parses colors from text strings. Supports formats:#F00
#FFAABB
rgb(100,100,100)
rgba(100,100,100, 100)
hsl(100,100,100)
hsla(100,100,100, 100)
-65536
red
- 0-255
- 0%-100%
- 0.0%-100.0%
- 0.0-1.0
- 0f-1f
- 0.0f-1.0f
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
canParseColor(java.lang.String colorString)
Check if the given color string can be parsed.static java.awt.Color
toColor(java.lang.String colorString)
Parse the string and convert it to aColor
.static java.lang.String
toRGB(java.awt.Color color)
Get the "rgb(...)" representation for a color.
-
-
-
Method Detail
-
toColor
public static java.awt.Color toColor(java.lang.String colorString)
Parse the string and convert it to aColor
. See class description for details on the supported color formats.- Parameters:
colorString
- the color string encoded.- Returns:
- Always return a Color or an exception
- Throws:
java.lang.NumberFormatException
- when the colorString cannot be parsed
-
canParseColor
public static boolean canParseColor(java.lang.String colorString)
Check if the given color string can be parsed.- Parameters:
colorString
- The color to parse.
-
toRGB
public static java.lang.String toRGB(java.awt.Color color)
Get the "rgb(...)" representation for a color.- Parameters:
color
- The color.
-
-