jdsl.extension.LEDA
Class Color

java.lang.Object
  |
  +--jdsl.extension.LEDA.Color

public class Color
extends java.lang.Object
implements java.lang.Cloneable

This class represents a color. A color can be definied by an index or a rgb tripel. There are several access methods. Switches between both representation are internal.


Field Summary
static int BLACK
          A valid color: black.
static int BLUE
          A valid color: blue.
static int BLUE2
          A valid color: dark blue.
static int BROWN
          A valid color: brown.
static int CYAN
          A valid color: cyan.
static int DEFAULTCOLOR
          A valid color: standard color.
static int GREEN
          A valid color: green.
static int GREEN2
          A valid color: dark green.
static int GREY1
          A valid color: light grey.
static int GREY2
          A valid color: grey.
static int GREY3
          A valid color: dark grey.
static int INVISIBLE
          A valid color: invisible.
static int ORANGE
          A valid color: orange.
static int PINK
          A valid color: pink.
static int RED
          A valid color: red.
static int VIOLET
          A valid color: violet
static int WHITE
          A valid color: white.
static int YELLOW
          A valid color: yellow.
 
Constructor Summary
Color(Color c)
          Copy-Constructor.
Color(int index)
          Contructs a new color by an index value.
Color(int r, int g, int b)
          Constructs a new color by an rgb tripel.
 
Method Summary
 int bestPossibleIndex()
          Returns current color as index.
 java.lang.Object clone()
          Cloneable implenentation.
static java.lang.String codeIndexToRGB(int index)
          Returns color definied by index as a rgb tripel (as a string).
static java.lang.String codeRGBToIndex(int r, int g, int b)
          Returns color definied by r, g, b as an index (as a string).
 int getB()
          Returns the blue part of current color.
 int getG()
          Returns the green part of current color.
 int getIndex()
          Returns current color index.
 int getR()
          Returns the red part of current color.
 void setB(int b)
          Sets a new blue part.
 void setG(int g)
          Sets a new green part.
 void setIndex(int colorIndex)
          Sets a new color index;
 void setR(int r)
          Sets a new red part.
 java.lang.String toString()
          Returns current used representation (as an index or as a rgb tripel).
 java.lang.String toString(boolean useIndex)
          Returns a representation (as an index or as a rgb tripel).
 java.lang.String toStringBoth()
          Returns both representations (as an index and as a rgb tripel).
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INVISIBLE

public static final int INVISIBLE
A valid color: invisible.
See Also:
WHITE, BLACK, RED, GREEN, BLUE, YELLOW, VIOLET, ORANGE, CYAN, BROWN, PINK, GREEN2, BLUE2, GREY1, GREY2, GREY3, DEFAULTCOLOR

WHITE

public static final int WHITE
A valid color: white.
See Also:
INVISIBLE, BLACK, RED, GREEN, BLUE, YELLOW, VIOLET, ORANGE, CYAN, BROWN, PINK, GREEN2, BLUE2, GREY1, GREY2, GREY3, DEFAULTCOLOR

BLACK

public static final int BLACK
A valid color: black.
See Also:
INVISIBLE, WHITE, RED, GREEN, BLUE, YELLOW, VIOLET, ORANGE, CYAN, BROWN, PINK, GREEN2, BLUE2, GREY1, GREY2, GREY3, DEFAULTCOLOR

RED

public static final int RED
A valid color: red.
See Also:
INVISIBLE, WHITE, BLACK, GREEN, BLUE, YELLOW, VIOLET, ORANGE, CYAN, BROWN, PINK, GREEN2, BLUE2, GREY1, GREY2, GREY3, DEFAULTCOLOR

GREEN

public static final int GREEN
A valid color: green.
See Also:
INVISIBLE, WHITE, BLACK, RED, BLUE, YELLOW, VIOLET, ORANGE, CYAN, BROWN, PINK, GREEN2, BLUE2, GREY1, GREY2, GREY3, DEFAULTCOLOR

BLUE

public static final int BLUE
A valid color: blue.
See Also:
INVISIBLE, WHITE, BLACK, RED, GREEN, YELLOW, VIOLET, ORANGE, CYAN, BROWN, PINK, GREEN2, BLUE2, GREY1, GREY2, GREY3, DEFAULTCOLOR

YELLOW

public static final int YELLOW
A valid color: yellow.
See Also:
INVISIBLE, WHITE, BLACK, RED, GREEN, BLUE, VIOLET, ORANGE, CYAN, BROWN, PINK, GREEN2, BLUE2, GREY1, GREY2, GREY3, DEFAULTCOLOR

VIOLET

public static final int VIOLET
A valid color: violet
See Also:
INVISIBLE, WHITE, BLACK, RED, GREEN, BLUE, YELLOW, ORANGE, CYAN, BROWN, PINK, GREEN2, BLUE2, GREY1, GREY2, GREY3, DEFAULTCOLOR

ORANGE

