jcurzez
Class Color

java.lang.Object
  |
  +--jcurzez.Color
Direct Known Subclasses:
BackgroundColor, ForegroundColor

class Color
extends java.lang.Object

A Jcurzez color, different from java.awt.Color. There are two classes extending this one, respectively named BackgroundColor and ForegroundColor. This one is package private, it should not be used.

Basically, a Color is defined by its name and by an object, its real color. This object will depend on the implementation of Jcurzez. Thus the user should not call setRealColor(Object).

Note: all colors are immutable ojects, so they can be compare using ==. Anyway, equals(java.lang.Object) is the same as ==, and it will remain ; I made it final.

Version:
0.0.3
Author:
Thomas Girard

Field Summary
protected  java.lang.String name
          Name of this color.
private  java.lang.Object realColor
          The real color object.
 
Constructor Summary
protected Color(java.lang.String name)
          Creates a new Color with specified name.
 
Method Summary
 boolean equals(java.lang.Object o)
          Tests equality.
 java.lang.Object getRealColor()
          Returns the real color.
 void setRealColor(java.lang.Object o)
          Modifies the real color.
 java.lang.String toString()
          Returns the name of this color.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

realColor

private java.lang.Object realColor
The real color object. Platform-dependent.


name

protected final java.lang.String name
Name of this color.

Constructor Detail

Color

protected Color(java.lang.String name)
Creates a new Color with specified name.

Throws:
java.lang.IllegalArgumentException - thrown if name is null.
Method Detail

toString

public java.lang.String toString()
Returns the name of this color.

Overrides:
toString in class java.lang.Object
Returns:
name.

setRealColor

public void setRealColor(java.lang.Object o)
Modifies the real color. This operation must be done only once, (no more, no less) otherwise an runtime exception is thrown.

Parameters:
o - the object to store as a real color.
Throws:
IllegalColorStateException - if this method is invoked more than once.
java.lang.IllegalArgumentException - if o is null.

getRealColor

public java.lang.Object getRealColor()
Returns the real color.

Returns:
realColor.

equals

public final boolean equals(java.lang.Object o)
Tests equality. Prevents overridding by making it final.

Overrides:
equals in class java.lang.Object


Send me an email