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
    boolean equals​(Object o)  
    float getBlue()  
    float getGreen()  
    float getRed()  
    int hashCode()  
    static Color of​(float red, float green, float blue)
    Creates a Color object with the specified red, green, and blue parts.
    static Color of​(int redGreenBlue)
    Creates a Color object 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 Color of​(int red, int green, int blue)
    Creates a Color object with the specified red, green, and blue parts.
    static Color of​(Integer redGreenBlue)
    Creates a Color object 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 Color of​(Object otherColorObject)
    Accepts another kind of `Color` object, such as an instance of a java.awt.Color or android.graphics.Color, and tries to parse it into this kind of a Color object.
    static Color of​(String hexRgb)
    Creates a Color object from the given string that should represent a three bytes long hexadecimal number.
    String toString()  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • getRed

      public float getRed()
    • getGreen

      public float getGreen()
    • getBlue

      public float getBlue()
    • of

      public static Color of​(float red, float green, float blue)
      Creates a Color object with the specified red, green, and blue parts.
      Parameters:
      red - A float number from 0 to 1 inclusive
      green - A float number from 0 to 1 inclusive
      blue - A float number from 0 to 1 inclusive
      Returns:
      A Color object
      Throws:
      IllegalArgumentException - if the values are out of range
    • of

      public static Color of​(int red, int green, int blue)
      Creates a Color object with the specified red, green, and blue parts.
      Parameters:
      red - An integer number from 0 to 255 inclusive
      green - An integer number from 0 to 255 inclusive
      blue - An integer number from 0 to 255 inclusive
      Returns:
      A Color object
      Throws:
      IllegalArgumentException - if the values are out of range
    • of

      public static Color of​(int redGreenBlue)
      Creates a Color object 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 Color object, as parsed from the three lowest bytes of the given integer
    • of

      public static Color of​(Integer redGreenBlue)
      Creates a Color object 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 Color object, as parsed from the three lowest bytes of the given integer
      Throws:
      IllegalArgumentException - if the input value is null
    • of

      public static Color of​(String hexRgb)
      Creates a Color object 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, #ff0000 for red, or 00FF00 for blue.
      Returns:
      A Color object, or an IllegalArgumentException if the value is not of the required format
      Throws:
      IllegalArgumentException - in case the parameter cannot be parsed as a color string
    • of

      public static Color of​(Object otherColorObject)
      Accepts another kind of `Color` object, such as an instance of a java.awt.Color or android.graphics.Color, and tries to parse it into this kind of a Color object.
      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 Color object.
      Throws:
      IllegalArgumentException - in case the parameter cannot be parsed as a color
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object