Package adams.gui.tools.audioannotator
Class EventQueue
- java.lang.Object
-
- adams.gui.tools.audioannotator.EventQueue
-
- All Implemented Interfaces:
AnnotationListener
public class EventQueue extends Object implements AnnotationListener
A queue that ensures that events are added to the annotations one at a time. This is to prevent race conditions- Author:
- sjb90
-
-
Field Summary
Fields Modifier and Type Field Description protected ConcurrentLinkedQueue<AudioAnnotation>
m_AnnotationQueue
the internal queueprotected AudioAnnotations
m_Annotations
the annotations we add the steps toprotected boolean
m_Playing
a flag that says if we're paused or notprotected adams.flow.core.RunnableWithLogging
m_Runnable
the runable we use for the internal threadstatic long
SLEEP_TIME
a constant defining the amount of time to sleep for
-
Constructor Summary
Constructors Constructor Description EventQueue()
Constructs a queue that adds steps to a annotations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
annotationOccurred(AnnotationEvent e)
Receives an AnnotationEvent that contains a Stepvoid
cleanUp()
Cleans up any loose endsprotected void
clearQueue()
AudioAnnotations
getAnnotations()
A getter for the annotations EventQueue adds steps tovoid
loadAnnotations(AudioAnnotations annotations)
Loads a saved annotations EventQueue adds steps to.void
resetAnnotations()
Resets the annotations to an empty one.protected void
start()
adams.data.spreadsheet.SpreadSheet
toSpreadSheet()
Turns the inner annotations into a spreadsheet.
-
-
-
Field Detail
-
SLEEP_TIME
public static final long SLEEP_TIME
a constant defining the amount of time to sleep for- See Also:
- Constant Field Values
-
m_AnnotationQueue
protected ConcurrentLinkedQueue<AudioAnnotation> m_AnnotationQueue
the internal queue
-
m_Annotations
protected AudioAnnotations m_Annotations
the annotations we add the steps to
-
m_Runnable
protected adams.flow.core.RunnableWithLogging m_Runnable
the runable we use for the internal thread
-
m_Playing
protected boolean m_Playing
a flag that says if we're paused or not
-
-
Method Detail
-
resetAnnotations
public void resetAnnotations()
Resets the annotations to an empty one. Clears the queue so any left over steps are not added mistakenly to the new annotations.
-
getAnnotations
public AudioAnnotations getAnnotations()
A getter for the annotations EventQueue adds steps to- Returns:
- The annotations we've been adding steps to
-
loadAnnotations
public void loadAnnotations(AudioAnnotations annotations)
Loads a saved annotations EventQueue adds steps to. Clears the steps queue so any remaining steps are not mistakenly added to the newly loaded queue.- Parameters:
annotations
- The annotations we're loading in
-
clearQueue
protected void clearQueue()
-
start
protected void start()
-
toSpreadSheet
public adams.data.spreadsheet.SpreadSheet toSpreadSheet()
Turns the inner annotations into a spreadsheet.- Returns:
- the spread sheet object
-
annotationOccurred
public void annotationOccurred(AnnotationEvent e)
Description copied from interface:AnnotationListener
Receives an AnnotationEvent that contains a Step- Specified by:
annotationOccurred
in interfaceAnnotationListener
- Parameters:
e
- the event containing the Step
-
cleanUp
public void cleanUp()
Cleans up any loose ends
-
-