- java.lang.Object
-
- org.testfx.util.ColorUtils
-
public final class ColorUtils extends Object
ContainsColorutility methods.- See Also:
- Named Colors
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublecalculateColorDistSq(Color color0, Color color1)Calculates and returns the distance between twoColors, using a simple Euclidean metric.static StringgetClosestNamedColor(Integer hexColor)Returns the named color that is closest to the given hex code color value.static ColorgetClosestNamedColor(Color color)Returns the named color that is closest to the givencolor.static Optional<String>getNamedColor(Integer hexColor)Returns the named color that is exactly equal to the given hex code color value.static Optional<Color>getNamedColor(String name)Returns anOptionalwith a value of the namedColorthat has the givenname, if it exists.static Optional<Color>getNamedColor(Color color)Returns anOptionalwith a value of the namedColorthat is equal to the givencolor, if it exists.
-
-
-
Method Detail
-
getClosestNamedColor
public static String getClosestNamedColor(Integer hexColor)
Returns the named color that is closest to the given hex code color value.Only the first 6 bytes of
hexColorare taken into account. That is two bytes for each red, blue, and green component.- Parameters:
hexColor- theIntegerhex color value of the named color to return- Returns:
- the named color that is closest to the given
hexStringcolor
-
getClosestNamedColor
public static Color getClosestNamedColor(Color color)
Returns the named color that is closest to the givencolor.- Parameters:
color- the color to find the closest named color for- Returns:
- the named color that is closest to the given
color
-
getNamedColor
public static Optional<Color> getNamedColor(String name)
Returns anOptionalwith a value of the namedColorthat has the givenname, if it exists. Otherwise returns an emptyOptional.- Parameters:
name- the name of the namedColorto return- Returns:
- an
Optional<Color>that either contains the named color with the givennameor nothing (i.e. an emptyOptionalif no such named color exists
-
getNamedColor
public static Optional<Color> getNamedColor(Color color)
Returns anOptionalwith a value of the namedColorthat is equal to the givencolor, if it exists. Otherwise returns an emptyOptional.- Parameters:
color- the color of the named color to return- Returns:
- an
Optional<Color>that either contains the named color that is equal to the givencoloror nothing (i.e. an emptyOptional) if no such named color exists
-
getNamedColor
public static Optional<String> getNamedColor(Integer hexColor)
Returns the named color that is exactly equal to the given hex code color value.Only the first 6 bytes of
hexColorare taken into account. That is two bytes for each red, blue, and green component.- Parameters:
hexColor- theIntegerhex color value of the named color to return- Returns:
- an
Optional<String>that either contains the named color that equals the givenhexColoror nothing if no such named color exists
-
-