gate.gui.docview
Class AnnotationSetsView

java.lang.Object
  extended by gate.util.AbstractFeatureBearer
      extended by gate.creole.AbstractResource
          extended by gate.gui.docview.AbstractDocumentView
              extended by gate.gui.docview.AnnotationSetsView
All Implemented Interfaces:
AnnotationSetListener, DocumentListener, ActionsPublisher, AnnotationEditorOwner, DocumentView, Resource, FeatureBearer, NameBearer, VisualResource, Serializable, EventListener

public class AnnotationSetsView
extends AbstractDocumentView
implements DocumentListener, AnnotationSetListener, AnnotationEditorOwner

Display document annotation sets and types in a tree view like with a table. Allow the selection of annotation type and modification of their color.

See Also:
Serialized Form

Nested Class Summary
protected  class AnnotationSetsView.DeleteSelectedAnnotationsAction
           
protected  class AnnotationSetsView.EditAnnotationAction
           
protected  class AnnotationSetsView.HandleDocumentEventsAction
           
protected  class AnnotationSetsView.HighlightMenuItem
          The popup menu items used to select annotations Apart from the normal JMenuItem behaviour, this menu item also highlights the annotation which it would select if pressed.
protected  class AnnotationSetsView.MouseStoppedMovingAction
          Used to select an annotation for editing.
protected  class AnnotationSetsView.NewAnnotationAction
           
protected  class AnnotationSetsView.NewAnnotationSetAction
           
protected  class AnnotationSetsView.SavePreserveFormatAction
           
 class AnnotationSetsView.SetHandler
          Stores the data related to an annotation set
protected  class AnnotationSetsView.SetSelectedAnnotationsAction
           
protected  class AnnotationSetsView.SetsTableCellEditor
           
protected  class AnnotationSetsView.SetsTableCellRenderer
           
protected  class AnnotationSetsView.SetsTableModel
           
protected  class AnnotationSetsView.TextMouseListener
          A mouse listener used for events in the text view.
 class AnnotationSetsView.TypeHandler
           
 
Field Summary
protected  List actions
           
protected static ColorGenerator colourGenerator
           
protected  Timer eventMinder
          Timer used to handle events coming from the document
protected  String lastAnnotationType
           
protected  Timer mouseMovementTimer
           
protected  AnnotationSetsView.MouseStoppedMovingAction mouseStoppedMovingAction
           
protected  BlockingQueue<GateEvent> pendingEvents
           
protected  PropertyChangeListener textChangeListener
          Listener for property changes on the text pane.
protected  AnnotationSetsView.TextMouseListener textMouseListener
          The listener for mouse and mouse motion events in the text view.
protected  BlockingQueue<gate.gui.docview.AnnotationSetsView.TypeSpec> visibleAnnotationTypes
          Stores the list of visible annotation types when the view is inactivated so that the selection can be restored when the view is made active again.
 
Fields inherited from class gate.gui.docview.AbstractDocumentView
active, document, guiInitialised, handle, owner
 
Fields inherited from class gate.creole.AbstractResource
name
 
Fields inherited from class gate.util.AbstractFeatureBearer
features
 
Fields inherited from interface gate.gui.docview.DocumentView
CENTRAL, HORIZONTAL, VERTICAL
 
Constructor Summary
AnnotationSetsView()
           
 
Method Summary
 void annotationAdded(AnnotationSetEvent e)
          Called when a new Annotation has been added
 void annotationChanged(Annotation ann, AnnotationSet set, String oldType)
          Called by the annotation editor when an annotation has been changed.
 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
 void changeOrientation(ComponentOrientation orientation)
          changes the orientation of the annotation editor component only
 void cleanup()
          releases the memory allocated to this resource
 void contentEdited(DocumentEvent e)
          Called when the content of the document has changed through an edit operation.
protected  OwnedAnnotationEditor createAnnotationEditor(TextualDocumentView textView, AnnotationSetsView asView)
          Create the annotation editor (responsible for creating the window used to edit individual annotations).
 List getActions()
          Returns a list of Action objects.
static Color getColor(String annotationSet, String annotationType)
          Get the saved colour for this annotation type or create a new one and save it.
 Component getGUI()
          Returns the actual UI component this view represents.
 AnnotationList getListComponent()
           
 Annotation getNextAnnotation()
          Called by the editor for obtaining the next annotation to be edited.
 Annotation getPreviousAnnotation()
          Called by the editor for obtaining the previous annotation to be edited.
protected  AnnotationSetsView.SetHandler getSetHandler(String name)
          Get an annotation set handler in this annotation set view.
 JTextComponent getTextComponent()
          Gets the UI component used to display the document text.
 int getType()
          Returns the type of this view.
 AnnotationSetsView.TypeHandler getTypeHandler(String set, String type)
          Get an annotation type handler in this annotation set view.
protected  void initGUI()
          Implementers should override this method and use it for populating the GUI.
protected  void initListeners()
           
protected  void populateUI()
           
protected  void registerHooks()
          This method will be called whenever the view becomes active.
 void restoreSavedSelectedTypes()
          Restore previously selected types from the preferences.
protected  void restoreSelectedTypes()
          Restores the selected types based on the state saved in the visibleAnnotationTypes data structure.
protected  void saveColor(String annotationSet, String annotationType, Color colour)
           
 void saveType(String setName, String typeName, boolean selected)
          Save type or remove unselected type in the preferences.
 void selectAnnotation(Annotation ann, AnnotationSet annSet)
          Sets a particular annotation as selected.
 void selectAnnotation(AnnotationData aData)
          Queues an an action for selecting the provided annotation
 void setNewAnnSetCreationEnabled(boolean b)
          Enables or disables creation of the new annotation set.
 void setSelectedAnnotations(List<AnnotationData> selectedAnnots)
          Some document views can use the concept of selected annotations.
 void setTypeSelected(String setName, String typeName, boolean selected)
          Un/select an annotation type in this annotation set view and indirectly highlight it in the document view.
protected  void storeSelectedTypes()
          Populates the visibleAnnotationTypes structure based on the current selection
protected  void unregisterHooks()
          This method will be called whenever this view becomes inactive.
 
Methods inherited from class gate.gui.docview.AbstractDocumentView
getDocument, getHandle, getOwner, isActive, setActive, setHandle, setOwner, setTarget
 
Methods inherited from class gate.creole.AbstractResource
checkParameterValues, getBeanInfo, getInitParameterValues, getInitParameterValues, getName, getParameterValue, getParameterValue, getParameterValues, init, removeResourceListeners, setName, setParameterValue, setParameterValue, setParameterValues, setParameterValues, setResourceListeners
 
Methods inherited from class gate.util.AbstractFeatureBearer
getFeatures, setFeatures
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gate.gui.annedit.AnnotationEditorOwner
getDocument
 
Methods inherited from interface gate.Resource
getParameterValue, init, setParameterValue, setParameterValues
 
Methods inherited from interface gate.util.FeatureBearer
getFeatures, setFeatures
 
Methods inherited from interface gate.util.NameBearer
getName, setName
 

Field Detail

textMouseListener

protected AnnotationSetsView.TextMouseListener textMouseListener
The listener for mouse and mouse motion events in the text view.


textChangeListener

protected PropertyChangeListener textChangeListener
Listener for property changes on the text pane.


visibleAnnotationTypes

protected BlockingQueue<gate.gui.docview.AnnotationSetsView.TypeSpec> visibleAnnotationTypes
Stores the list of visible annotation types when the view is inactivated so that the selection can be restored when the view is made active again. The values are String[2] pairs of form .


mouseMovementTimer

protected Timer mouseMovementTimer

eventMinder

protected Timer eventMinder
Timer used to handle events coming from the document


pendingEvents

protected BlockingQueue<GateEvent> pendingEvents

mouseStoppedMovingAction

protected AnnotationSetsView.MouseStoppedMovingAction mouseStoppedMovingAction

lastAnnotationType

protected String lastAnnotationType

actions

protected List actions

colourGenerator

protected static final ColorGenerator colourGenerator
Constructor Detail

AnnotationSetsView

public AnnotationSetsView()
Method Detail

annotationChanged

public void annotationChanged(Annotation ann,
                              AnnotationSet set,
                              String oldType)
Description copied from interface: AnnotationEditorOwner
Called by the annotation editor when an annotation has been changed.

Specified by:
annotationChanged in interface AnnotationEditorOwner
Parameters:
ann - the annotation modified (after the modification occurred).
set - the parent annotation set for the annotation
oldType - the old type of the annotation. This value is only set if the annotation modification included a change of type.

changeOrientation

public void changeOrientation(ComponentOrientation orientation)
changes the orientation of the annotation editor component only

Parameters:
orientation -

selectAnnotation

public void selectAnnotation(AnnotationData aData)
Queues an an action for selecting the provided annotation

Specified by:
selectAnnotation in interface AnnotationEditorOwner

getNextAnnotation

public Annotation getNextAnnotation()
Description copied from interface: AnnotationEditorOwner
Called by the editor for obtaining the next annotation to be edited.

Specified by:
getNextAnnotation in interface AnnotationEditorOwner
Returns:
an Annotation value.

getPreviousAnnotation

public Annotation getPreviousAnnotation()
Description copied from interface: AnnotationEditorOwner
Called by the editor for obtaining the previous annotation to be edited.

Specified by:
getPreviousAnnotation in interface AnnotationEditorOwner
Returns:
an Annotation value.

getTextComponent

public JTextComponent getTextComponent()
Description copied from interface: AnnotationEditorOwner
Gets the UI component used to display the document text. This is used by the annotation editor for obtaining positioning information.

Specified by:
getTextComponent in interface AnnotationEditorOwner
Returns:
a JTextComponent object.