public static final int ORANGE
A valid color: orange.
See Also:
INVISIBLE, WHITE, BLACK, RED, GREEN, BLUE, YELLOW, VIOLET, CYAN, BROWN, PINK, GREEN2, BLUE2, GREY1, GREY2, GREY3, DEFAULTCOLOR

CYAN

public static final int CYAN
A valid color: cyan.
See Also:
INVISIBLE, WHITE, BLACK, RED, GREEN, BLUE, YELLOW, VIOLET, ORANGE, BROWN, PINK, GREEN2, BLUE2, GREY1, GREY2, GREY3, DEFAULTCOLOR

BROWN

public static final int BROWN
A valid color: brown.
See Also:
INVISIBLE, WHITE, BLACK, RED, GREEN, BLUE, YELLOW, VIOLET, ORANGE, CYAN, PINK, GREEN2, BLUE2, GREY1, GREY2, GREY3, DEFAULTCOLOR

PINK

public static final int PINK
A valid color: pink.
See Also:
INVISIBLE, WHITE, BLACK, RED, GREEN, BLUE, YELLOW, VIOLET, ORANGE, CYAN, BROWN, GREEN2, BLUE2, GREY1, GREY2, GREY3, DEFAULTCOLOR

GREEN2

public static final int GREEN2
A valid color: dark green.
See Also:
INVISIBLE, WHITE, BLACK, RED, GREEN, BLUE, YELLOW, VIOLET, ORANGE, CYAN, BROWN, PINK, BLUE2, GREY1, GREY2, GREY3, DEFAULTCOLOR

BLUE2

public static final int BLUE2
A valid color: dark blue.
See Also:
INVISIBLE, WHITE, BLACK, RED, GREEN, BLUE, YELLOW, VIOLET, ORANGE, CYAN, BROWN, PINK, GREEN2, GREY1, GREY2, GREY3, DEFAULTCOLOR

GREY1

public static final int GREY1
A valid color: light grey.
See Also:
INVISIBLE, WHITE, BLACK, RED, GREEN, BLUE, YELLOW, VIOLET, ORANGE, CYAN, BROWN, PINK, GREEN2, BLUE2, GREY2, GREY3, DEFAULTCOLOR

GREY2

public static final int GREY2
A valid color: grey.
See Also:
INVISIBLE, WHITE, BLACK, RED, GREEN, BLUE, YELLOW, VIOLET, ORANGE, CYAN, BROWN, PINK, GREEN2, BLUE2, GREY1, GREY3, DEFAULTCOLOR

GREY3

public static final int GREY3
A valid color: dark grey.
See Also:
INVISIBLE, WHITE, BLACK, RED, GREEN, BLUE, YELLOW, VIOLET, ORANGE, CYAN, BROWN, PINK, GREEN2, BLUE2, GREY1, GREY2, DEFAULTCOLOR

DEFAULTCOLOR

public static final int DEFAULTCOLOR
A valid color: standard color.
See Also:
INVISIBLE, WHITE, BLACK, RED, GREEN, BLUE, YELLOW, VIOLET, ORANGE, CYAN, BROWN, PINK, GREEN2, BLUE2, GREY1, GREY2, GREY3
Constructor Detail

Color

public Color(int index)
Contructs a new color by an index value.

Color

public Color(int r,
             int g,
             int b)
Constructs a new color by an rgb tripel.
Parameters:
r - red part
g - green part
b - blue part

Color

public Color(Color c)
Copy-Constructor.
Method Detail

clone

public java.lang.Object clone()
Cloneable implenentation.
Overrides:
clone in class java.lang.Object

getIndex

public int getIndex()
Returns current color index.
Returns:
value of index.

setIndex

public void setIndex(int colorIndex)
Sets a new color index;
Parameters:
colorIndex - value to assign to index.

getR

public int getR()
Returns the red part of current color.
Returns:
value of the red part

getG

public int getG()
Returns the green part of current color.
Returns:
value of the green part

getB

public int getB()
Returns the blue part of current color.
Returns:
value of the blue part

setR

public void setR(int r)
Sets a new red part.
Parameters:
r - new red part

setG

public void setG(int g)
Sets a new green part.
Parameters:
g - new green part

setB

public void setB(int b)
Sets a new blue part.
Parameters:
b - new blue part

toStringBoth

public java.lang.String toStringBoth()
Returns both representations (as an index and as a rgb tripel).

toString

public java.lang.String toString()
Returns current used representation (as an index or as a rgb tripel).
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(boolean useIndex)
Returns a representation (as an index or as a rgb tripel).
Parameters:
useIndex - if true a index representation is used, else a rgb representation.

bestPossibleIndex

public int bestPossibleIndex()
Returns current color as index. If current color has no index representation, best possible index is choosen.

codeIndexToRGB

public static java.lang.String codeIndexToRGB(int index)
Returns color definied by index as a rgb tripel (as a string).

codeRGBToIndex

public static java.lang.String codeRGBToIndex(int r,
                                              int g,
                                              int b)
Returns color definied by r, g, b as an index (as a string).