IcanGui
Class GuiGlobals

java.lang.Object
  extended by IcanGui.GuiGlobals

public class GuiGlobals
extends java.lang.Object

Save global variables and methods for GUI. Create components and associate a Font. Save a reference to each component for which the Font may be changed.

Since:
1.0;
Version:
1.1.15;
Updated by Louis Handler on Dec 12, 2007, 13:12 EST (1.1.15).
Updated by Louis Handler on Jul 19, 2006, 09:04 EDT (1.1.9).
Updated by Louis Handler on Jan 3, 2005, 09:01 EST (1.1.0).
Updated by Louis Handler on Nov 10, 2004, 16:00 EST (1.0.10).
Updated by Louis Handler on Apr 26, 2004, 08:17 EDT (1.0.6).
Updated by Louis Handler on Apr 8, 2004, 09:02 EDT.
Updated by Louis Handler on Sep 8, 2003, 15:10 EDT.
Updated by Louis Handler on Sep 8, 2003, 10:27 EDT.
Updated by Louis Handler on Aug 23, 2002, 15:33 EDT.
Updated by Louis Handler on Nov 21, 2000, 15:18 EST.
Updated by Louis Handler on Nov 21, 2000, 07:52 EST.
Updated by Louis Handler on Aug 1, 2000, 15:25 EDT.
Updated by Louis Handler on Mar 21, 2000, 07:52 EST.
Updated by Louis Handler on Mar 13, 2000, 13:56 EST.
Updated by Louis Handler on Feb 25, 2000, 09:15 EST.
Updated by Louis Handler on Nov 15, 1999, 09:26 EST.
Updated by Louis Handler on Dec 30, 1998, 15:20 EST.
Updated by Louis Handler on Nov 23, 1998, 10:29 EST.
Updated by Louis Handler on Nov 20, 1998, 16:12 EST.
Updated by Louis Handler on Nov 6, 1998, 08:03 EST.
Updated by Louis Handler on Jun 18, 1998.
Author:
Louis Handler

Field Summary
private static boolean changedDefaultProps
          Switch for whether any default property value has been changed.
private static java.util.Properties defaultProps
          This Properties item contains the default properties.
private static java.awt.Font font
          The current Font used.
static java.lang.String fontNameConstantWidth
          The constant width Font name available to be used.
static java.lang.String fontNameVariableWidth
          The variable width Font name available to be used.
private static int height_applet_warning
          Extra height for Applet warning: "Warning: Applet Window".
private static boolean inApplet
          Whether in applet (or application).
private static boolean inputDataChanged
          Switch for whether any input data value has been changed.
private static boolean olderThan13
          True, if Java version is older than 1.3; false, if Java version 1.3 or later.
private static java.lang.Object printJobAttributes
          A set of attributes that control a print job.
private static java.lang.Object printPageAttributes
          A set of attributes that control a print job.
private static java.util.Properties printProps
          The following Properties item contains the print properties.
private static java.lang.String propFile
          Path for default properties.
private static boolean saveAllowed
          Switch whether local read/save/print is allowed.
private static int screenHeight
          Screen height in pixels.
private static int screenResolution
          Screen resolution in pixels per inch.
private static int screenWidth
          Screen width in pixels.
private static java.applet.Applet thisApplet
          Need an Applet for some commands, so I save it here.
static java.lang.String TIMEZONE
          Standard time zone at current location.
private static java.util.Vector vComp
          The following Vector contains a list of basic Components which may have their Font changed by the user.
 
Constructor Summary
GuiGlobals(boolean inAnApplet)
          Constructor stores boolean telling whether in Applet or application.
 
Method Summary
static java.applet.Applet getApplet()
          Get current Applet for commands that need it.
static int getAppletHeight()
          Get height in pixels to add for Applet warning: "Warning: Applet Window".
static java.lang.String getDefaultProperty(java.lang.String property)
          Get default property value for given property name.
static java.awt.Font getFont()
          Return the Font used.
static int getFontSize()
          Return the Font size used.
static java.lang.String getName()
          Get class name.
static java.awt.PrintJob getPrintJob(java.awt.Frame frame, java.lang.String title)
          Get a PrintJob object to print graphics or text.
static java.lang.String getPrintOrientation()
          Get orientation: portrait or landscape.
static int getScreenHeight()
          Get screen height.
static int getScreenResolution()
          Get screen resolution.
static int getScreenWidth()
          Get screen width.
static int[] getSize(java.lang.String text)
          Obtain the number of rows and columns needed to display the text in a TextArea.
