Class ColorStringParser
- java.lang.Object
-
- com.martiansoftware.jsap.StringParser
-
- com.martiansoftware.jsap.stringparsers.ColorStringParser
-
public class ColorStringParser extends StringParser
AStringParser
for parsing java.awt.Color objects. Color information can be specified in a variety of formats:- RGB, as integers in the range 0-255, separated by commas (e.g., "123,45,6")
- RGB, as floats in the range 0.0-1.0, separated by commas (e.g., "0.123,0.45,0.6")
- RGB, as hexadecimal strings following the '#' character (e.g., "#1234ef")
- By name, as matching the names of the color fields of java.awt.Color (case-insensitive). (e.g., "black")
- RGBAlpha, as integers in the range 0-255, separated by commas (e.g., "123,45,6,128")
- RGBAlpha, as floats in the range 0.0-1.0, separated by commas (e.g., "0.123,0.45,0.6,.5")
- RGBAlpha, as hexadecimal strings following the '#' character (e.g., "#1234efab")
- Author:
- Marty Lamb
- See Also:
StringParser
,Color
-
-
Constructor Summary
Constructors Constructor Description ColorStringParser()
Deprecated.UsegetParser()
or, even better,JSAP.COLOR_PARSER
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ColorStringParser
getParser()
Returns aColorStringParser
.java.lang.Object
parse(java.lang.String arg)
Parses java.awt.Color objects from Strings.-
Methods inherited from class com.martiansoftware.jsap.StringParser
setUp, tearDown
-
-
-
-
Constructor Detail
-
ColorStringParser
public ColorStringParser()
Deprecated.UsegetParser()
or, even better,JSAP.COLOR_PARSER
.Creates a new ColorStringParser.
-
-
Method Detail
-
getParser
public static ColorStringParser getParser()
Returns aColorStringParser
.Convenient access to the only instance returned by this method is available through
JSAP.COLOR_PARSER
.- Returns:
- a
ColorStringParser
.
-
parse
public java.lang.Object parse(java.lang.String arg) throws ParseException
Parses java.awt.Color objects from Strings. Color information can be specified in a variety of formats:- RGB, as integers in the range 0-255, separated by commas (e.g., "123,45,6")
- RGB, as floats in the range 0.0-1.0, separated by commas (e.g., "0.123,0.45,0.6")
- RGB, as hexadecimal strings following the '#' character (e.g., "#1234ef")
- By name, as matching the names of the color fields of java.awt.Color (case-insensitive). (e.g., "black")
- RGBAlpha, as integers in the range 0-255, separated by commas (e.g., "123,45,6,128")
- RGBAlpha, as floats in the range 0.0-1.0, separated by commas (e.g., "0.123,0.45,0.6,.5")
- RGBAlpha, as hexadecimal strings following the '#' character (e.g., "#1234efab")
- Specified by:
parse
in classStringParser
- Parameters:
arg
- the String to convert to a Color object.- Returns:
- the Color specified by arg.
- Throws:
ParseException
- if arg cannot be interpreted as a Color as described above.
-
-