org.jvnet.substance.utils
Class SubstanceColorUtilities

java.lang.Object
  extended by org.jvnet.substance.utils.SubstanceColorUtilities

public class SubstanceColorUtilities
extends java.lang.Object

Various color-related utilities. This class is for internal use only.

Author:
Kirill Grouchnikov

Constructor Summary
SubstanceColorUtilities()
           
 
Method Summary
static java.awt.Color getAlphaColor(java.awt.Color color, int alpha)
          Returns a translucent of the specified color.
static java.awt.Color getBackgroundColor(SubstanceTheme theme)
          Returns background color for the specified theme.
static java.awt.Color getBottomBorderColor(ColorScheme scheme, boolean isDark)
          Returns the color of the bottom portion of border.
static java.awt.Color getBottomBorderColor(ColorScheme scheme1, ColorScheme scheme2, double cycleCoef)
          Returns the color of the bottom portion of border in control backgrounds.
static java.awt.Color getBottomFillColor(ColorScheme scheme1, ColorScheme scheme2, double cycleCoef, boolean useCyclePosAsInterpolation)
          Returns the color of the bottom portion of fill in control backgrounds.
static java.awt.Color getBottomShineColor(ColorScheme scheme1, ColorScheme scheme2, double cycleCoef, boolean useCyclePosAsInterpolation)
          Returns the color of the bottom portion of shine in control backgrounds.
static java.awt.Color getColorBlindColor(java.awt.Color orig, double[][] rgbToLms, ColorBlindColorScheme.BlindnessKind kind, double[][] lmsToRgb)
          Converts the specified color into color-blind version.
static int getColorBrightness(int rgb)
          Returns the brightness of the specified color.
static float getColorStrength(java.awt.Color color)
          Returns the color strength.
static java.awt.Color getDarkerColor(java.awt.Color color, double diff)
          Returns darker version of the specified color.
static java.awt.Color getDisabledForegroundColor(SubstanceTheme theme)
          Returns disabled foreground color for the specified theme.
static java.awt.Color getFocusColor(java.awt.Component comp)
          Returns the color of the focus ring for the specified component.
static java.awt.Color getForegroundColor(SubstanceTheme theme)
          Returns the foreground color of the specified theme.
static java.awt.Color getHueShiftedColor(java.awt.Color color, double hueShift)
          Returns hue-shifted (in HSV space) version of the specified color.
static java.awt.Color getInterpolatedColor(java.awt.Color color1, java.awt.Color color2, double color1Likeness)
          Interpolates color.
static int getInterpolatedRGB(java.awt.Color color1, java.awt.Color color2, double color1Likeness)
          Interpolates color.
static java.awt.Color getLighterColor(java.awt.Color color, double diff)
          Returns lighter version of the specified color.
static java.awt.Color getLineColor(SubstanceTheme theme)
          Returns line color for the specified theme.
static java.awt.Color getMidBorderColor(ColorScheme scheme1, ColorScheme scheme2, double cycleCoef)
          Returns the color of the middle portion of border in control backgrounds.
static java.awt.Color getMidFillColor(ColorScheme scheme1, ColorScheme scheme2, double cycleCoef, boolean useCyclePosAsInterpolation)
          Returns the color of the middle portion of fill in control backgrounds.
static java.awt.Color getNegativeColor(java.awt.Color color)
          Returns a negative of the specified color.
static int getNegativeColor(int rgb)
          Returns a negative of the specified color.
static java.awt.Color getSaturatedColor(java.awt.Color color, double factor)
          Returns saturated version of the specified color.
static java.awt.Color getSelectionBackgroundColor(SubstanceTheme theme)
          Returns selection background color for the specified theme.
static java.awt.Color getSelectionForegroundColor(SubstanceTheme theme)
          Returns selection foreground color for the specified theme.
static java.awt.Color getTopBorderColor(ColorScheme scheme, boolean isDark)
          Returns the color of the top portion of border.
static java.awt.Color getTopBorderColor(ColorScheme scheme1, ColorScheme scheme2, double cycleCoef)
          Returns the color of the top portion of border in control backgrounds.
static java.awt.Color getTopFillColor(ColorScheme scheme1, ColorScheme scheme2, double cycleCoef, boolean useCyclePosAsInterpolation)
          Returns the color of the top portion of fill in control backgrounds.
static java.awt.Color getTopShineColor(ColorScheme scheme1, ColorScheme scheme2, double cycleCoef, boolean useCyclePosAsInterpolation)
          Returns the color of the top portion of shine in control backgrounds.
static java.awt.Color getWatermarkDarkColor()
          Returns the watermark dark color for the current theme.
