public final class ColorUtils extends Object
Modifier and Type | Method and Description |
---|---|
static Color |
getContrastColor(Color aColor)
Creates a contrasting color, based on the "perceived luminance" of the
given color.
|
static Color |
getHighlightColor(Color aColor,
float aFactor)
Calculates a highlight color for the given color.
|
static double |
getPerceivedLuminance(Color aColor)
Returns the Digital CCIR601 luminance value of the given color.
|
static double |
getStandardLuminance(Color aColor)
Returns the Photometric/digital ITU-R luminance value of the given color.
|
static Color |
interpolate(Color aBaseColor,
Color aSecondaryColor,
float aDelta)
Interpolates a gray-scale color between two given colors.
|
static Color |
parseColor(String aColor)
Parses the given color-string into a valid Color instance.
|
static String |
toHexString(Color aColor)
Returns the given color instance as a string in the form of
RR GG BB in which RR, GG, BB are the
hexadecimal representations of red, green and blue.
|
public static Color getContrastColor(Color aColor)
See also: http://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color , and http://stackoverflow.com/questions/1855884/determine-font-color-based-on-background-color .
aColor
- the color to create a contrasting color for, cannot be
null
.null
.public static Color getHighlightColor(Color aColor, float aFactor)
aColor
- the color to create a highlight color for, cannot be
null
;aFactor
- the highlight factor to apply, >= 0.0 && <= 1.0f;null
.public static double getPerceivedLuminance(Color aColor)
aColor
- the color to return the luminance value for, cannot be
null
.public static double getStandardLuminance(Color aColor)
aColor
- the color to return the luminance value for, cannot be
null
.public static Color interpolate(Color aBaseColor, Color aSecondaryColor, float aDelta)
aBaseColor
- aSecondaryColor
- aDelta
- public static final Color parseColor(String aColor)
A color-string has the following form: [#]rrggbb where rr, gg and bb are the hexadecimal color values for red, green and blue. The string may optionally start with a hashpound sign.
aColor
- the color string to parse as color, cannot be null
.null
.public static String toHexString(Color aColor)
aColor
- the color to return as a string value, cannot be null
.parseColor(String)
Copyright © 2015 L'Xtreme IT consultancy. All rights reserved.