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
FieldsModifier and TypeFieldDescriptionstatic final ColorThe color aqua in sRGB space.static final ColorThe color black in sRGB space.static final ColorThe color blue in sRGB space.static final ColorThe color fuchsia in sRGB space.static final ColorThe color gray in sRGB space.static final ColorThe color green in sRGB space.static final ColorThe color lime in sRGB space.static final ColorThe color maroon in sRGB space.static final ColorThe color navy in sRGB space.static final ColorThe color olive in sRGB space.static final ColorThe color orange in sRGB space.static final ColorThe color purple in sRGB space.static final ColorThe color red in sRGB space.static final ColorThe color silver in sRGB space.static final ColorThe color teal in sRGB space.static final ColorThe color white in sRGB space.static final ColorThe color yellow in sRGB space. -
Constructor Summary
ConstructorsConstructorDescriptionColor(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.ColorConstruct Color by the parsing the given string. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturn the correspondinginstance of the Color data type.java.awt.ColorinthashCode()static booleanCheck if the specified String is a valid color data type.static ColormapColorToAWTColor(Color color) Map a Color data type to.java.awt.Colorstatic StringtoSixDigitHexRGB(String colorValue) Convert RGB color formats to six-digit hex RGB format.toString()Returns the Color in six HEX sRGB notation.static ColorReturns 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,greenorblueare 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,greenorblueare 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 correspondinginstance 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()
-