static int[] getTextSize(java.lang.String text, java.awt.TextArea inTextArea)
          Obtain the height and width in pixels needed to display the text in a TextArea.
static boolean isAnApplet()
          Return boolean telling whether in applet or not.
static boolean isDefaultPropertyChanged()
          Get switch for whether any default property value has been changed.
static boolean isInputDataChanged()
          Get switch for whether any input data value has been changed.
static boolean isPrintAllowed()
          Indicate whether printing is allowed.
static boolean isSaveAllowed()
          Indicate whether saving to a file is allowed.
static void loadDefaultProperties(java.io.DataInputStream dInput)
          Load default properties from a file or input stream.
static java.awt.Button makeButton(java.lang.String text)
          Create a Button with additional properties.
static java.awt.Checkbox makeCheckbox(java.lang.String text)
          Create a checkbox with additional properties.
static java.awt.Checkbox makeCheckbox(java.lang.String text, boolean whb)
          Create a checkbox with additional properties.
static java.awt.Checkbox makeCheckbox(java.lang.String text, boolean whb, java.awt.CheckboxGroup cbg)
          Create a checkbox with additional properties.
static java.awt.Label makeLabel(java.lang.String text)
          Create a Label with additional properties.
static java.awt.Label makeLabel(java.lang.String text, int alignment)
          Create a Label with additional properties.
static java.awt.TextArea makeTextArea(int rows, int columns)
          Create a TextArea with additional properties.
static java.awt.TextArea makeTextArea(java.lang.String text)
          Create a TextArea with additional properties.
static java.awt.TextArea makeTextArea(java.lang.String text, int rows, int columns)
          Create a TextArea with additional properties.
static java.awt.TextArea makeTextArea(java.lang.String text, int rows, int columns, int scroll)
          Create a TextArea with additional properties.
static java.awt.TextField makeTextField(int columns)
          Create a TextField with additional properties.
static java.awt.TextField makeTextField(java.lang.String text)
          Create a TextField with additional properties.
static java.awt.TextField makeTextField(java.lang.String text, int columns)
          Create a TextField with additional properties.
static void readDefaultProperties()
          Read ICAN/JAVA default properties from "~/.ICAN" file, if possible.
static void remove(java.awt.Component comp)
          Remove component from vector containing list of all components that have a font associated.
static void saveComponent(java.awt.Component comp)
          Add component to vector containing list of all components that have a font associated.
static void scrollToSee(java.awt.Component compFocus)
          Scrolling is performed, if necessary, to put the component in the view port.
static void setApplet(java.applet.Applet applet)
          Save current Applet for commands that need it.
static void setDefaultProperty(java.lang.String property, java.lang.String value)
          Set default property value for given property name.
static void setFont(java.awt.Font fnt)
          Set the Font to be used to display text on Components.
static void setFontSize(int size)
          Set the Font size to be used to display text on Components.
static void setInputDataChanged(boolean changedInputData)
          Set switch for whether any input data value has been changed.
static void setPrintColor(java.lang.String color)
          Set color or monochrome.
static void setPrinter(java.lang.String queue)
          Set printer queue; for example, b142a12a.
static void setPrintFile(java.lang.String filename)
          Set print output file name.
static void setPrintMedia(java.lang.String media)
          Set printer; for example, b142a12a.
static void setPrintOrientation(java.lang.String orient)
          Set orientation: portrait or landscape.
static void setSaveAllowed(boolean allowed)
          Save switch to override whether read/save/print are allowed locally.
static void writeDefaultProperties()
          Write ICAN/JAVA default properties to "~/.ICAN" file, if possible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TIMEZONE

public static java.lang.String TIMEZONE
Standard time zone at current location.


inApplet

private static boolean inApplet
Whether in applet (or application).


thisApplet

private static java.applet.Applet thisApplet
Need an Applet for some commands, so I save it here.


saveAllowed

private static boolean saveAllowed
Switch whether local read/save/print is allowed. These operations are normally not allowed in an Applet.


height_applet_warning

private static int height_applet_warning
Extra height for Applet warning: "Warning: Applet Window".


font

private static java.awt.Font font
The current Font used.


fontNameVariableWidth

public static java.lang.String fontNameVariableWidth
The variable width Font name available to be used.


fontNameConstantWidth

public static java.lang.String fontNameConstantWidth
The constant width Font name available to be used.


screenResolution

private static int screenResolution
Screen resolution in pixels per inch.


screenHeight

private static int screenHeight
Screen height in pixels.


screenWidth

private static int screenWidth
Screen width in pixels.


vComp

