com.alee.utils
Class ColorUtils

java.lang.Object
  extended by com.alee.utils.ColorUtils

public final class ColorUtils
extends java.lang.Object

This class provides a set of utilities to work with colors.

Author:
Mikle Garin

Constructor Summary
ColorUtils()
           
 
Method Summary
static java.awt.Color black(int alpha)
          Returns black color with specified alpha
static java.lang.String getHexColor(java.awt.Color color)
          Returns hex color string for the specified color.
static java.lang.String getHexColor(int rgb)
          Returns hex color string for the specified rgb value.
static java.awt.Color getIntermediateColor(java.awt.Color color1, java.awt.Color color2, float progress)
          Returns intermediate color between two specified colors.
static int getIntermediateValue(int value1, int value2, float progress)
          Returns intermediate value between two specified values.
static java.awt.Color getRandomSoftColor(java.awt.Color base)
          Returns randomly generated soft color based on the specified color.
static java.awt.Color getTransparentColor(java.awt.Color color, int alpha)
          Returns color with modified alpha value.
static java.awt.Color getWebSafeColor(java.awt.Color color)
          Returns web-safe color.
static int getWebSafeValue(int value)
          Returns web-safe color value.
static java.awt.Color parseHexColor(java.lang.String hex)
          Returns color decoded from a hex color string.
static java.awt.Color parseRgbColor(java.lang.String rgb)
          Returns color decoded from an rgb color string.
static java.awt.Color parseRgbColor(java.lang.String rgb, java.lang.String separator)
          Returns color decoded from an rgb color string.
static java.awt.Color removeAlpha(java.awt.Color color)
          Returns color with alpha value set to 255.
static java.awt.Color white(int alpha)
          Returns white color with specified alpha
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorUtils

public ColorUtils()
Method Detail

removeAlpha

public static java.awt.Color removeAlpha(java.awt.Color color)
Returns color with alpha value set to 255.

Parameters:
color - color to modify
Returns:
color with alpha value set to 255

getTransparentColor

public static java.awt.Color getTransparentColor(java.awt.Color color,
                                                 int alpha)
Returns color with modified alpha value.

Parameters:
color - color to process
alpha - new alpha value
Returns:
color with modified alpha value

getIntermediateColor

public static java.awt.Color getIntermediateColor(java.awt.Color color1,
                                                  java.awt.Color color2,
                                                  float progress)
Returns intermediate color between two specified colors.

Parameters:
color1 - first color
color2 - second color
progress - progress of the intermediate color
Returns:
intermediate color between two specified colors

getIntermediateValue

public static int getIntermediateValue(int value1,
                                       int value2,
                                       float progress)
Returns intermediate value between two specified values.

Parameters:
value1 - first value
value2 - second value
progress - progress of the intermediate value
Returns:
intermediate value between two specified values

getWebSafeColor

public static java.awt.Color getWebSafeColor(java.awt.Color color)
Returns web-safe color.

Parameters:
color - color to process
Returns:
web-safe color

getWebSafeValue

public static int getWebSafeValue(int value)
Returns web-safe color value.

Parameters:
value - value to process
Returns:
web-safe color value

getHexColor

public static java.lang.String getHexColor(java.awt.Color color)
Returns hex color string for the specified color.

Parameters:
color - color to process
Returns:
hex color string for the specified color

getHexColor

public static java.lang.String getHexColor(int rgb)
Returns hex color string for the specified rgb value.

Parameters:
rgb - rgb value
Returns:
hex color string for the specified rgb value

parseHexColor

public static java.awt.Color parseHexColor(java.lang.String hex)
Returns color decoded from a hex color string.

Parameters:
hex - hex color string
Returns:
color decoded from a hex color string

parseRgbColor

public static java.awt.Color parseRgbColor(java.lang.String rgb)
Returns color decoded from an rgb color string.

Parameters:
rgb - rgb color string
Returns:
color decoded from an rgb color string

parseRgbColor

public static java.awt.Color parseRgbColor(java.lang.String rgb,
                                           java.lang.String separator)
Returns color decoded from an rgb color string.

Parameters:
rgb - rgb color string
separator - color parts separator
Returns:
color decoded from an rgb color string

black

public static java.awt.Color black(int alpha)
Returns black color with specified alpha

Parameters:
alpha - color alpha
Returns:
black color with specified alpha

white

public static java.awt.Color white(int alpha)
Returns white color with specified alpha

Parameters:
alpha - color alpha
Returns:
white color with specified alpha

getRandomSoftColor

public static java.awt.Color getRandomSoftColor(java.awt.Color base)
Returns randomly generated soft color based on the specified color.

Parameters:
base - color base
Returns:
randomly generated soft color based on the specified color