net.sourceforge.olduvai.treejuxtaposer
Class UI

java.lang.Object
  extended by net.sourceforge.olduvai.treejuxtaposer.UI
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.WindowListener, java.util.EventListener

public class UI
extends java.lang.Object
implements java.awt.event.WindowListener, java.awt.event.ActionListener

User interface class that externalizes most of the menu setup for the top menu bar, and the main implementation of the dialog to add new trees.

Author:
jeffrey

Field Summary
private static int ABOUTOPT
          Index for Help->Readme option.
private static boolean[][] allActive
          Collection of sets of flags that define if a string is selectable or a space.
private static java.lang.String[][] allMenu
          Collection of all menu strings.
(package private)  java.io.File currDir
          Current directory used for file loaders (saving and opening trees).
private  net.sourceforge.olduvai.treejuxtaposer.DebugFrame debugFrame
          Debug frame.
private static int DEBUGOPT
          Index for Tools->Debug option.
private  java.awt.GridLayout drawLayout
          Layout for drawing panel.
private  java.awt.Panel drawPanel
          Drawing panel that hold canvas objects.
private static boolean[] fileActive
          Flags to indicate if menu options are active (true) or spaces (false).
private static java.lang.String[] fileMenu
          Strings for File menu section.
private static int FILEMENU
          Index for File menu.
private  java.io.File[] files
          Files that are selected for reading trees, used in the addTree function.
private static boolean[] findActive
          Flags to indicate if menu options are active (true) or spaces (false).
private static java.lang.String[] findMenu
          Strings for Find menu section.
private static int FINDMENU
          Index for Find menu.
private static int FINDOPT
          Index for Find->Find option.
private static int GROUPOPT
          Index for Tools->Groups option.
private static boolean[] helpActive
          Flags to indicate if menu options are active (true) or spaces (false).
private static java.lang.String[] helpMenu
          Strings for the help menu section.
private static int HELPMENU
          Index for Help menu.
private  java.awt.Frame mainFrame
          Main drawing frame that has the menu bar at the top, and holds the drawing panel.
private static java.awt.Menu[] menu
          Array of top level menus: File, Find, Tool, Help.
private  java.awt.MenuBar menuBar
          Menu bar object, to be later initialized with menu objects.
private static int MENUFONTSIZE
          Font size for menu.
private static int MENUFONTSTYLE
          Font style for menu.
private static java.lang.String MENUFONTTYPE
          Font type for menu.
private static java.lang.String[] menuHeader
          Top-level menu bar string constants.
private  java.awt.MenuItem[][] menuItem
          List of all menu items, to be later initialized with constants.
private static int OPENOPT
          Index for File->Open option.
private static int QUITOPT
          Index for File->Quit option.
private static int REMOVEOPT
          Index for File->Remove option.
private static int SAVEOPT
          Index for File->Save option.
private  java.awt.Dimension screendim
          Read actual screen dimensions.
private  IncrementalSearch searchFrame
          Incremental search frame.
private static int SETTINGOPT
          Index for Tools->Settings option.
private  SettingsFrame settingsFrame
          Settings frame for options such as line width and font size.
private  StateFrame stateFrame
          State frame for marking and active group manipulation.
private  TreeJuxtaposer tj
          TreeJuxtaposer object.
private static boolean[] toolActive
          Flags to indicate if menu options are active (true) or spaces (false).
private  java.awt.Toolkit toolkit
          Toolkit used to get screen dimensions.
private static java.lang.String[] toolMenu
          Strings for Tools menu section.
private static int TOOLMENU
          Index for Tools menu.
 
Constructor Summary
UI(TreeJuxtaposer tj, java.lang.String title)
          Initializes the drawing surface and menu bar on the main frame.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Menu listener.
protected  void addAction()
          Add a new tree action.
private  void addMenuBar()
          Set up the menu bar, with all the items that are defined with the string externalization.
protected  net.sourceforge.olduvai.treejuxtaposer.DebugFrame getDebugFrame()
          Get the debug frame DebugFrame.
protected  java.awt.GridLayout getDrawLayout()
          Get the drawing layout manager.
protected  java.awt.Panel getDrawPanel()
          Return the drawing panel, which holds all the canvas objects that are the drawers.
protected  java.awt.Frame getMainFrame()
          Return the main frame object for holding the drawing panel.
