Converters string to Color object and vice versa based on the patterns and the transparency set.
Pattern format for colors:Color Format Syntax:
To specify the color format use a color pattern string. In this pattern, all ASCII letters are reserved as pattern letters, which are defined as the following:
Symbol Meaning Presentation Example ------ ------- ------------ ------- r red component (Number) 242 g green component (Number) 242 b blue component (Number) 242 a alpha component (Number) 255 R red component (Hex) F2 G green component (Hex) F2 B blue component (Hex) F2 A alpha component (Hex) FF ' escape for text (Delimiter) '' single quote (Literal) '
Examples:
Format Pattern Result -------------- ------- "#RRGGBB" ->> #6609CC "rrr,ggg,bbb" ->> 102,009,204 "t" ->> Transparent (when alpha is zero)
If patterns is not set then it defaults to patterns "#RRGGBB", "r,g,b" The first pattern is special - it is always used for formatting color values. For default case, getAsString() will use "#RRGGBB" format to represent the color. Object as String.
The getAsObject()
method parses a String into a {@link java.awt.Color}, according to the following algorithm:
null
. Otherwise, trim leading and trailing whitespace before proceeding.null
.setConvertMessageDetail()
. The custom message can contain placeholders as specified in {@link #CONVERT_MESSAGE_ID}. The placeholders will be replaced by appropriate values as mentioned in {@link #CONVERT_MESSAGE_ID}The getAsString()
method expects a value of type {@link Color} (or a subclass), and creates a formattedString according to the following algorithm:
|
|