public class ColorUtils extends Object
| Constructor and Description |
|---|
ColorUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
expandShorthandHex(String color)
Expand the hex if it is in shorthand
|
static String |
expandShorthandHexSingle(String color)
Expand the hex single if it is in shorthand
|
static int |
getAlpha(int color)
Get the alpha color from color integer
|
static String |
getAlpha(String hex)
Get the hex alpha color from the hex string if it exists
|
static int |
getBlue(int color)
Get the blue color from color integer
|
static String |
getBlue(String hex)
Get the hex blue color from the hex string
|
static int |
getGreen(int color)
Get the green color from color integer
|
static String |
getGreen(String hex)
Get the hex green color from the hex string
|
static int |
getRed(int color)
Get the red color from color integer
|
static String |
getRed(String hex)
Get the hex red color from the hex string
|
static boolean |
isValidArithmeticRGB(float color)
Check if the arithmetic RGB float color is valid, inclusively between 0.0
and 1.0
|
static boolean |
isValidHex(String color)
Check if the hex color value is valid
|
static boolean |
isValidHexSingle(String color)
Check if the hex single color value is valid
|
static boolean |
isValidHue(float hue)
Check if the HSL hue float value is valid, inclusively between 0.0 and
360.0
|
static boolean |
isValidLightness(float lightness)
Check if the HSL lightness float value is valid, inclusively between 0.0
and 1.0
|
static boolean |
isValidRGB(int color)
Check if the RBG integer color is valid, inclusively between 0 and 255
|
static boolean |
isValidSaturation(float saturation)
Check if the HSL saturation float value is valid, inclusively between 0.0
and 1.0
|
static String |
shorthandHex(String color)
Shorthand the hex color if possible
|
static String |
shorthandHexSingle(String color)
Shorthand the hex single color if possible
|
static float[] |
toArithmeticRGB(float hue,
float saturation,
float lightness)
Convert HSL (hue, saturation, and lightness) values to RGB arithmetic
values
|
static float |
toArithmeticRGB(int color)
Convert the RGB integer to an arithmetic RBG float
|
static float |
toArithmeticRGB(String color)
Convert the hex single color to an arithmetic RBG float
|
static int |
toColor(int red,
int green,
int blue)
Convert the RBG values to a color integer
|
static String |
toColor(String red,
String green,
String blue)
Convert the hex color values to a hex color
|
static String |
toColorShorthand(String red,
String green,
String blue)
Convert the hex color values to a hex color, shorthanded when possible
|
static String |
toColorShorthandWithAlpha(String red,
String green,
String blue)
Convert the hex color values to a hex color including an opaque alpha
value of FF or F, shorthanded when possible
|
static String |
toColorShorthandWithAlpha(String red,
String green,
String blue,
String alpha)
Convert the hex color values to a hex color, shorthanded when possible
|
static int |
toColorWithAlpha(int red,
int green,
int blue)
Convert the RBG values to a color integer including an opaque alpha value
of 255
|
static int |
toColorWithAlpha(int red,
int green,
int blue,
int alpha)
Convert the RBGA values to a color integer
|
static String |
toColorWithAlpha(String red,
String green,
String blue)
Convert the hex color values to a hex color including an opaque alpha
value of FF
|
static String |
toColorWithAlpha(String red,
String green,
String blue,
String alpha)
Convert the hex color values to a hex color
|
static String |
toHex(float color)
Convert the arithmetic RGB float to a hex single color
|
static String |
toHex(int color)
Convert the RGB integer to a hex single color
|
static float[] |
toHSL(float red,
float green,
float blue)
Convert red, green, and blue arithmetic values to HSL (hue, saturation,
lightness) values
|
static float[] |
toHSL(int red,
int green,
int blue)
Convert red, green, and blue integer values to HSL (hue, saturation,
lightness) values
|
static int |
toRGB(float color)
Convert the arithmetic RGB float to a RBG integer
|
static int[] |
toRGB(float hue,
float saturation,
float lightness)
Convert HSL (hue, saturation, and lightness) values to RGB integer values
|
static int |
toRGB(String color)
Convert the hex single color to a RBG integer
|
static void |
validateArithmeticRGB(float color)
Validate the arithmetic RGB float color is inclusively between 0.0 and
1.0
|
static void |
validateHex(String color)
Validate the hex color value
|
static void |
validateHexSingle(String color)
Validate the hex single color value
|
static void |
validateHue(float hue)
Validate the HSL hue float value is inclusively between 0.0 and 360.0
|
static void |
validateLightness(float lightness)
Validate the HSL lightness float value is inclusively between 0.0 and 1.0
|
static void |
validateRGB(int color)
Validate the RBG integer color is inclusively between 0 and 255
|
static void |
validateSaturation(float saturation)
Validate the HSL saturation float value is inclusively between 0.0 and
1.0
|
public static String toColor(String red, String green, String blue)
red - red hex color in format RR or Rgreen - green hex color in format GG or Gblue - blue hex color in format BB or Bpublic static String toColorShorthand(String red, String green, String blue)
red - red hex color in format RR or Rgreen - green hex color in format GG or Gblue - blue hex color in format BB or Bpublic static String toColorWithAlpha(String red, String green, String blue)
red - red hex color in format RR or Rgreen - green hex color in format GG or Gblue - blue hex color in format BB or Bpublic static String toColorShorthandWithAlpha(String red, String green, String blue)
red - red hex color in format RR or Rgreen - green hex color in format GG or Gblue - blue hex color in format BB or Bpublic static String toColorWithAlpha(String red, String green, String blue, String alpha)
red - red hex color in format RR or Rgreen - green hex color in format GG or Gblue - blue hex color in format BB or Balpha - alpha hex color in format AA or A, null to not include alphapublic static String toColorShorthandWithAlpha(String red, String green, String blue, String alpha)
red - red hex color in format RR or Rgreen - green hex color in format GG or Gblue - blue hex color in format BB or Balpha - alpha hex color in format AA or A, null to not include alphapublic static int toColor(int red,
int green,
int blue)
red - red integer color inclusively between 0 and 255green - green integer color inclusively between 0 and 255blue - blue integer color inclusively between 0 and 255public static int toColorWithAlpha(int red,
int green,
int blue)
red - red integer color inclusively between 0 and 255green - green integer color inclusively between 0 and 255blue - blue integer color inclusively between 0 and 255public static int toColorWithAlpha(int red,
int green,
int blue,
int alpha)
red - red integer color inclusively between 0 and 255green - green integer color inclusively between 0 and 255blue - blue integer color inclusively between 0 and 255alpha - alpha integer color inclusively between 0 and 255, -1 to not
include alphapublic static String toHex(int color)
color - integer color inclusively between 0 and 255public static String toHex(float color)
color - float color inclusively between 0.0 and 1.0public static int toRGB(String color)
color - hex single color in format FF or Fpublic static int toRGB(float color)
color - float color inclusively between 0.0 and 1.0public static float toArithmeticRGB(String color)
color - hex single color in format FF or Fpublic static float toArithmeticRGB(int color)
color - integer color inclusively between 0 and 255public static float[] toHSL(float red,
float green,
float blue)
red - red color inclusively between 0.0 and 1.0green - green color inclusively between 0.0 and 1.0blue - blue color inclusively between 0.0 and 1.0public static float[] toHSL(int red,
int green,
int blue)
red - red color inclusively between 0 and 255green - green color inclusively between 0 and 255blue - blue color inclusively between 0 and 255public static float[] toArithmeticRGB(float hue,
float saturation,
float lightness)
hue - hue value inclusively between 0.0 and 360.0saturation - saturation inclusively between 0.0 and 1.0lightness - lightness inclusively between 0.0 and 1.0public static int[] toRGB(float hue,
float saturation,
float lightness)
hue - hue value inclusively between 0.0 and 360.0saturation - saturation inclusively between 0.0 and 1.0lightness - lightness inclusively between 0.0 and 1.0public static String getRed(String hex)
hex - hex colorpublic static String getGreen(String hex)
hex - hex colorpublic static String getBlue(String hex)
hex - hex colorpublic static String getAlpha(String hex)
hex - hex colorpublic static int getRed(int color)
color - color integerpublic static int getGreen(int color)
color - color integerpublic static int getBlue(int color)
color - color integerpublic static int getAlpha(int color)
color - color integerpublic static String shorthandHex(String color)
color - hex colorpublic static String expandShorthandHex(String color)
color - hex colorpublic static String shorthandHexSingle(String color)
color - hex single colorpublic static String expandShorthandHexSingle(String color)
color - hex single colorpublic static boolean isValidHex(String color)
color - hex colorpublic static void validateHex(String color)
color - hex colorpublic static boolean isValidHexSingle(String color)
color - hex single colorpublic static void validateHexSingle(String color)
color - hex single colorpublic static boolean isValidRGB(int color)
color - decimal colorpublic static void validateRGB(int color)
color - decimal colorpublic static boolean isValidArithmeticRGB(float color)
color - decimal colorpublic static void validateArithmeticRGB(float color)
color - decimal colorpublic static boolean isValidHue(float hue)
hue - hue valuepublic static void validateHue(float hue)
hue - hue valuepublic static boolean isValidSaturation(float saturation)
saturation - saturation valuepublic static void validateSaturation(float saturation)
saturation - saturation valuepublic static boolean isValidLightness(float lightness)
lightness - lightness valuepublic static void validateLightness(float lightness)
lightness - lightness valueCopyright © 2020 National Geospatial-Intelligence Agency. All rights reserved.