de.enough.polish.ui
Class Color

java.lang.Object
  extended by de.enough.polish.ui.Color
All Implemented Interfaces:
Serializable

public class Color
extends java.lang.Object
implements Serializable

Wraps an (A)RGB color and can also contain dynamic references like Display.COLOR_BACKGROUND.

For compatibility with MIDP 1.0 devices, the color class also defines COLOR_BACKGROUND etc with the very same values.

Copyright Enough Software 2006 - 2008

 history
        06-Jun-2006 - rob creation
 

Author:
Robert Virkus, j2mepolish@enough.de

Field Summary
static int COLOR_BACKGROUND
          A color specifier for use with getColor.
static int COLOR_BORDER
          A color specifier for use with getColor.
static int COLOR_FOREGROUND
          A color specifier for use with getColor.
static int COLOR_HIGHLIGHTED_BACKGROUND
          A color specifier for use with getColor.
static int COLOR_HIGHLIGHTED_BORDER
          A color specifier for use with getColor.
static int COLOR_HIGHLIGHTED_FOREGROUND
          A color specifier for use with getColor.
static int TRANSPARENT
          A color that defines transparent together with the dynamic flag.
 
Constructor Summary
Color(int argb)
          Creates a new color
Color(int argb, boolean isDynamic)
          Creates a new color
 
Method Summary
 int getColor()
          Retrieves the actual (A)RGB color value.
 java.lang.Integer getInteger()
          Retrieves the integer representation of this color.
 boolean isDynamic()
          Determines whether this color is a dynamic one like Display.COLOR_BACKGROUND
 boolean isTransparent()
          Determines whether this color represents transparent.
 java.lang.String toString()
          Retrieves a string representation of this color.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TRANSPARENT

public static final int TRANSPARENT
A color that defines transparent together with the dynamic flag. The value of TRANSPARENT is -1.

See Also:
Constant Field Values

COLOR_BACKGROUND

public static final int COLOR_BACKGROUND
A color specifier for use with getColor. COLOR_BACKGROUND specifies the background color of the screen. The background color will always contrast with the foreground color.

COLOR_BACKGROUND has the value 0.

See Also:
Constant Field Values

COLOR_FOREGROUND

public static final int COLOR_FOREGROUND
A color specifier for use with getColor. COLOR_FOREGROUND specifies the foreground color, for text characters and simple graphics on the screen. Static text or user-editable text should be drawn with the foreground color. The foreground color will always constrast with background color.

COLOR_FOREGROUND has the value 1.

See Also:
Constant Field Values

COLOR_HIGHLIGHTED_BACKGROUND

public static final int COLOR_HIGHLIGHTED_BACKGROUND
A color specifier for use with getColor. COLOR_HIGHLIGHTED_BACKGROUND identifies the color for the focus, or focus highlight, when it is drawn as a filled in rectangle. The highlighted background will always constrast with the highlighted foreground.

COLOR_HIGHLIGHTED_BACKGROUND has the value 2.

See Also:
Constant Field Values

COLOR_HIGHLIGHTED_FOREGROUND

public static final int COLOR_HIGHLIGHTED_FOREGROUND
A color specifier for use with getColor. COLOR_HIGHLIGHTED_FOREGROUND identifies the color for text characters and simple graphics when they are highlighted. Highlighted foreground is the color to be used to draw the highlighted text and graphics against the highlighted background. The highlighted foreground will always constrast with the highlighted background.

COLOR_HIGHLIGHTED_FOREGROUND has the value 3.

See Also:
Constant Field Values

COLOR_BORDER

public static final int COLOR_BORDER
A color specifier for use with getColor. COLOR_BORDER identifies the color for boxes and borders when the object is to be drawn in a non-highlighted state. The border color is intended to be used with the background color and will contrast with it. The application should draw its borders using the stroke style returned by getBorderStyle().

COLOR_BORDER has the value 4.

See Also:
Constant Field Values

COLOR_HIGHLIGHTED_BORDER

public static final int COLOR_HIGHLIGHTED_BORDER
A color specifier for use with getColor. COLOR_HIGHLIGHTED_BORDER identifies the color for boxes and borders when the object is to be drawn in a highlighted state. The highlighted border color is intended to be used with the background color (not the highlighted background color) and will contrast with it. The application should draw its borders using the stroke style returned by getBorderStyle().

COLOR_HIGHLIGHTED_BORDER has the value 5.

See Also:
Constant Field Values
Constructor Detail

Color

public Color(int argb)
Creates a new color

Parameters:
argb - the (A)RGB value of the color

Color

public Color(int argb,
             boolean isDynamic)
Creates a new color

Parameters:
argb - the (A)RGB value of the color or Display.COLOR_BACKGROUND, Display.COLOR_FOREGROUND etc
isDynamic - true when this color references one of the Display color fields like Display.BACKGROUND_COLOR, Display.FOREGROUND_COLOR etc
See Also:
COLOR_BACKGROUND, COLOR_BORDER, COLOR_FOREGROUND, COLOR_HIGHLIGHTED_BACKGROUND, COLOR_HIGHLIGHTED_BORDER, COLOR_HIGHLIGHTED_FOREGROUND, TRANSPARENT
Method Detail

getInteger

public java.lang.Integer getInteger()
Retrieves the integer representation of this color. This method allows a backwards compability with J2ME Polish components that use Style.getIntProperty() for retrieving colors

Returns:
an Integer representing this color
Throws:
java.lang.IllegalStateException - when this is a dynamic color and the StyleSheet.display variable is not yet set up. The StyleSheet.display field is set within the startApp() method of the parent MIDlet.

getColor

public int getColor()
Retrieves the actual (A)RGB color value.

Returns:
the color value
Throws:
java.lang.IllegalStateException - when this is a dynamic color and the StyleSheet.display variable is not yet set up. The StyleSheet.display field is set within the startApp() method of the parent MIDlet.

isTransparent

public boolean isTransparent()
Determines whether this color represents transparent.

Returns:
true when this is a dynamic color with TRANSPARENT as the color value

isDynamic

public boolean isDynamic()
Determines whether this color is a dynamic one like Display.COLOR_BACKGROUND

Returns:
true when this is a dynamic color

toString

public java.lang.String toString()
Retrieves a string representation of this color.

Overrides:
toString in class java.lang.Object
Returns:
the color as a hex string, when an IllegalStateException occurs, the super.toString() implementation will be used instead