BioLegato 0.7.3 Core API

org.biolegato.core.main
Class BLMain

java.lang.Object
  extended by org.biolegato.core.main.BLMain

public final class BLMain
extends java.lang.Object

The main program and generic function class.

This class is used to generate the main window, do all startup processing, and run the program. This class also contains most of the utility functions.

Version:
0.7.3 6-Dec-2010
Author:
Graham Alvare, Brian Fristensky

Nested Class Summary
static class BLMain.ARCH
           
static class BLMain.OS
           
 
Field Summary
static javax.swing.JMenuItem ABOUT_MENUITEM
          The menu item for BioLegato's "About..."
static BLMain.ARCH CURRENT_ARCH
          Stores the current machine architecture
static java.lang.String CURRENT_DIR
          This constant is set to the path of where biolegato was run The value of this constant determined at runtime.
static BLMain.OS CURRENT_OS
          Stores the current operating system
static boolean debug
          Stores information regarding the usage of the debug command NOTE: This should always be accessed using BLMain.debug
static java.awt.Font DEFAULT_FONT
          The default font for BioLegato
static int DOUBLE_CLICK_TIME
          The amount of time between clicks to be considered a double click.
static javax.swing.JMenuItem EXIT_MENUITEM
          The menu item for BioLegato's "Exit..."
static java.lang.String HOME_DIR
          Stores the user's home directory
static java.lang.String NAME
          This constant stores the program's name
static java.lang.String PROGRAM_DIR
          This constant is set to the path of BioLegato.jar The value of this constant determined at runtime.
static long serialVersionUID
          This constant is used for Serialization
static java.lang.String VERSION
          This constant is used to keep track of version changes.
 
Constructor Summary
BLMain()
           
 
Method Summary
static void aboutPopup()
          Displays an about popup for BioLegato.
static javax.swing.JMenu addMenuHeading(int order, java.lang.String name)
          Adds a menu heading (JMenu) to our menu (BLMenu).
static javax.swing.JMenu addMenuHeading(java.lang.String name)
          Adds a menu heading (JMenu) to our menu (BLMenu).
static void addMenuItem(int location, java.lang.String headingName, javax.swing.JMenuItem menuItem)
          Adds a menu item (JMenuItem) to a menu heading (JMenu) within the window (ProgramWindow)
static void addMenuItem(java.lang.String headingName, javax.swing.JMenuItem menuItem)
          Adds a menu item (JMenuItem) to a menu heading (JMenu) within the window (ProgramWindow)
static void addPropertiesListener(java.lang.String key, PropertiesListener listener)
          Adds a properties listener to the properties object.
static java.lang.String envreplace(java.lang.String change)
          Replaces $VARIABLE name with environment variables.
static void error(java.lang.String message)
          Sends an error message to BioLegato's standard err.
static void error(java.lang.String message, java.lang.String location)
          Sends an error message to BioLegato's standard err.
static DataCanvas getCanvas()
          Returns the current/selected data in the canvas.
static java.io.File getCurrentPWD()
          Gets the present working directory "PWD" for BioLegato (this does NOT change CURRENT_DIR!) This value can be used to cache which directory file dialog boxes should use as their "current working directory"
static javax.swing.JFrame getJFrame()
          Provides access for other classes to the main program window JFrame object.
static java.util.Collection<PluginWrapper> getPlugins(java.lang.Class<?> type)
          Returns a list with all of the plugins loaded by BioLegato that are instances of the class type indicated.
static BLProperties getProperties()
          Returns the properties object associated with this instance of BioLegato
static java.lang.String getProperty(java.lang.String property)
          Retrieves individual settings for BioLegato.
static boolean isDigit(char test)
          Tests if a character is a digit or not.
static void main(java.lang.String[] args)
          Starts up BioLegato.
static void message(java.lang.String message)
          Sends a message to BioLegato's standard out.
static void message(java.lang.String message, java.lang.String location)
          Sends a message to BioLegato's standard out.
static boolean notDigit(char test)
          Tests if a character is a digit or not.
static java.lang.String readStream(java.io.BufferedReader reader)
          Reads the complete contents of a BufferedReader into a string.
static java.lang.Process safeExecute(java.lang.String cmd)
          Ensures that the command will be executed properly as a shell command
static void setCurrentPWD(java.io.File newPWD)
          Sets the present working directory "PWD" for BioLegato (this does NOT change CURRENT_DIR!) This value can be used to cache which directory file dialog boxes should use as their "current working directory"
static void setProperty(java.lang.String key, java.lang.String value)
          Changes properties for BioLegato.
