Package org.openhab.core.library.types
Class HSBType
java.lang.Object
java.lang.Number
org.openhab.core.library.types.DecimalType
org.openhab.core.library.types.PercentType
org.openhab.core.library.types.HSBType
- All Implemented Interfaces:
Serializable,Comparable<DecimalType>,Command,ComplexType,PrimitiveType,State,Type
The HSBType is a complex type with constituents for hue, saturation and
brightness and can be used for color items.
- Author:
- Kai Kreuzer - Initial contribution, Chris Jackson - Added fromRGB, Andrew Fiddian-Green - closeTo (copied from binding)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HSBTypestatic final HSBTypestatic final HSBTypeprotected BigDecimalstatic final Stringstatic final Stringstatic final Stringstatic final HSBTypeprotected BigDecimalstatic final HSBTypeFields inherited from class org.openhab.core.library.types.PercentType
HUNDRED, ZEROFields inherited from class org.openhab.core.library.types.DecimalType
BIG_DECIMAL_HUNDRED, value -
Constructor Summary
ConstructorsConstructorDescriptionHSBType()Constructs a HSBType instance from a given string.HSBType(DecimalType h, PercentType s, PercentType b) Constructs a HSBType instance with the given values -
Method Summary
Modifier and TypeMethodDescription<T extends State>
@Nullable TConvert thisState's value into another typebooleanHelper method for checking if two HSBType colors are close to each other.booleanFormats the value of this type according to a pattern (seeFormatter).static HSBTypefromRGB(int r, int g, int b) Create HSB from RGB.static HSBTypefromXY(float x, float y) Deprecated.getBlue()Deprecated.UseColorUtil.hsbToRgb(HSBType)insteadReturns all constituents with their names as a sorted mapgetGreen()Deprecated.UseColorUtil.hsbToRgb(HSBType)insteadgetHue()getRed()Deprecated.UseColorUtil.hsbToRgb(HSBType)insteadintgetRGB()Deprecated.UseColorUtil.hsbTosRgb(HSBType)instead.inthashCode()Get a string representation that contains the whole internal representation of the type.toRGB()Deprecated.toString()toXY()Returns the xyY values representing this object's color in CIE XY color model.static HSBTypeMethods inherited from class org.openhab.core.library.types.DecimalType
compareTo, defaultConversion, doubleValue, floatValue, intValue, longValue, toBigDecimalMethods inherited from class java.lang.Number
byteValue, shortValue
-
Field Details
-
KEY_HUE
- See Also:
-
KEY_SATURATION
- See Also:
-
KEY_BRIGHTNESS
- See Also:
-
BLACK
-
WHITE
-
RED
-
GREEN
-
BLUE
-
hue
-
saturation
-
-
Constructor Details
-
HSBType
public HSBType() -
HSBType
Constructs a HSBType instance with the given values- Parameters:
h- the hue value in the range from0 <= h < 360s- the saturation as a percent valueb- the brightness as a percent value
-
HSBType
Constructs a HSBType instance from a given string. The string has to be in comma-separated format with exactly three segments, which correspond to the hue, saturation and brightness values. where the hue value in the range from0 <= h < 360and the saturation and brightness are percent values.- Parameters:
value- a stringified HSBType value in the format "hue,saturation,brightness"
-
-
Method Details
-
valueOf
-
fromRGB
Create HSB from RGB. See alsoColorUtil.rgbToHsb(int[]).- Parameters:
r- red 0-255g- green 0-255b- blue 0-255- Throws:
IllegalArgumentException- when color values exceed allowed range
-
fromXY
Deprecated.UseColorUtil.xyToHsb(double[])orColorUtil.xyToHsb(double[], ColorUtil.Gamut)instead. Returns a HSBType object representing the provided xy color values in CIE XY color model. Conversion from CIE XY color model to sRGB using D65 reference white Returned color is set to full brightness- Parameters:
x- , y color information 0.0 - 1.0- Returns:
- new HSBType object representing the given CIE XY color, full brightness
- Throws:
IllegalArgumentException- when input array has wrong size or exceeds allowed value range
-
getConstituents
Description copied from interface:ComplexTypeReturns all constituents with their names as a sorted map- Specified by:
getConstituentsin interfaceComplexType- Returns:
- all constituents with their names
-
getHue
-
getSaturation
-
getBrightness
-
getRed
Deprecated.UseColorUtil.hsbToRgb(HSBType)instead -
getGreen
Deprecated.UseColorUtil.hsbToRgb(HSBType)instead -
getBlue
Deprecated.UseColorUtil.hsbToRgb(HSBType)instead -
getRGB
Deprecated.UseColorUtil.hsbTosRgb(HSBType)instead. Returns the RGB value representing the color in the default sRGB color model. (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue).- Returns:
- the RGB value of the color in the default sRGB color model
-
toString
- Overrides:
toStringin classDecimalType
-
toFullString
Description copied from interface:TypeGet a string representation that contains the whole internal representation of the type.The returned string could be consumed by the static 'valueOf(String)' method of the respective type to build a new type that is equal to this type.
- Specified by:
toFullStringin interfaceType- Overrides:
toFullStringin classDecimalType- Returns:
- a full string representation of the type to be consumed by 'valueOf(String)'
-
format
Description copied from interface:TypeFormats the value of this type according to a pattern (seeFormatter).- Specified by:
formatin interfaceType- Overrides:
formatin classDecimalType- Parameters:
pattern- the pattern to use- Returns:
- the formatted string
-
hashCode
public int hashCode()- Overrides:
hashCodein classDecimalType
-
equals
- Overrides:
equalsin classDecimalType
-
toRGB
Deprecated. -
toXY
Returns the xyY values representing this object's color in CIE XY color model. Conversion from sRGB to CIE XY using D65 reference white xy pair contains color information Y represents relative luminance- Returns:
- PercentType[x, y, Y] values in the CIE XY color model
-
as
Description copied from interface:StateConvert thisState's value into another type -
closeTo
Helper method for checking if two HSBType colors are close to each other. A maximum deviation is specifid in percent.- Parameters:
other- an HSBType containing the other color.maxPercentage- the maximum allowed difference in percent (range 0.0..1.0).- Throws:
IllegalArgumentException- if percentage is out of range.
-
ColorUtil.xyToHsb(double[])orColorUtil.xyToHsb(double[], ColorUtil.Gamut)instead.