Class ColorObject

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getColor()
      Returns the String holding the color value of this ColorObject instance.
      static ColorObject getFromColor​(@NotNull java.awt.Color color)
      Creates a new ColorObject instance using the provided Color object.
      static ColorObject getFromRGB​(int r, int g, int b)
      Creates a new ColorObject instance using the provided r, g and b values.
      static ColorObject getFromRGBA​(int r, int g, int b, int a)
      Creates a new ColorObject instance using the provided r, g, b and a values.
      static ColorObject getFromString​(@NotNull java.lang.String color)
      Creates a new ColorObject instance using the provided String.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getFromColor

        public static ColorObject getFromColor​(@NotNull
                                               @NotNull java.awt.Color color)
        Creates a new ColorObject instance using the provided Color object.
        Parameters:
        color - The color to use for this ColorObject instance.
        Returns:
        New ColorObject instance containing the color values.
      • getFromString

        public static ColorObject getFromString​(@NotNull
                                                @NotNull java.lang.String color)
        Creates a new ColorObject instance using the provided String.

        You can use the following formats for the String:

        • r,g,b for RGB color values ranging from 0 to 255 each.
        • r,g,b,a for RGBA color values ranging from 0 to 255 each.
        • #rrggbb for hexadecimal color values.
        • Any valid HTML/CSS color name.
        Note that this wrapper will not try to validate and/or sanitize the provided value. Whatever has been set will be forwarded to the API, so make sure the provided value is actually valid.

        An IllegalArgumentException may be thrown in the following case:

        • Color is an empty String.
        Parameters:
        color - The color to use for this ColorObject instance.
        Returns:
        New ColorObject instance containing the color values.
      • getFromRGB

        public static ColorObject getFromRGB​(int r,
                                             int g,
                                             int b)
        Creates a new ColorObject instance using the provided r, g and b values.

        An IllegalArgumentException may be thrown in any of the following cases:

        • R is less than 0 or larger than 255.
        • G is less than 0 or larger than 255.
        • B is less than 0 or larger than 255.
        Parameters:
        r - Red color value to use.
        g - Green color value to use.
        b - Blue color value to use.
        Returns:
        New ColorObject instance containing the color values.
      • getFromRGBA

        public static ColorObject getFromRGBA​(int r,
                                              int g,
                                              int b,
                                              int a)
        Creates a new ColorObject instance using the provided r, g, b and a values.

        An IllegalArgumentException may be thrown in any of the following cases:

        • R is less than 0 or larger than 255.
        • G is less than 0 or larger than 255.
        • B is less than 0 or larger than 255.
        • A is less than 0 or larger than 255.
        Parameters:
        r - Red color value to use.
        g - Green color value to use.
        b - Blue color value to use.
        a - Alpha value to use.
        Returns:
        New ColorObject instance containing the color values.
      • getColor

        public java.lang.String getColor()
        Returns the String holding the color value of this ColorObject instance.

        When using getFromColor(Color) or getFromRGB(int, int, int) will the returned String always be in the format r,g,b. When using getFromRGBA(int, int, int, int) will the returned String always be in the format r,g,b,a.
        In any other case is the returned String not guaranteed to follow any particular format.

        Returns:
        The String created when using any of the getFromX methods.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object