Package ch.andre601.fluxpoint4j.util
Class ColorObject
- java.lang.Object
-
- ch.andre601.fluxpoint4j.util.ColorObject
-
public class ColorObject extends java.lang.ObjectSimple 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.StringgetColor()Returns the String holding the color value of this ColorObject instance.static ColorObjectgetFromColor(@NotNull java.awt.Color color)Creates a new ColorObject instance using the providedColor object.static ColorObjectgetFromRGB(int r, int g, int b)Creates a new ColorObject instance using the provided r, g and b values.static ColorObjectgetFromRGBA(int r, int g, int b, int a)Creates a new ColorObject instance using the provided r, g, b and a values.static ColorObjectgetFromString(@NotNull java.lang.String color)Creates a new ColorObject instance using the provided String.java.lang.StringtoString()
-
-
-
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,bfor RGB color values ranging from 0 to 255 each.r,g,b,afor RGBA color values ranging from 0 to 255 each.#rrggbbfor hexadecimal color values.- Any valid HTML/CSS color name.
An
IllegalArgumentExceptionmay 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
IllegalArgumentExceptionmay 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
IllegalArgumentExceptionmay 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
getFromXmethods.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-