private static java.util.Vector vComp
The following Vector contains a list of basic Components which may have their Font changed by the user.


printProps

private static java.util.Properties printProps
The following Properties item contains the print properties. The following print properties may be set in UNIX systems but not for PC's or MAC's.
     "awt.print.destination"   - can be "printer" or "file"
     "awt.print.printer"       - print command
     "awt.print.fileName"      - name of the file to print
     "awt.print.numCopies"     - obvious
     "awt.print.options"       - options to pass to the print command
     "awt.print.orientation"   - can be "portrait" or "landscape"
     "awt.print.paperSize"     - can be "letter","legal","executive" or "a4"
This was improved in Java 1.3 by replacing it with JobAttributes and PageAttributes.


printJobAttributes

private static java.lang.Object printJobAttributes
A set of attributes that control a print job. This only exists in Java 1.3 and after.


printPageAttributes

private static java.lang.Object printPageAttributes
A set of attributes that control a print job. This only exists in Java 1.3 and after.


olderThan13

private static boolean olderThan13
True, if Java version is older than 1.3; false, if Java version 1.3 or later.


propFile

private static java.lang.String propFile
Path for default properties. Usually ".../.ICAN".


defaultProps

private static java.util.Properties defaultProps
This Properties item contains the default properties.

See Also:
IcanDataSet.BooleanDescriptions, IcanDataSet.OutputDescriptions, IcanConfigure.DEFAULT_BOOLEAN_PREFIX, IcanConfigure.DEFAULT_BROWSER, IcanConfigure.DEFAULT_FILE_EXT_PREFIX, IcanConfigure.DEFAULT_FONTSIZE, IcanConfigure.DEFAULT_OUTPUT_PREFIX, IcanConfigure.DEFAULT_PRINT_IN_COLOR, IcanConfigure.DEFAULT_UNIT_SYSTEM

changedDefaultProps

private static boolean changedDefaultProps
Switch for whether any default property value has been changed.


inputDataChanged

private static boolean inputDataChanged
Switch for whether any input data value has been changed.

Constructor Detail

GuiGlobals

public GuiGlobals(boolean inAnApplet)
Constructor stores boolean telling whether in Applet or application. The rest of the static variables are set later.

Parameters:
inAnApplet - Boolean value is true if ICAN/JAVA is executed as an applet. The boolean value is false if ICAN/JAVA is executed as an application.
Method Detail

isAnApplet

public static boolean isAnApplet()
Return boolean telling whether in applet or not.

Returns:
Boolean indicating whether in applet or application. True if in applet; otherwise, false.

readDefaultProperties

public static void readDefaultProperties()
Read ICAN/JAVA default properties from "~/.ICAN" file, if possible. There may exist defaults for Booleans, Outputs, font size, and units.

See Also:
defaultProps

writeDefaultProperties

public static void writeDefaultProperties()
Write ICAN/JAVA default properties to "~/.ICAN" file, if possible. There may exist defaults for Booleans, Outputs, font size, and units.

See Also:
defaultProps

getDefaultProperty

public static java.lang.String getDefaultProperty(java.lang.String property)
Get default property value for given property name.

Parameters:
property - Property name for which property value is obtained.
Returns:
Corresponding property value obtained.
See Also:
defaultProps

setDefaultProperty

public static void setDefaultProperty(java.lang.String property,
                                      java.lang.String value)
Set default property value for given property name.

Parameters:
property - Property name to store.
value - Property value to store.
See Also:
defaultProps

isDefaultPropertyChanged

public static boolean isDefaultPropertyChanged()
Get switch for whether any default property value has been changed.

Returns:
Corresponding property value obtained.

loadDefaultProperties

public static void loadDefaultProperties(java.io.DataInputStream dInput)
Load default properties from a file or input stream.


setInputDataChanged

public static void setInputDataChanged(boolean changedInputData)
Set switch for whether any input data value has been changed.

Parameters:
changedInputData - True, if input data value has been changed; false, if input data value has not been changed.
See Also:
inputDataChanged

isInputDataChanged

public static boolean isInputDataChanged()
Get switch for whether any input data value has been changed.

Returns:
True, if input data value has been changed; false, if input data value has not been changed.

getFont

public static java.awt.Font getFont()
Return the Font used.

Returns:
Font specified or system default.

getFontSize

public static int getFontSize()
Return the Font size used.

Returns:
Font size used.

setFontSize

public static void setFontSize(int size)
Set the Font size to be used to display text on Components.

Parameters:
size - Font size to be used to display text on Components.

setFont

public static void setFont(java.awt.Font fnt)
Set the Font to be used to display text on Components.

