public class Range
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static byte |
clip(byte number,
byte min,
byte max)
clip 'number' if 'number' is less than 'min' or greater than 'max'
|
static double |
clip(double number,
double min,
double max)
clip 'number' if 'number' is less than 'min' or greater than 'max'
|
static float |
clip(float number,
float min,
float max)
clip 'number' if 'number' is less than 'min' or greater than 'max'
|
static int |
clip(int number,
int min,
int max)
clip 'number' if 'number' is less than 'min' or greater than 'max'
|
static short |
clip(short number,
short min,
short max)
clip 'number' if 'number' is less than 'min' or greater than 'max'
|
static double |
scale(double n,
double x1,
double x2,
double y1,
double y2)
Scale a number in the range of x1 to x2, to the range of y1 to y2
|
static void |
throwIfRangeIsInvalid(double number,
double min,
double max)
Throw an IllegalArgumentException if 'number' is less than 'min' or greater than 'max'
|
static void |
throwIfRangeIsInvalid(int number,
int min,
int max)
Throw an IllegalArgumentException if 'number' is less than 'min' or greater than 'max'
|
public static double scale(double n, double x1, double x2, double y1, double y2)
n
- number to scalex1
- lower bound range of nx2
- upper bound range of ny1
- lower bound of scaley2
- upper bound of scalepublic static double clip(double number, double min, double max)
number
- number to testmin
- minimum value allowedmax
- maximum value allowedpublic static float clip(float number, float min, float max)
number
- number to testmin
- minimum value allowedmax
- maximum value allowedpublic static int clip(int number, int min, int max)
number
- number to testmin
- minimum value allowedmax
- maximum value allowedpublic static short clip(short number, short min, short max)
number
- number to testmin
- minimum value allowedmax
- maximum value allowedpublic static byte clip(byte number, byte min, byte max)
number
- number to testmin
- minimum value allowedmax
- maximum value allowedpublic static void throwIfRangeIsInvalid(double number, double min, double max) throws java.lang.IllegalArgumentException
number
- number to testmin
- minimum value allowedmax
- maximum value allowedjava.lang.IllegalArgumentException
- if number is outside of rangepublic static void throwIfRangeIsInvalid(int number, int min, int max) throws java.lang.IllegalArgumentException
number
- number to testmin
- minimum value allowedmax
- maximum value allowedjava.lang.IllegalArgumentException
- if number is outside of range