Oxygen XML Editor 11.2 Author API

ro.sync.exml.view.graphics
Class Color

java.lang.Object
  extended by ro.sync.exml.view.graphics.Color

public class Color
extends Object

The class used to represent a Color.


Field Summary
static Color COLOR_BLACK
          Black color constant.
static Color COLOR_BLUE
          Blue color constant.
static Color COLOR_DARK_GRAY
          Dark gray color constant.
static Color COLOR_GRAY
          Gray color constant.
static Color COLOR_LIGHT_GRAY
          Light gray color constant.
static Color COLOR_LIGHT_GREEN
          Light green color constant.
static Color COLOR_LIGHT_YELLOW
          Light yellow color constant.
static Color COLOR_LIGHTER_BLUE
          Lighter blue color constant.
static Color COLOR_LIGHTER_GRAY
          Lighter gray color constant.
static Color COLOR_ORANGE
          Orange color constant.
static Color COLOR_RED
          Red color constant.
static Color COLOR_RED_DARKER
          Red darker color constant.
static Color COLOR_WHITE
          White color constant.
 
Constructor Summary
Color(int rgb)
          Creates an sRGB color from the specified RGB color value.
Color(int r, int g, int b)
          Creates an opaque sRGB color with the specified red, green, and blue values in the range (0 - 255).
Color(int r, int g, int b, int a)
          Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0 - 255).
 
Method Summary
static Color brighter(Color color)
          Increase brightness of the color.
static Color darker(Color color)
          Decrease the brightness of the color.
static Color darker(Color color, float percent)
          Decrease the brightness of the color.
static Color decodeColor(String colorString)
          Method used to decode the given string to a color.
static Color desaturate(Color fillColor, double percent)
          Used for decrease the color saturation with the given percent.
 boolean equals(Object obj)
          Checks if the two colors have the same RGB value.
 int getAlpha()
          Returns the alpha component in the range 0-255.
 int getBlue()
          Returns the blue component in the range 0-255 in the default sRGB space.
 float getBrightness()
          Gets the L component form the HSL spectrum of the color.
 int getGreen()
          Returns the green component in the range 0-255 in the default sRGB space.
 int getRed()
          Returns the red component in the range 0-255 in the default sRGB space.
 int getRGB()
          Returns the RGB value representing the color in the default sRGB (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue).
 int hashCode()
           
 String toString()
          Returns a string representation of this Color.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COLOR_LIGHT_GRAY

public static final Color COLOR_LIGHT_GRAY
Light gray color constant. The RGB values are: (192, 192, 192).


COLOR_WHITE

public static final Color COLOR_WHITE
White color constant. The RGB values are: (255, 255, 255).


COLOR_BLACK

public static final Color COLOR_BLACK
Black color constant. The RGB values are: (0, 0, 0).


COLOR_RED

public static final Color COLOR_RED
Red color constant. The RGB values are: (255, 0, 0).


COLOR_RED_DARKER

public static final Color COLOR_RED_DARKER
Red darker color constant. The RGB values are: (178, 0, 0).


COLOR_DARK_GRAY

public static final Color COLOR_DARK_GRAY
Dark gray color constant. The RGB values are: (64, 64, 64).


COLOR_BLUE

public static final Color COLOR_BLUE
Blue color constant. The RGB values are: (0, 0, 255).


COLOR_GRAY

public static final Color COLOR_GRAY
Gray color constant. The RGB values are: (128, 128, 128).


COLOR_LIGHT_YELLOW

public static final Color COLOR_LIGHT_YELLOW
Light yellow color constant. The RGB values are: (255, 255, 230).


COLOR_LIGHT_GREEN

public static final Color COLOR_LIGHT_GREEN
Light green color constant. The RGB values are: (230, 255, 230).


COLOR_ORANGE

public static final Color COLOR_ORANGE
Orange color constant. The RGB values are: (255, 200, 0).


COLOR_LIGHTER_GRAY

public static final Color COLOR_LIGHTER_GRAY
Lighter gray color constant. The RGB values are: (240, 240, 240).


COLOR_LIGHTER_BLUE

public static final Color COLOR_LIGHTER_BLUE
Lighter blue color constant. The RGB values are: (238, 246, 253).

Constructor Detail

Color

public Color(int r,
             int g,
             int b,
             int a)
Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0 - 255).

Parameters:
r - the red component.
g - the green component.
b - the blue component.
a - the alpha component.

Color

public Color(int rgb)
Creates an sRGB color from the specified RGB color value.

Parameters:
rgb - The value of the RGB color. Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue.

Color

public Color(int r,
             int g,
             int b)
Creates an opaque sRGB color with the specified red, green, and blue values in the range (0 - 255). The actual color used in rendering depends on finding the best match given the color space available for a given output device. Alpha is defaulted to 255.

Parameters:
r - the red component.
g - the green component.
b - the blue component.
Method Detail

getRed

public int getRed()
Returns the red component in the range 0-255 in the default sRGB space.

Returns:
The red component.

getGreen

public int getGreen()
Returns the green component in the range 0-255 in the default sRGB space.

Returns:
The green component.

getBlue

public int getBlue()
Returns the blue component in the range 0-255 in the default sRGB space.

Returns:
The blue component.

getAlpha

public int getAlpha()
Returns the alpha component in the range 0-255.

Returns:
The alpha component.

getRGB

public int getRGB()
Returns the RGB value representing the color in the default sRGB (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue).

Returns:
the RGB value of the color in the default sRGB ColorModel.

toString

public String toString()
Returns a string representation of this Color. This method is intended to be used only for debugging purposes. The content and format of the returned string might vary between implementations. The returned string might be empty but cannot be null.

Overrides:
toString in class Object
Returns:
A string representation of this Color.

equals

public boolean equals(Object obj)
Checks if the two colors have the same RGB value. The alpha is also taken into account.

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

desaturate

public static Color desaturate(Color fillColor,
                               double percent)
Used for decrease the color saturation with the given percent.

Parameters:
fillColor - The color to be darkened.
percent - The percent to be used for decrease the color saturation.
Returns:
The modified color.

decodeColor

public static Color decodeColor(String colorString)
Method used to decode the given string to a color.

Parameters:
colorString - The string representation of the color.
Returns:
The decoded color if possible, black otherwise.

darker

public static Color darker(Color color)
Decrease the brightness of the color.

Parameters:
color - The color to be modified.
Returns:
The color with decreased brightness.

darker

public static Color darker(Color color,
                           float percent)
Decrease the brightness of the color.

Parameters:
color - The color to be modified.
percent - The percent to be used for darkening a color.
Returns:
The color with decreased brightness.

brighter

public static Color brighter(Color color)
Increase brightness of the color.

Parameters:
color - The color to be modified.
Returns:
The color with increased brightness.

getBrightness

public float getBrightness()
Gets the L component form the HSL spectrum of the color.

Returns:
The brightness of the color. Between 0.0 and 1.0

Oxygen XML Editor 11.2 Author API

© Copyright SyncRO Soft SRL 2002 - 2010.