public final class Color
extends java.lang.Object
int
in the format 0x00RRGGBB.
A color is defined as a mixture of red, green and blue color values. Each value is in the range of 0 to 255 where 0 is darkest and 255 is brightest. For example, Color(255, 0, 0) is the color red.
Here are some more examples:
Modifier and Type | Field and Description |
---|---|
static int |
BLACK |
static int |
BLUE |
static int |
BRIGHT |
static int |
CYAN |
static int |
DARK |
static int |
FULL_STEP
Increase or decrease all RGB values by 96.
|
static int |
GREEN |
static int |
HALF_STEP
Increase or decrease all RGB values by 48.
|
static int |
LESS_STEP
Increase or decrease all RGB values by 32.
|
static int |
MAGENTA |
static int |
ORANGE |
static int |
PINK |
static int |
RED |
static int |
WHITE |
static int |
YELLOW |
Modifier and Type | Method and Description |
---|---|
static int |
brighter(int rgb)
Returns a color that is brighter than the current one.
|
static int |
brighter(int rgb,
int step)
Returns a color that is brighter than the current one.
|
static int |
darker(int rgb)
Return a color that is darker than the current one.
|
static int |
darker(int rgb,
int step)
Returns a color that is darker than the current one.
|
static int |
getAlpha(int rgb)
Deprecated.
|
static int |
getBetterContrast(int original,
int color1,
int color2)
Returns a color that better contrasts with the given original color.
|
static int |
getBlue(int rgb)
Returns the blue value of the color.
|
static int |
getBrightness(int rgb)
Returns the brightness value of a color, in the range 0-255.
|
static int |
getCursorColor(int rgb)
Returns the best cursor color depending on this color
|
static int |
getCursorColor(int rgb,
int step)
Returns the best cursor color depending on this color
|
static int |
getGray(int c)
Returns a gray color based on the given one
|
static int |
getGreen(int rgb)
Returns the green value of the color.
|
static int |
getInvertedGray(int c)
Returns an inverted gray color based on the given one (255 - gray)
|
static int |
getRandomColor(Random r)
Returns a random color.
|
static int |
getRed(int rgb)
Returns the red value of the color.
|
static int |
getRGB(int red,
int green,
int blue)
Returns a color integer value with the given red, green and blue components.
|
static int |
getRGB(java.lang.String rrggbb)
Returns a color integer value parsing the given rgb.
|
static int |
getRGBEnsureRange(int red,
int green,
int blue)
Returns a color integer value with the given red, green and blue components,
ensuring that the values are within the 0-255 range.
|
static int |
interpolate(int color1,
int color2)
Interpolates the given colors.
|
static int |
interpolate(int color1,
int color2,
int factor)
Interpolates the given colors by the given factor, ranging from 0 to 100.
|
static int |
interpolateA(int color1,
int color2,
int factor)
Interpolates the given colors by the given factor, ranging from 0 to 255.
|
static int |
PremultiplyAlpha(int color,
int backColor,
int alpha) |
static java.lang.String |
toString(int rgb)
Returns the string representation of this color: the rgb in hexadecimal
|
public static final int WHITE
public static final int BRIGHT
public static final int DARK
public static final int BLACK
public static final int RED
public static final int PINK
public static final int ORANGE
public static final int YELLOW
public static final int GREEN
public static final int MAGENTA
public static final int CYAN
public static final int BLUE
public static final int FULL_STEP
public static final int LESS_STEP
public static final int HALF_STEP
public static int getRGB(int red, int green, int blue)
red
- the red value in the range of 0 to 255green
- the green value in the range of 0 to 255blue
- the blue value in the range of 0 to 255public static int getRGBEnsureRange(int red, int green, int blue)
red
- the red value in any rangegreen
- the green value in any rangeblue
- the blue value in any rangepublic static int getRGB(java.lang.String rrggbb)
rrggbb
- a string in the format RRGGBB (colors in hex).@Deprecated public static int getAlpha(int rgb)
getBrightness(int)
public static int getBlue(int rgb)
public static int getGreen(int rgb)
public static int getRed(int rgb)
public static int brighter(int rgb)
public static int darker(int rgb)
public static int getBrightness(int rgb)
public static int getCursorColor(int rgb)
public static int getCursorColor(int rgb, int step)
public static int brighter(int rgb, int step)
public static int darker(int rgb, int step)
public static java.lang.String toString(int rgb)
public static int interpolate(int color1, int color2)
public static int interpolate(int color1, int color2, int factor)
public static int interpolateA(int color1, int color2, int factor)
public static int getBetterContrast(int original, int color1, int color2)
public static int getRandomColor(Random r)
Random r = new Random(); for (int i = 0; i < tt.length; i++) tabPanel.getContainer(i).setBackColor(Color.getRandomColor(r));
public static int getGray(int c)
public static int getInvertedGray(int c)
public static int PremultiplyAlpha(int color, int backColor, int alpha)