Package org.odftoolkit.odfdom.type
Class Color
java.lang.Object
org.odftoolkit.odfdom.type.Color
- All Implemented Interfaces:
OdfDataType
This class represents the in OpenDocument format used data type color See W3C CSS specification for
further details.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Color
The color aqua in sRGB space.static final Color
The color black in sRGB space.static final Color
The color blue in sRGB space.static final Color
The color fuchsia in sRGB space.static final Color
The color gray in sRGB space.static final Color
The color green in sRGB space.static final Color
The color lime in sRGB space.static final Color
The color maroon in sRGB space.static final Color
The color navy in sRGB space.static final Color
The color olive in sRGB space.static final Color
The color orange in sRGB space.static final Color
The color purple in sRGB space.static final Color
The color red in sRGB space.static final Color
The color silver in sRGB space.static final Color
The color teal in sRGB space.static final Color
The color white in sRGB space.static final Color
The color yellow in sRGB space. -
Constructor Summary
ConstructorDescriptionColor
(float red, float green, float blue) Construct Color using the specified red, green, and blue values in the range (0.0 - 1.0).Color
(int red, int green, int blue) Construct Color using the specified red, green and blue values in the range (0 - 255).Construct Color using
.java.awt.Color
Construct Color by the parsing the given string. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Return the corresponding
instance of the Color data type.java.awt.Color
int
hashCode()
static boolean
Check if the specified String is a valid color data type.static Color
mapColorToAWTColor
(Color color) Map a Color data type to
.java.awt.Color
static String
toSixDigitHexRGB
(String colorValue) Convert RGB color formats to six-digit hex RGB format.toString()
Returns the Color in six HEX sRGB notation. format.static Color
Returns a Color instance representing the specified String value.
-
Field Details
-
AQUA
The color aqua in sRGB space. -
BLACK
The color black in sRGB space. -
BLUE
The color blue in sRGB space. -
FUCHSIA
The color fuchsia in sRGB space. -
GRAY
The color gray in sRGB space. -
GREEN
The color green in sRGB space. -
LIME
The color lime in sRGB space. -
MAROON
The color maroon in sRGB space. -
NAVY
The color navy in sRGB space. -
OLIVE
The color olive in sRGB space. -
ORANGE
The color orange in sRGB space. -
PURPLE
The color purple in sRGB space. -
RED
The color red in sRGB space. -
SILVER
The color silver in sRGB space. -
TEAL
The color teal in sRGB space. -
WHITE
The color white in sRGB space. -
YELLOW
The color yellow in sRGB space.
-
-
Constructor Details
-
Color
Construct Color by the parsing the given string. The string should be observed sRGB color standard which starts with "#" and following with six numbers or three numbers in Hex format. For example, "#FFFFFF" is a valid argument and white color will be constructed.For further information on sRGB, see http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html .
- Parameters:
color
- represented using the 3 or 6 HEX sRGB notation.- Throws:
IllegalArgumentException
- if the given argument is not a valid Color in sRGB HEX notation.
-
Color
public Color(int red, int green, int blue) Construct Color using the specified red, green and blue values in the range (0 - 255).- Parameters:
red
- the red component.green
- the green component.blue
- the blue component.- Throws:
IllegalArgumentException
- ifred
,green
orblue
are outside of the range 0 to 255, inclusive.
-
Color
public Color(float red, float green, float blue) Construct Color using the specified red, green, and blue values in the range (0.0 - 1.0).- Parameters:
red
- the red componentgreen
- the green componentblue
- the blue component- Throws:
IllegalArgumentException
- ifred
,green
orblue
are outside of the range 0.0 to 1.0, inclusive.
-
Color
Construct Color using
.java.awt.Color
- Parameters:
color
- the specified
.java.awt.Color
- Throws:
IllegalArgumentException
- if the given argument is not a valid Color.- See Also:
-
-
Method Details
-
toString
Returns the Color in six HEX sRGB notation. format. -
valueOf
Returns a Color instance representing the specified String value.- Parameters:
colorValue
- a six (or three) number hexadecimal string representation of the Color- Returns:
- return a Color instance representing
stringValue
. - Throws:
IllegalArgumentException
- if the given argument is not a valid Color.
-
isValid
Check if the specified String is a valid color data type.- Parameters:
colorValue
- a six (or three) number hexadecimal string representation of the Color- Returns:
- true if the value of argument is valid forcolor data type false otherwise.
-
toSixDigitHexRGB
Convert RGB color formats to six-digit hex RGB format.The RGB mapping works as follows: rgb(110%, 0%, 0%)----clipped to rgb(100%,0%,0%), return #ff0000 maroon----one of the seventeen fixed labeled numbers, return #800000 #ff0000----six-digit notation #rrggbb, returns the input #f00----three-digit notation #rgb, return #ff0000 rgb(255,0,0)----integer range 0 - 255, return #ff0000 rgb(300,0,0)----clipped to rgb(255,0,0), return #ff0000 rgb(255,-10,0)----clipped to rgb(255,0,0), return #ff0000
- Parameters:
colorValue
- The sRGB color value to be converted.- Returns:
- the converted color.
-
getAWTColor
Return the corresponding
instance of the Color data type.java.awt.Color
- Returns:
- the converted
instance..java.awt.Color
-
mapColorToAWTColor
Map a Color data type to
.java.awt.Color
- Parameters:
color
- The color data type to be mapped..- Returns:
- the converted
instance.java.awt.Color
-
equals
-
hashCode
public int hashCode()
-