info.monitorenter.gui.util
Class HSBColor

java.lang.Object
  extended by info.monitorenter.gui.util.HSBColor
All Implemented Interfaces:
Serializable, Cloneable

public class HSBColor
extends Object
implements Serializable, Cloneable

Color that internally works with the Hue Saturation Luminance color space.

Version:
$Revision: 1.2 $
Author:
Achim Westermann
See Also:
Serialized Form

Field Summary
protected  float m_hue
          Hue value between 0.0 and 1.0.
protected  float m_lum
          Luminance value between 0.0 and 1.0.
protected  float m_sat
          Saturation value between 0.0 and 1.0.
 
Constructor Summary
HSBColor(Color rgbcolor)
          Creates an instance transformed from the rgb color.
 
Method Summary
 Object clone()
          Clone implementation.
 boolean equals(Object o)
          Equals implementation.
 Color getRGBColor()
          Returns the transformation of this color to the rgb color.
 int hashCode()
           
static HSBColor rgbToHSB(Color color)
          Inspired by float[] java.awt.Color.RGBtoHSB(int r,int g, int b, float[]hsbvals) except that algorithm is tuned
Testing results showed about 25% speed up.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_hue

protected float m_hue
Hue value between 0.0 and 1.0.


m_lum

protected float m_lum
Luminance value between 0.0 and 1.0.


m_sat

protected float m_sat
Saturation value between 0.0 and 1.0.

Constructor Detail

HSBColor

public HSBColor(Color rgbcolor)
Creates an instance transformed from the rgb color.

Parameters:
rgbcolor - standard java rgb color.
Method Detail

rgbToHSB

public static HSBColor rgbToHSB(Color color)
Inspired by float[] 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 - the java.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

public Object 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.

Overrides:
clone in class Object
Returns:
an intance copied from this one.

equals

public boolean equals(Object o)
Equals implementation.

Returns true if :
o.instanceof HSBColor && (this.hue==o.hue) && (this.sat == o.sat) && (this.lum == o.lum)

Overrides:
equals in class Object
Parameters:
o - the other HSBColor instance.
Returns:
true if the colors are judged equal.

getRGBColor

public Color 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()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()


Copyright © 2001 - 2007 LGPL, All Rights Footloose.