public class ColorRgb
extends java.lang.Object
implements java.io.Externalizable
Modifier and Type | Field and Description |
---|---|
static ColorRgb |
BLACK
A constant for black color.
|
private int |
blue
Blue value
|
static ColorRgb |
BLUE
A constant for pure blue color.
|
static ColorRgb |
CYAN
A constant for cyan color.
|
static ColorRgb |
GRAY
A constant for medium gray color.
|
private int |
green
Green value
|
static ColorRgb |
GREEN
A constant for pure green.
|
static ColorRgb |
MAGENTA
A constant for magenta color.
|
private java.lang.String |
name
Color name
|
private int |
red
Red value
|
static ColorRgb |
RED
A constant for pure red color.
|
static ColorRgb |
WHITE
A constant for white color.
|
static ColorRgb |
YELLOW
A constant for yellow color.
|
Constructor and Description |
---|
ColorRgb()
Constructor.
|
ColorRgb(java.awt.Color color)
Constructor.
|
ColorRgb(ColorRgb rgb)
Copy constructor.
|
ColorRgb(int rgbColor)
Constructor.
|
ColorRgb(int red,
int green,
int blue)
Constructor.
|
ColorRgb(int red,
int green,
int blue,
java.lang.String name)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
asHexString()
Return a string with the RGB value in "0xRRGGBB" format where the red, green and
blue values are each encoded as 2 hexadecimal digits.
|
java.lang.String |
asString()
Return a RGB as string comma separated.
|
boolean |
equals(java.lang.Object obj)
Reports if the given object is the same color as this instance.
|
static ColorRgb |
fromHSL(ColorHSL hslColor)
Creates a new RGB color from a set of HSL values.
|
static ColorRgb |
fromString(java.lang.String rgb,
ColorRgb def)
Helper to take a Java compatible color definition and create a new instance of this class.
|
int |
getBlue()
Get blue value.
|
int |
getGreen()
Get green value.
|
int |
getGuiRgb()
Get a combination of red, green and blue value Java compliant.
|
protected java.lang.String |
getName()
Get color name.
|
int |
getRed()
Get red value.
|
int |
getRgb()
Get a combination of red, green and blue value P4GL compliant.
|
int |
hashCode()
Calculate hash code compatible with equals()
|
void |
readExternal(java.io.ObjectInput in)
Replacement for the default object reading method.
|
void |
setBlue(int blue)
Set blue value.
|
void |
setGreen(int green)
Set green value.
|
void |
setGuiRgb(int rgb)
Set color values form a RGB value using Java parsing of the integer.
|
protected void |
setName(java.lang.String name)
Set color name.
|
void |
setRed(int red)
Set red value.
|
void |
setRgb(int rgb)
Set color values form a RGB value using Progress 4GL parsing of the integer.
|
ColorHSL |
toHSL()
Converts this color to HSL equivalent.
|
void |
writeExternal(java.io.ObjectOutput out)
Replacement for the default object writing method.
|
private int red
private int green
private int blue
private java.lang.String name
public static final ColorRgb BLACK
public static final ColorRgb GRAY
public static final ColorRgb BLUE
public static final ColorRgb GREEN
public static final ColorRgb CYAN
public static final ColorRgb RED
public static final ColorRgb MAGENTA
public static final ColorRgb YELLOW
public static final ColorRgb WHITE
public ColorRgb()
public ColorRgb(int red, int green, int blue)
red
- Red value.green
- Green value.blue
- Blue value.public ColorRgb(int red, int green, int blue, java.lang.String name)
red
- Red value.green
- Green value.blue
- Blue value.name
- Color name.public ColorRgb(ColorRgb rgb)
rgb
- ColorRgb copy.public ColorRgb(java.awt.Color color)
color
parameter.color
- An java awt color.public ColorRgb(int rgbColor)
rgbColor
parameter.rgbColor
- An integer that hold the color information in ARBG format. Alpha chanel is ignored.public static ColorRgb fromString(java.lang.String rgb, ColorRgb def)
rgb
- Color in octal, hexadecimal (0xFFFFFF or #FFFFFF) or decimal format. This uses
Integer.decode()
to create the integer that is then split into
rgb values.def
- Value to copy if the string input is invalid.public int getRed()
public void setRed(int red)
red
- New red valuepublic int getGreen()
public void setGreen(int green)
green
- New green value.public int getBlue()
public void setBlue(int blue)
blue
- New blue value.public int getRgb()
public void setRgb(int rgb)
rgb
- A combination of red, green and blue value.public int getGuiRgb()
public void setGuiRgb(int rgb)
rgb
- A combination of red, green and blue value.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- The object to compare.true
if the objects are equivalent, false
if the given
instance is null
, is not an instance of this class or if its rgb
value is not equivalent.public int hashCode()
hashCode
in class java.lang.Object
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
in
- The input source from which fields will be restored.java.io.IOException
- In case of I/O errors.java.lang.ClassNotFoundException
- If payload can't be instantiated.public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
out
- The output destination to which fields will be saved.java.io.IOException
- In case of I/O errors.public java.lang.String asString()
public java.lang.String asHexString()
protected java.lang.String getName()
protected void setName(java.lang.String name)
name
- Color name.public static ColorRgb fromHSL(ColorHSL hslColor)
ColorHSL.toRGB()
.ColorRgb
color equivalent to hslColor
.public ColorHSL toHSL()
ColorHSL.fromRGB(com.goldencode.p2j.ui.ColorRgb)
;