Overview | Package | Class | Tree | Index | Help NetCharts Pro (Applets) 7.0
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

netcharts.util
Class NFUtil

java.lang.Object
  |
  +--netcharts.util.NFUtil

public class NFUtil
implements NFCompare
Provides a number of useful utilities and methods


Method Summary
static void busyCursor(java.awt.Component comp, boolean onoff)
          Change the frame cursor for the given component on or off.
static void centerWindow(java.awt.Component comp1, java.awt.Component comp2)
          Center comp2 on comp1.
int compare(java.lang.Object d1, java.lang.Object d2)
          Part of qsort, this is the default comparison function to be used if no NFCompare object is passed to qsort.
static void compPaint(java.awt.Graphics ig, java.awt.Component comp)
          Recursively paint the given component, or all components contained in the given container.
static void compPrint(java.awt.Graphics ig, java.awt.Component comp)
          Recursively print the given component, or all components contained in the given container.
static java.lang.String encodeURL(java.lang.String s)
          URL encode a string for use in a HTTP request header.
static java.net.URL getFileURL(java.lang.String filename)
          Returns a URL for the given file.
static java.net.URL getFileURL(java.lang.String filename, NFContext ctxt)
          Returns a URL for the given filename, using the given context information as needed to resolve relative paths.
static java.net.URL getFileURL(java.lang.String filename, java.net.URL documentBase)
          Returns a URL for the given filename, using the given document base information as needed to resolve relative paths.
static java.awt.Font getFont(java.lang.String name, int style, int size)
          Gets the Font object for the given name, style and size.
static java.awt.Frame getFrame(java.awt.Component c)
          Returns the top level frame for the given component.
static double getJDKVersion()
          Returns the version of the underlying JVM.
static java.awt.Component getTopLevelComponent(java.awt.Component c)
          Returns the top level component
static java.awt.Component getWindow(java.awt.Component c)
          Returns the top level frame or dialog in which the given component is contained.
static double log(double value, double base)
          Compute the log of "value" with base "base".
static void qsort(java.util.Vector v, int left, int right, NFCompare cmp)
          This quicksort method will sort the objects in the Vector using the NFCompare comparison object.
static java.lang.String resolvePath(java.lang.String filename, NFContext ctxt)
          Examines the given filename and replaces any initial path variables with the current values.
static java.lang.String resolvePath(java.lang.String filename, java.net.URL documentBase, java.net.URL codeBase)
          Examines the given filename and replaces any initial path variables with the current values.
static double rint(double v)
          This method rounds the given value to the nearest integer and returns it as a double.
static void setFrameIcon(java.awt.Frame frame, java.net.URL url)
          Set the icon of a Frame to a image at a specific URL.
static java.lang.String sprintf(int groupSize, char groupSymbol, char decSymbol, java.lang.String fmt, java.lang.Object[] arg)
          Returns a formatted string using the given format expression and the array of objects.
static java.lang.String sprintf(int groupSize, char groupSymbol, char decSymbol, java.lang.String fmt, java.lang.Object[] arg, boolean includeExtraChars)
          Returns a formatted string using the given format expression and the array of objects.
 

Method Detail

getJDKVersion

public static double getJDKVersion()
Returns the version of the underlying JVM.
Returns:
The JDK version as a double.

getFont

public static java.awt.Font getFont(java.lang.String name,
                           int style,
                           int size)
Gets the Font object for the given name, style and size. If the font was previously created, then a hashed reference to the Font object is used, instead of creating a new one.
Parameters:
name - Font family.
style - Font style.
size - Font size.
Returns:
Font specified by given parameters.

compare

public int compare(java.lang.Object d1,
                   java.lang.Object d2)
Part of qsort, this is the default comparison function to be used if no NFCompare object is passed to qsort. This method will make the comparison based on the .toString() values of the objects.
Specified by:
compare in interface NFCompare
Parameters:
d1 - Object one.
d2 - Object two.
Returns:
0 if equal, -1 if d1 is less than d2, 1 if d1 is greater than d2.

qsort

