org.jdesktop.swingx.color
Class ColorUtil

java.lang.Object
  extended by org.jdesktop.swingx.color.ColorUtil

public class ColorUtil
extends Object


Constructor Summary
ColorUtil()
           
 
Method Summary
static Paint getCheckerPaint()
          Obtain a java.awt.Paint instance which draws a checker background of black and white.
static Paint getCheckerPaint(Color c1, Color c2, int size)
           
static Color interpolate(Color b, Color a, float t)
           
static Color removeAlpha(Color color)
          Returns a new color equal to the old one, except that there is no alpha channel (transparency).
static Color setAlpha(Color col, int alpha)
          Modifies the passed in color by setting a new alpha channel (transparency) and returns the new color.
static Color setBrightness(Color color, float brightness)
          Modifies the passed in color by changing it's brightness using HSB calculations.
static Color setSaturation(Color color, float saturation)
           
static void tileStretchPaint(Graphics g, JComponent comp, BufferedImage img, Insets ins)
          Draws an image on top of a component by doing a 3x3 grid stretch of the image using the specified insets.
static String toHexString(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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorUtil

public ColorUtil()
Method Detail

removeAlpha

public static Color removeAlpha(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 Color setAlpha(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 Color setBrightness(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

toHexString

public static String toHexString(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

getCheckerPaint

public static Paint getCheckerPaint()
Obtain a java.awt.Paint instance which draws a checker background of black and white. Note: The returned instance may be shared. Note: This method should be reimplemented to not use a png resource.

Returns:
a Paint implementation

getCheckerPaint

public static Paint getCheckerPaint(Color c1,
                                    Color c2,
                                    int size)

tileStretchPaint

public static void tileStretchPaint(Graphics g,
                                    JComponent comp,
                                    BufferedImage img,
                                    Insets ins)
Draws an image on top of a component by doing a 3x3 grid stretch of the image using the specified insets.


setSaturation

public static Color setSaturation(Color color,
                                  float saturation)

interpolate

public static Color interpolate(Color b,
                                Color a,
                                float t)