static void shellCommand(java.lang.String cmd, java.lang.String data)
          Runs simple shell commands.
static boolean testNumber(char[] test)
          Checks if a character array is all digits.
static void warning(java.lang.String message)
          Sends an warning message to BioLegato's standard err.
static void warning(java.lang.String message, java.lang.String location)
          Sends an warning message to BioLegato's standard err.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final java.lang.String NAME
This constant stores the program's name

See Also:
Constant Field Values

PROGRAM_DIR

public static final java.lang.String PROGRAM_DIR
This constant is set to the path of BioLegato.jar The value of this constant determined at runtime.


CURRENT_DIR

public static final java.lang.String CURRENT_DIR
This constant is set to the path of where biolegato was run The value of this constant determined at runtime.


VERSION

public static final java.lang.String VERSION
This constant is used to keep track of version changes.

See Also:
Constant Field Values

DEFAULT_FONT

public static final java.awt.Font DEFAULT_FONT
The default font for BioLegato


HOME_DIR

public static final java.lang.String HOME_DIR
Stores the user's home directory


DOUBLE_CLICK_TIME

public static final int DOUBLE_CLICK_TIME
The amount of time between clicks to be considered a double click.

See Also:
Constant Field Values

CURRENT_OS

public static final BLMain.OS CURRENT_OS
Stores the current operating system


CURRENT_ARCH

public static final BLMain.ARCH CURRENT_ARCH
Stores the current machine architecture


serialVersionUID

public static final long serialVersionUID
This constant is used for Serialization

See Also:
Constant Field Values

ABOUT_MENUITEM

public static final javax.swing.JMenuItem ABOUT_MENUITEM
The menu item for BioLegato's "About..."


EXIT_MENUITEM

public static final javax.swing.JMenuItem EXIT_MENUITEM
The menu item for BioLegato's "Exit..."


debug

public static boolean debug
Stores information regarding the usage of the debug command NOTE: This should always be accessed using BLMain.debug

Constructor Detail

BLMain

public BLMain()
Method Detail

main

public static void main(java.lang.String[] args)
Starts up BioLegato.

Parameters:
args - the command line arguments for BioLegato.

setProperty

public static void setProperty(java.lang.String key,
                               java.lang.String value)
Changes properties for BioLegato.

Parameters:
key - the property to change.
value - the new value for the property.

getProperty

public static java.lang.String getProperty(java.lang.String property)
Retrieves individual settings for BioLegato. This is used to obtain values of properties in BioLeagato

Parameters:
property - the property key to retrieve the value for
Returns:
the property value corresponding to the key parameter

getCanvas

public static DataCanvas getCanvas()
                            throws javax.swing.text.BadLocationException
Returns the current/selected data in the canvas.

Returns:
the current data for usage by commands
Throws:
javax.swing.text.BadLocationException - any exceiptions related to obtaining the data

getJFrame

public static javax.swing.JFrame getJFrame()
Provides access for other classes to the main program window JFrame object.

Returns:
the JFrame object corresponding to the main program window.

getProperties

public static BLProperties getProperties()
Returns the properties object associated with this instance of BioLegato

Returns:
the properties object associated

addMenuHeading

public static javax.swing.JMenu addMenuHeading(java.lang.String name)
Adds a menu heading (JMenu) to our menu (BLMenu).

Parameters:
name - the name of the menu heading
Returns:
either the JMenu which was added or the JMenu that corresponds to the existing menu heading.

addMenuHeading

public static javax.swing.JMenu addMenuHeading(int order,
                                               java.lang.String name)
Adds a menu heading (JMenu) to our menu (BLMenu).

Parameters:
order - the position to place the menu tag
name - the name of the menu heading
Returns:
either the JMenu which was added or the JMenu that corresponds to the existing menu heading.

addMenuItem

public static void addMenuItem(int location,
                               java.lang.String headingName,
                               javax.swing.JMenuItem menuItem)
Adds a menu item (JMenuItem) to a menu heading (JMenu) within the window (ProgramWindow)

If the heading which was entered does not exist, this function will create it; hence why addMenuHeading returns the heading corresponding to the name entered if a menu heading with that name already exists.

Parameters:
location - is the location in the menu to insert the item at
headingName - is the name of the menu heading to add the menu item to.
menuItem - is the menu item to add to the heading.

addMenuItem

public static void addMenuItem(java.lang.String headingName,
                               javax.swing.JMenuItem menuItem)
Adds a menu item (JMenuItem) to a menu heading (JMenu) within the window (ProgramWindow)

