Package org.scijava.util
Class ColorRGB
- java.lang.Object
-
- 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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)static ColorRGBfromHSVColor(double h, double s, double v)static ColorRGBfromHTMLColor(String color)Convert a string in the format specified by CSS Color Module Level 3 - W3C Recommendation 07 June 2011 to aColorRGBobject.intgetAlpha()intgetARGB()Gets the color as a packed integer, 8 bits per color component.intgetBlue()intgetGreen()intgetRed()inthashCode()StringtoHTMLColor()Convert this ColorRGB to a string in the format specified by CSS Color Module Level 3 - W3C Recommendation 07 June 2011.StringtoString()
-
-
-
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:- HTML color codes starting with hash (
#), as handled byfromHTMLColor(String). - Color presets, as handled by
Colors.getColor(String). - Integer triples of the form
r,g,b, with each element in the range[0, 255].
- HTML color codes starting with hash (
-
-
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
-
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 aColorRGBobject.- Parameters:
color- The color string to convert.- Returns:
- The resultant color object.
-
fromHSVColor
public static ColorRGB fromHSVColor(double h, double s, double v)
-
-