fi.helsinki.dacopan.animseq
Class AnimationSequence

java.lang.Object
  extended by fi.helsinki.dacopan.animseq.AnimationSequence
All Implemented Interfaces:
Saveable

public class AnimationSequence
extends java.lang.Object
implements Saveable

A class to handle the logic of the animation sequence (also called scenario play list). This class encapsulates the list itself and all direct references to list items. This class provides functionality for recording items, deleting items, playing the list in sequential order and for navigating the list by showing each individual item item upon request.

The play list consists of specific item. Each item is either showable or non-showable. Non-showable items are some kind of markers, and selecting them from the list causes no actions. The end marker at the end of the list is one such marker. All showable items, when selected, cause the UI of the application to present some type of visualisation.

Inserting or recording new items to the list is possible when the recording mode is on. In that case some user actions (such as pressing play, changing the layer, or showing the encapsulation for a unit) are automatically interpreted (by MainFrame) as recording actions. Other recording actions are manually initiated by selecting buttons in the ScenarioEditorPanel. New items are always inserted in the insertion positions (in the place of the current item) in the list. At any time, at most one 'unfinished' item may exist in the list. An unfinished item is an MSC item with the start time recorded but the end time missing. In cases of new recording actions while there still is an unfinished item, the AnimationSequence tries to finish the unfinished item by recording the 'now time' as the end time for the unfinished item.

The actions of scenario play list are closely related to the scenario ScenarioEditorDialog. Such a dialog should always be is existence. The dialog can be hidden, but never closed and disposed of.

Some methods in this class are purposefully package private, so that they can only be called by classes in the same package. This is done to enforce encapsulation of the logic inside this package.


Constructor Summary
AnimationSequence(MainFrame frame)
          Creates a new instance of AnimationSequence
 
Method Summary
 java.lang.Object getData()
          Returns the list data for saving in a scenario file.
 java.lang.String[] getPlaylist()
          Returns the visible data for the scenario play list.
 boolean hasShowables()
          Returns true if animation sequence contains showable items (items that will set MainFrame to some state) and false otherwise.
 boolean isActive()
          Returns true if the scenario dialog is visible, false otherwise.
 boolean isInRecordingMode()
          Returns true if AnimationSequence is in recording mode, false otherwise.
 boolean layerChanged()
          This method should be called from MainFrame whenever the user tries to change layer.
 void notifyExitFromEnc()
          The MainFrame should call this method when quitting the enc mode.
 void recordEnc(TransferUnit unit)
          Instructs the AnimationSequence to record a new ENC item in the current insertion position.
 void recordStartMSC(SettingsMSC settings, float startTime)
          Should be called when the start time for a new MSC item should be recorded.
 void refreshRecordingButtons()
           
 void refreshWindow()
          Completely re-creates the scenario window with all its contents.
 void setActive(boolean isScenarioModeActive)
          Either shows the scenario play list dialog or hides it.
 void setData(java.lang.Object o)
          Initialises the state of the AnimationTimeState and replaces the old play list with the new list given as parameter.
 boolean showFirstShowable()
          Shows the first showable item.
 void showNext()
          Moves to the next item in play list and executes the action associated with it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnimationSequence

public AnimationSequence(MainFrame frame)
Creates a new instance of AnimationSequence

Method Detail

showNext

public void showNext()
Moves to the next item in play list and executes the action associated with it. Does nothing when called in record mode, or when the list is already at the end.

Parameters:
playNext - If true, the AnimationTimeState is set to play mode after executing the action within the item.

setActive

public void setActive(boolean isScenarioModeActive)
Either shows the scenario play list dialog or hides it.

Parameters:
isScenarioModeActive - If true, the dialog is shown, if false, the dialog is hidden.

notifyExitFromEnc

public void notifyExitFromEnc()
The MainFrame should call this method when quitting the enc mode. That way the next item in the list can be properly displayed. This method can always be called when coming out of enc mode, the AnimationSequence is responsible for ignoring unnecessary calls.


getPlaylist

public java.lang.String[] getPlaylist()
Returns the visible data for the scenario play list.

Returns:
A String[] array with each element representing one line in the play list.

recordStartMSC

public void recordStartMSC(SettingsMSC settings,
                           float startTime)
Should be called when the start time for a new MSC item should be recorded. If the recording mode is not on, calling this does nothing.

Parameters:
settings - The settings for the new item.
startTime - The start time for the new item.

recordEnc

public void recordEnc(TransferUnit unit)
Instructs the AnimationSequence to record a new ENC item in the current insertion position. A new item will only be recorded if the recording mode is on.

Parameters:
unit - The selected unit in the enc diagram.

getData

public java.lang.Object getData()
Returns the list data for saving in a scenario file.

Specified by:
getData in interface Saveable
Returns:
The scenario play list.

setData

public void setData(java.lang.Object o)
Initialises the state of the AnimationTimeState and replaces the old play list with the new list given as parameter.

Specified by:
setData in interface Saveable
Parameters:
o - New scenario list, as loaded from a scenario file.

hasShowables

public boolean hasShowables()
Returns true if animation sequence contains showable items (items that will set MainFrame to some state) and false otherwise.

Returns:

showFirstShowable

public boolean showFirstShowable()
Shows the first showable item. If showable items are available, the first one is shown and true is recorded. If no showables are available, calling this method does nothing, and false is returned.

Returns:

refreshWindow

public void refreshWindow()
Completely re-creates the scenario window with all its contents. Should be used e.g. when the locale is changed, to refresh the window UI to match the new locale. Calling this method preserves the location, size and visibility status of the old window.


refreshRecordingButtons

public void refreshRecordingButtons()

isActive

public boolean isActive()
Returns true if the scenario dialog is visible, false otherwise.


isInRecordingMode

public boolean isInRecordingMode()
Returns true if AnimationSequence is in recording mode, false otherwise.


layerChanged

public boolean layerChanged()
This method should be called from MainFrame whenever the user tries to change layer. In the case that recording a scenario is in such a state that changing the layer would not be a valid action, false is returned. If false is returned, the layer MUST NOT be changed.

Returns:
True if layer can be changed, false otherwise.


© Dacopan2 team, 2005-