gate.gui
Class AnnotationEditor.DelayedListener

java.lang.Object
  |
  +--gate.gui.AnnotationEditor.DelayedListener
All Implemented Interfaces:
AnnotationSetListener, DocumentListener, EventListener, Runnable
Enclosing class:
AnnotationEditor

class AnnotationEditor.DelayedListener
extends Object
implements DocumentListener, AnnotationSetListener, Runnable

Used to process a bunch of events after they happened. E.g. when a processing resource runs over a document it is likely to generate a set of new annotations. We don't want the interface to be updated for each of them but rather to be updated from time to time with a bunch of annnotations at a time. This listener runs in its own thread that mostly sleeps and only wakes up when there are unprocessed events after a given time interval (sleepInterval) has passed from the last event occured. When the thread wakes it will process all the pending events and then will go back to sleep.


Field Summary
protected  List eventQueue
           
protected  long lastEvent
           
(package private)  int sleepInterval
           
(package private)  boolean stop
           
 
Constructor Summary
AnnotationEditor.DelayedListener()
           
 
Method Summary
 void annotationAdded(AnnotationSetEvent e)
          Called when a new Annotation has been added
 void annotationRemoved(AnnotationSetEvent e)
          Called when an Annotation has been removed
 void annotationSetAdded(DocumentEvent e)
          Called when a new AnnotationSet has been added
 void annotationSetRemoved(DocumentEvent e)
          Called when an AnnotationSet has been removed
protected  void processEventQueue()
           
 void run()
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

sleepInterval

int sleepInterval

stop

boolean stop

eventQueue

protected List eventQueue

lastEvent

protected long lastEvent
Constructor Detail

AnnotationEditor.DelayedListener

public AnnotationEditor.DelayedListener()
Method Detail

annotationSetAdded

public void annotationSetAdded(DocumentEvent e)
Description copied from interface: DocumentListener
Called when a new AnnotationSet has been added
Specified by:
annotationSetAdded in interface DocumentListener

annotationSetRemoved

public void annotationSetRemoved(DocumentEvent e)
Description copied from interface: DocumentListener
Called when an AnnotationSet has been removed
Specified by:
annotationSetRemoved in interface DocumentListener

annotationAdded

public void annotationAdded(AnnotationSetEvent e)
Description copied from interface: AnnotationSetListener
Called when a new Annotation has been added
Specified by:
annotationAdded in interface AnnotationSetListener

annotationRemoved

public void annotationRemoved(AnnotationSetEvent e)
Description copied from interface: AnnotationSetListener
Called when an Annotation has been removed
Specified by:
annotationRemoved in interface AnnotationSetListener

processEventQueue

protected void processEventQueue()

run

public void run()
Specified by:
run in interface Runnable