static java.awt.Color getWatermarkDarkColor(SubstanceTheme theme)
          Returns the watermark dark color for the current theme.
static java.awt.Color getWatermarkLightColor()
          Returns the watermark light color for the current theme.
static java.awt.Color getWatermarkLightColor(float coef)
          Returns the watermark light color for the current theme.
static java.awt.Color getWatermarkLightColor(SubstanceTheme theme)
          Returns the watermark light color for the current theme.
static java.awt.Color getWatermarkLightColor(SubstanceTheme theme, float coef)
          Returns the watermark light color for the current theme.
static java.awt.Color getWatermarkStampColor()
          Returns the watermark stamp color for the current theme.
static java.awt.Color getWatermarkStampColor(int alpha)
          Returns the watermark stamp color of the specified opacity for the current theme.
static java.awt.Color getWatermarkStampColor(SubstanceTheme theme)
          Returns the watermark stamp color for the current theme.
static java.awt.Color invertColor(java.awt.Color color)
          Inverts the specified color.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubstanceColorUtilities

public SubstanceColorUtilities()
Method Detail

getTopBorderColor

public static java.awt.Color getTopBorderColor(ColorScheme scheme1,
                                               ColorScheme scheme2,
                                               double cycleCoef)
Returns the color of the top portion of border in control backgrounds.

Parameters:
scheme1 - The first color scheme.
scheme2 - The second color scheme.
cycleCoef - Cycle position. Is used for rollover and pulsation effects. Must be in 0.0 .. 1.0 range.
Returns:
The color of the top portion of border in control backgrounds.

getTopBorderColor

public static java.awt.Color getTopBorderColor(ColorScheme scheme,
                                               boolean isDark)
Returns the color of the top portion of border.

Parameters:
scheme - The color scheme.
isDark - Indicates whether the matching theme is dark.
Returns:
The color of the top portion of border.

getBottomBorderColor

public static java.awt.Color getBottomBorderColor(ColorScheme scheme,
                                                  boolean isDark)
Returns the color of the bottom portion of border.

Parameters:
scheme - The color scheme.
isDark - Indicates whether the matching theme is dark.
Returns:
The color of the bottom portion of border.

getMidBorderColor

public static java.awt.Color getMidBorderColor(ColorScheme scheme1,
                                               ColorScheme scheme2,
                                               double cycleCoef)
Returns the color of the middle portion of border in control backgrounds.

Parameters:
scheme1 - The first color scheme.
scheme2 - The second color scheme.
cycleCoef - Cycle position. Is used for rollover and pulsation effects. Must be in 0.0 .. 1.0 range.
Returns:
The color of the middle portion of border in control backgrounds.

getBottomBorderColor

public static java.awt.Color getBottomBorderColor(ColorScheme scheme1,
                                                  ColorScheme scheme2,
                                                  double cycleCoef)
Returns the color of the bottom portion of border in control backgrounds.

Parameters:
scheme1 - The first color scheme.
scheme2 - The second color scheme.
cycleCoef - Cycle position. Is used for rollover and pulsation effects. Must be in 0.0 .. 1.0 range.
Returns:
The color of the bottom portion of border in control backgrounds.

getTopFillColor

public static java.awt.Color getTopFillColor(ColorScheme scheme1,
                                             ColorScheme scheme2,
                                             double cycleCoef,
                                             boolean useCyclePosAsInterpolation)
Returns the color of the top portion of fill in control backgrounds.

Parameters:
scheme1 - The first color scheme.
scheme2 - The second color scheme.
cycleCoef - Cycle position. Is used for rollover and pulsation effects. Must be in 0.0 .. 1.0 range.
useCyclePosAsInterpolation - Indicates the algorithm to use for computing various colors. If true, the cyclePos is used to interpolate colors between different color components of both color schemes. If false, the cyclePos is used to interpolate colors between different color components of the first color scheme.
Returns:
The color of the top portion of fill in control backgrounds.

getMidFillColor

public static java.awt.Color getMidFillColor(ColorScheme scheme1,
                                             ColorScheme scheme2,
                                             double cycleCoef,
                                             boolean useCyclePosAsInterpolation)
Returns the color of the middle portion of fill in control backgrounds.

Parameters:
scheme1 - The first color scheme.
scheme2 - The second color scheme.
cycleCoef - Cycle position. Is used for rollover and pulsation effects. Must be in 0.0 .. 1.0 range.
useCyclePosAsInterpolation - Indicates the algorithm to use for computing various colors. If true, the cyclePos is used to interpolate colors between different color components of both color schemes. If false, the cyclePos is used to interpolate colors between different color components of the first color scheme.
Returns:
The color of the middle portion of fill in control backgrounds.