getListComponent

public AnnotationList getListComponent()

getActions

public List getActions()
Description copied from interface: ActionsPublisher
Returns a list of Action objects. This method will be called everytime a menu for this resource needs to be built, thus allowing for dynamic updates to the list of actions. A null value in this list will cause a separator to be created.

Specified by:
getActions in interface ActionsPublisher
Overrides:
getActions in class AbstractDocumentView
Returns:
a List of Actions.

getType

public int getType()
Description copied from interface: DocumentView
Returns the type of this view.

Specified by:
getType in interface DocumentView
Returns:
an int value
See Also:
DocumentView.CENTRAL, DocumentView.HORIZONTAL, DocumentView.VERTICAL

initGUI

protected void initGUI()
Description copied from class: AbstractDocumentView
Implementers should override this method and use it for populating the GUI.

Specified by:
initGUI in class AbstractDocumentView

createAnnotationEditor

protected OwnedAnnotationEditor createAnnotationEditor(TextualDocumentView textView,
                                                       AnnotationSetsView asView)
                                                throws ResourceInstantiationException
Create the annotation editor (responsible for creating the window used to edit individual annotations).

Throws:
ResourceInstantiationException - if an error occurs

populateUI

protected void populateUI()

getGUI

public Component getGUI()
Description copied from interface: DocumentView
Returns the actual UI component this view represents.

Specified by:
getGUI in interface DocumentView
Returns:
a Component value.

getColor

public static Color getColor(String annotationSet,
                             String annotationType)
Get the saved colour for this annotation type or create a new one and save it. The colours are saved in the user configuration file.

Parameters:
annotationType - type to get a colour for
Returns:
a colour

saveColor

protected void saveColor(String annotationSet,
                         String annotationType,
                         Color colour)

saveType

public void saveType(String setName,
                     String typeName,
                     boolean selected)
Save type or remove unselected type in the preferences.

Parameters:
setName - set name to save/remove or null for the default set
typeName - type name to save/remove
selected - state of the selection

restoreSavedSelectedTypes

public void restoreSavedSelectedTypes()
Restore previously selected types from the preferences.


setNewAnnSetCreationEnabled

public void setNewAnnSetCreationEnabled(boolean b)
Enables or disables creation of the new annotation set.


registerHooks

protected void registerHooks()
This method will be called whenever the view becomes active. Implementers should use this to add hooks (such as mouse listeners) to the other views as required by their functionality.

Specified by:
registerHooks in class AbstractDocumentView

unregisterHooks

protected void unregisterHooks()
This method will be called whenever this view becomes inactive. Implementers should use it to unregister whatever hooks they registered in registerHooks().

Specified by:
unregisterHooks in class AbstractDocumentView

storeSelectedTypes

protected void storeSelectedTypes()
Populates the visibleAnnotationTypes structure based on the current selection


restoreSelectedTypes

protected void restoreSelectedTypes()
Restores the selected types based on the state saved in the visibleAnnotationTypes data structure.


initListeners

protected void initListeners()

cleanup

public void cleanup()
Description copied from class: AbstractResource
releases the memory allocated to this resource

Specified by:
cleanup in interface Resource
Overrides:
cleanup in class AbstractResource

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

contentEdited

public void contentEdited(DocumentEvent e)
Called when the content of the document has changed through an edit operation.

Specified by:
contentEdited 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

getSetHandler

protected AnnotationSetsView.SetHandler getSetHandler(String name)
Get an annotation set handler in this annotation set view.

Parameters:
name - name of the annotation set or null for the default set
Returns:
the annotation set handler

getTypeHandler

public AnnotationSetsView.TypeHandler getTypeHandler(String set,
                                                     String type)
Get an annotation type handler in this annotation set view.

Parameters:
set - name of the annotation set or null for the default set
type - type of the annotation
Returns:
the type handler

setTypeSelected

public void setTypeSelected(String setName,
                            String typeName,
                            boolean selected)
Un/select an annotation type in this annotation set view and indirectly highlight it in the document view.

Parameters:
setName - name of the annotation set or null for the default set
typeName - type of the annotation
selected - state of the selection

setSelectedAnnotations

public void setSelectedAnnotations(List<AnnotationData> selectedAnnots)
Description copied from interface: DocumentView
Some document views can use the concept of selected annotations. This method is called to change the set of selected annotations. The recommended way to change the selected annotations set is by calling the DocumentEditor.setSelectedAnnotations(List) method.

Specified by:
setSelectedAnnotations in interface DocumentView
Overrides:
setSelectedAnnotations in class AbstractDocumentView

selectAnnotation

public void selectAnnotation(Annotation ann,
                             AnnotationSet annSet)
Sets a particular annotation as selected. If the list view is visible and active, it makes sure that the same annotation is selected there. If the annotation editor exists and is active, it switches it to this current annotation.

Parameters:
ann - the annotation
annSet - the parent set