Oracle UIX API Reference
Release 2.1.22.0.0
B12196-01

oracle.cabo.image.painter
Class ColorUtils

java.lang.Object
  |
  +--oracle.cabo.image.painter.ColorUtils

public class ColorUtils
extends java.lang.Object

The ColorUtils Class includes class functions for performing operations on colors.


Field Summary
static int DEFAULT_LIGHTER_CHANGE
          A good amount to modify a base color in order to calculate a lighter color, equal to approximately 20% luminosity, when calling getShadeColor().
static double NTSC_WEIGHT_BLUE
          NTSC-specified weight to use for blue RGB component when converting to luminance.
static double NTSC_WEIGHT_GREEN
          NTSC-specified weight to use for green RGB component when converting to luminance.
static double NTSC_WEIGHT_RED
          NTSC-specified weight to use for red RGB component when converting to luminance.
 
Constructor Summary
ColorUtils()
           
 
Method Summary
static java.awt.Color darkerShadeColor(java.awt.Color baseColor)
          Convenience function that calls shadeColor() to return a darker color given a base color.
static int getApproximateLuminance(java.awt.Color color)
          Returns the approximate luminosity of the color as an integer between 0 and 255, where 0 is black and 255 is white.
static double getNTSCLuminance(java.awt.Color color)
          Returns the luminosity of the color as a double between 0.0 and 1.0, where 0.0 is black and 1.0 is white, using the NTSC contribution weights (.299, .587, .144) for the red, green, and blue components.
static java.awt.Color lighterShadeColor(java.awt.Color baseColor)
          Convenience function that calls shadeColor() to return a lighter color given a base color.
static java.awt.Color shadeColor(java.awt.Color baseColor, int change)
          Given a base color, returns a new shade given a base color and an amount to change.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NTSC_WEIGHT_RED

public static final double NTSC_WEIGHT_RED
NTSC-specified weight to use for red RGB component when converting to luminance.

NTSC_WEIGHT_GREEN

public static final double NTSC_WEIGHT_GREEN
NTSC-specified weight to use for green RGB component when converting to luminance.

NTSC_WEIGHT_BLUE

public static final double NTSC_WEIGHT_BLUE
NTSC-specified weight to use for blue RGB component when converting to luminance.

DEFAULT_LIGHTER_CHANGE

public static final int DEFAULT_LIGHTER_CHANGE
A good amount to modify a base color in order to calculate a lighter color, equal to approximately 20% luminosity, when calling getShadeColor(). A good darker color can be found by using -DEFAULT_LIGHTER_CHANGE.

Constructor Detail

ColorUtils

public ColorUtils()
Method Detail

getApproximateLuminance

public static int getApproximateLuminance(java.awt.Color color)
Returns the approximate luminosity of the color as an integer between 0 and 255, where 0 is black and 255 is white. This approximation is based on NTSC but rather than the NTSC contribution weights (.299, .587, .144) for red, green, and blue, this uses (.25, .50, .25) for speed.

Parameters:
color - The color to return the approximate luminance of.

See Also:
getNTSCLuminance(java.awt.Color)

getNTSCLuminance

public static double getNTSCLuminance(java.awt.Color color)
Returns the luminosity of the color as a double between 0.0 and 1.0, where 0.0 is black and 1.0 is white, using the NTSC contribution weights (.299, .587, .144) for the red, green, and blue components.

Parameters:
color - The color to return the NTSC luminance of.

See Also:
getApproximateLuminance(java.awt.Color)

shadeColor

public static java.awt.Color shadeColor(java.awt.Color baseColor,
                                        int change)
Given a base color, returns a new shade given a base color and an amount to change. In order to avoid problems caused by clipping the colors at either end of the luminosity range, shadeColor() uses the base color's luminosity to determine how to modify the change amount passed in.

Parameters:
baseColor - The color to return the new shade of
change - The proposed amount to change each component of the baseColor. Depending on the baseColor's luminance, the actual amount the baseColor's components are changed may differ. The valid range for this value is -255 to 255.

See Also:
lighterShadeColor(java.awt.Color), darkerShadeColor(java.awt.Color)

lighterShadeColor

public static final java.awt.Color lighterShadeColor(java.awt.Color baseColor)
Convenience function that calls shadeColor() to return a lighter color given a base color.

Parameters:
baseColor - Color to return a lighter shade of

See Also:
shadeColor(java.awt.Color, int), darkerShadeColor(java.awt.Color)

darkerShadeColor

public static final java.awt.Color darkerShadeColor(java.awt.Color baseColor)
Convenience function that calls shadeColor() to return a darker color given a base color.

Parameters:
baseColor - Color to return a darker shade of

See Also:
shadeColor(java.awt.Color, int), lighterShadeColor(java.awt.Color)

Oracle UIX API Reference
Release 2.1.22.0.0
B12196-01

Copyright © 2002,2003, Oracle. All Rights Reserved.