public class

Color

extends Object
java.lang.Object
   ↳ com.carto.graphics.Color

Class Overview

A color represented in RGBA space, alpha is expected to be non-premultiplied.

Summary

Public Constructors
Color()
Constructs a completely opaque black color object.
Color(short r, short g, short b, short a)
Constructs a map color object from the red, green, blue and alpha components.
Color(int color)
Constructs a map color object from a 32-bit encoded integer.
Public Methods
synchronized void delete()
boolean equals(Object obj)
Checks if this object is equal to the specified object.
short getA()
Returns the alpha component of this map color.
int getARGB()
Encodes this map color into 32-bit integer value (ARGB format).
short getB()
Returns the blue component of this map color.
short getG()
Returns the green component of this map color.
short getR()
Returns the red component of this map color.
int hashCode()
Returns the hash value of this object.
String toString()
Creates a string representation of this map color, useful for logging.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Color ()

Constructs a completely opaque black color object.

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.

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.

Public Methods

public synchronized void delete ()

public boolean equals (Object obj)

Checks if this object is equal to the specified object.

Parameters
obj The reference object.
Returns
  • True when objects are equal, false otherwise.

public short getA ()

Returns the alpha component of this map color.

Returns
  • The alpha component in the [0..255] range.

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.

public short getB ()

Returns the blue component of this map color.

Returns
  • The blue component in the [0..255] range.

public short getG ()

Returns the green component of this map color.

Returns
  • The green component in the [0..255] range.

public short getR ()

Returns the red component of this map color.

Returns
  • The red component in the [0..255] range.

public int hashCode ()

Returns the hash value of this object.

Returns
  • The hash value of this object.

public String toString ()

Creates a string representation of this map color, useful for logging.

Returns
  • The string representation of this map color.