|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jdesktop.swingx.color.ColorUtil
public class ColorUtil
A collection of utility methods for working with Color
s.
Constructor Summary | |
---|---|
ColorUtil()
|
Method Summary | |
---|---|
static java.awt.Paint |
getCheckerPaint()
Obtain a java.awt.Paint instance which draws a checker
background of black and white. |
static java.awt.Paint |
getCheckerPaint(java.awt.Color c1,
java.awt.Color c2,
int size)
|
static java.awt.Color |
interpolate(java.awt.Color b,
java.awt.Color a,
float t)
|
static java.awt.Color |
removeAlpha(java.awt.Color color)
Returns a new color equal to the old one, except that there is no alpha (transparency) channel. |
static java.awt.Color |
setAlpha(java.awt.Color color,
int alpha)
Returns a new color equal to the old one, except alpha (transparency) channel is set to the new value. |
static java.awt.Color |
setBrightness(java.awt.Color color,
float brightness)
Returns a new color equal to the old one, except the brightness is set to the new value. |
static java.awt.Color |
setSaturation(java.awt.Color color,
float saturation)
Returns a new color equal to the old one, except the saturation is set to the new value. |
static void |
tileStretchPaint(java.awt.Graphics g,
javax.swing.JComponent comp,
java.awt.image.BufferedImage img,
java.awt.Insets ins)
Draws an image on top of a component by doing a 3x3 grid stretch of the image using the specified insets. |
static java.lang.String |
toHexString(java.awt.Color color)
Creates a String that represents the supplied color as a
hex-value RGB triplet, including the "#". |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ColorUtil()
Method Detail |
---|
public static java.awt.Color removeAlpha(java.awt.Color color)
This method is a convenience and has the same effect as setAlpha(color, 255)
.
color
- the color to remove the alpha (transparency) from
Color
java.lang.NullPointerException
- if color
is null
public static java.awt.Color setAlpha(java.awt.Color color, int alpha)
color
- the color to modifyalpha
- the new alpha (transparency) level. Must be an int between 0
and 255
Color
java.lang.IllegalArgumentException
- if alpha
is not between 0 and 255 inclusive
java.lang.NullPointerException
- if color
is null
public static java.awt.Color setSaturation(java.awt.Color color, float saturation)
The color is modified using HSB calculations. The saturation must be a float between 0 and 1. If 0 the resulting color will be gray. If 1 the resulting color will be the most saturated possible form of the passed in color.
color
- the color to modifysaturation
- the saturation to use in the new color
Color
java.lang.IllegalArgumentException
- if saturation
is not between 0 and 1 inclusive
java.lang.NullPointerException
- if color
is null
public static java.awt.Color setBrightness(java.awt.Color color, float brightness)
The color is modified 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.
color
- the color to modifybrightness
- the brightness to use in the new color
Color
java.lang.IllegalArgumentException
- if brightness
is not between 0 and 1 inclusive
java.lang.NullPointerException
- if color
is null
public static java.lang.String toHexString(java.awt.Color color)
String
that represents the supplied color as a
hex-value RGB triplet, including the "#". The return value is suitable
for use in HTML. The alpha (transparency) channel is neither include nor
used in producing the string.
color
- the color to convert
String
public static java.awt.Paint getCheckerPaint()
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.
public static java.awt.Paint getCheckerPaint(java.awt.Color c1, java.awt.Color c2, int size)
public static void tileStretchPaint(java.awt.Graphics g, javax.swing.JComponent comp, java.awt.image.BufferedImage img, java.awt.Insets ins)
TODO this is image related; move to GraphicsUtilities
public static java.awt.Color interpolate(java.awt.Color b, java.awt.Color a, float t)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |