jist.runtime.guilog
Class GuiLog

java.lang.Object
  extended by jist.runtime.guilog.GuiLog

public class GuiLog
extends java.lang.Object

Title: GuiLog

Description: Creates a GUI that displays event information.

Version:
1.0
Author:
Mark Fong, Rimon Barr <barr+jist@cs.cornell.edu>

Nested Class Summary
static class GuiLog.ButtonHandler
          Defines how mouse clicks on the buttons are handled.
static class GuiLog.ChildrenCellEditor
          ChildrenCellEditor is a customized TableCellEditor for JiST Events.
 class GuiLog.EventCellRenderer
          EventCellRenderer is a customized TableCellRenderer for JiST Events.
static class GuiLog.EventNode
          An EventNode encapsulates the construct formed by an Event and the relationships it has with its parent and children Events.
static class GuiLog.EventNodeComparator
          The EventNodeComparator class defines how to sort two Events.
static class GuiLog.EventTableModel
          The EventTableModel class is the data model for the JTable.
static class GuiLog.MouseAdapterHandler
          Defines how mouse clicks on the Parent column are handled.
static class GuiLog.UntilTask
          UntilTask is a task that can be scheduled to either Pause or Resume the GuiLog.
 
Field Summary
static javax.swing.JButton cellDownButton
          Re-used JButton.
static javax.swing.JButton cellUpButton
          Re-used JButton.
static javax.swing.ImageIcon downIcon
          Re-used Icon.
static GuiLog.EventNodeComparator EVENT_COMPARE
          Used for sorting Events.
static javax.swing.JFrame frame
          The JFrame for displaying the GUI.
private static boolean isStep
          Whether to Step through one event or not.
private  java.util.LinkedList list
          A list used to track the events as they are generated so that they can easily be deleted first-in, first-out.
private static java.lang.reflect.Method m
          Dummy method for testing.
private  GuiLog.EventTableModel model
          The data model for the table.
private  int numEventsThreshHold
          Maximum number of Events allowed to be displayed in table.
private  javax.swing.JPanel panel
          The JPanel for displaying the GUI.
private static javax.swing.JButton pauseButton
          The JButton that pauses and resumes the GuiLog.
private static boolean paused
          Pause-status of the Controller.
static javax.swing.ImageIcon pauseIcon
          Re-used Icon.
private static java.lang.Object pauselock
          Object that acquires the lock for pausing the Controller.
static javax.swing.ImageIcon resumeIcon
          Re-used Icon.
private static javax.swing.JButton stepButton
          The JButton that allows one event to be added, and then pauses.
static javax.swing.ImageIcon stepIcon
          Re-used Icon.
private  javax.swing.JTable table
          The JTable for displaying the Event information.
static java.awt.Font tableFont
          The font used for most of the table.
private static javax.swing.JButton untilButton
          The JButton that starts the Until-timer dialog.
static javax.swing.ImageIcon untilIcon
          Re-used Icon.
static javax.swing.ImageIcon upIcon
          Re-used Icon.
 
Constructor Summary
GuiLog(int maxNumEvents)
          GuiLog creates and shows the GUI when an outside synchronized thread instantiates an instance of GuiLog.
 
Method Summary
 void add(Event id, Event parent)
          Adds an Event to the GUI.
private  void addComponent(java.awt.Component c, java.awt.GridBagConstraints constraints, int x, int y, int w, int h)
          helper method.
 void checkListSize()
          Checks the number of Events in the list.
 void checkLock()
          If not stepping through one Event, checkLock attempts to acquire a lock on pauseLock.
private  void createAndShowGUI()
          Creates the JTable and shows it.
static javax.swing.ImageIcon createImageIcon(java.lang.String path)
          Creates an ImageIcon.
private  javax.swing.table.TableColumn createTableColumn(java.lang.String name, int width, int colIndex, boolean resize)
          helper method.
 void del(Event id)
          Deletes an Event from the GUI.
static javax.swing.JButton getPauseButton()
          Getter method.
static javax.swing.JButton getStepButton()
          Getter method.
static javax.swing.JButton getUntilButton()
          Getter method.
static void main(java.lang.String[] args)
          Test program.
static void pause()
          Sets paused to true.
static void resume()
          Sets paused to false and notifies all methods that are synchronized on pauseLock.
static void stepEvent()
          Step through one Event.
static void untilTimer()
          Prompts the user for the number of seconds to unpause the GuiLog, then unpauses it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tableFont

public static java.awt.Font tableFont
The font used for most of the table.


pauselock

private static java.lang.Object pauselock
Object that acquires the lock for pausing the Controller.


paused

private static boolean paused
Pause-status of the Controller.


isStep

private static boolean isStep
Whether to Step through one event or not.


pauseIcon

public static javax.swing.ImageIcon pauseIcon
Re-used Icon. Displayed on pauseButton.


