Class Color
Package com.here.sdk.core
Class Color
- java.lang.Object
-
- com.here.sdk.core.Color
-
public final class Color extends java.lang.ObjectRepresents a color value.
The class is compatible with the native package
android.graphicsand replaces native classColor.Usage example:
import com.here.sdk.core.Color; import static android.graphics.Color.BLUE; import static android.graphics.Color.green; // Convert native colors to HERE color. Color blue = Color.valueOf(android.graphics.Color.BLUE); Color anotherColor = Color.valueOf(0.25f, 0.5f, 0.75f, 0.9f); //ARGB // Retrieve the blue color component. float blueColorValue = anotherColor.blue(); // = 0.9f // Convert back to a native color component with the range [0,255]. int greenColorValue = android.graphics.Color.green(anotherColor.toArgb()); // = 230
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description floatalpha()floatblue()booleanequals(java.lang.Object obj)floatgreen()inthashCode()floatred()inttoArgb()Converts this color to an ARGB color int.java.lang.StringtoString()static ColorvalueOf(float red, float green, float blue)Creates a new opaque color from individual RGB components.static ColorvalueOf(float red, float green, float blue, float alpha)Creates a new color from individual RGBA components.static ColorvalueOf(int color)
-
-
-
Method Detail
-
valueOf
@NonNull public static Color valueOf(float red, float green, float blue)
Creates a new opaque color from individual RGB components.- Parameters:
red-the value of red component [0,1]
green-the value of green component [0,1]
blue-the value of blue component [0,1]
- Returns:
- a new Color instance from given components.
-
valueOf
@NonNull public static Color valueOf(float red, float green, float blue, float alpha)
Creates a new color from individual RGBA components.- Parameters:
red-the value of red component [0,1]
green-the value of green component [0,1]
blue-the value of blue component [0,1]
alpha-the value of alpha component [0,1]
- Returns:
- a new Color instance from given components.
-
valueOf
@NonNull public static Color valueOf(@ColorInt int color)
- Parameters:
color- ARGB color int- Returns:
- a new Color instance from color int.
-
red
public float red()
- Returns:
- value of red component in range [0,1]
-
green
public float green()
- Returns:
- value of green component in range [0,1]
-
blue
public float blue()
- Returns:
- value of blue component in range [0,1]
-
alpha
public float alpha()
- Returns:
- value of alpha component in range [0,1]
-
toArgb
@ColorInt public int toArgb()
Converts this color to an ARGB color int.- Returns:
- ARGB color int
-
toString
@NonNull public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-