fi.helsinki.dacopan.ui
Class MainFrame

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by fi.helsinki.dacopan.ui.MainFrame
All Implemented Interfaces:
ControlSignalsListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class MainFrame
extends javax.swing.JFrame
implements ControlSignalsListener

MainFrame controls the program execution.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int DACOPAN_EXPLORE_MODE
           
static java.lang.String DACOPAN_EXTENSION_PEF
           
static java.lang.String DACOPAN_EXTENSION_SCENARIO
           
static int DACOPAN_NO_MODE
           
static int DACOPAN_SCENARIO_MODE
           
static int DACOPAN_STEP_BACKWARD
           
static int DACOPAN_STEP_FORWARD
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MainFrame()
          This is the normal constructor that just creates the MainFrame and sets up the animator, and then waits for the user to do something.
MainFrame(DataView data, NoteManager noteManager)
          This constructor can be used in testing the animator, as it works with a given dataview as if a PEF had already been loaded in the memory.
 
Method Summary
 void advance(float step, float nowTime)
          Signals the listener that it should visualise the network exchange data at the nowTime point in time, possibly as an incremental change to previous state.
protected  void applyDefaultSettings(GeneralSettings generalSettings)
          Creates default GeneralSettings and MSC settings for all layers based on the data that is currently in DataView.
 void changeLayer(Layer layer)
          Changes the layer to the one requested.
 void closeAnimation()
          Closes the animation and returns to the start state
 void continueAnimationModeMSC()
          When the animation comes back from the ENC mode we need to handle that event in different ways depending on the animator mode: in explore mode we just continue from where we paused the animation when going to ENC.
 void fastForwardAnimation()
          Fast forwards the animation to the end.
 AnimationTimeState getAnimationTimeState()
           
 TransferUnit getCurrentENCUnit()
          Returns the current enc unit if in ENC mode.
 Layer getCurrentLayer()
          Return a reference to the layer currently visible in MSC/UFO/ENC
 SettingsMSC getCurrentMSCSettings()
           
 DataView getDataView()
          Returns a reference to the data view so that for example the animation panels can use the data.
 FileInformation getFileInformation()
           
 int getMode()
           
 MSCPanel getMSCPanel()
           
 NoteManager getNoteManager()
          Returns the current instance of the NoteManager being used to store the notes of the currently loaded scenario
 GeneralSettings getSettings()
          Returns a reference to the general settings for the animator.
 void invokeChangeSettings()
           
 boolean isAnimationSequenceDialogActive()
           
 boolean isInENCMode()
           
 boolean isInExploreMode()
           
 boolean isInMSCMode()
           
 boolean isInPlayMode()
           
 boolean isInScenarioMode()
           
 boolean isInTSCMode()
           
 boolean isPaused()
           
 boolean isTSCEnabled()
           
 void loadAllSettings(GeneralSettings generalSettings)
          Loads and applies the global settings stored in a global settings file in the user's home directory.
 void loadAnimationFile(java.io.File file)
          Loads an animation file to the animator.
static void main(java.lang.String[] args)
          Creates the MainFrame object and shows it - and so it starts running :)
 void pauseAnimation()
          Pauses the animation
 void playAnimation()
          Starts or resumes the animation.
 void recreateUI()
           
 void refreshScenarioSettings()
           
 void refreshSettings()
          Refreshes the MSC mode with updated settings from animatorSettings.
 void refreshUI()
           
 void rewindAnimation()
          Rewinds the animation to the beginning
 void saveAllSettings()
          Saves the global settings in a global settings file in the user's home directory
 void saveAnimationFile(boolean forceFileChooser)
          Saves the scenario that is currently in memory.
 void setAnimatorMode(int mode)
          Sets the animation mode to the given mode: DACOPAN_SCENARIO_MODE: Scenario DACOPAN_EXPLORE_MODE: Explore mode
 void setFileModified(boolean value)
           
 void setSettings(GeneralSettings generalSettings)
           
 void setupAnimationModeENC(TransferUnit unit)
          Sets up the ENC animation mode.
 void setupAnimationModeMSC(SettingsMSC mscSettings, boolean resetNowTime)
          This method sets up the MSC animation mode by creating the needed animation panels and giving them correct settings.
 void setupAnimationModeTSC()
           
 void showScenarioDialog()
           
 void stepInAnimation(int stepDirection)
          Steps in the animation.
 void stepTo(float nowTime)
          Signals the listener that it should visualise the network exchange data at the nowTime point in time.
 void toPauseMode()
          Signals the listener that the animation has moved to PAUSE mode.
 void toPlayMode()
          Signals the listener that the animation has moved to PLAY mode.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

