net.clackrouter.jgraph.utils
Class Utilities

java.lang.Object
  extended by net.clackrouter.jgraph.utils.Utilities

public final class Utilities
extends java.lang.Object

Utility methods. A utility method is characterized as a method which is of general utility and is not specific to JGraphpad or JGraph. For example, this would include things like generic sorting algorithms, parsing routines, standard error handling methods, etc. It is important that this code be optimized, and secondly you should be concerned about not reinventing the wheel...before adding content here you should try and find another open source project that already implements said functionality in a robust manner. A good place to look is: Apache/Jakarta Commons. There are many methods commented out in this class as many of these methods were imported from different projects but not yet currently used. Please take a look here first to see if anything that you need has already been implemented.


Method Summary
static void center(java.awt.Window frame)
           
static boolean createDirectoryRecursively(java.io.File f)
          Create a directory, plus all parent directories necessary to contain it.
static java.lang.String getClassNameWithoutPackage(java.lang.Class cl)
          Returns the classname without the package.
static float[] parsePattern(java.lang.String pattern)
          parses the pattern and tries to parse each token as a float.
static java.util.Properties readPropertiesFromFile(java.awt.Frame parentFrame, java.io.File file)
           
static java.util.Properties readPropertiesFromFile(java.awt.Frame parentFrame, java.lang.String fileName)
           
static java.util.Properties readPropertiesFromFile(java.lang.String fileName)
           
static int rnd(int max)
          Returns a random number between 0 and max.
static java.lang.String[] tokenize(java.lang.String input)
          Take the given string and chop it up into a series of strings on whitespace boundries.
static java.lang.String[] tokenize(java.lang.String input, java.lang.String delim)
           
static void writePropertiesToFile(java.awt.Frame parentFrame, java.util.Properties properties, java.io.File file, java.lang.String fileHeader)
           
static void writePropertiesToFile(java.awt.Frame parentFrame, java.util.Properties properties, java.lang.String fileName, java.lang.String fileHeader)
           
static void writePropertiesToFile(java.util.Properties properties, java.lang.String fileName, java.lang.String fileHeader)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

tokenize

public static java.lang.String[] tokenize(java.lang.String input)
Take the given string and chop it up into a series of strings on whitespace boundries. This is useful for trying to get an array of strings out of the resource file.


tokenize

public static java.lang.String[] tokenize(java.lang.String input,
                                          java.lang.String delim)

rnd

public static int rnd(int max)
Returns a random number between 0 and max.


parsePattern

public static float[] parsePattern(java.lang.String pattern)
parses the pattern and tries to parse each token as a float.

Returns:
array with the float value for each token

getClassNameWithoutPackage

public static java.lang.String getClassNameWithoutPackage(java.lang.Class cl)
Returns the classname without the package. Example: If the input class is java.lang.String than the return value is String.

Parameters:
cl - The class to inspect
Returns:
The classname

center

public static void center(java.awt.Window frame)

createDirectoryRecursively

public static boolean createDirectoryRecursively(java.io.File f)
Create a directory, plus all parent directories necessary to contain it. For example, if c:\this\is\an\example\file.name was encapsulated in File, and c:\this existed but contained no subdirectories, then the remaining directories is\an\example\ would all be created.

Parameters:
f - Directory path to create.
Returns:
true if successful.

readPropertiesFromFile

public static final java.util.Properties readPropertiesFromFile(java.awt.Frame parentFrame,
                                                                java.io.File file)

readPropertiesFromFile

public static final java.util.Properties readPropertiesFromFile(java.awt.Frame parentFrame,
                                                                java.lang.String fileName)

readPropertiesFromFile

public static final java.util.Properties readPropertiesFromFile(java.lang.String fileName)
                                                         throws java.io.IOException,
                                                                java.lang.Exception
Throws:
java.io.IOException
java.lang.Exception

writePropertiesToFile

public static final void writePropertiesToFile(java.awt.Frame parentFrame,
                                               java.util.Properties properties,
                                               java.io.File file,
                                               java.lang.String fileHeader)

writePropertiesToFile

public static final void writePropertiesToFile(java.awt.Frame parentFrame,
                                               java.util.Properties properties,
                                               java.lang.String fileName,
                                               java.lang.String fileHeader)

writePropertiesToFile

public static final void writePropertiesToFile(java.util.Properties properties,
                                               java.lang.String fileName,
                                               java.lang.String fileHeader)
                                        throws java.io.IOException,
                                               java.lang.Exception
Throws:
java.io.IOException
java.lang.Exception