public final class ColorUtils
extends java.lang.Object
Color utility methods.| Modifier and Type | Method and Description |
|---|---|
static double |
calculateColorDistSq(javafx.scene.paint.Color color0,
javafx.scene.paint.Color color1)
Calculates and returns the distance between two
Colors, using a simple
Euclidean metric. |
static javafx.scene.paint.Color |
getClosestNamedColor(javafx.scene.paint.Color color)
Returns the named color that is closest to the given
color. |
static java.lang.String |
getClosestNamedColor(java.lang.Integer hexColor)
Returns the named color that is closest to the given hex code color value.
|
static java.util.Optional<javafx.scene.paint.Color> |
getNamedColor(javafx.scene.paint.Color color)
Returns an
Optional with a value of the named Color that is equal
to the given color, if it exists. |
static java.util.Optional<java.lang.String> |
getNamedColor(java.lang.Integer hexColor)
Returns the named color that is exactly equal to the given hex code color value.
|
static java.util.Optional<javafx.scene.paint.Color> |
getNamedColor(java.lang.String name)
Returns an
Optional with a value of the named Color that has
the given name, if it exists. |
public static java.lang.String getClosestNamedColor(java.lang.Integer hexColor)
Only the first 6 bytes of hexColor are taken into account. That is two bytes
for each red, blue, and green component.
hexColor - the Integer hex color value of the named color to returnhexString colorpublic static javafx.scene.paint.Color getClosestNamedColor(javafx.scene.paint.Color color)
color.color - the color to find the closest named color forcolorpublic static java.util.Optional<javafx.scene.paint.Color> getNamedColor(java.lang.String name)
Optional with a value of the named Color that has
the given name, if it exists. Otherwise returns an empty Optional.name - the name of the named Color to returnOptional<Color> that either contains the named color
with the given name or nothing (i.e. an empty Optional
if no such named color existspublic static java.util.Optional<javafx.scene.paint.Color> getNamedColor(javafx.scene.paint.Color color)
Optional with a value of the named Color that is equal
to the given color, if it exists. Otherwise returns an empty Optional.color - the color of the named color to returnOptional<Color> that either contains the named color
that is equal to the given color or nothing (i.e. an empty Optional)
if no such named color existspublic static java.util.Optional<java.lang.String> getNamedColor(java.lang.Integer hexColor)
Only the first 6 bytes of hexColor are taken into account. That is two bytes
for each red, blue, and green component.
hexColor - the Integer hex color value of the named color to returnOptional<String> that either contains the named color that equals
the given hexColor or nothing if no such named color existspublic static double calculateColorDistSq(javafx.scene.paint.Color color0,
javafx.scene.paint.Color color1)
Colors, using a simple
Euclidean metric.color0 - the first colorcolor1 - the second color