protected  IncrementalSearch getSearchFrame()
          Get the search panel frame IncrementalSearch.
protected  SettingsFrame getSettingsFrame()
          Get the settings frame SettingsFrame.
protected  StateFrame getStateFrame()
          Get the state frame StateFrame.
protected  void quitAction()
          Kills the application with an exit.
protected  void removeAction()
          Triggers a new tree removal panel TreeRemovalPanel.
protected  void saveAction()
          Performs a save operation with the current trees.
 void windowActivated(java.awt.event.WindowEvent event)
          Action to perform on an activation.
 void windowClosed(java.awt.event.WindowEvent event)
          Action to perform on a close operation.
 void windowClosing(java.awt.event.WindowEvent event)
          Action to perform when the window is closing.
 void windowDeactivated(java.awt.event.WindowEvent event)
          Action to perform on an deactivation.
 void windowDeiconified(java.awt.event.WindowEvent event)
          Action to perform on an deiconification.
 void windowIconified(java.awt.event.WindowEvent event)
          Action to perform on an iconification.
 void windowOpened(java.awt.event.WindowEvent event)
          Action to perform on an open.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mainFrame

private java.awt.Frame mainFrame
Main drawing frame that has the menu bar at the top, and holds the drawing panel.


stateFrame

private StateFrame stateFrame
State frame for marking and active group manipulation.


settingsFrame

private SettingsFrame settingsFrame
Settings frame for options such as line width and font size.


searchFrame

private IncrementalSearch searchFrame
Incremental search frame.


debugFrame

private net.sourceforge.olduvai.treejuxtaposer.DebugFrame debugFrame
Debug frame.


drawPanel

private java.awt.Panel drawPanel
Drawing panel that hold canvas objects.


drawLayout

private java.awt.GridLayout drawLayout
Layout for drawing panel.


toolkit

private java.awt.Toolkit toolkit
Toolkit used to get screen dimensions.


screendim

private java.awt.Dimension screendim
Read actual screen dimensions.


currDir

java.io.File currDir
Current directory used for file loaders (saving and opening trees).


menuBar

private java.awt.MenuBar menuBar
Menu bar object, to be later initialized with menu objects.


menuItem

private java.awt.MenuItem[][] menuItem
List of all menu items, to be later initialized with constants.


MENUFONTTYPE

private static final java.lang.String MENUFONTTYPE
Font type for menu.

See Also:
Constant Field Values

MENUFONTSTYLE

private static final int MENUFONTSTYLE
Font style for menu.

See Also:
Constant Field Values

MENUFONTSIZE

private static final int MENUFONTSIZE
Font size for menu.

See Also:
Constant Field Values

menuHeader

private static final java.lang.String[] menuHeader
Top-level menu bar string constants.


FILEMENU

private static final int FILEMENU
Index for File menu.

See Also:
Constant Field Values

FINDMENU

private static final int FINDMENU
Index for Find menu.

See Also:
Constant Field Values

TOOLMENU

private static final int TOOLMENU
Index for Tools menu.

See Also:
Constant Field Values

HELPMENU

private static final int HELPMENU
Index for Help menu.

See Also:
Constant Field Values

menu

private static final java.awt.Menu[] menu
Array of top level menus: File, Find, Tool, Help.


fileMenu

private static final java.lang.String[] fileMenu
Strings for File menu section.


fileActive

private static final boolean[] fileActive
Flags to indicate if menu options are active (true) or spaces (false).


OPENOPT

private static final int OPENOPT
Index for File->Open option.

See Also:
Constant Field Values

SAVEOPT

private static final int SAVEOPT
Index for File->Save option.

See Also:
Constant Field Values

REMOVEOPT

private static final int REMOVEOPT
Index for File->Remove option.

See Also:
Constant Field Values

QUITOPT

private static final int QUITOPT
Index for File->Quit option.

See Also:
Constant Field Values

findMenu

private static final java.lang.String[] findMenu
Strings for Find menu section.


findActive

private static final boolean[] findActive
Flags to indicate if menu options are active (true) or spaces (false).


FINDOPT

private static final int FINDOPT
Index for Find->Find option.

See Also:
Constant Field Values

toolMenu

private static final java.lang.String[] toolMenu
Strings for Tools menu section.


toolActive

private static final boolean[] toolActive
Flags to indicate if menu options are active (true) or spaces (false).


