public class ColorFormatter extends AbstractFormatter<Color>
A Formatter that can parse Strings into java.awt.Color and back
 using several patterns
Supported patterns are:
#RGB#RGBA#RRGGBB#RRGGBBAAR - redG - greenB - blueA - alphaFormatter| Modifier and Type | Field and Description | 
|---|---|
| static String | DEFAULT_PATTERN"#RRGGBB" | 
| static ColorFormatter | LONGColorFormatterthat uses thePATTERN_LONGpattern | 
| static ColorFormatter | LONG_WITH_ALPHAColorFormatterthat uses thePATTERN_LONG_WITH_ALPHApattern | 
| static String | PATTERN_LONG"#RRGGBB" | 
| static String | PATTERN_LONG_WITH_ALPHA"#RRGGBBAA" | 
| static String | PATTERN_SHORT"#RGB" | 
| static String | PATTERN_SHORT_WITH_ALPHA"#RGBA" | 
| static ColorFormatter | SHORTColorFormatterthat uses thePATTERN_SHORTpattern | 
| static ColorFormatter | SHORT_WITH_ALPHAColorFormatterthat uses thePATTERN_SHORT_WITH_ALPHApattern | 
| Modifier | Constructor and Description | 
|---|---|
| protected  | ColorFormatter(String pattern) | 
| Modifier and Type | Method and Description | 
|---|---|
| String | format(Color color)Formats an instance into its literal representation. | 
| static ColorFormatter | getInstance(String pattern)Returns a  ColorFormattergiven a color pattern. | 
| String | getPattern()Returns the pattern used by this  ColorFormatter | 
| Color | parse(String str)Parses a literal representation into an instance of type  T. | 
| static Color | parseColor(String str)Parses a string into a  java.awt.Colorinstance. | 
parseError, parseError, parseHexInt, parseHexIntpublic static final String PATTERN_SHORT
public static final String PATTERN_SHORT_WITH_ALPHA
public static final String PATTERN_LONG
public static final String PATTERN_LONG_WITH_ALPHA
public static final String DEFAULT_PATTERN
public static final ColorFormatter SHORT
ColorFormatter that uses the PATTERN_SHORT patternpublic static final ColorFormatter SHORT_WITH_ALPHA
ColorFormatter that uses the PATTERN_SHORT_WITH_ALPHA patternpublic static final ColorFormatter LONG
ColorFormatter that uses the PATTERN_LONG patternpublic static final ColorFormatter LONG_WITH_ALPHA
ColorFormatter that uses the PATTERN_LONG_WITH_ALPHA pattern@Nonnull public static ColorFormatter getInstance(@Nullable String pattern)
Returns a ColorFormatter given a color pattern.
pattern - the input pattern. Must be one of the 4 supported color patterns.ColorPattern instanceIllegalArgumentException - if the supplied pattern is not supported@Nullable public String format(@Nullable Color color)
FormatterFormats an instance into its literal representation.
The resulting String may be set as an argument to Formatter.parse(java.lang.String)
 resulting in a similar instance as the input.
color - the instance to be formattedString representing the instance's state.@Nullable public Color parse(@Nullable String str) throws ParseException
FormatterParses a literal representation into an instance of type T.
The resulting instance T may be set as an argument to Formatter.format(T)
 resulting in an equal String as the input.
str - the String to be parsedT whose state is initialized given the
 parameters of the input String.ParseException - if the String cannot be parsed.@Nonnull public String getPattern()
ColorFormatterColorFormatter uses for parsing/formatting.@Nonnull public static Color parseColor(@Nonnull String str) throws ParseException
Parses a string into a java.awt.Color instance.
The parsing pattern is chosen given the length of the input string
#RGB#RGBA#RRGGBB#RRGGBBAAgriffon.pivot.support.Colors.str - the string representation of a java.awt.Colorjava.awt.Color instance matching the supplied RGBA color componentsParseException - if the string cannot be parsed by the chosen patternColors