|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.XObject
edu.neu.ccs.XColor
Object wrapper for the Color class
that also provides
capabilities.
The default value for this class is
the StringableColor representation of black,
.Color.black
| Field Summary | |
private Color |
color
The wrapped color for this object. |
| Fields inherited from class edu.neu.ccs.XObject |
changeAdapter, VALUE |
| Constructor Summary | |
XColor()
Constructs a wrapper for the default Color value. |
|
XColor(Color c)
Constructs a wrapper for the given Color value. |
|
XColor(float r,
float g,
float b)
Constructs a wrapper for the Color constructed
from the specified red, green, and blue values in the range
[0.0, 1.0]. |
|
XColor(float r,
float g,
float b,
float a)
Constructs a wrapper for the Color constructed
from the specified red, green, blue, and alpha values in the
range [0.0, 1.0]. |
|
XColor(int r,
int g,
int b)
Constructs a wrapper for the Color constructed
from the specified red, green, and blue values in the range
[0, 255]. |
|
XColor(int r,
int g,
int b,
int a)
Constructs a wrapper for the Color constructed
from the specified red, green, blue, and alpha values in the
range [0, 255]. |
|
XColor(String s)
Constructs a wrapper for the Color value
whose state information is encapsulated in the given
String data. |
|
| Method Summary | |
static String |
colorToString(Color color)
Returns a String encapsulation of the
Color parameter that contains the
int values of red, green, blue, (and possibly alpha)
each in the range [0, 255]. |
boolean |
equals(Object other)
Returns true if other is of class
XColor and if the wrapped color of this object
and the wrapped color of other are equal. |
void |
fromStringData(String data)
Sets the state of the XColor object using
information contained in the given String. |
static Color |
getColor(String data)
Gets a Color value from a data String
if the data is valid or returns null. |
private Color |
getColorFromDecimal(String data)
Returns the Color expressed in decimal data or throws a ParseException. |
private Color |
getColorFromHexidecimal(String data)
Returns the Color expressed in hexidecimal data or throws a ParseException. |
Color |
getValue()
Returns the value wrapped by this object. |
int |
hashCode()
Returns an int hash code
appropriate for the wrapped color. |
static Color |
parseColor(String data)
Gets a Color value from a data String
if the data is valid or throws a
ParseException. |
void |
setValue(Color c)
Sets the value wrapped by this object to the given Color value. |
void |
setValue(float r,
float g,
float b)
Sets the wrapped value to the Color constructed
from the specified red, green, and blue values in the range
[0.0, 1.0]. |
void |
setValue(float r,
float g,
float b,
float a)
Sets the wrapped value to the Color constructed
from the specified red, green, blue, and alpha values in the
range [0.0, 1.0]. |
void |
setValue(int r,
int g,
int b)
Sets the wrapped value to the Color constructed
from the specified red, green, and blue values in the range
[0, 255]. |
void |
setValue(int r,
int g,
int b,
int a)
Sets the wrapped value to the Color constructed
from the specified red, green, blue, and alpha values in the
range [0, 255]. |
static Color[] |
toPrimitiveArray(XColor[] x)
Returns an array of Color objects
copied from the given array
of XColor objects. |
String |
toString()
Returns a String representation
of the wrapped value. |
String |
toStringData()
Returns a String encapsulation of the
XColor object that contains the
int values of red, green, blue, (and possibly alpha)
each in the range [0, 255]. |
static XColor[] |
toXArray(Color[] a)
Returns an array of XColor objects
initialized from the given array
of Color objects. |
| Methods inherited from class edu.neu.ccs.XObject |
addPropertyChangeListener, addPropertyChangeListener, formatErrorMessage, removePropertyChangeListener, removePropertyChangeListener, toStringArray |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
private Color color
| Constructor Detail |
public XColor()
Color value.
XColor(Color),
XColor(int, int, int),
XColor(int, int, int, int),
XColor(float, float, float),
XColor(float, float, float, float),
XColor(String)public XColor(Color c)
Color value.
c - the value to be wrappedXColor(),
XColor(int, int, int),
XColor(int, int, int, int),
XColor(float, float, float),
XColor(float, float, float, float),
XColor(String)
public XColor(int r,
int g,
int b)
Color constructed
from the specified red, green, and blue values in the range
[0, 255].
r - the red value in the range [0, 255]g - the green value in the range [0, 255]b - the blue value in the range [0, 255]XColor(),
XColor(Color),
XColor(int, int, int, int),
XColor(float, float, float),
XColor(float, float, float, float),
XColor(String)
public XColor(int r,
int g,
int b,
int a)
Color constructed
from the specified red, green, blue, and alpha values in the
range [0, 255].
r - the red value in the range [0, 255]g - the green value in the range [0, 255]b - the blue value in the range [0, 255]a - the alpha value in the range [0, 255]XColor(),
XColor(Color),
XColor(int, int, int),
XColor(float, float, float),
XColor(float, float, float, float),
XColor(String)
public XColor(float r,
float g,
float b)
Color constructed
from the specified red, green, and blue values in the range
[0.0, 1.0].
r - the red value in the range [0.0, 1.0]g - the green value in the range [0.0, 1.0]b - the blue value in the range [0.0, 1.0]XColor(),
XColor(Color),
XColor(int, int, int),
XColor(int, int, int, int),
XColor(float, float, float, float),
XColor(String)
public XColor(float r,
float g,
float b,
float a)
Color constructed
from the specified red, green, blue, and alpha values in the
range [0.0, 1.0].
r - the red value in the range [0.0, 1.0]g - the green value in the range [0.0, 1.0]b - the blue value in the range [0.0, 1.0]a - the alpha value in the range [0.0, 1.0]XColor(),
XColor(Color),
XColor(int, int, int),
XColor(int, int, int, int),
XColor(float, float, float),
XColor(String)
public XColor(String s)
throws ParseException
Color value
whose state information is encapsulated in the given
String data.
s - a String representation
of the desired value
ParseException - if the data is malformedXColor(),
XColor(Color),
XColor(int, int, int),
XColor(int, int, int, int),
XColor(float, float, float),
XColor(float, float, float, float)| Method Detail |
public void fromStringData(String data)
throws ParseException
Sets the state of the XColor object using
information contained in the given String.
The following formats are supported for input of a color using a text string.
Data format 1: A comma and/or blank separated text
string with 3 int components:
red, green, blue
or 4 int components:
red, green, blue, alpha.
The int components should be in the range
[0, 255].
If the alpha component is omitted then it is assumed to be 255.
Data format 2: A String of the form
#rRgGbB or #rRgGbBaA
where r, R, g, G, b, B, a, A are hex digits with
red = rR,
green = gG,
blue = bB,
alpha = aA.
Data format 3: A String of the form
#rgb or #rgba that is interpreted as
#rrggbb or #rrggbbaa respectively.
Data format 4: A color name that is contained in
the internal static structure of the class
Colors. An array with the currently valid
installed color names can be obtained via the call:
Colors.getColorNamesAsArray()
fromStringData in interface StringablefromStringData in class XObjectdata - the String containing color information
ParseException - if the data is malformedtoStringData()
private Color getColorFromDecimal(String data)
throws ParseException
data - the String that may contain decimal color information
ParseException
private Color getColorFromHexidecimal(String data)
throws ParseException
data - the String that may contain hexidecimal color information
ParseExceptionpublic String toStringData()
Returns a String encapsulation of the
XColor object that contains the
int values of red, green, blue, (and possibly alpha)
each in the range [0, 255].
The alpha component is omitted if it is equal to 255.
toStringData in interface StringabletoStringData in class XObjectfromStringData(String)public String toString()
String representation
of the wrapped value.
public boolean equals(Object other)
true if other is of class
XColor and if the wrapped color of this object
and the wrapped color of other are equal.
other - the object to be compared with the wrapped objectpublic int hashCode()
int hash code
appropriate for the wrapped color.
public void setValue(Color c)
Color value.
If null, the value is set to
Color.black.
c - the value to be wrappedsetValue(int, int, int),
setValue(int, int, int, int),
setValue(float, float, float),
setValue(float, float, float, float),
getValue()
public void setValue(int r,
int g,
int b)
Color constructed
from the specified red, green, and blue values in the range
[0, 255].
r - the red value in the range [0, 255]g - the green value in the range [0, 255]b - the blue value in the range [0, 255]setValue(Color),
setValue(int, int, int, int),
setValue(float, float, float),
setValue(float, float, float, float),
getValue()
public void setValue(int r,
int g,
int b,
int a)
Color constructed
from the specified red, green, blue, and alpha values in the
range [0, 255].
r - the red value in the range [0, 255]g - the green value in the range [0, 255]b - the blue value in the range [0, 255]a - the alpha value in the range [0, 255]setValue(Color),
setValue(int, int, int),
setValue(float, float, float),
setValue(float, float, float, float),
getValue()
public void setValue(float r,
float g,
float b)
Color constructed
from the specified red, green, and blue values in the range
[0.0, 1.0].
r - the red value in the range [0.0, 1.0]g - the green value in the range [0.0, 1.0]b - the blue value in the range [0.0, 1.0]setValue(Color),
setValue(int, int, int),
setValue(int, int, int, int),
setValue(float, float, float, float),
getValue()
public void setValue(float r,
float g,
float b,
float a)
Color constructed
from the specified red, green, blue, and alpha values in the
range [0.0, 1.0].
setValue(Color),
setValue(int, int, int),
setValue(int, int, int, int),
setValue(float, float, float),
getValue()public Color getValue()
setValue(Color),
setValue(int, int, int),
setValue(int, int, int, int),
setValue(float, float, float),
setValue(float, float, float, float)public static Color getColor(String data)
Gets a Color value from a data String
if the data is valid or returns null.
data - the String to parse
public static Color parseColor(String data)
throws ParseException
Gets a Color value from a data String
if the data is valid or throws a
ParseException.
data - the String to parse
ParseException - if the data is invalidpublic static String colorToString(Color color)
Returns a String encapsulation of the
Color parameter that contains the
int values of red, green, blue, (and possibly alpha)
each in the range [0, 255].
The alpha component is omitted if it is equal to 255.
color - the color to represent as a stringpublic static Color[] toPrimitiveArray(XColor[] x)
Color objects
copied from the given array
of XColor objects.
x - an array of XColors
Color objectstoXArray(Color[])public static XColor[] toXArray(Color[] a)
XColor objects
initialized from the given array
of Color objects.
a - an array of Colors
XColor objectstoPrimitiveArray(XColor[])
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||