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
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HSBType
static final HSBType
static final HSBType
protected BigDecimal
static final String
static final String
static final String
static final HSBType
protected BigDecimal
static final HSBType
Fields inherited from class org.openhab.core.library.types.PercentType
HUNDRED, ZERO
Fields 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 typeboolean
Formats the value of this type according to a pattern (seeFormatter
).static HSBType
fromRGB
(int r, int g, int b) Create HSB from RGBstatic HSBType
fromXY
(float x, float y) Returns a HSBType object representing the provided xy color values in CIE XY color model.getBlue()
Returns all constituents with their names as a sorted mapgetGreen()
getHue()
getRed()
int
getRGB()
Returns the RGB value representing the color in the default sRGB color model.int
hashCode()
Get a string representation that contains the whole internal representation of the type.toRGB()
toString()
toXY()
Returns the xyY values representing this object's color in CIE XY color model.static HSBType
Methods inherited from class org.openhab.core.library.types.DecimalType
compareTo, defaultConversion, doubleValue, floatValue, intValue, longValue, toBigDecimal
Methods 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 from 0 <= 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 from 0 <= h < 360 and 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- Parameters:
r
- red 0-255g
- green 0-255b
- blue 0-255
-
fromXY
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
-
getConstituents
Description copied from interface:ComplexType
Returns all constituents with their names as a sorted map- Specified by:
getConstituents
in interfaceComplexType
- Returns:
- all constituents with their names
-
getHue
-
getSaturation
-
getBrightness
-
getRed
-
getGreen
-
getBlue
-
getRGB
public int getRGB()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:
toString
in classDecimalType
-
toFullString
Description copied from interface:Type
Get 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:
toFullString
in interfaceType
- Overrides:
toFullString
in classDecimalType
- Returns:
- a full string representation of the type to be consumed by 'valueOf(String)'
-
format
Description copied from interface:Type
Formats the value of this type according to a pattern (seeFormatter
).- Specified by:
format
in interfaceType
- Overrides:
format
in classDecimalType
- Parameters:
pattern
- the pattern to use- Returns:
- the formatted string
-
hashCode
public int hashCode()- Overrides:
hashCode
in classDecimalType
-
equals
- Overrides:
equals
in classDecimalType
-
toRGB
-
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- Parameters:
HSBType
- color object- Returns:
- PercentType[x, y, Y] values in the CIE XY color model
-
as
Description copied from interface:State
Convert thisState
's value into another type
-