fi.helsinki.dacopan.model
Class NoteManager

java.lang.Object
  extended by fi.helsinki.dacopan.model.NoteManager
All Implemented Interfaces:
Saveable

public class NoteManager
extends java.lang.Object
implements Saveable

This class acts as a container for all Notes. It takes care of providing an ecapsulated notes management strategy, so that each component that need notes data uses the services in this class. In the design this is sometimes referred to as the "notes interface".


Field Summary
protected  java.util.Map notesEnc
           
protected  java.util.Map notesMsc
          Notes attached to time and layer are stored in one map, with as many entries as there are layers.
protected  java.util.Map notesTsc
           
 
Constructor Summary
NoteManager()
          This constructor sets up the proper HashMaps needed for keeping track of the notes relevant to a particular set of protocol events.
 
Method Summary
 void addNoteEnc(Note note)
          Adds an encapsulation note that is attached to a specific TransferUnit.
 void addNoteTimeLayer(Note note)
          Adds a note to the requested layer by putting it in the corresponding linked list.
 void addNoteTsc(Note note)
           
 void deleteNote(Note note)
          Deletes the passed note from the NoteManager
 java.lang.Object getData()
          This method is used to save all notes to a scenario file.
 Note getNoteEnc(TransferUnit transferUnit)
          Returns the encapsulation note attached to the given TransferUnit.
 java.util.Map getNotesEnc()
          Returns the map where ENC notes are stored, in linked lists, one per layer.
 java.util.LinkedList getNotesForLayer(Layer layer)
          Returns a Linked list (Collection) of all the notes corresponding to the requested layer.
 java.util.Collection getNotesInTimeRange(Layer layer, float startTime, float endTime)
          Returns the notes corresponding to the requested layer where the times are between startTime and endTime.
 java.util.Map getNotesMsc()
          Returns the map where MSC notes are stored, in linked lists, one per layer.
 java.util.Map getNotesTsc()
           
 Note getNoteTimeLayerNext(Layer layer, float time, boolean inclusive)
          Returns the first note coming AFTER the given time on the given layer.
 Note getNoteTimeLayerPrev(Layer layer, float time, boolean inclusive)
          Returns the first note coming BEFORE the given time on the given layer.
 Note getNoteTsc(TransferUnit transferUnit)
           
 void setData(java.lang.Object o)
          Used to load notes from a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

notesMsc

protected java.util.Map notesMsc
Notes attached to time and layer are stored in one map, with as many entries as there are layers. The layer acts as the key, and the value is a LinkedList of all the Notes on that layer, in time order. Encapsulation notes that are attached to transfer units are stored in a hash map with the TransferUnit as the key.


notesEnc

protected java.util.Map notesEnc

notesTsc

protected java.util.Map notesTsc
Constructor Detail

NoteManager

public NoteManager()
This constructor sets up the proper HashMaps needed for keeping track of the notes relevant to a particular set of protocol events. (a scenario)

Parameters:
dataView -
Method Detail

addNoteTimeLayer

public void addNoteTimeLayer(Note note)
Adds a note to the requested layer by putting it in the corresponding linked list.

Parameters:
note -

deleteNote

public void deleteNote(Note note)
                throws java.lang.IllegalArgumentException
Deletes the passed note from the NoteManager

Parameters:
note -
Throws:
java.lang.IllegalArgumentException

getNoteTimeLayerPrev

public Note getNoteTimeLayerPrev(Layer layer,
                                 float time,
                                 boolean inclusive)
Returns the first note coming BEFORE the given time on the given layer. This method is used in the UI to find the note to be shown at a particular time.

Parameters:
layer -
time -
inclusive - whether the timestamp is inclusive or not
Returns:
note or null if there is no note before the specified time

getNoteTimeLayerNext

public Note getNoteTimeLayerNext(Layer layer,
                                 float time,
                                 boolean inclusive)
Returns the first note coming AFTER the given time on the given layer. This method is used to get the next "steppable" event for the global animation event stepping architecture. This is needed for instance to implement the note column, and stepping to notes.

Parameters:
layer -
time -
inclusive - whether the timestamp is inclusive or not
Returns:
note or null if there is no note after the specified time

getNotesForLayer

public java.util.LinkedList getNotesForLayer(Layer layer)
Returns a Linked list (Collection) of all the notes corresponding to the requested layer.

Parameters:
layer -

getNotesInTimeRange

public java.util.Collection getNotesInTimeRange(Layer layer,
                                                float startTime,
                                                float endTime)
Returns the notes corresponding to the requested layer where the times are between startTime and endTime.

Parameters:
layer -
startTime -
endTime -
Returns:
Collection A LinkedList of notes in the given time range.

addNoteEnc

public void addNoteEnc(Note note)
Adds an encapsulation note that is attached to a specific TransferUnit.

Parameters:
noteText -

getNoteEnc

public Note getNoteEnc(TransferUnit transferUnit)
Returns the encapsulation note attached to the given TransferUnit.

Parameters:
transferUnit -
Returns:
Note if exists, null otherwise

addNoteTsc

public void addNoteTsc(Note note)

getNoteTsc

public Note getNoteTsc(TransferUnit transferUnit)

getData

public java.lang.Object getData()
This method is used to save all notes to a scenario file.

Specified by:
getData in interface Saveable
Returns:
arbitrary data (might be null)

setData

public void setData(java.lang.Object o)
Used to load notes from a file. Assigns the 2 maps from the loaded object to this object.

Specified by:
setData in interface Saveable
Parameters:
o - loaded object

getNotesMsc

public java.util.Map getNotesMsc()
Returns the map where MSC notes are stored, in linked lists, one per layer. This method is basically used only for retrieving a NoteManager instance from a scenario file.

Returns:
Map of MSC notes, with one LinkedList per layer.

getNotesTsc

public java.util.Map getNotesTsc()

getNotesEnc

public java.util.Map getNotesEnc()
Returns the map where ENC notes are stored, in linked lists, one per layer. This method is basically used only for retrieving a NoteManager instance from a scenario file.

Returns:
Map of ENC notes, keys are units.


© Dacopan2 team, 2005-