getBottomFillColor

public static java.awt.Color getBottomFillColor(ColorScheme scheme1,
                                                ColorScheme scheme2,
                                                double cycleCoef,
                                                boolean useCyclePosAsInterpolation)
Returns the color of the bottom portion of fill in control backgrounds.

Parameters:
scheme1 - The first color scheme.
scheme2 - The second color scheme.
cycleCoef - Cycle position. Is used for rollover and pulsation effects. Must be in 0.0 .. 1.0 range.
useCyclePosAsInterpolation - Indicates the algorithm to use for computing various colors. If true, the cyclePos is used to interpolate colors between different color components of both color schemes. If false, the cyclePos is used to interpolate colors between different color components of the first color scheme.
Returns:
The color of the bottom portion of fill in control backgrounds.

getTopShineColor

public static java.awt.Color getTopShineColor(ColorScheme scheme1,
                                              ColorScheme scheme2,
                                              double cycleCoef,
                                              boolean useCyclePosAsInterpolation)
Returns the color of the top portion of shine in control backgrounds.

Parameters:
scheme1 - The first color scheme.
scheme2 - The second color scheme.
cycleCoef - Cycle position. Is used for rollover and pulsation effects. Must be in 0.0 .. 1.0 range.
useCyclePosAsInterpolation - Indicates the algorithm to use for computing various colors. If true, the cyclePos is used to interpolate colors between different color components of both color schemes. If false, the cyclePos is used to interpolate colors between different color components of the first color scheme.
Returns:
The color of the top portion of shine in control backgrounds.

getBottomShineColor

public static java.awt.Color getBottomShineColor(ColorScheme scheme1,
                                                 ColorScheme scheme2,
                                                 double cycleCoef,
                                                 boolean useCyclePosAsInterpolation)
Returns the color of the bottom portion of shine in control backgrounds.

Parameters:
scheme1 - The first color scheme.
scheme2 - The second color scheme.
cycleCoef - Cycle position. Is used for rollover and pulsation effects. Must be in 0.0 .. 1.0 range.
useCyclePosAsInterpolation - Indicates the algorithm to use for computing various colors. If true, the cyclePos is used to interpolate colors between different color components of both color schemes. If false, the cyclePos is used to interpolate colors between different color components of the first color scheme.
Returns:
The color of the bottom portion of shine in control backgrounds.

getInterpolatedRGB

public static int getInterpolatedRGB(java.awt.Color color1,
                                     java.awt.Color color2,
                                     double color1Likeness)
Interpolates color.

Parameters:
color1 - The first color
color2 - The second color
color1Likeness - The closer this value is to 0.0, the closer the resulting color will be to color2.
Returns:
Interpolated RGB value.

getInterpolatedColor

public static java.awt.Color getInterpolatedColor(java.awt.Color color1,
                                                  java.awt.Color color2,
                                                  double color1Likeness)
Interpolates color.

Parameters:
color1 - The first color
color2 - The second color
color1Likeness - The closer this value is to 0.0, the closer the resulting color will be to color2.
Returns:
Interpolated color.

invertColor

public static java.awt.Color invertColor(java.awt.Color color)
Inverts the specified color.

Parameters:
color - The original color.
Returns:
The inverted color.

getBackgroundColor

public static java.awt.Color getBackgroundColor(SubstanceTheme theme)
Returns background color for the specified theme.

Parameters:
theme - Theme.
Returns:
Background color for the specified theme.

getDisabledForegroundColor

public static java.awt.Color getDisabledForegroundColor(SubstanceTheme theme)
Returns disabled foreground color for the specified theme.

Parameters:
theme - Theme.
Returns:
Disabled foreground color for the specified theme.

getSelectionBackgroundColor

public static java.awt.Color getSelectionBackgroundColor(SubstanceTheme theme)
Returns selection background color for the specified theme.

Parameters:
theme - Theme.
Returns:
Selection background color for the specified theme.

getLineColor

public static java.awt.Color getLineColor(SubstanceTheme theme)
Returns line color for the specified theme.

Parameters:
theme - Theme.
Returns:
Line color for the specified theme.

getSelectionForegroundColor

public static java.awt.Color getSelectionForegroundColor(SubstanceTheme theme)
Returns selection foreground color for the specified theme.

Parameters:
theme - Theme.
Returns:
Selection foreground color for the specified theme.

getWatermarkStampColor

public static java.awt.Color getWatermarkStampColor()
Returns the watermark stamp color for the current theme.

Returns:
Watermark stamp color for the current theme.

getWatermarkStampColor

public static java.awt.Color getWatermarkStampColor(SubstanceTheme theme)
Returns the watermark stamp color for the current theme.

