org.scijava.util
Class ColorRGB

java.lang.Object
  extended by org.scijava.util.ColorRGB
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ColorRGBA

public class ColorRGB
extends Object
implements Serializable

A color with red, green and blue color components.

It exists mainly to avoid AWT references to Color.

Author:
Curtis Rueden, Lee Kamentsky, Barry DeZonia
See Also:
Serialized Form

Constructor Summary
ColorRGB(int red, int green, int blue)
           
ColorRGB(String s)
          Parses a color from the given string.
 
Method Summary
 boolean equals(Object obj)
           
static ColorRGB fromHSVColor(double h, double s, double v)
           
static ColorRGB fromHTMLColor(String color)
          Convert a string in the format specified by CSS Color Module Level 3 - W3C Recommendation 07 June 2011 to a ColorRGB object.
 int getAlpha()
           
 int getARGB()
          Gets the color as a packed integer, 8 bits per color component.
 int getBlue()
           
 int getGreen()
           
 int getRed()
           
 int hashCode()
           
 String toHTMLColor()
          Convert this ColorRGB to a string in the format specified by CSS Color Module Level 3 - W3C Recommendation 07 June 2011.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ColorRGB

public ColorRGB(int red,
                int green,
                int blue)

ColorRGB

public ColorRGB(String s)
Parses a color from the given string. The following formats are supported:
  1. HTML color codes starting with hash (#), as handled by fromHTMLColor(String).
  2. Color presets, as handled by Colors.getColor(String).
  3. Integer triples of the form r,g,b, with each element in the range [0, 255].

Method Detail

getRed

public int getRed()

getGreen

public int getGreen()

getBlue

public int getBlue()

getAlpha

public int getAlpha()

getARGB

public int getARGB()
Gets the color as a packed integer, 8 bits per color component. HSB is alpha, next is red, then green, and finally blue is LSB.


toHTMLColor

public String toHTMLColor()
Convert this ColorRGB to a string in the format specified by CSS Color Module Level 3 - W3C Recommendation 07 June 2011.

We preferentially encode using one of the colors in the table and fall back to the hex encoding.

Returns:
HTML-encoded string

toString

public String toString()
Overrides:
toString in class Object

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

fromHTMLColor

public static ColorRGB fromHTMLColor(String color)
Convert a string in the format specified by CSS Color Module Level 3 - W3C Recommendation 07 June 2011 to a ColorRGB object.

Parameters:
color - The color string to convert.
Returns:
The resultant color object.

fromHSVColor

public static ColorRGB fromHSVColor(double h,
                                    double s,
                                    double v)


Copyright © 2009–2015 SciJava. All rights reserved.