If the heading which was entered does not exist, this function will create it; hence why addMenuHeading returns the heading corresponding to the name entered if a menu heading with that name already exists.

Parameters:
headingName - is the name of the menu heading to add the menu item to.
menuItem - is the menu item to add to the heading.

aboutPopup

public static void aboutPopup()
Displays an about popup for BioLegato.


addPropertiesListener

public static void addPropertiesListener(java.lang.String key,
                                         PropertiesListener listener)
Adds a properties listener to the properties object.

Parameters:
key - the key of the properties to listen to.
listener - the listener to add to the object.

safeExecute

public static java.lang.Process safeExecute(java.lang.String cmd)
Ensures that the command will be executed properly as a shell command

This function generates a command list for execution. The command list will contain the appropriate shell for the current operating system, followed by the "execution-argument", (whatever flag is required to tell the shell that the rest of the commandline should be executed by the shell), followed by the command to execute (the variable cmd)

Operating system values obtained from http://lopica.sourceforge.net/os.html

Parameters:
cmd - the command string to execute
Returns:
if successful a Process object for the executed command.

shellCommand

public static void shellCommand(java.lang.String cmd,
                                java.lang.String data)
Runs simple shell commands. Reroutes all output to the console.

Parameters:
cmd - the command string to run
data - the data to use as standard input (System.in)

error

public static void error(java.lang.String message)
Sends an error message to BioLegato's standard err. Alias for error(message, null);

Parameters:
message - the error message to send.

error

public static void error(java.lang.String message,
                         java.lang.String location)
Sends an error message to BioLegato's standard err.

Parameters:
message - the error message to send.
location - the location the error occurred.

warning

public static void warning(java.lang.String message)
Sends an warning message to BioLegato's standard err. Alias for warning(message, null);

Parameters:
message - the warning message to send.

warning

public static void warning(java.lang.String message,
                           java.lang.String location)
Sends an warning message to BioLegato's standard err.

Parameters:
message - the warning message to send.
location - the location the error occurred.

message

public static void message(java.lang.String message)
Sends a message to BioLegato's standard out. Alias for message(message, null);

Parameters:
message - the message to send.

message

public static void message(java.lang.String message,
                           java.lang.String location)
Sends a message to BioLegato's standard out.

Parameters:
message - the message to send.
location - the location the message was sent from.

readStream

public static java.lang.String readStream(java.io.BufferedReader reader)
                                   throws java.io.IOException
Reads the complete contents of a BufferedReader into a string.

Parameters:
reader - the BufferedReader to read.
Returns:
the contents of the BufferedReader.
Throws:
java.io.IOException - throws any exceptions from the read operation.

testNumber

public static boolean testNumber(char[] test)
Checks if a character array is all digits.

Parameters:
test - the character array to test.
Returns:
true if the array only contains digits.

envreplace

public static java.lang.String envreplace(java.lang.String change)
Replaces $VARIABLE name with environment variables. This function provides functionality similar to BASH. NOTE: if the variable is $BL_HOME, and this is not set, the variable will default to the current working directory.

Parameters:
change - the string to modify.
Returns:
the modified string.

notDigit

public static final boolean notDigit(char test)
Tests if a character is a digit or not. Digits are from 0-9, a-z, and A-Z

Parameters:
test - the character to test.
Returns:
true if the character is not a digit, otherwise false.

isDigit

public static final boolean isDigit(char test)
Tests if a character is a digit or not. Digits are from 0-9, a-z, and A-Z

Parameters:
test - the character to test.
Returns:
true if the character is a digit, otherwise false.

getCurrentPWD

public static java.io.File getCurrentPWD()
Gets the present working directory "PWD" for BioLegato (this does NOT change CURRENT_DIR!) This value can be used to cache which directory file dialog boxes should use as their "current working directory"

Returns:
the current value of "PWD"

setCurrentPWD

public static void setCurrentPWD(java.io.File newPWD)
Sets the present working directory "PWD" for BioLegato (this does NOT change CURRENT_DIR!) This value can be used to cache which directory file dialog boxes should use as their "current working directory"

Parameters:
newPWD - the new directory to use as the "PWD"

getPlugins

public static java.util.Collection<PluginWrapper> getPlugins(java.lang.Class<?> type)
Returns a list with all of the plugins loaded by BioLegato that are instances of the class type indicated.

Parameters:
type - the plugin type to find
Returns:
a list containing all of the plugins loaded

BioLegato 0.7.3 Core API

Copyright © 2008-2010 University of Manitoba.