Package info.monitorenter.gui.util
Class HSBColor
java.lang.Object
info.monitorenter.gui.util.HSBColor
- All Implemented Interfaces:
Serializable
,Cloneable
Color that internally works with the Hue Saturation Luminance color space.
- Version:
- $Revision: 1.7 $
- Author:
- Achim Westermann
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected double
The unused alpha channel between 0 and 255: stored here for allow java.awt.Color instances to be transformed to instances of this class and be re - transformed with preserving their alpha setting.protected double
Hue value between 0.0 and 1.0.protected double
Luminance value between 0.0 and 1.0.protected double
Saturation value between 0.0 and 1.0. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
Clone implementation.boolean
Returns the transformation of this color to the rgb color.int
hashCode()
static HSBColor
Inspired byfloat[] java.awt.Color.RGBtoHSB(int r,int g, int b, float[]hsbvals)
except that algorithm is tuned
Testing results showed about 25% speed up.
-
Field Details
-
m_hue
protected double m_hueHue value between 0.0 and 1.0. -
m_lum
protected double m_lumLuminance value between 0.0 and 1.0. -
m_sat
protected double m_satSaturation value between 0.0 and 1.0. -
m_alpha
protected double m_alphaThe unused alpha channel between 0 and 255: stored here for allow java.awt.Color instances to be transformed to instances of this class and be re - transformed with preserving their alpha setting.
-
-
Constructor Details
-
HSBColor
Creates an instance transformed from the rgb color.- Parameters:
rgbcolor
- standard java rgb color.
-
-
Method Details
-
rgbToHSB
Inspired byfloat[] java.awt.Color.RGBtoHSB(int r,int g, int b, float[]hsbvals)
except that algorithm is tuned
Testing results showed about 25% speed up. Therefore the sources have become harder to understand.- Parameters:
color
- thejava.awt.Color
(that follows the RGB model) and should be transformed to a color instance in the hue-saturation-luminance model.- Returns:
- the transformed values of the RGB colors in that order: hue,saturation,brightness.
-
clone
Clone implementation.Following statements are true:
x.clone() != x x.clone().getClass() == x.getClass() x.clone().equals(x)
A deep copy of this HSBColor is returned. -
equals
-
getRGBColor
Returns the transformation of this color to the rgb color.- Returns:
- the transformation of this color to the rgb color.
-
hashCode
public int hashCode()
-