DACOPAN_EXTENSION_PEF

public static final java.lang.String DACOPAN_EXTENSION_PEF
See Also:
Constant Field Values

DACOPAN_EXTENSION_SCENARIO

public static final java.lang.String DACOPAN_EXTENSION_SCENARIO
See Also:
Constant Field Values

DACOPAN_STEP_BACKWARD

public static final int DACOPAN_STEP_BACKWARD
See Also:
Constant Field Values

DACOPAN_STEP_FORWARD

public static final int DACOPAN_STEP_FORWARD
See Also:
Constant Field Values

DACOPAN_NO_MODE

public static final int DACOPAN_NO_MODE
See Also:
Constant Field Values

DACOPAN_EXPLORE_MODE

public static final int DACOPAN_EXPLORE_MODE
See Also:
Constant Field Values

DACOPAN_SCENARIO_MODE

public static final int DACOPAN_SCENARIO_MODE
See Also:
Constant Field Values
Constructor Detail

MainFrame

public MainFrame(DataView data,
                 NoteManager noteManager)
This constructor can be used in testing the animator, as it works with a given dataview as if a PEF had already been loaded in the memory.


MainFrame

public MainFrame()
This is the normal constructor that just creates the MainFrame and sets up the animator, and then waits for the user to do something.

Method Detail

playAnimation

public void playAnimation()
Starts or resumes the animation.

We just call animationTimeState to continue playing the MSC settings it has been set up to show.


pauseAnimation

public void pauseAnimation()
Pauses the animation


rewindAnimation

public void rewindAnimation()
Rewinds the animation to the beginning


fastForwardAnimation

public void fastForwardAnimation()
Fast forwards the animation to the end.


stepInAnimation

public void stepInAnimation(int stepDirection)
Steps in the animation. Can step both backward and forward.

Parameters:
stepDirection - The direction for stepping

isInPlayMode

public boolean isInPlayMode()

setAnimatorMode

public void setAnimatorMode(int mode)
                     throws java.lang.IllegalArgumentException
Sets the animation mode to the given mode:

Parameters:
mode -
Throws:
java.lang.IllegalArgumentException

loadAnimationFile

public void loadAnimationFile(java.io.File file)
Loads an animation file to the animator. The file can be either a protocol events file or a scenario file.

Parameters:
file - The file to be loaded

saveAnimationFile

public void saveAnimationFile(boolean forceFileChooser)
Saves the scenario that is currently in memory. If the scenario is not saved already, a file chooser dialog is shown.


setFileModified

public void setFileModified(boolean value)

closeAnimation

public void closeAnimation()
Closes the animation and returns to the start state


changeLayer

public void changeLayer(Layer layer)
                 throws java.lang.IllegalStateException,
                        java.lang.IllegalArgumentException
Changes the layer to the one requested.

Parameters:
layer -
Throws:
java.lang.IllegalStateException
java.lang.IllegalArgumentException

refreshSettings

public void refreshSettings()
Refreshes the MSC mode with updated settings from animatorSettings. This method is called after the settings panel has been closed.


refreshScenarioSettings

public void refreshScenarioSettings()

getDataView

public DataView getDataView()
Returns a reference to the data view so that for example the animation panels can use the data.

Returns:
DataView

getCurrentLayer

public Layer getCurrentLayer()
Return a reference to the layer currently visible in MSC/UFO/ENC

Returns:
Current layer

getNoteManager

public NoteManager getNoteManager()
Returns the current instance of the NoteManager being used to store the notes of the currently loaded scenario

Returns:
NoteManager

getFileInformation

public FileInformation getFileInformation()

getSettings

public GeneralSettings getSettings()
Returns a reference to the general settings for the animator.

Returns:
DataView

setSettings

public void setSettings(GeneralSettings generalSettings)

getAnimationTimeState

public AnimationTimeState getAnimationTimeState()

getMSCPanel

