jhplot.v3d
Class Util

java.lang.Object
  extended by jhplot.v3d.Util

public final class Util
extends java.lang.Object

Various useful functions of general purpose.


Method Summary
static void belowWithin(java.awt.Component parent, java.awt.Component child)
           
static java.awt.Point belowWithin(java.awt.Rectangle rec, java.awt.Dimension dim)
           
static void centreWithin(java.awt.Component parent, java.awt.Component child)
          Centres the child component within its parent.
static java.awt.Point centreWithin(java.awt.Rectangle rec, java.awt.Dimension dim)
          Calculates the X and Y coordinates that a child component should have to be centered within its parent.
static void copyFile(java.io.File inputFile, java.io.File outputFile)
          Copies the contents of any disk file to a specified output file.
static boolean deleteDir(java.io.File dir)
          Deletes all files and subdirectories under dir.
static boolean ensureDirectory(java.io.File dir, java.io.File defaultDir)
          Ensures the existence of the directory specified by the parameter.
static boolean ensureFilePath(java.io.File file, java.io.File defaultDir)
          Ensures the existence of the directory which may be part of the path specification of parameter file.
static java.lang.String fileNameOfPath(java.lang.String path)
           
static java.lang.String htmlEncoded(java.lang.String text)
          Substitutes conflicting characters in text with html masked expressions.
static java.lang.String pathNameOfPath(java.lang.String path)
           
static void rightWithin(java.awt.Component parent, java.awt.Component child)
          Puts to the right
static java.awt.Point rightWithin(java.awt.Rectangle rec, java.awt.Dimension dim)
           
static java.lang.String substituteText(java.lang.String text, java.lang.String token, java.lang.String substitute)
          Renders a string based on text where any occurence of token is replaced by substitute.
static java.lang.String substituteTextS(java.lang.String text, java.lang.String token, java.lang.String substitute)
          Renders a string based on text where any occurence of token is replaced by substitute.
static int textVariance(char[] ca)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

centreWithin

public static java.awt.Point centreWithin(java.awt.Rectangle rec,
                                          java.awt.Dimension dim)
Calculates the X and Y coordinates that a child component should have to be centered within its parent. This method does not try to constrain the calculation so that the point remains wholly onscreen.

Parameters:
rec - the bounding rectangle of the parent.
dim - the dimensions of the child.
Returns:
the X and Y coordinates the child should have.

rightWithin

public static java.awt.Point rightWithin(java.awt.Rectangle rec,
                                         java.awt.Dimension dim)

belowWithin

public static java.awt.Point belowWithin(java.awt.Rectangle rec,
                                         java.awt.Dimension dim)

centreWithin

public static void centreWithin(java.awt.Component parent,
                                java.awt.Component child)
Centres the child component within its parent.

Parameters:
parent - the parent component.
child - the child component.

rightWithin

public static void rightWithin(java.awt.Component parent,
                               java.awt.Component child)
Puts to the right

Parameters:
parent - the parent component.
child - the child component.

belowWithin

public static void belowWithin(java.awt.Component parent,
                               java.awt.Component child)

fileNameOfPath

public static java.lang.String fileNameOfPath(java.lang.String path)

pathNameOfPath

public static java.lang.String pathNameOfPath(java.lang.String path)

substituteText

public static java.lang.String substituteText(java.lang.String text,
                                              java.lang.String token,
                                              java.lang.String substitute)
Renders a string based on text where any occurence of token is replaced by substitute.

Returns:
String

substituteTextS

public static java.lang.String substituteTextS(java.lang.String text,
                                               java.lang.String token,
                                               java.lang.String substitute)
Renders a string based on text where any occurence of token is replaced by substitute.

Returns:
String

htmlEncoded

public static java.lang.String htmlEncoded(java.lang.String text)
Substitutes conflicting characters in text with html masked expressions. The returned string is displayable in html interpreting components.

Parameters:
text -
Returns:

copyFile

public static void copyFile(java.io.File inputFile,
                            java.io.File outputFile)
                     throws java.io.IOException
Copies the contents of any disk file to a specified output file. If the output file is a relative path, it is made absolute against the directory of the input file. The output file will be overwritten if it exist. A CRC32 check is performed to compare source and copy after the copy process and if results negative a StreamCorruptedException is thrown. Function reports errors to System.err.

Parameters:
inputFile - a File object
outputFile - a File object
Throws:
java.io.IOException - if the function could not be completed because of an IO or CRC check error

ensureFilePath

public static boolean ensureFilePath(java.io.File file,
                                     java.io.File defaultDir)
Ensures the existence of the directory which may be part of the path specification of parameter file. If the specified file is a relative path, it is made absolute against defaultDir. If defaultDir is null the System property "user.dir" is assumed as default directory.

Returns:
true if and only if the parent directory of the specified file exists after this function terminates

ensureDirectory

public static boolean ensureDirectory(java.io.File dir,
                                      java.io.File defaultDir)
Ensures the existence of the directory specified by the parameter. If the directory does not exist, an attempt is performed to create it including all necessary parent directories that may be implied by the specification.

Parameters:
dir - File specifying the intended directory; if the specified path is a relative path, it is made absolute against defaultDir. If defaultDir is null the System directory "user.dir" is assumed as default.
defaultDir - default directory.
Returns:
true if and only if the specified file exists and is a directory after this function terminates

textVariance

public static int textVariance(char[] ca)

deleteDir

public static boolean deleteDir(java.io.File dir)
Deletes all files and subdirectories under dir. Returns true if all deletions were successful. If a deletion fails, the method stops attempting to delete and returns false.



jHepWork 1.7 (C) Chekanov