public class Utils extends Object
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
assertionEnabled()
*
Miscellaneous utilities *
*
|
static double |
calculateBrightness(Color color)
Calculates a perceptual brightness for a color between 0.0 black and 1.0 while
|
static double |
clamp(double min,
double value,
double max)
Simple utility function which clamps the given value to be strictly
between the min and max values.
|
static float |
clamp(float min,
float value,
float max)
Simple utility function which clamps the given value to be strictly
between the min and max values.
|
static int |
clamp(int min,
int value,
int max)
Simple utility function which clamps the given value to be strictly
between the min and max values.
|
static int |
clampMax(int value,
int max)
Simple utility function which clamps the given value to be strictly
under the max value.
|
static double |
clampMin(double value,
double min)
Simple utility function which clamps the given value to be strictly
above the min value.
|
static boolean |
contains(String src,
String s)
Because mobile doesn't have string.contains(s) function, this function
was written.
|
static Color |
convertLinearRGBtoSRGB(Color color)
Helper function to convert a color in linear RGB space to SRGB space.
|
static Color |
convertSRGBtoLinearRGB(Color color)
Helper function to convert a color in sRGB space to linear RGB space.
|
static String |
convertUnicode(String src)
*
Unicode-related utilities *
*
|
static Color |
deriveColor(Color c,
double brightness)
Derives a lighter or darker of a given color.
|
static Screen |
getScreen(Object obj)
This function attempts to determine the best screen given the parent object
from which we are wanting to position another item relative to.
|
static Screen |
getScreenForPoint(double x,
double y) |
static Screen |
getScreenForRectangle(Rectangle2D rect) |
static boolean |
hasFullScreenStage(Screen screen) |
static double[] |
HSBtoRGB(double hue,
double saturation,
double brightness) |
static boolean |
isMac()
Returns true if the operating system is a form of Mac OS.
|
static boolean |
isQVGAScreen() |
static boolean |
isUnix()
Returns true if the operating system is a form of Unix, including Linux.
|
static boolean |
isWindows()
Returns true if the operating system is a form of Windows.
|
static Color |
ladder(Color color,
Stop[] stops)
Get the color at the give
position in the ladder of color stops |
static double |
nearest(double less,
double value,
double more)
Utility function which returns either
less or more
depending on which value is closer to. |
static Point2D |
pointRelativeTo(Node parent,
double anchorWidth,
double anchorHeight,
HPos hpos,
VPos vpos,
double dx,
double dy,
boolean reposition) |
static Point2D |
pointRelativeTo(Node parent,
Node node,
HPos hpos,
VPos vpos,
double dx,
double dy,
boolean reposition) |
static Point2D |
pointRelativeTo(Object parent,
double width,
double height,
double screenX,
double screenY,
HPos hpos,
VPos vpos)
This is the fallthrough function that most other functions fall into.
|
static double[] |
RGBtoHSB(double r,
double g,
double b) |
static String[] |
split(String str,
String separator)
Because mobile doesn't have string.split(s) function, this function
was written.
|
static String |
stripQuotes(String str)
Helper to remove leading and trailing quotes from a string.
|
static double |
sum(double[] values)
helper function for calculating the sum of a series of numbers
|
public static float clamp(float min, float value, float max)
public static int clamp(int min, int value, int max)
public static double clamp(double min, double value, double max)
public static double clampMin(double value, double min)
public static int clampMax(int value, int max)
public static double nearest(double less, double value, double more)
less
or more
depending on which value
is closer to. If value
is perfectly between them, then either may be returned.public static String stripQuotes(String str)
public static String[] split(String str, String separator)
public static boolean contains(String src, String s)
public static double calculateBrightness(Color color)
public static Color deriveColor(Color c, double brightness)
c
- The color to derive frombrightness
- The brightness difference for the new color -1.0 being 100% dark which is always black, 0.0 being
no change and 1.0 being 100% lighter which is always whitepublic static Color ladder(Color color, Stop[] stops)
position
in the ladder of color stopspublic static double[] HSBtoRGB(double hue, double saturation, double brightness)
public static double[] RGBtoHSB(double r, double g, double b)
public static Color convertSRGBtoLinearRGB(Color color)
public static Color convertLinearRGBtoSRGB(Color color)
public static double sum(double[] values)
public static Point2D pointRelativeTo(Node parent, Node node, HPos hpos, VPos vpos, double dx, double dy, boolean reposition)
public static Point2D pointRelativeTo(Node parent, double anchorWidth, double anchorHeight, HPos hpos, VPos vpos, double dx, double dy, boolean reposition)
public static Point2D pointRelativeTo(Object parent, double width, double height, double screenX, double screenY, HPos hpos, VPos vpos)
width
and public static boolean hasFullScreenStage(Screen screen)
public static boolean isQVGAScreen()
public static Screen getScreen(Object obj)
public static Screen getScreenForRectangle(Rectangle2D rect)
public static Screen getScreenForPoint(double x, double y)
public static boolean assertionEnabled()
public static boolean isWindows()
public static boolean isMac()
public static boolean isUnix()
Copyright © 2020. All rights reserved.