public class ModelColor
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int |
B |
static double[] |
BRIGHTNESS_BANDS |
protected int |
G |
protected double |
H |
static int |
NUM_COLOR_RINGS |
static int |
NUM_SEGMENTS |
protected int |
R |
protected double |
rgbMaxValue |
protected double |
rgbMinValue |
protected double |
S |
static double[] |
SATURATION_BANDS |
protected double |
V |
protected boolean |
webSnap |
Constructor and Description |
---|
ModelColor(double H,
double S,
double V) |
ModelColor(int R,
int G,
int B)
Create a new ModelColor
|
ModelColor(int R,
int G,
int B,
int H)
Create a new ModelColor
|
ModelColor(ModelColor c)
Creates a copy of an ModelColor
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
col2Gray(double r,
double g,
double b)
Get a grayscale hex value for an rgb color
|
static java.lang.String |
dec2hex(int n)
Convert a decimal rgb value to a hexadecimal value
|
static ModelColor[][] |
getBaseColors() |
int |
getBlue()
Get the blue value
|
double |
getBrightness()
Get the brightness value
|
int |
getGreen()
Get the green value
|
double |
getH()
Get the hue value
|
int |
getHue()
Get the hue value
|
int |
getRed()
Get the red value
|
double |
getSaturation()
Get the saturation value
|
static int |
hex2dec(java.lang.String n)
Convert a hexadecimal rgb value to a decimal value
|
void |
rotate(int angle)
Rotate this color by a specified amount
|
void |
setHSV(double _h,
double _s,
double _v)
Set the color to a HSV value
|
void |
setRGB(int R,
int G,
int B)
Set an RGB color
|
void |
setRGB(int r,
int g,
int b,
int h)
Set an RGB color
|
void |
setWebSnap(boolean snapTo)
Set the snap to web colors setting
|
static java.lang.String |
toHexString(int value)
Get a two letter hex string for the decimal value in the range 0-255
|
public static final int NUM_COLOR_RINGS
public static final int NUM_SEGMENTS
protected boolean webSnap
protected int R
protected int G
protected int B
protected double H
protected double S
protected double V
protected double rgbMinValue
protected double rgbMaxValue
public static double[] SATURATION_BANDS
public static double[] BRIGHTNESS_BANDS
public ModelColor(int R, int G, int B)
R
- the red value in the range 0-255G
- the green value in the range 0-255B
- the blue value in the range 0-255public ModelColor(double H, double S, double V)
public ModelColor(int R, int G, int B, int H)
R
- the red value in the range 0-255G
- the green value in the range 0-255B
- the blue value in the range 0-255H
- the hue value in the range 0-255public ModelColor(ModelColor c)
c
- the ModelColor to copypublic int getRed()
public int getGreen()
public int getBlue()
public int getHue()
public double getH()
public double getSaturation()
public double getBrightness()
public void setRGB(int R, int G, int B)
R
- the red value in the range 0-255G
- the green value in the range 0-255B
- the blue value in the range 0-255public void setRGB(int r, int g, int b, int h)
R
- the red value in the range 0-255G
- the green value in the range 0-255B
- the blue value in the range 0-255H
- the hue value in the range 0-255public void setHSV(double _h, double _s, double _v)
_h
- the hue_s
- the saturation_v
- the valuepublic void rotate(int angle)
angle
- the angle by which to move this color (hue)public void setWebSnap(boolean snapTo)
snapTo
- true to snap to web colorspublic static java.lang.String dec2hex(int n)
n
- the decimal valuepublic static int hex2dec(java.lang.String n)
n
- the hex valuepublic static java.lang.String toHexString(int value)
public static java.lang.String col2Gray(double r, double g, double b)
r
- the red valueg
- the green valueb
- the blue valuepublic static ModelColor[][] getBaseColors()