public MSCPanel getMSCPanel()

isInExploreMode

public boolean isInExploreMode()
Returns:
true if in explore mode, otherwise false

isInScenarioMode

public boolean isInScenarioMode()
Returns:
true if in scenario mode, otherwise false

isInMSCMode

public boolean isInMSCMode()

isInENCMode

public boolean isInENCMode()

isInTSCMode

public boolean isInTSCMode()

getCurrentENCUnit

public TransferUnit getCurrentENCUnit()
                               throws java.lang.IllegalStateException
Returns the current enc unit if in ENC mode.

Throws:
java.lang.IllegalStateException

setupAnimationModeMSC

public void setupAnimationModeMSC(SettingsMSC mscSettings,
                                  boolean resetNowTime)
This method sets up the MSC animation mode by creating the needed animation panels and giving them correct settings. It can be called by the MainFrame itself (for example setting a default mode once loaded an animation file) or by the ControlSignals Framework.

Parameters:
mscSettings - Settings for the MSC animation

setupAnimationModeTSC

public void setupAnimationModeTSC()

continueAnimationModeMSC

public void continueAnimationModeMSC()
When the animation comes back from the ENC mode we need to handle that event in different ways depending on the animator mode:


setupAnimationModeENC

public void setupAnimationModeENC(TransferUnit unit)
Sets up the ENC animation mode. This can be called by the Animation sequence framework or some panel that has received information from the user asking to change to Encapsulation animation. Such panel can be either a UFO panel or an MSC panel.

Parameters:
unit -

saveAllSettings

public void saveAllSettings()
Saves the global settings in a global settings file in the user's home directory


loadAllSettings

public void loadAllSettings(GeneralSettings generalSettings)
Loads and applies the global settings stored in a global settings file in the user's home directory. The settings object has to be correctly initialized with default values before calling this method.

Parameters:
generalSettings - The settings object for which the settings are loaded (can be other than the settings currently in use).

applyDefaultSettings

protected void applyDefaultSettings(GeneralSettings generalSettings)
Creates default GeneralSettings and MSC settings for all layers based on the data that is currently in DataView.


main

public static void main(java.lang.String[] args)
Creates the MainFrame object and shows it - and so it starts running :)

Parameters:
args -

advance

public void advance(float step,
                    float nowTime)
Description copied from interface: ControlSignalsListener
Signals the listener that it should visualise the network exchange data at the nowTime point in time, possibly as an incremental change to previous state. The change is given as step parameter.

The listener is free to implement the advance signal as if it was the same thing as receiving a stepTo signal.

It is the responsibility of the listening object to call repaint() on itself as a result of receiving this signal.

Specified by:
advance in interface ControlSignalsListener
Parameters:
step - The incremental time step from the previous state.
nowTime - The point of time in network exchange data the listener should visualize.

stepTo

public void stepTo(float nowTime)
Description copied from interface: ControlSignalsListener
Signals the listener that it should visualise the network exchange data at the nowTime point in time.

It is the responsibility of the listening object to call repaint() on itself as a result of receiving this signal.

Specified by:
stepTo in interface ControlSignalsListener
Parameters:
nowTime - The point of time in network exchange data the listener should visualize.

toPauseMode

public void toPauseMode()
Description copied from interface: ControlSignalsListener
Signals the listener that the animation has moved to PAUSE mode. There are no strict responsibilities for the listener to react to this in any way.

Specified by:
toPauseMode in interface ControlSignalsListener

toPlayMode

public void toPlayMode()
Description copied from interface: ControlSignalsListener
Signals the listener that the animation has moved to PLAY mode. There are no strict responsibilities for the listener to react to this in any way.

Specified by:
toPlayMode in interface ControlSignalsListener

isPaused

public boolean isPaused()
Returns:

getCurrentMSCSettings

public SettingsMSC getCurrentMSCSettings()
Returns:

getMode

public int getMode()
Returns:

invokeChangeSettings

public void invokeChangeSettings()

isAnimationSequenceDialogActive

public boolean isAnimationSequenceDialogActive()
Returns:

showScenarioDialog

public void showScenarioDialog()

isTSCEnabled

public boolean isTSCEnabled()

refreshUI

public void refreshUI()

recreateUI

public void recreateUI()


© Dacopan2 team, 2005-