Package io.github.zeroone3010.yahueapi
Class Color
java.lang.Object
io.github.zeroone3010.yahueapi.Color
public final class Color extends Object
Use this class to define a color for a color light -- or for a room with color lights.
-
Method Summary
Modifier and Type Method Description booleanequals(Object o)floatgetBlue()floatgetGreen()floatgetRed()inthashCode()static Colorof(float red, float green, float blue)Creates aColorobject with the specified red, green, and blue parts.static Colorof(int redGreenBlue)Creates aColorobject from the given integer such that the least significant byte (0xFF) represent blue, the next byte green (0xFF00) and the next one red (0xFF0000).static Colorof(int red, int green, int blue)Creates aColorobject with the specified red, green, and blue parts.static Colorof(Integer redGreenBlue)Creates aColorobject from the given integer such that the least significant byte (0xFF) represent blue, the next byte green (0xFF00) and the next one red (0xFF0000).static Colorof(Object otherColorObject)Accepts another kind of `Color` object, such as an instance of ajava.awt.Colororandroid.graphics.Color, and tries to parse it into this kind of aColorobject.static Colorof(String hexRgb)Creates aColorobject from the given string that should represent a three bytes long hexadecimal number.StringtoString()
-
Method Details
-
getRed
public float getRed() -
getGreen
public float getGreen() -
getBlue
public float getBlue() -
of
Creates aColorobject with the specified red, green, and blue parts.- Parameters:
red- A float number from 0 to 1 inclusivegreen- A float number from 0 to 1 inclusiveblue- A float number from 0 to 1 inclusive- Returns:
- A
Colorobject - Throws:
IllegalArgumentException- if the values are out of range
-
of
Creates aColorobject with the specified red, green, and blue parts.- Parameters:
red- An integer number from 0 to 255 inclusivegreen- An integer number from 0 to 255 inclusiveblue- An integer number from 0 to 255 inclusive- Returns:
- A
Colorobject - Throws:
IllegalArgumentException- if the values are out of range
-
of
Creates aColorobject from the given integer such that the least significant byte (0xFF) represent blue, the next byte green (0xFF00) and the next one red (0xFF0000). All other bytes are ignored.- Parameters:
redGreenBlue- An integer representing a 24-bit RGB color- Returns:
- A
Colorobject, as parsed from the three lowest bytes of the given integer
-
of
Creates aColorobject from the given integer such that the least significant byte (0xFF) represent blue, the next byte green (0xFF00) and the next one red (0xFF0000). All other bytes are ignored.- Parameters:
redGreenBlue- An integer representing a 24-bit RGB color- Returns:
- A
Colorobject, as parsed from the three lowest bytes of the given integer - Throws:
IllegalArgumentException- if the input value is null
-
of
Creates aColorobject from the given string that should represent a three bytes long hexadecimal number.- Parameters:
hexRgb- Six hexadecimal digits, with an optional number sign (#) in front. For example,#ff0000for red, or00FF00for blue.- Returns:
- A
Colorobject, or anIllegalArgumentExceptionif the value is not of the required format - Throws:
IllegalArgumentException- in case the parameter cannot be parsed as a color string
-
of
Accepts another kind of `Color` object, such as an instance of ajava.awt.Colororandroid.graphics.Color, and tries to parse it into this kind of aColorobject.- Parameters:
otherColorObject- An instance of another sensible color object that provides methods with which one can read the red, green, and blue component values.- Returns:
- A
Colorobject. - Throws:
IllegalArgumentException- in case the parameter cannot be parsed as a color
-
toString
-
equals
-
hashCode
public int hashCode()
-