Parameters:
fnt - Font to be used to display text on Components.

getScreenHeight

public static int getScreenHeight()
Get screen height.

Returns:
Screen height in dots.

getScreenWidth

public static int getScreenWidth()
Get screen width.

Returns:
Screen width in dots.

getScreenResolution

public static int getScreenResolution()
Get screen resolution.

Returns:
Screen resolution in dots per inch.

saveComponent

public static void saveComponent(java.awt.Component comp)
Add component to vector containing list of all components that have a font associated.

Parameters:
comp - Component to save.

remove

public static void remove(java.awt.Component comp)
Remove component from vector containing list of all components that have a font associated.

Parameters:
comp - Component to remove.

makeButton

public static java.awt.Button makeButton(java.lang.String text)
Create a Button with additional properties. Set the Font, if non-null, for the component and save a reference to the component which may be used to change the Font later.

Parameters:
text - Text to be displayed on button.
See Also:
Button

makeCheckbox

public static java.awt.Checkbox makeCheckbox(java.lang.String text)
Create a checkbox with additional properties. Set the Font, if non-null, for the component and save a reference to the component which may be used to change the Font later.

Parameters:
text - Text to be displayed on checkbox.
See Also:
Checkbox

makeCheckbox

public static java.awt.Checkbox makeCheckbox(java.lang.String text,
                                             boolean whb)
Create a checkbox with additional properties. Set the Font, if non-null, for the component and save a reference to the component which may be used to change the Font later.

Parameters:
text - Text to be displayed on checkbox.
whb - State of the checkbox at creation.
See Also:
Checkbox

makeCheckbox

public static java.awt.Checkbox makeCheckbox(java.lang.String text,
                                             boolean whb,
                                             java.awt.CheckboxGroup cbg)
Create a checkbox with additional properties. Set the Font, if non-null, for the component and save a reference to the component which may be used to change the Font later.

Parameters:
text - Text to be displayed on checkbox.
whb - State of the checkbox at creation.
cbg - Group that checkbox is in. If checkbox is in a group, only one item in the group may be checked at a time.
See Also:
Checkbox

makeLabel

public static java.awt.Label makeLabel(java.lang.String text)
Create a Label with additional properties. Set the Font, if non-null, for the component and save a reference to the component which may be used to change the Font later.

Parameters:
text - Text to be displayed on label.
See Also:
Label

makeLabel

public static java.awt.Label makeLabel(java.lang.String text,
                                       int alignment)
Create a Label with additional properties. Set the Font, if non-null, for the component and save a reference to the component which may be used to change the Font later.

Parameters:
text - Text to be displayed on label.
alignment - Alignment may be LEFT, CENTER, or RIGHT.
See Also:
Label

makeTextArea

public static java.awt.TextArea makeTextArea(java.lang.String text)
Create a TextArea with additional properties. Set the Font, if non-null, for the component and save a reference to the component which may be used to change the Font later.

Parameters:
text - Text to be displayed on TextArea.
See Also:
TextArea

makeTextArea

public static java.awt.TextArea makeTextArea(int rows,
                                             int columns)
Create a TextArea with additional properties. Set the Font, if non-null, for the component and save a reference to the component which may be used to change the Font later.

Parameters:
rows - Number of rows in which data may be entered.
columns - Number of columns in which data may be entered.
See Also:
TextArea

makeTextArea

public static java.awt.TextArea makeTextArea(java.lang.String text,
                                             int rows,
                                             int columns)
Create a TextArea with additional properties. Set the Font, if non-null, for the component and save a reference to the component which may be used to change the Font later.

Parameters:
text - Text to be displayed on TextArea.
rows - Number of rows in which data may be entered.
columns - Number of columns in which data may be entered.
See Also:
TextArea

makeTextArea

public static java.awt.TextArea makeTextArea(java.lang.String text,
                                             int rows,
                                             int columns,
                                             int scroll)
Create a TextArea with additional properties. Set the Font, if non-null, for the component and save a reference to the component which may be used to change the Font later.

Parameters:
text - Text to be displayed on TextArea.
rows - Number of rows in which data may be entered.
columns - Number of columns in which data may be entered.
scroll - Visibility of scrollbars. May be: SCROLLBARS_VERTICAL_ONLY, SCROLLBARS_HORIZONTAL_ONLY, or SCROLLBARS_BOTH.
See Also:
TextArea

makeTextField

public static java.awt.TextField makeTextField(java.lang.String text)
Create a TextField with additional properties. Set the Font, if non-null, for the component and save a reference to the component which may be used to change the Font later.

