org.vizzini.ui
Class ColorUtilities

java.lang.Object
  extended by org.vizzini.ui.ColorUtilities

public class ColorUtilities
extends Object

Provides utility methods for dealing with Color objects.

Since:
v0.1
Version:
v0.3
Author:
Jeffrey M. Thompson

Constructor Summary
ColorUtilities()
           
 
Method Summary
static Color blend(Color color0, Color color1)
          Blend the given colors.
static Color brighter(Color color)
          Return a color brighter than the given color.
static Color complement(Color color)
          Return the complementary color.
static Color convertFromString(String colorDesc)
          Return a Color object described by the given String.
static String convertToString(Color color)
          Return a String description of the given color.
static Color darker(Color color)
          Return a color darker than the given color.
static String toString(Color color)
          Return a formatted String describing the given Color.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorUtilities

public ColorUtilities()
Method Detail

blend

public static Color blend(Color color0,
                          Color color1)
Blend the given colors.

Since:
v0.1

brighter

public static Color brighter(Color color)
Return a color brighter than the given color. The method calls brighter( darker( color ) ) will NOT return the original color due to rounding and color component limits. Note that Color.WHITE can't get any brighter.

Parameters:
color - The color of interest.
Throws:
IllegalArgumentException - if color is null.
Since:
v0.1
See Also:
darker(java.awt.Color)

complement

public static Color complement(Color color)
Return the complementary color.

Since:
v0.1

convertFromString

public static Color convertFromString(String colorDesc)
Return a Color object described by the given String. The method calls convertFromString(convertToString( color ) ) return the original color.

Parameters:
colorDesc - A String description of a color.
Throws:
IllegalArgumentException - if colorDesc is null.
IllegalArgumentException - if the integers in colorDesc are outside the range [0,255].
NumberFormatException - if the description is improperly formatted.
Since:
v0.1
See Also:
convertToString(java.awt.Color)

convertToString

public static String convertToString(Color color)
Return a String description of the given color. The method calls convertToString( convertFromString( string ) ) return the original string.

Parameters:
color - The color of interest.
Throws:
IllegalArgumentException - if color is null.
Since:
v0.1
See Also:
convertFromString(java.lang.String)

darker

public static Color darker(Color color)
Return a color darker than the given color. The method calls darker( brighter( color ) ) will NOT return the original color due to rounding and color component limits. Note that Color.BLACK can't get any darker.

Parameters:
color - The color of interest.
Throws:
IllegalArgumentException - if color is null.
Since:
v0.1
See Also:
brighter(java.awt.Color)

toString

public static String toString(Color color)
Return a formatted String describing the given Color. This method mimics the behavior of java.awt.Color.toString() with the addition of the alpha component.

Parameters:
color - The color of interest.
Throws:
IllegalArgumentException - if color is null.
Since:
v0.1


Copyright 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02