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_AnnotationQueuethe internal queueprotected AudioAnnotationsm_Annotationsthe annotations we add the steps toprotected booleanm_Playinga flag that says if we're paused or notprotected adams.flow.core.RunnableWithLoggingm_Runnablethe runable we use for the internal threadstatic longSLEEP_TIMEa 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 voidannotationOccurred(AnnotationEvent e)Receives an AnnotationEvent that contains a StepvoidcleanUp()Cleans up any loose endsprotected voidclearQueue()AudioAnnotationsgetAnnotations()A getter for the annotations EventQueue adds steps tovoidloadAnnotations(AudioAnnotations annotations)Loads a saved annotations EventQueue adds steps to.voidresetAnnotations()Resets the annotations to an empty one.protected voidstart()adams.data.spreadsheet.SpreadSheettoSpreadSheet()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:AnnotationListenerReceives an AnnotationEvent that contains a Step- Specified by:
annotationOccurredin interfaceAnnotationListener- Parameters:
e- the event containing the Step
-
cleanUp
public void cleanUp()
Cleans up any loose ends
-
-