de.kosi.gui.util
Class CUtilities
java.lang.Object
|
+--de.kosi.gui.util.CUtilities
- public class CUtilities
- extends java.lang.Object
This class provides some static utilitiy functions.
Method Summary |
static void |
checkInRange(int val,
int min,
int max)
Throws an IllegalArgumentException if val
is greater than min or less than max . |
static void |
checkNotNull(java.lang.Object object)
Throws an IllegalArgumentException if the argument
is null . |
static double |
clamp(double value,
double min,
double max)
|
static float |
clamp(float value,
float min,
float max)
|
static int |
clamp(int value,
int min,
int max)
|
static int |
countChar(java.lang.String string,
char ch)
Counts the number of occurences of a character in
a string. |
static java.awt.Image |
getImage(java.lang.String name)
|
static void |
handleException(java.lang.Exception exception)
Tells the user that an exception was thrown. |
static double |
interpolate(double x,
double y,
double alpha)
Linear interpolation of double values. |
static float |
interpolate(float x,
float y,
float alpha)
Linear interpolation of float values. |
static int |
random(int min,
int max)
|
static java.lang.String[] |
splitString(java.lang.String string,
char separator)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CUtilities
public CUtilities()
getImage
public static java.awt.Image getImage(java.lang.String name)
splitString
public static java.lang.String[] splitString(java.lang.String string,
char separator)
countChar
public static int countChar(java.lang.String string,
char ch)
- Counts the number of occurences of a character in
a string.
- Parameters:
string
- the string to examine.ch
- the character which number occurences you want to know.
handleException
public static void handleException(java.lang.Exception exception)
- Tells the user that an exception was thrown.
- Parameters:
exception
- the exception that was thrown.
checkInRange
public static void checkInRange(int val,
int min,
int max)
- Throws an
IllegalArgumentException
if val
is greater than min
or less than max
.
- Parameters:
val
- the value to check if it is in the allowed range.min
- the minimum value allowed.max
- the upper bound of the range / the maximum value allowed.
checkNotNull
public static void checkNotNull(java.lang.Object object)
- Throws an
IllegalArgumentException
if the argument
is null
.
- Parameters:
object
- the pointer to check if it is not null
.
interpolate
public static double interpolate(double x,
double y,
double alpha)
- Linear interpolation of
double
values.
- Parameters:
x
- y
- alpha
- - Returns:
-
interpolate
public static float interpolate(float x,
float y,
float alpha)
- Linear interpolation of
float
values.
- Returns:
(1.f - alpha) * i + alpha * j
random
public static int random(int min,
int max)
clamp
public static double clamp(double value,
double min,
double max)
clamp
public static float clamp(float value,
float min,
float max)
clamp
public static int clamp(int value,
int min,
int max)