public static void qsort(java.util.Vector v,
                         int left,
                         int right,
                         NFCompare cmp)
This quicksort method will sort the objects in the Vector using the NFCompare comparison object. If the comparison object is null, the compare method in NFUtil will be used. Note that NFCompare is an interface and may be implemented as necessary. the algorithm for this qsort was translated directly from "The C Programming Language" by Brian Kernighan and Dennis Ritchie.
Parameters:
v - The Vector of objects to sort.
left - Left pivot.
right - Right pivot.
cmp - The NFCompare object to use for comparisons.

getWindow

public static java.awt.Component getWindow(java.awt.Component c)
Returns the top level frame or dialog in which the given component is contained.
Parameters:
c - Component to start looking for a frame or dialog from.
Returns:
The toplevel frame or dialog.

getFrame

public static java.awt.Frame getFrame(java.awt.Component c)
Returns the top level frame for the given component.
Parameters:
c - Component to start looking for a frame from.
Returns:
The toplevel frame.

getTopLevelComponent

public static java.awt.Component getTopLevelComponent(java.awt.Component c)
Returns the top level component
Parameters:
c - Component to start looking from.
Returns:
The toplevel component.

busyCursor

public static void busyCursor(java.awt.Component comp,
                              boolean onoff)
Change the frame cursor for the given component on or off.
Parameters:
comp - The component on which to change the cursor.
onoff - Whether to change the cursor to busy or not.

getFileURL

public static final java.net.URL getFileURL(java.lang.String filename,
                                   NFContext ctxt)
                                    throws java.lang.Exception
Returns a URL for the given filename, using the given context information as needed to resolve relative paths.
Parameters:
filename - The filename to convert to a url.
ctxt - The NFContext to use for resolution of relative paths.
Returns:
The URL version of the filename.
Throws:
java.lang.Exception - If the url is malformed.

getFileURL

public static final java.net.URL getFileURL(java.lang.String filename)
                                    throws java.lang.Exception
Returns a URL for the given file. If the filename begins with a protocol, then a URL for that url is returned. If the <filename> begins with a '/' or '\' or 'c:' (any drive letter), then it is assumed to be an absolute pathname, otherwise, it is prepended by the current directory for the application.
Parameters:
filename - The filename to convert to a url.
Returns:
The URL version of the filename.
Throws:
java.lang.Exception - If the url is malformed.

getFileURL

public static final java.net.URL getFileURL(java.lang.String filename,
                                   java.net.URL documentBase)
                                    throws java.lang.Exception
Returns a URL for the given filename, using the given document base information as needed to resolve relative paths.
Parameters:
filename - The filename to convert to a url.
documentBase - The document base to use for resolving relative paths.
Returns:
The URL version of the filename.
Throws:
java.lang.Exception - If the url is malformed.

resolvePath

public static java.lang.String resolvePath(java.lang.String filename,
                                 NFContext ctxt)
Examines the given filename and replaces any initial path variables with the current values. The following variables are supported: Note: Each symbol must be at the beginning of the filename in order to be processed properly.
Parameters:
filename - The filename to resolve.
ctxt - The NFContext to use for resolution of document and code base references.
Returns:
The resolved version of the filename.

resolvePath

public static java.lang.String resolvePath(java.lang.String filename,
                                 java.net.URL documentBase,
                                 java.net.URL codeBase)
Examines the given filename and replaces any initial path variables with the current values. The following variables are supported: Note: Each symbol must be at the beginning of the filename in order to be processed properly.
Parameters:
filename - The filename to resolve.
documentBase - The document base.
codeBase - The code base.
Returns:
The resolved version of the filename.

rint

public static double rint(double v)
This method rounds the given value to the nearest integer and returns it as a double. It replaces Math.rint() because Netscape3.x/HP implements that method improperly for negative values.
Parameters:
v - The double to round.
Returns:
The nearest integer value.

sprintf

public static java.lang.String sprintf(int groupSize,
                             char groupSymbol,
                             char decSymbol,
                             java.lang.String fmt,
                             java.lang.Object[] arg)
