Package ch.andre601.fluxpoint4j.util
Class ColorObject
- java.lang.Object
-
- ch.andre601.fluxpoint4j.util.ColorObject
-
public class ColorObject extends java.lang.Object
Simple class to allow having a unified format for colors in the Fluxpoint API.Currently supported options are:
*This wrapper will not try to validate the provided String in any shape or form.
-
-
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 providedColor 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()
-
-
-
Method Detail
-
getFromColor
public static ColorObject getFromColor(@NotNull @NotNull java.awt.Color color)
Creates a new ColorObject instance using the providedColor 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.
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)
orgetFromRGB(int, int, int)
will the returned String always be in the formatr,g,b
. When usinggetFromRGBA(int, int, int, int)
will the returned String always be in the formatr,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 classjava.lang.Object
-
-