Parameters:
theme - Theme.
Returns:
Watermark stamp color for the current theme.

getNegativeColor

public static java.awt.Color getNegativeColor(java.awt.Color color)
Returns a negative of the specified color.

Parameters:
color - Color.
Returns:
Negative of the specified color.

getNegativeColor

public static int getNegativeColor(int rgb)
Returns a negative of the specified color.

Parameters:
rgb - Color RGB.
Returns:
Negative of the specified color.

getWatermarkLightColor

public static java.awt.Color getWatermarkLightColor()
Returns the watermark light color for the current theme.

Returns:
Watermark light color for the current theme.

getWatermarkLightColor

public static java.awt.Color getWatermarkLightColor(SubstanceTheme theme)
Returns the watermark light color for the current theme.

Parameters:
theme - Theme.
Returns:
Watermark light color for the current theme.

getWatermarkLightColor

public static java.awt.Color getWatermarkLightColor(float coef)
Returns the watermark light color for the current theme.

Parameters:
coef - Translucency coefficient.
Returns:
Watermark light color for the current theme.

getWatermarkLightColor

public static java.awt.Color getWatermarkLightColor(SubstanceTheme theme,
                                                    float coef)
Returns the watermark light color for the current theme.

Parameters:
theme - Theme.
coef - Translucency coefficient.
Returns:
Watermark light color for the current theme.

getWatermarkDarkColor

public static java.awt.Color getWatermarkDarkColor()
Returns the watermark dark color for the current theme.

Returns:
Watermark dark color for the current theme.

getWatermarkDarkColor

public static java.awt.Color getWatermarkDarkColor(SubstanceTheme theme)
Returns the watermark dark color for the current theme.

Parameters:
theme - Theme.
Returns:
Watermark dark color for the current theme.

getWatermarkStampColor

public static java.awt.Color getWatermarkStampColor(int alpha)
Returns the watermark stamp color of the specified opacity for the current theme.

Parameters:
alpha - Alpha channel value.
Returns:
Watermark stamp color of the specified opacity for the current theme.

getAlphaColor

public static java.awt.Color getAlphaColor(java.awt.Color color,
                                           int alpha)
Returns a translucent of the specified color.

Parameters:
color - Color.
alpha - Alpha channel value.
Returns:
Translucent of the specified color that matches the requested alpha channel value.

getSaturatedColor

public static java.awt.Color getSaturatedColor(java.awt.Color color,
                                               double factor)
Returns saturated version of the specified color.

Parameters:
color - Color.
factor - Saturation factor.
Returns:
Saturated color.

getHueShiftedColor

public static java.awt.Color getHueShiftedColor(java.awt.Color color,
                                                double hueShift)
Returns hue-shifted (in HSV space) version of the specified color.

Parameters:
color - Color.
hueShift - hue shift factor.
Returns:
Hue-shifted (in HSV space) color.

getForegroundColor

public static java.awt.Color getForegroundColor(SubstanceTheme theme)
Returns the foreground color of the specified theme.

Parameters:
theme - Theme.
Returns:
Theme foreground color.

getLighterColor

public static java.awt.Color getLighterColor(java.awt.Color color,
                                             double diff)
Returns lighter version of the specified color.

Parameters:
color - Color.
diff - Difference factor (values closer to 0.0 will produce results closer to white color).
Returns:
Lighter version of the specified color.

getDarkerColor

public static java.awt.Color getDarkerColor(java.awt.Color color,
                                            double diff)
Returns darker version of the specified color.

Parameters:
color - Color.
diff - Difference factor (values closer to 1.0 will produce results closer to black color).
Returns:
Darker version of the specified color.

getColorBlindColor

public static java.awt.Color getColorBlindColor(java.awt.Color orig,
                                                double[][] rgbToLms,
                                                ColorBlindColorScheme.BlindnessKind kind,
                                                double[][] lmsToRgb)
Converts the specified color into color-blind version.

Parameters:
orig - The original color.
rgbToLms - RGB to LMS conversion matrix.
kind - Color-blindness kind.
lmsToRgb - LMS to RGB conversion matrix.
Returns:
Color-blind version of the original color.

getColorBrightness

public static int getColorBrightness(int rgb)
Returns the brightness of the specified color.

Parameters:
rgb - RGB value of a color.
Returns:
The brightness of the specified color.

getFocusColor

public static java.awt.Color getFocusColor(java.awt.Component comp)
Returns the color of the focus ring for the specified component.

Parameters:
comp - Component.
Returns:
The color of the focus ring for the specified component.

getColorStrength

public static float getColorStrength(java.awt.Color color)
Returns the color strength.

Parameters:
color - Color.
Returns:
Color strength.