Returns a formatted string using the given format expression and the array of objects. The following types are supported: %s = accepts any Object and converts it to a string %d = accepts any Number, prints only the integer value %x = accepts any Number, prints only the hexadecimal value %f = accepts any Number, prints a decimal value %g = accepts any Number, prints it using the standard representation for the local system For any format type, the following modifiers are supported: -,0WW.DD where all parts are optional and are interpretted as follows: - = left justify the result, otherwise right justify , = use group symbol to separate whole number into groups Grouping is defined using setGrouping(). 0 = zero fill (number formats only) WW = total width of formatted field. If the field is naturally wider than this value, it is ignored. . = use decimal symbol to separate whole number from decimal value. Use setDecSymbol() to define the decimal symbol. DD = number of decimal digits (%f format only). The default number is 2. May also be used with string expressions to specify the maximum number of characters to be printed in the field.
Parameters:
fmt - Ther format string.
arg - The Objects to print.
Returns:
The formatted string representation of the Objects.

sprintf

public static java.lang.String sprintf(int groupSize,
                             char groupSymbol,
                             char decSymbol,
                             java.lang.String fmt,
                             java.lang.Object[] arg,
                             boolean includeExtraChars)
Returns a formatted string using the given format expression and the array of objects. The following types are supported: %s = accepts any Object and converts it to a string %d = accepts any Number, prints only the integer value %x = accepts any Number, prints only the hexadecimal value %f = accepts any Number, prints a decimal value %g = accepts any Number, prints it using the standard representation for the local system For any format type, the following modifiers are supported: -,0WW.DD where all parts are optional and are interpretted as follows: - = left justify the result, otherwise right justify , = use group symbol to separate whole number into groups Grouping is defined using setGrouping(). 0 = zero fill (number formats only) WW = total width of formatted field. If the field is naturally wider than this value, it is ignored. . = use decimal symbol to separate whole number from decimal value. Use setDecSymbol() to define the decimal symbol. DD = number of decimal digits (%f format only). The default number is 2. May also be used with string expressions to specify the maximum number of characters to be printed in the field.
Parameters:
fmt - Ther format string.
arg - The Objects to print.
includeExtraChars - Whether to include extra characters not relatred tor the specific % format.
Returns:
The formatted string representation of the Objects.

compPaint

public static void compPaint(java.awt.Graphics ig,
                             java.awt.Component comp)
Recursively paint the given component, or all components contained in the given container. This replaces paintComponents() which doesn't work with image objects in JDK 1.1
Parameters:
ig - The Graphics on which to paint.
comp - The Container to paint.

compPrint

public static void compPrint(java.awt.Graphics ig,
                             java.awt.Component comp)
Recursively print the given component, or all components contained in the given container. This replaces printComponents() which doesn't work with image objects in JDK 1.1
Parameters:
ig - The Graphics on which to print.
comp - The Container to print.

setFrameIcon

public static void setFrameIcon(java.awt.Frame frame,
                                java.net.URL url)
Set the icon of a Frame to a image at a specific URL.
Parameters:
frame - The Frame to set the icon on.
The - URL to retrieve.

centerWindow

public static void centerWindow(java.awt.Component comp1,
                                java.awt.Component comp2)
Center comp2 on comp1.
Parameters:
comp1 - The component to center.
comp2 - The component to center comp1 on.

encodeURL

public static java.lang.String encodeURL(java.lang.String s)
URL encode a string for use in a HTTP request header. Does not encode the query string.
Returns:
The URL-encoded string.

log

public static double log(double value,
                         double base)
Compute the log of "value" with base "base".
Returns:
The log.

Overview | Package | Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD


Visual Mining, Inc.
2099 Gaither Grove Rd.
Suite 220
Rockville, MD 20850
800.308.0731
301.947.8293 FAX

Copyright © Visual Mining, Inc. 1996 - 2010
All Rights Reserved.

NetCharts ProTM is a registered trademark of Visual Mining, Inc. Other brands and their products are trademarks of their respective holders.

Last Modified: Jun 29, 2010