GROUPOPT

private static final int GROUPOPT
Index for Tools->Groups option.

See Also:
Constant Field Values

SETTINGOPT

private static final int SETTINGOPT
Index for Tools->Settings option.

See Also:
Constant Field Values

DEBUGOPT

private static final int DEBUGOPT
Index for Tools->Debug option.

See Also:
Constant Field Values

helpMenu

private static final java.lang.String[] helpMenu
Strings for the help menu section.


helpActive

private static final boolean[] helpActive
Flags to indicate if menu options are active (true) or spaces (false).


ABOUTOPT

private static final int ABOUTOPT
Index for Help->Readme option.

See Also:
Constant Field Values

allMenu

private static final java.lang.String[][] allMenu
Collection of all menu strings. Order defines real menu order in the bar.


allActive

private static final boolean[][] allActive
Collection of sets of flags that define if a string is selectable or a space.


files

private java.io.File[] files
Files that are selected for reading trees, used in the addTree function.


tj

private TreeJuxtaposer tj
TreeJuxtaposer object.

Constructor Detail

UI

public UI(TreeJuxtaposer tj,
          java.lang.String title)
Initializes the drawing surface and menu bar on the main frame.

Parameters:
tj - TreeJuxtaposer object.
title - Initial title for the main frame window.
Method Detail

windowClosing

public void windowClosing(java.awt.event.WindowEvent event)
Action to perform when the window is closing. Halts the program.

Specified by:
windowClosing in interface java.awt.event.WindowListener
Parameters:
event - Window event.

windowClosed

public void windowClosed(java.awt.event.WindowEvent event)
Action to perform on a close operation. Halts the program.

Specified by:
windowClosed in interface java.awt.event.WindowListener
Parameters:
event - Window event.

windowActivated

public void windowActivated(java.awt.event.WindowEvent event)
Action to perform on an activation. Currently does nothing.

Specified by:
windowActivated in interface java.awt.event.WindowListener
Parameters:
event - Window event.

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent event)
Action to perform on an deiconification. Requests a redraw.

Specified by:
windowDeiconified in interface java.awt.event.WindowListener
Parameters:
event - Window event.

windowOpened

public void windowOpened(java.awt.event.WindowEvent event)
Action to perform on an open. Currently does nothing.

Specified by:
windowOpened in interface java.awt.event.WindowListener
Parameters:
event - Window event.

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent event)
Action to perform on an deactivation. Currently does nothing.

Specified by:
windowDeactivated in interface java.awt.event.WindowListener
Parameters:
event - Window event.

windowIconified

public void windowIconified(java.awt.event.WindowEvent event)
Action to perform on an iconification. Currently does nothing.

Specified by:
windowIconified in interface java.awt.event.WindowListener
Parameters:
event - Window event.

addMenuBar

private void addMenuBar()
Set up the menu bar, with all the items that are defined with the string externalization.


getMainFrame

protected java.awt.Frame getMainFrame()
Return the main frame object for holding the drawing panel. Used to hold the control panel, which does not exist anymore.

Returns:
The main frame object.

getDrawPanel

protected java.awt.Panel getDrawPanel()
Return the drawing panel, which holds all the canvas objects that are the drawers.

Returns:
The drawing panel.

getDrawLayout

protected java.awt.GridLayout getDrawLayout()
Get the drawing layout manager.

Returns:
The drawing layout, for positioning new drawers on the canvas.

getSearchFrame

protected IncrementalSearch getSearchFrame()
Get the search panel frame IncrementalSearch.

Returns:
The search panel frame.

getSettingsFrame

protected SettingsFrame getSettingsFrame()
Get the settings frame SettingsFrame.

Returns:
The settings frame.

getDebugFrame

protected net.sourceforge.olduvai.treejuxtaposer.DebugFrame getDebugFrame()
Get the debug frame DebugFrame.

Returns:
The debug frame.

getStateFrame

protected StateFrame getStateFrame()
Get the state frame StateFrame.

Returns:
The state frame.

addAction

protected void addAction()
Add a new tree action.


removeAction

protected void removeAction()
Triggers a new tree removal panel TreeRemovalPanel.


saveAction

protected void saveAction()
Performs a save operation with the current trees.


quitAction

protected void quitAction()
Kills the application with an exit.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Menu listener.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - Menu event, parsed and handled here.