public class ValueUtil
extends java.lang.Object
Constructor and Description |
---|
ValueUtil() |
Modifier and Type | Method and Description |
---|---|
static double |
adjustValue(double currentValue,
double desiredValue,
double valueChange)
Adjusts the passed current value by valueChange and makes sure that
desired value is not exceeded.
|
static double |
adjustValue(double currentValue,
double desiredValue,
double valueChangeAdd,
double valueChangeSubtract)
Adjusts the passed current value by valueChange and makes sure that
desired value is not exceeded.
|
static double |
getScale(double[] values,
double maxValue) |
static double |
getValueAdjustment(double currentValue,
double desiredValue,
double valueChangeAdd,
double valueChangeSubtract)
Returns the effective value change to adjust currentValue do desiredValue.
|
static boolean |
isValueInRange(double value,
double min,
double max)
Checks if the given value is inside the range defined by min and max.
|
static boolean |
isValueInRange(double value,
double min,
double max,
double epsilon)
Checks if the given value is inside the range defined by (min - epsilon)
and (max + epsilon).
|
static boolean |
isValueInRange(float value,
float min,
float max)
Checks if the given value is inside the range defined by min and max.
|
static boolean |
isValueInRange(float value,
float min,
float max,
float epsilon)
Checks if the given value is inside the range defined by (min - epsilon)
and (max + epsilon).
|
static double |
limitAbs(double value,
double limit)
Limits the passed value's absolute value by the limit passed.
|
static float |
limitAbs(float value,
float limit)
Limits the passed value's absolute value by the limit passed.
|
static double |
limitValue(double value,
double min,
double max)
Limits the passed value to the range passed.
|
static float |
limitValue(float value,
float min,
float max)
Limits the passed value to the range passed.
|
public static float limitValue(float value, float min, float max)
value
- the value to limitmin
- the smallest value value can havemax
- the highest value value can havepublic static double limitValue(double value, double min, double max)
value
- the value to limitmin
- the smallest value value can havemax
- the highest value value can havepublic static double limitAbs(double value, double limit)
value
- the value to limitlimit
- positive upper limit of the intervalpublic static float limitAbs(float value, float limit)
value
- the value to limitlimit
- positive upper limit of the intervalpublic static double adjustValue(double currentValue, double desiredValue, double valueChange)
currentValue
- the value to adjustdesiredValue
- the value we want to reachvalueChange
- the delta to be added to current valuepublic static double adjustValue(double currentValue, double desiredValue, double valueChangeAdd, double valueChangeSubtract)
currentValue
- the value to adjustdesiredValue
- the value we want to reachvalueChangeAdd
- the delta to be added to current valuevalueChangeSubtract
- the delta to be subtracted from current valuepublic static double getValueAdjustment(double currentValue, double desiredValue, double valueChangeAdd, double valueChangeSubtract)
currentValue
- the value to adjustdesiredValue
- the value we want to reachvalueChangeAdd
- the delta to be added to current valuevalueChangeSubtract
- the delta to be subtracted from current valuepublic static double getScale(double[] values, double maxValue)
values
- the values to addmaxValue
- the value to which to scale if sum is biggerpublic static boolean isValueInRange(double value, double min, double max, double epsilon)
value
- The value to checkmin
- The lower bound of the valid rangemax
- The upper bound of the valid rangeepsilon
- The allowed deviation from the defined rangepublic static boolean isValueInRange(float value, float min, float max, float epsilon)
value
- The value to checkmin
- The lower bound of the valid rangemax
- The upper bound of the valid rangeepsilon
- The allowed deviation from the defined rangepublic static boolean isValueInRange(double value, double min, double max)
value
- The value to checkmin
- The lower bound of the valid rangemax
- The upper bound of the valid rangepublic static boolean isValueInRange(float value, float min, float max)
value
- The value to checkmin
- The lower bound of the valid rangemax
- The upper bound of the valid range