Parameters:
text - Text to be displayed on TextField.
See Also:
TextField

makeTextField

public static java.awt.TextField makeTextField(int columns)
Create a TextField with additional properties. Set the Font, if non-null, for the component and save a reference to the component which may be used to change the Font later.

Parameters:
columns - Number of columns in which data may be entered.
See Also:
TextField

makeTextField

public static java.awt.TextField makeTextField(java.lang.String text,
                                               int columns)
Create a TextField with additional properties. Set the Font, if non-null, for the component and save a reference to the component which may be used to change the Font later.

Parameters:
text - Text to be displayed on TextField.
columns - Number of columns in which data may be entered.
See Also:
TextField

getSize

public static int[] getSize(java.lang.String text)
Obtain the number of rows and columns needed to display the text in a TextArea. The rows are separated by "\n". The number of columns required are computed as the maximum number of characters between successive "\n"s.

Parameters:
text - Text to display in TextArea before accepting a response in the form of a button click.
Returns:
Array containing the number of rows and columns required in the TextArea.

getTextSize

public static int[] getTextSize(java.lang.String text,
                                java.awt.TextArea inTextArea)
Obtain the height and width in pixels needed to display the text in a TextArea. The rows are separated by "\n". The width is computed from the maximum width for each string, between successive "\n"s, at the default font size. For consistency, the width is adjusted to be at least as big as 40 M's.

Parameters:
text - Text to display in TextArea before accepting a response in the form of a button click.
inTextArea - TextArea in which text is displayed.
Returns:
Array containing the height and width in pixels needed to display the text in a TextArea.

scrollToSee

public static void scrollToSee(java.awt.Component compFocus)
Scrolling is performed, if necessary, to put the component in the view port. If the component can be seen in the view port, return. If the component can not be seen, scroll until it can be seen. To decide if scrolling is necessary, the horizontal and vertical directions are considered separately.

Parameters:
compFocus - The component which the user wants to see.

getAppletHeight

public static int getAppletHeight()
Get height in pixels to add for Applet warning: "Warning: Applet Window".

Returns:
Height in pixels to add for Applet warning: "Warning: Applet Window". Zero if application, not Applet.

getApplet

public static java.applet.Applet getApplet()
Get current Applet for commands that need it.

Returns:
Current Applet.

setApplet

public static void setApplet(java.applet.Applet applet)
Save current Applet for commands that need it.

Parameters:
applet - Current Applet.

isSaveAllowed

public static boolean isSaveAllowed()
Indicate whether saving to a file is allowed. Saving to a file is not allowed from Applets currently.

Returns:
Boolean indicating whether saving to a file is allowed. False if in applet; otherwise, true.

isPrintAllowed

public static boolean isPrintAllowed()
Indicate whether printing is allowed. Printing is not allowed from Applets currently.

Returns:
Boolean indicating whether printing is allowed. False if in applet; otherwise, true.

setSaveAllowed

public static void setSaveAllowed(boolean allowed)
Save switch to override whether read/save/print are allowed locally.

Parameters:
allowed - True, if read/save/print are allowed locally; else, false, if read/save/print are NOT allowed locally.

getPrintJob

public static java.awt.PrintJob getPrintJob(java.awt.Frame frame,
                                            java.lang.String title)
Get a PrintJob object to print graphics or text. It uses an internal Properties object or JobAttributes and PageAttributes depending on the version of Java. These are set as appropriate before instantiation of the PrintJob object.

Parameters:
frame - the parent of the print dialog.
title - the title of the PrintJob. A null is equivalent to "".
Returns:
a PrintJob instance.

setPrintFile

public static void setPrintFile(java.lang.String filename)
Set print output file name.

Parameters:
filename - output file name.

setPrinter

public static void setPrinter(java.lang.String queue)
Set printer queue; for example, b142a12a.

Parameters:
queue - printer/queue name.

setPrintMedia

public static void setPrintMedia(java.lang.String media)
Set printer; for example, b142a12a.

Parameters:
media - printer/queue name.

setPrintColor

public static void setPrintColor(java.lang.String color)
Set color or monochrome.

Parameters:
color - color or monochrome.

getPrintOrientation

public static java.lang.String getPrintOrientation()
Get orientation: portrait or landscape.

Returns:
portrait or lanscape orientation.

setPrintOrientation

public static void setPrintOrientation(java.lang.String orient)
Set orientation: portrait or landscape.

Parameters:
orient - orientation.

getName

public static java.lang.String getName()
Get class name.

Returns:
Class name.