nodebox.graphics
Class Color

java.lang.Object
  extended by nodebox.graphics.Color
All Implemented Interfaces:
Cloneable

public final class Color
extends Object
implements Cloneable


Nested Class Summary
static class Color.Mode
           
 
Field Summary
static Color BLACK
           
static Color WHITE
           
 
Constructor Summary
Color()
          Create an empty (black) color object.
Color(Color color)
          Create a new color with the the given color.
Color(Color other)
          Create a new color with the the given color.
Color(double v)
          Create a new color with the given grayscale value.
Color(double v, double a)
          Create a new color with the given grayscale and alpha value.
Color(double r, double g, double b)
          Create a new color with the the given R/G/B value.
Color(double x, double y, double z, Color.Mode m)
          Create a new color with the the given R/G/B value.
Color(double r, double g, double b, double a)
          Create a new color with the the given R/G/B/A or H/S/B/A value.
Color(double x, double y, double z, double a, Color.Mode m)
          Create a new color with the the given R/G/B/A or H/S/B/A value.
Color(String colorName)
           
 
Method Summary
 Color clone()
           
 boolean equals(Object obj)
           
static Color fromHSB(double hue, double saturation, double brightness)
           
static Color fromHSB(double hue, double saturation, double brightness, double alpha)
           
 double getA()
           
 double getAlpha()
           
 Color getAwtColor()
           
 double getB()
           
 double getBlue()
           
 double getBrightness()
           
 double getG()
           
 double getGreen()
           
 double getH()
           
 double getHue()
           
 double getR()
           
 double getRed()
           
 double getS()
           
 double getSaturation()
           
 double getV()
           
 boolean isVisible()
           
static Color parseColor(String value)
          Parse a hexadecimal value and return a Color object.
 void set(Graphics2D g)
           
 String toString()
          Returns the color as a 8-bit hexadecimal value, e.g.
static Color valueOf(String hex)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BLACK

public static final Color BLACK

WHITE

public static final Color WHITE
Constructor Detail

Color

public Color()
Create an empty (black) color object.


Color

public Color(double v)
Create a new color with the given grayscale value.

Parameters:
v - the gray component.

Color

public Color(double v,
             double a)
Create a new color with the given grayscale and alpha value.

Parameters:
v - the grayscale value.
a - the alpha value.

Color

public Color(double x,
             double y,
             double z,
             Color.Mode m)
Create a new color with the the given R/G/B value.

Parameters:
x - the red or hue component.
y - the green or saturation component.
z - the blue or brightness component.
m - the specified color mode.

Color

public Color(double r,
             double g,
             double b)
Create a new color with the the given R/G/B value.

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

Color

public Color(double r,
             double g,
             double b,
             double a)
Create a new color with the the given R/G/B/A or H/S/B/A value.

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

Color

public Color(double x,
             double y,
             double z,
             double a,
             Color.Mode m)
Create a new color with the the given R/G/B/A or H/S/B/A value.

Parameters:
x - the red or hue component.
y - the green or saturation component.
z - the blue or brightness component.
a - the alpha component.
m - the specified color mode.

Color

public Color(String colorName)

Color

public Color(Color color)
Create a new color with the the given color.

The color object is cloned; you can change the original afterwards. If the color object is null, the new color is turned off (same as nocolor).

Parameters:
color - the color object.

Color

public Color(Color other)
Create a new color with the the given color.

The color object is cloned; you can change the original afterwards. If the color object is null, the new color is turned off (same as nocolor).

Parameters:
other - the color object.
Method Detail

fromHSB

public static Color fromHSB(double hue,
                            double saturation,
                            double brightness)

fromHSB

public static Color fromHSB(double hue,
                            double saturation,
                            double brightness,
                            double alpha)

valueOf

public static Color valueOf(String hex)

getRed

public double getRed()

getR

public double getR()

getGreen

public double getGreen()

getG

public double getG()

getBlue

public double getBlue()

getB

public double getB()

getAlpha

public double getAlpha()

getA

public double getA()

isVisible

public boolean isVisible()

getHue

public double getHue()

getH

public double getH()

getSaturation

public double getSaturation()

getS

public double getS()

getBrightness

public double getBrightness()

getV

public double getV()

getAwtColor

public Color getAwtColor()

set

public void set(Graphics2D g)

clone

public Color clone()
Overrides:
clone in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

parseColor

public static Color parseColor(String value)
Parse a hexadecimal value and return a Color object.

The value needs to have four components. (R,G,B,A)

Parameters:
value - the hexadecimal color value, e.g. #995423ff
Returns:
a Color object.

toString

public String toString()
Returns the color as a 8-bit hexadecimal value, e.g. #ae45cdff

Overrides:
toString in class Object
Returns:
the color as a 8-bit hexadecimal value


Copyright © 2013. All Rights Reserved.