Class Color

  • java.lang.Object
    • com.here.sdk.core.Color

  • public final class Color
    extends java.lang.Object

    Represents a color value.

    The class is compatible with the native package android.graphics and replaces native class Color.

    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
      float alpha()  
      float blue()  
      boolean equals​(java.lang.Object obj)  
      float green()  
      int hashCode()  
      float red()  
      int toArgb()
      Converts this color to an ARGB color int.
      java.lang.String toString()  
      static Color valueOf​(float red, float green, float blue)
      Creates a new opaque color from individual RGB components.
      static Color valueOf​(float red, float green, float blue, float alpha)
      Creates a new color from individual RGBA components.
      static Color valueOf​(int color)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • 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:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object