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 ColorAn 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 Stringcolor2html(Color color)Use a givenColorto get the corresponding HTML string.static ColordecodeHtmlColor(String htmlColor)Parses the string argument as aColor.
-
Method Details
-
color2html
Use a givenColorto get the corresponding HTML string.- Parameters:
color-Colorto get as string.- Returns:
- HTML representation #hexvalue of the color
-
decodeHtmlColor
Parses the string argument as aColor.An exception of type
NumberFormatExceptionis thrown if any of the following situations occurs:- The htmlColor argument is
nullor 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- theStringcontaining the HTML color representation to be parsed- Returns:
- the Color represented by the string argument.
- Throws:
NumberFormatException- if theStringdoes not contain a parsableColor.IllegalArgumentException- ifhtmlColoris 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 opaqueColoropacity- opacity value- Returns:
- the
Colorwith the desired opacity - Throws:
IllegalArgumentException- if opacity is outside of the range 0.0 to 1.0, inclusive
-