|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.caff.gimmix.Utility
public class Utility
Utility contains some helpful functionality.
Main thing to know is that the Utility.setApplet(java.applet.Applet)
method has to be called explicitely in the init()
method of an Applet
for everything to work smoothly.
![]() |
![]() |
![]() |
![]() |
Constructor Summary | |
---|---|
Utility()
|
Method Summary | |
---|---|
static boolean |
areWeInAnApplet()
Are we running an applet? |
static boolean |
areWeOnDOS()
Test wether our System is a DOS. |
static java.lang.String |
compileString(java.lang.String tag,
java.lang.Object[] args,
java.util.ResourceBundle res)
Compile a formatted string with maximum 10 args. |
static void |
debug(java.lang.Object x)
Print message if debug mode is on. |
static void |
debug(java.lang.Throwable x)
Print the stack trace if debug mode is on. |
static boolean |
equalBytes(byte[] arr1,
int off1,
byte[] arr2,
int off2,
int len)
Compare two byte arrays. |
static java.applet.Applet |
getApplet()
Get the applet we are running in (if any). |
static boolean |
getBooleanParameter(java.lang.String key,
boolean def)
Look for a boolean applet parameter or application property. |
static java.awt.Color |
getColorParameter(java.lang.String key,
java.awt.Color def)
Look for a color applet parameter or application property. |
static double |
getDoubleParameter(java.lang.String key,
double def)
Look for a double applet parameter or application property. |
static float |
getFloatParameter(java.lang.String key,
float def)
Look for a float applet parameter or application property. |
static java.awt.Frame |
getFrame(java.awt.Component comp)
Method to get the frame parent of any component. |
static int |
getIntParameter(java.lang.String key,
int def)
Look for a integer applet parameter or application property. |
static int |
getIntParameter(java.lang.String key,
int def,
int base)
Look for an integer applet parameter or application property. |
static java.lang.String |
getStringParameter(java.lang.String key,
java.lang.String def)
Look for a String applet parameter or application property. |
static boolean |
globEquals(java.lang.String mask,
java.lang.String str)
An equal function which accepts globbing. |
static boolean |
isDebug()
Get the debug mode. |
static java.awt.Image |
loadImage(java.lang.String path)
Load an image and prepare a representation. |
static java.awt.Image |
loadImage(java.lang.String path,
java.awt.Component renderer)
Load an image and prepare a representation. |
static java.lang.String |
loadText(java.lang.String path)
Load a text file into a string. |
static void |
printProperties()
In debug mode: print properties to console. |
static void |
printProperty(java.lang.String prop)
Print a given property to the console. |
static void |
setApplet(java.applet.Applet applet)
Set the applet we are running in (if any). |
static void |
setDebug(boolean mode)
Set the debugging mode. |
static void |
setResourceDir(java.lang.String dir)
Set the resource directory. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Utility()
Method Detail |
---|
public static void setDebug(boolean mode)
mode
- new modepublic static boolean isDebug()
public static java.awt.Image loadImage(java.lang.String path)
path
- path of the image file
public static java.awt.Image loadImage(java.lang.String path, java.awt.Component renderer)
path
- path of the image filerenderer
- renderer used to render the image
public static java.lang.String loadText(java.lang.String path)
path
- name of the text file
public static boolean areWeOnDOS()
public static void setResourceDir(java.lang.String dir)
dir
- the image drirectorypublic static java.lang.String compileString(java.lang.String tag, java.lang.Object[] args, java.util.ResourceBundle res)
Special signs: %# where hash is a digit from 0 to 9 means insert arg # @# where hash is a digit from 0 to 9 means insert localized arg # %% means % @&@64; means @
tag
- resource tag for format stringargs
- arguments for insertionres
- active resource bundle
public static java.awt.Frame getFrame(java.awt.Component comp)
comp
- the component to search the frame for
public static boolean equalBytes(byte[] arr1, int off1, byte[] arr2, int off2, int len)
len
bytes from array 1 starting with offset 1
with len
bytes from array 2 starting with offset 2.
Will return always true
for len ≤= 0
arr1
- array 1off1
- offset 1arr2
- array 2off2
- offset 2len
- length to compare
true
if both chunks are equalfalse
otherwisepublic static void setApplet(java.applet.Applet applet)
applet
- applet we are running in (if null
then we
are running in an applicationpublic static java.applet.Applet getApplet()
null
public static boolean areWeInAnApplet()
public static boolean getBooleanParameter(java.lang.String key, boolean def)
key
- parameter keydef
- default value
public static java.lang.String getStringParameter(java.lang.String key, java.lang.String def)
key
- parameter keydef
- default value
public static java.awt.Color getColorParameter(java.lang.String key, java.awt.Color def)
key
- parameter keydef
- default value
public static int getIntParameter(java.lang.String key, int def)
key
- parameter keydef
- default value
public static int getIntParameter(java.lang.String key, int def, int base)
key
- parameter keydef
- default valuebase
- number base
public static double getDoubleParameter(java.lang.String key, double def)
key
- parameter keydef
- default value
public static float getFloatParameter(java.lang.String key, float def)
key
- parameter keydef
- default value
public static void debug(java.lang.Object x)
x
- object which's toString is calledpublic static void debug(java.lang.Throwable x)
x
- exceptionpublic static void printProperty(java.lang.String prop)
prop
- poperty namepublic static void printProperties()
public static boolean globEquals(java.lang.String mask, java.lang.String str)
mask
- glob mask (containing special chars)str
- string to be checked against mask
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |