Package org.odftoolkit.odfdom.type
Class Color
- java.lang.Object
-
- org.odftoolkit.odfdom.type.Color
-
- All Implemented Interfaces:
OdfDataType
public class Color extends Object implements OdfDataType
This class represents the in OpenDocument format used data type color See W3C CSS specification for further details.
-
-
Field Summary
Fields Modifier and Type Field Description static ColorAQUAThe color aqua in sRGB space.static ColorBLACKThe color black in sRGB space.static ColorBLUEThe color blue in sRGB space.static ColorFUCHSIAThe color fuchsia in sRGB space.static ColorGRAYThe color gray in sRGB space.static ColorGREENThe color green in sRGB space.static ColorLIMEThe color lime in sRGB space.static ColorMAROONThe color maroon in sRGB space.static ColorNAVYThe color navy in sRGB space.static ColorOLIVEThe color olive in sRGB space.static ColorORANGEThe color orange in sRGB space.static ColorPURPLEThe color purple in sRGB space.static ColorREDThe color red in sRGB space.static ColorSILVERThe color silver in sRGB space.static ColorTEALThe color teal in sRGB space.static ColorWHITEThe color white in sRGB space.static ColorYELLOWThe color yellow in sRGB space.
-
Constructor Summary
Constructors Constructor Description Color(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).Color(Color color)Construct Color using.java.awt.ColorColor(String color)Construct Color by the parsing the given string.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)ColorgetAWTColor()Return the correspondinginstance of the Color data type.java.awt.ColorinthashCode()static booleanisValid(String colorValue)Check 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.StringtoString()Returns the Color in six HEX sRGB notation.static ColorvalueOf(String colorValue)Returns a Color instance representing the specified String value.
-
-
-
Field Detail
-
AQUA
public static final Color AQUA
The color aqua in sRGB space.
-
BLACK
public static final Color BLACK
The color black in sRGB space.
-
BLUE
public static final Color BLUE
The color blue in sRGB space.
-
FUCHSIA
public static final Color FUCHSIA
The color fuchsia in sRGB space.
-
GRAY
public static final Color GRAY
The color gray in sRGB space.
-
GREEN
public static final Color GREEN
The color green in sRGB space.
-
LIME
public static final Color LIME
The color lime in sRGB space.
-
MAROON
public static final Color MAROON
The color maroon in sRGB space.
-
NAVY
public static final Color NAVY
The color navy in sRGB space.
-
OLIVE
public static final Color OLIVE
The color olive in sRGB space.
-
ORANGE
public static final Color ORANGE
The color orange in sRGB space.
-
PURPLE
public static final Color PURPLE
The color purple in sRGB space.
-
RED
public static final Color RED
The color red in sRGB space.
-
SILVER
public static final Color SILVER
The color silver in sRGB space.
-
TEAL
public static final Color TEAL
The color teal in sRGB space.
-
WHITE
public static final Color WHITE
The color white in sRGB space.
-
YELLOW
public static final Color YELLOW
The color yellow in sRGB space.
-
-
Constructor Detail
-
Color
public Color(String 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
public Color(Color 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:
Color
-
-
Method Detail
-
toString
public String toString()
Returns the Color in six HEX sRGB notation. format.
-
valueOf
public static Color valueOf(String colorValue)
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
public static boolean isValid(String colorValue)
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
public static String toSixDigitHexRGB(String colorValue)
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
public Color getAWTColor()
Return the correspondinginstance of the Color data type.java.awt.Color- Returns:
- the converted
instance..java.awt.Color
-
mapColorToAWTColor
public static Color mapColorToAWTColor(Color color)
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
-
-