net.sourceforge.webcompmath.applets
Class AppletUtilities

java.lang.Object
  extended by net.sourceforge.webcompmath.applets.AppletUtilities

public class AppletUtilities
extends java.lang.Object

This class includes various utility methods used by WCM applets.

Author:
Tom Downey

Constructor Summary
AppletUtilities()
           
 
Method Summary
static java.awt.Color getColorParam(java.applet.Applet app, java.lang.String data)
          Get The value of an applet parameter that specifies a color.
static java.awt.Color getColorParam(java.applet.Applet app, java.lang.String paramName, java.awt.Color defaultColor)
          Get The value of an applet parameter that specifies a color.
static double[] getNumericParam(java.applet.Applet app, java.lang.String paramName)
          Get The value of an applet parameter that consists of a list of numbers.
static double[] getNumericParam(java.applet.Applet app, java.lang.String paramName, double[] defaults)
          Get The value of an applet parameter that consists of a list of numbers.
static java.lang.String getParameter(java.applet.Applet app, java.lang.String paramName, java.lang.String defaultValue)
          Get the value of an applet parameter, but return a default if the value is null.
static void setUIFontSize(float fs)
          Set the default font size for all Swing default fonts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AppletUtilities

public AppletUtilities()
Method Detail

setUIFontSize

public static void setUIFontSize(float fs)
Set the default font size for all Swing default fonts. This utility method scans the complete list of default UI values for swing and adjusts the font size for any font resources.

Parameters:
fs - the new font size

getParameter

public static java.lang.String getParameter(java.applet.Applet app,
                                            java.lang.String paramName,
                                            java.lang.String defaultValue)
Get the value of an applet parameter, but return a default if the value is null.

Parameters:
app - the applet to get a parameter from (usually "this")
paramName - The name of the applet parameter.
defaultValue - The value to be returned if getParameter(paramName) is null.
Returns:
the parameter's value

getNumericParam

public static double[] getNumericParam(java.applet.Applet app,
                                       java.lang.String paramName)
Get The value of an applet parameter that consists of a list of numbers. The parameter value, if any, is parsed and returned as array of double values. The numbers can be separated by commas, spaces, tabs, or semicolons. If there is a parse error, null is returned.

Parameters:
app - the applet to get a parameter from (usually "this")
paramName - the name of the parameter to get
Returns:
the parameter's value

getNumericParam

public static double[] getNumericParam(java.applet.Applet app,
                                       java.lang.String paramName,
                                       double[] defaults)
Get The value of an applet parameter that consists of a list of numbers. The parameter value, if any, is parsed and returned as array of double values. The numbers can be separated by commas, spaces, tabs, or semicolons.

Parameters:
app - the applet to get a parameter from (usually "this")
paramName - The name of the applet parameter.
defaults - The value to be returned if getParameter(paramName) is null or is not a valid list of numbers.
Returns:
the parameter's array of values

getColorParam

public static java.awt.Color getColorParam(java.applet.Applet app,
                                           java.lang.String data)
Get The value of an applet parameter that specifies a color. The color can be specfied as a list of three numbers in the range 0 to 255 or by one of the standard color names ("black", "red", "blue", "green", "yellow", "cyan", "magenta", "gray", "darkgray", "lightgray", "pink", "orange", "white"). Color names are not case sensitive. If the value of the applet parameter is null does not specify a legal color, then the return value is null.

Parameters:
app - the applet to get a parameter from (usually "this")
data - the name of the parameter
Returns:
value of the parameter

getColorParam

public static java.awt.Color getColorParam(java.applet.Applet app,
                                           java.lang.String paramName,
                                           java.awt.Color defaultColor)
Get The value of an applet parameter that specifies a color. The color can be specfied as a list of three numbers in the range 0 to 255 or by one of the standard color names ("black", "red", "blue", "green", "yellow", "cyan", "magenta", "gray", "darkgray", "lightgray", "pink", "orange", "white"). Color names are not case sensitive.

Parameters:
app - the applet to get a parameter from (usually "this")
paramName - The name of the applet parameter.
defaultColor - The value to be returned if getParameter(paramName) is null or is not a valid color.
Returns:
the parameter's value as a Color