BioLegato 0.7.0 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.6.2 12-Feb-2010
Author:
Graham Alvare, Brian Fristensky

Field Summary
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 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 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 void addData(Sequence[] dataAdd)
          Adds the data to the canvas.
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(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 Sequence[] getAllData()
          Returns the complete contents of the data in the canvas.
static Sequence[] getClipboard()
          Obtains the current contents of the clipboard (null if empty).
static Sequence[] getData()
          Returns the current/selected data in the canvas.
static javax.swing.JFrame getJFrame()
          Provides access for other classes to the main program window JFrame object.
static java.lang.String getProperty(java.lang.String property)
          Retrieves individual settings for BioLegato.
static SeqDoc getSeqDoc()
          Returns the root sequence document for BioLegato.
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 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 setClipboard(Sequence[] copy)
          Changes the current contents of the clipboard.
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


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

serialVersionUID

public static final long serialVersionUID
This constant is used for Serialization

See Also:
Constant Field Values
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

getClipboard

public static Sequence[] getClipboard()
Obtains the current contents of the clipboard (null if empty).

Returns:
the current contents of the clipboard.

setClipboard

public static void setClipboard(Sequence[] copy)
Changes the current contents of the clipboard.

Parameters:
copy - the new content for the clipboard.

getSeqDoc

public static SeqDoc getSeqDoc()
Returns the root sequence document for BioLegato.

Returns:
the root sequence document.

getData

public static Sequence[] getData()
                          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

getAllData

public static Sequence[] getAllData()
                             throws javax.swing.text.BadLocationException
Returns the complete contents of the data in the canvas.

Returns:
the complete contents of the data in the canvas
Throws:
javax.swing.text.BadLocationException - any location exceptions thrown by the underlying Document class

addData

public static void addData(Sequence[] dataAdd)
Adds the data to the canvas.

Parameters:
dataAdd - the data to add to the canvas.
Throws:
javax.swing.text.BadLocationException - any exceptions thrown by the underlying document class

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.

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(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 $BIOLEGATO_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.

BioLegato 0.7.0 Core API

Copyright © 2008-2010 University of Manitoba.