Package be.gaudry.model.drawing.color
Class ColorUtils
java.lang.Object
be.gaudry.model.drawing.color.ColorUtils
Provided by the broldev.core.model project.
- Since:
- 1.0 Dec 2, 2008, broldev.core.model 0.0.1-SNAPSHOT dependency
- Version:
- 1.2 Nov 9, 2010
- Author:
- Steph GAUDRY
-
Method Summary
Modifier and TypeMethodDescriptionstatic Color
An opacity value of 1.0 means that the color is completely opaque and an alpha value of 0.0 means that the color is completely transparent.static String
color2html(Color color)
Use a givenColor
to get the corresponding HTML string.static Color
decodeHtmlColor(String htmlColor)
Parses the string argument as aColor
.
-
Method Details
-
color2html
Use a givenColor
to get the corresponding HTML string.- Parameters:
color
-Color
to get as string.- Returns:
- HTML representation #hexvalue of the color
-
decodeHtmlColor
Parses the string argument as aColor
.An exception of type
NumberFormatException
is thrown if any of the following situations occurs:- The htmlColor argument is
null
or is a string of length zero. - The htmlColor argument does not match to the following pattern # + red hex value on two chars + green hex value on two chars + blue hex value on two chars.
Examples:
decodeHtmlColor("#FFFFFF;") returns Color.WHITE decodeHtmlColor("FFFFFF") returns Color.WHITE decodeHtmlColor("FFF") returns Color.WHITE decodeHtmlColor("FFFFFF;") returns Color.WHITE decodeHtmlColor("#OOOOOO") returns Color.BLACK decodeHtmlColor("FFFFFFF") throws a NumberFormatException decodeHtmlColor("#FFG") throws a NumberFormatException decodeHtmlColor("white") throws a NumberFormatException
- Parameters:
htmlColor
- theString
containing the HTML color representation to be parsed- Returns:
- the Color represented by the string argument.
- Throws:
NumberFormatException
- if theString
does not contain a parsableColor
.IllegalArgumentException
- ifhtmlColor
is null
- The htmlColor argument is
-
alpha
An opacity value of 1.0 means that the color is completely opaque and an alpha value of 0.0 means that the color is completely transparent.- Parameters:
opaqueColor
- original opaqueColor
opacity
- opacity value- Returns:
- the
Color
with the desired opacity - Throws:
IllegalArgumentException
- if opacity is outside of the range 0.0 to 1.0, inclusive
-