gui.run
Class ColorUtils

java.lang.Object
  extended by gui.run.ColorUtils

public class ColorUtils
extends java.lang.Object


Constructor Summary
ColorUtils()
           
 
Method Summary
static java.lang.String getColorHexString(java.awt.Color c)
           
static java.awt.Color removeAlpha(java.awt.Color color)
          Returns a new color equal to the old one, except that there is no alpha channel (transparency).
static java.awt.Color setAlpha(java.awt.Color col, int alpha)
          Modifies the passed in color by setting a new alpha channel (transparency) and returns the new color.
static java.awt.Color setBrightness(java.awt.Color color, float brightness)
          Modifies the passed in color by changing it's brightness using HSB calculations.
static java.lang.String toHexString(java.awt.Color color)
          Produces a String representing the passed in color as a hex value (including the #) suitable for use in html.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorUtils

public ColorUtils()
Method Detail

getColorHexString

public static java.lang.String getColorHexString(java.awt.Color c)

toHexString

public static java.lang.String toHexString(java.awt.Color color)
Produces a String representing the passed in color as a hex value (including the #) suitable for use in html. It does not include the alpha (transparency) channel in the string.

Parameters:
color - the color to convert
Returns:
the hex String

removeAlpha

public static java.awt.Color removeAlpha(java.awt.Color color)
Returns a new color equal to the old one, except that there is no alpha channel (transparency).

Parameters:
color - the color to remove the alpha (transparency) from
Returns:
Color

setAlpha

public static java.awt.Color setAlpha(java.awt.Color col,
                                      int alpha)
Modifies the passed in color by setting a new alpha channel (transparency) and returns the new color.

Parameters:
col - the color to modify
alpha - the new alpha (transparency) level. Must be an int between 0 and 255
Returns:
the new Color

setBrightness

public static java.awt.Color setBrightness(java.awt.Color color,
                                           float brightness)
Modifies the passed in color by changing it's brightness using HSB calculations. The brightness must be a float between 0 and 1. If 0 the resulting color will be black. If 1 the resulting color will be the brightest possible form of the passed in color.

Parameters:
color - the color to modify
brightness - the brightness to use in the new color
Returns:
the new Color