Class Color

java.lang.Object
com.massifmaps.graphics.Color

public class Color extends Object
A color represented in RGBA space, alpha is expected to be non-premultiplied.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a completely opaque black color object.
    Color(int color)
    Constructs a map color object from a 32-bit encoded integer.
    Color(short r, short g, short b, short a)
    Constructs a map color object from the red, green, blue and alpha components.
    Alpha component is interpreted as non-premultiplied transparency value,
    thus to make half-transparent green, use Color(0, 255, 0, 128).
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if this object is equal to the specified object.
    short
    Returns the alpha component of this map color.
    int
    Encodes this map color into 32-bit integer value (ARGB format).
    short
    Returns the blue component of this map color.
    short
    Returns the green component of this map color.
    short
    Returns the red component of this map color.
    int
    Returns the hash value of this object.
    Creates a string representation of this map color, useful for logging.

    Methods inherited from class java.lang.Object

    clone, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Color

      public Color()
      Constructs a completely opaque black color object.
    • Color

      public Color(short r, short g, short b, short a)
      Constructs a map color object from the red, green, blue and alpha components.
      Alpha component is interpreted as non-premultiplied transparency value,
      thus to make half-transparent green, use Color(0, 255, 0, 128).
      Parameters:
      r - The red component. Must be between 0 and 255.
      g - The green component. Must be between 0 and 255.
      b - The blue component. Must be between 0 and 255.
      a - The alpha component. Must be between 0 and 255.
    • Color

      public Color(int color)
      Constructs a map color object from a 32-bit encoded integer. The format is expected to be ARGB.
      Parameters:
      color - The color encoded into 32-bit integer as ARGB.
  • Method Details

    • equals

      public boolean equals(Object obj)
      Checks if this object is equal to the specified object.
      Overrides:
      equals in class Object
      Parameters:
      obj - The reference object.
      Returns:
      True when objects are equal, false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash value of this object.
      Overrides:
      hashCode in class Object
      Returns:
      The hash value of this object.
    • getR

      public short getR()
      Returns the red component of this map color.
      Returns:
      The red component in the [0..255] range.
    • getG

      public short getG()
      Returns the green component of this map color.
      Returns:
      The green component in the [0..255] range.
    • getB

      public short getB()
      Returns the blue component of this map color.
      Returns:
      The blue component in the [0..255] range.
    • getA

      public short getA()
      Returns the alpha component of this map color.
      Returns:
      The alpha component in the [0..255] range.
    • getARGB

      public int getARGB()
      Encodes this map color into 32-bit integer value (ARGB format).
      Returns:
      The encoded 32-bit integer representation of this map color.
    • toString

      public String toString()
      Creates a string representation of this map color, useful for logging.
      Overrides:
      toString in class Object
      Returns:
      The string representation of this map color.