resumeIcon

public static javax.swing.ImageIcon resumeIcon
Re-used Icon. Displayed on pauseButton.


stepIcon

public static javax.swing.ImageIcon stepIcon
Re-used Icon. Displayed on stepButton.


untilIcon

public static javax.swing.ImageIcon untilIcon
Re-used Icon. Displayed on untilButton.


upIcon

public static javax.swing.ImageIcon upIcon
Re-used Icon. Displayed on upButton.


downIcon

public static javax.swing.ImageIcon downIcon
Re-used Icon. Displayed on downButton.


cellUpButton

public static javax.swing.JButton cellUpButton
Re-used JButton. Points upwards to indicate position of event-relative.


cellDownButton

public static javax.swing.JButton cellDownButton
Re-used JButton. Points downwards to indicate position of event-relative.


frame

public static javax.swing.JFrame frame
The JFrame for displaying the GUI.


panel

private javax.swing.JPanel panel
The JPanel for displaying the GUI.


table

private javax.swing.JTable table
The JTable for displaying the Event information.


pauseButton

private static javax.swing.JButton pauseButton
The JButton that pauses and resumes the GuiLog.


stepButton

private static javax.swing.JButton stepButton
The JButton that allows one event to be added, and then pauses.


untilButton

private static javax.swing.JButton untilButton
The JButton that starts the Until-timer dialog.


list

private java.util.LinkedList list
A list used to track the events as they are generated so that they can easily be deleted first-in, first-out.


numEventsThreshHold

private int numEventsThreshHold
Maximum number of Events allowed to be displayed in table.


model

private GuiLog.EventTableModel model
The data model for the table.


EVENT_COMPARE

public static final GuiLog.EventNodeComparator EVENT_COMPARE
Used for sorting Events.


m

private static final java.lang.reflect.Method m
Dummy method for testing. Used in GuiLog's main method.

Constructor Detail

GuiLog

public GuiLog(int maxNumEvents)
GuiLog creates and shows the GUI when an outside synchronized thread instantiates an instance of GuiLog.

Parameters:
maxNumEvents - int Maximum number of Events allowed to be displayed in table.
Method Detail

createImageIcon

public static javax.swing.ImageIcon createImageIcon(java.lang.String path)
Creates an ImageIcon.

Parameters:
path - String The path where the image is located.
Returns:
ImageIcon with the specified image.

createAndShowGUI

private void createAndShowGUI()
Creates the JTable and shows it.


createTableColumn

private javax.swing.table.TableColumn createTableColumn(java.lang.String name,
                                                        int width,
                                                        int colIndex,
                                                        boolean resize)
helper method. Creates a TableColumn.

Parameters:
name - String TableColumn's HeaderValue.
width - int TableColumn's width.
colIndex - int TableColumn's model index.
resize - boolean If the TableColumn can be resized.
Returns:
TableColumn

addComponent

private void addComponent(java.awt.Component c,
                          java.awt.GridBagConstraints constraints,
                          int x,
                          int y,
                          int w,
                          int h)
helper method. Adds a component with layout constraints to the GuiLog's JPanel.

Parameters:
c - Component The component to be added.
constraints - GridBagConstraints The constraints for the GridBagLayout manager.
x - int The GridBagConstraints' gridx field.
y - int The GridBagConstraints' gridy field.
w - int The GridBagConstraints' gridwidth field.
h - int The GridBagConstraints' gridheight field.

getPauseButton

public static javax.swing.JButton getPauseButton()
Getter method.

Returns:
JButton

getStepButton

public static javax.swing.JButton getStepButton()
Getter method.

Returns:
JButton

getUntilButton

public static javax.swing.JButton getUntilButton()
Getter method.

Returns:
JButton

add

public void add(Event id,
                Event parent)
Adds an Event to the GUI.

Parameters:
id - Event
parent - Event

del

public void del(Event id)
Deletes an Event from the GUI.

Parameters:
id - Event

checkLock

public void checkLock()
If not stepping through one Event, checkLock attempts to acquire a lock on pauseLock. If it is successful, the method returns; otherwise, it waits. If stepping through one Event, then checkLock returns once so that one Event can be added.


stepEvent

public static void stepEvent()
Step through one Event.


untilTimer

public static void untilTimer()
Prompts the user for the number of seconds to unpause the GuiLog, then unpauses it. After the user-entered time, pauses the GuiLog.


checkListSize

public void checkListSize()
Checks the number of Events in the list. If the thresh hold limit has been reached, one event is deleted.


pause

public static void pause()
Sets paused to true.


resume

public static void resume()
Sets paused to false and notifies all methods that are synchronized on pauseLock.


main

public static void main(java.lang.String[] args)
Test program. Creates a GUI with a JTable. Creates Events, then adds and deletes them from the GuiLog.

Parameters:
args - String[]