tenua.gui
Class Tenua

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTabbedPane
                  extended by tenua.gui.Tenua
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener, javax.swing.event.DocumentListener, javax.swing.SwingConstants, DataGenerator.Listener

public class Tenua
extends javax.swing.JTabbedPane
implements javax.swing.event.DocumentListener, DataGenerator.Listener, javax.swing.event.ChangeListener

A chemical kinetics simulator written in Java. Based on Barshop & Frieden's KINSIM. Each Tenua is a tabbed pane with:

  1. a simple text editor that is compiled into a Mechanism that can be run
  2. a list of the initial values of the variables in that mechanism
  3. a graph of plotted data
  4. a table of that same data,
  5. a list of the last calculated values of the variables
  6. a text editor for recording notes about the simulation

The mechanism itself is stored as a bound property of the JFrame's content pane

Author:
Daniel Wachsstock
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 DataTableImpl data
          the data table for all the data
static java.lang.String MECHANISM
          the key to use to get the mechanism from this Tenua window
 javax.swing.text.Document mechanismCompilerErrors
          for displaying compiler errors
 javax.swing.text.Document mechanismText
          the text being edited to be compiled into a mechanism
 javax.swing.text.Document noteText
          the text of the notes panel
 
Fields inherited from class javax.swing.JTabbedPane
SCROLL_TAB_LAYOUT, WRAP_TAB_LAYOUT
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Tenua()
          Create a new Tenua window
 
Method Summary
 void addTab(java.lang.String name, java.lang.String tooltip, javax.swing.JPanel panel)
          Add a new tab panel to the Tenua window
 void changedUpdate(javax.swing.event.DocumentEvent e)
           
 void dispose()
          close the window
 void done(DataGenerator source)
          acknowleges the end of a simulation run by removing all empty rows
static void doNew()
           
 javax.swing.JPanel getActivePanel()
          returns the active panel of the tabbed pane
 Mechanism getMechanism()
          returns the compiled mechanism.
 int getNumWindows()
          returns the number of Tenua windows open
 boolean getShowHidden()
          Should hidden columns be displayed on the graph?
 void go()
          run the mechanism
 void insertUpdate(javax.swing.event.DocumentEvent e)
          if the mechanism text changes, invalidates the compiled mechanism
static void main(java.lang.String[] args)
          main entry point; creates one window
 void newData(DataGenerator source, Vec v)
          adds new data to the data table
 void removeUpdate(javax.swing.event.DocumentEvent e)
          if the mechanism text changes, invalidates the compiled mechanism
 void removeUserTabs()
          remove tabs added by the user
 void setMechanism(Mechanism mechanism)
          Sets the compiled mechanism.
 void setShowHidden(boolean flag)
          Set whether to display hidden columns on the graph
 void startingUp(DataGenerator source)
          starts a mechanism by adding the output columns to the data table.
 void stateChanged(javax.swing.event.ChangeEvent e)
          handle activation/deactivation
 void stop()
          stop the mechanism
 
Methods inherited from class javax.swing.JTabbedPane
add, add, add, add, add, addChangeListener, addTab, addTab, addTab, getAccessibleContext, getBackgroundAt, getBoundsAt, getChangeListeners, getComponentAt, getDisabledIconAt, getDisplayedMnemonicIndexAt, getForegroundAt, getIconAt, getMnemonicAt, getModel, getSelectedComponent, getSelectedIndex, getTabComponentAt, getTabCount, getTabLayoutPolicy, getTabPlacement, getTabRunCount, getTitleAt, getToolTipText, getToolTipTextAt, getUI, getUIClassID, indexAtLocation, indexOfComponent, indexOfTab, indexOfTab, indexOfTabComponent, insertTab, isEnabledAt, remove, remove, removeAll, removeChangeListener, removeTabAt, setBackgroundAt, setComponentAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setSelectedIndex, setTabComponentAt, setTabLayoutPolicy, setTabPlacement, setTitleAt, setToolTipTextAt, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

data

public final DataTableImpl data
the data table for all the data


mechanismCompilerErrors

public final javax.swing.text.Document mechanismCompilerErrors
for displaying compiler errors


mechanismText

public final javax.swing.text.Document mechanismText
the text being edited to be compiled into a mechanism


noteText

public final javax.swing.text.Document noteText
the text of the notes panel


MECHANISM

public static final java.lang.String MECHANISM
the key to use to get the mechanism from this Tenua window

See Also:
Constant Field Values
Constructor Detail

Tenua

public Tenua()
Create a new Tenua window

Method Detail

main

public static void main(java.lang.String[] args)
main entry point; creates one window


doNew

public static void doNew()

addTab

public void addTab(java.lang.String name,
                   java.lang.String tooltip,
                   javax.swing.JPanel panel)
Add a new tab panel to the Tenua window

Parameters:
name - the name of the new tab
tooltip - the tool tip to display when the mouse rests on the tab
panel - the JPanel to put on this tab

removeUserTabs

public void removeUserTabs()
remove tabs added by the user


go

public void go()
run the mechanism


stop

public void stop()
stop the mechanism


dispose

public void dispose()
close the window


startingUp

public void startingUp(DataGenerator source)
starts a mechanism by adding the output columns to the data table.

Specified by:
startingUp in interface DataGenerator.Listener

newData

public void newData(DataGenerator source,
                    Vec v)
adds new data to the data table

Specified by:
newData in interface DataGenerator.Listener
Parameters:
v - the data to add. v.get(0) should be the time and v.get(1..) should be the values

done

public void done(DataGenerator source)
acknowleges the end of a simulation run by removing all empty rows

Specified by:
done in interface DataGenerator.Listener

changedUpdate

public void changedUpdate(javax.swing.event.DocumentEvent e)
Specified by:
changedUpdate in interface javax.swing.event.DocumentListener

insertUpdate

public void insertUpdate(javax.swing.event.DocumentEvent e)
if the mechanism text changes, invalidates the compiled mechanism

Specified by:
insertUpdate in interface javax.swing.event.DocumentListener

removeUpdate

public void removeUpdate(javax.swing.event.DocumentEvent e)
if the mechanism text changes, invalidates the compiled mechanism

Specified by:
removeUpdate in interface javax.swing.event.DocumentListener

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
handle activation/deactivation

Specified by:
stateChanged in interface javax.swing.event.ChangeListener

getActivePanel

public javax.swing.JPanel getActivePanel()
returns the active panel of the tabbed pane


getMechanism

public Mechanism getMechanism()
returns the compiled mechanism. Is synchronized on this so the compiler thread and the Swing thread don't get out of sync.

Returns:
the current compiled mechanism

getNumWindows

public int getNumWindows()
returns the number of Tenua windows open


getShowHidden

public boolean getShowHidden()
Should hidden columns be displayed on the graph?


setShowHidden

public void setShowHidden(boolean flag)
Set whether to display hidden columns on the graph


setMechanism

public void setMechanism(Mechanism mechanism)
Sets the compiled mechanism. Is synchronized on this so the compiler thread and the Swing thread don't get out of sync.

Parameters:
mechanism - the new Mechanism.