gate.gui.docview
Class AnnotationEditor

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by gate.creole.AbstractVisualResource
                      extended by gate.gui.docview.AnnotationEditor
All Implemented Interfaces:
AnnotationVisualResource, OwnedAnnotationEditor, Resource, FeatureBearer, NameBearer, VisualResource, ImageObserver, MenuContainer, Serializable, Accessible

public class AnnotationEditor
extends AbstractVisualResource
implements OwnedAnnotationEditor

A generic annotation editor, which uses the known annotation schemas to help speed up the annotation process (e.g. by pre-populating sets of choices) but does not enforce the schemas, allowing the user full control.

See Also:
Serialized Form

Nested Class Summary
protected  class AnnotationEditor.AnnotationAction
          Base class for actions on annotations.
protected  class AnnotationEditor.ApplyAction
           
protected  class AnnotationEditor.DeleteAnnotationAction
           
protected  class AnnotationEditor.DismissAction
           
protected  class AnnotationEditor.EndOffsetLeftAction
           
protected  class AnnotationEditor.EndOffsetRightAction
           
protected  class AnnotationEditor.StartOffsetLeftAction
           
protected  class AnnotationEditor.StartOffsetRightAction
           
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  Annotation ann
          The annotation being edited.
protected  AnnotationEditor annotationEditorInstance
          Current instance of this class.
protected static int CTRL_SHIFT_INCREMENT
          Constant for the number of characters when changing annotation boundary with Ctrl+Shift keys pressed.
protected  JButton delButton
           
protected  JButton dismissButton
           
protected  JButton eolButton
           
protected  JButton eorButton
           
protected  FeaturesSchemaEditor featuresEditor
          Component for features editing.
protected  JScrollPane featuresScroller
           
protected static int HIDE_DELAY
          Constant for delay before hiding the popup window (in milliseconds).
protected  Timer hideTimer
           
protected  JToggleButton pinnedButton
          Toggle button used to pin down the dialog.
protected  JWindow popupWindow
          The popup window used by the editor.
protected  MouseEvent pressed
           
protected  Map<String,AnnotationSchema> schemasByType
          Stores the Annotation schema objects available in the system.
protected  AnnotationSet set
          The parent set of the current annotation.
protected static int SHIFT_INCREMENT
          Constant for the number of characters when changing annotation boundary with Shift key pressed.
protected  JButton solButton
           
protected  JButton sorButton
           
protected  JComboBox typeCombo
          Combobox for annotation type.
 
Fields inherited from class gate.creole.AbstractVisualResource
features, handle
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AnnotationEditor()
           
 
Method Summary
 void cancelAction()
          Does nothing, as this editor does not support cancelling and rollbacks.
 boolean canDisplayAnnotationType(String annotationType)
          Returns true always as this editor is generic and can edit any annotation type.
 void changeOrientation(ComponentOrientation orientation)
          Changes the orientation of components
 void editAnnotation(Annotation ann, AnnotationSet set)
          Changes the annotation currently being edited.
 boolean editingFinished()
          Checks whether the annotation currently being edited can be considered complete.
 Annotation getAnnotationCurrentlyEdited()
           
 AnnotationSet getAnnotationSetCurrentlyEdited()
           
 AnnotationEditorOwner getOwner()
           
 Resource init()
          Initialise this resource, and return it.
protected  void initData()
           
protected  void initGUI()
           
protected  void initListeners()
           
 boolean isActive()
          Checks whether the annotation editor is active (shown on screen and ready to edit annotations.
 boolean isShowing()
           
protected  void moveAnnotation(AnnotationSet set, Annotation oldAnnotation, Long newStartOffset, Long newEndOffset)
          Changes the span of an existing annotation by creating a new annotation with the same ID, type and features but with the new start and end offsets.
 void okAction()
          Does nothing as this editor works in auto-commit mode (changes are implemented immediately).
 void placeDialog(int start, int end)
          Finds the best location for the editor dialog for a given span of text.
 void setEditingEnabled(boolean isEditingEnabled)
          Enable or disable the editing GUI components.
 void setOwner(AnnotationEditorOwner owner)
          Sets the owner (i.e. controller) for this editor.
 void setPinnedMode(boolean pinned)
           
 void setVisible(boolean setVisible)
          Shows/Hides the UI(s) involved in annotation editing.
 boolean supportsCancel()
          Returns false, as this editor does not support cancel operations.
 
Methods inherited from class gate.creole.AbstractVisualResource
cleanup, getFeatures, getInitParameterValues, getParameterValue, setFeatures, setHandle, setParameterValue, setParameterValues, setTarget
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gate.VisualResource
setHandle, setTarget
 
Methods inherited from interface gate.Resource
cleanup, getParameterValue, setParameterValue, setParameterValues
 
Methods inherited from interface gate.util.FeatureBearer
getFeatures, setFeatures
 
Methods inherited from interface gate.util.NameBearer
getName, setName
 

Field Detail

popupWindow

protected JWindow popupWindow
The popup window used by the editor.


pinnedButton

protected JToggleButton pinnedButton
Toggle button used to pin down the dialog.


typeCombo

protected JComboBox typeCombo
Combobox for annotation type.


featuresEditor

protected FeaturesSchemaEditor featuresEditor
Component for features editing.


featuresScroller

protected JScrollPane featuresScroller

solButton

protected JButton solButton

sorButton

protected JButton sorButton

delButton

protected JButton delButton

eolButton

protected JButton eolButton

eorButton

protected JButton eorButton

dismissButton

protected JButton dismissButton

hideTimer

protected Timer hideTimer

pressed

protected MouseEvent pressed

HIDE_DELAY

protected static final int HIDE_DELAY
Constant for delay before hiding the popup window (in milliseconds).

See Also:
Constant Field Values

SHIFT_INCREMENT

protected static final int SHIFT_INCREMENT
Constant for the number of characters when changing annotation boundary with Shift key pressed.

See Also:
Constant Field Values

CTRL_SHIFT_INCREMENT

protected static final int CTRL_SHIFT_INCREMENT
Constant for the number of characters when changing annotation boundary with Ctrl+Shift keys pressed.

See Also:
Constant Field Values

schemasByType

protected Map<String,AnnotationSchema> schemasByType
Stores the Annotation schema objects available in the system. The annotation types are used as keys for the map.


ann

protected Annotation ann
The annotation being edited.


set

protected AnnotationSet set
The parent set of the current annotation.


annotationEditorInstance

protected AnnotationEditor annotationEditorInstance
Current instance of this class.

Constructor Detail

AnnotationEditor

public AnnotationEditor()
Method Detail

init

public Resource init()
              throws ResourceInstantiationException
Description copied from class: AbstractVisualResource
Initialise this resource, and return it.

Specified by:
init in interface Resource
Overrides:
init in class AbstractVisualResource
Throws:
ResourceInstantiationException

initData

protected void initData()

initGUI

protected void initGUI()

initListeners

protected void initListeners()

isActive

public boolean isActive()
Description copied from interface: AnnotationVisualResource
Checks whether the annotation editor is active (shown on screen and ready to edit annotations.

Specified by:
isActive in interface AnnotationVisualResource
Returns:
true iff the editor is active.

editAnnotation

public void editAnnotation(Annotation ann,
                           AnnotationSet set)
Description copied from interface: AnnotationVisualResource
Changes the annotation currently being edited.

Specified by:
editAnnotation in interface AnnotationVisualResource
Parameters:
ann - the new annotation.
set - the set to which the new annotation belongs.

getAnnotationCurrentlyEdited

public Annotation getAnnotationCurrentlyEdited()
Specified by:
getAnnotationCurrentlyEdited in interface AnnotationVisualResource
Returns:
the annotation currently edited

editingFinished

public boolean editingFinished()
Description copied from interface: AnnotationVisualResource
Checks whether the annotation currently being edited can be considered complete.

Specified by:
editingFinished in interface AnnotationVisualResource
Returns:
true iff the editor has finished editing the current annotation. This might return false for instance when the current annotation does not yet comply with the schema and the editor implementation is designed to enforce schemas.

isShowing

public boolean isShowing()
Overrides:
isShowing in class Component

setVisible

public void setVisible(boolean setVisible)
Shows/Hides the UI(s) involved in annotation editing.

Overrides:
setVisible in class JComponent

placeDialog

public void placeDialog(int start,
                        int end)
Finds the best location for the editor dialog for a given span of text.

Specified by:
placeDialog in interface OwnedAnnotationEditor

moveAnnotation

protected void moveAnnotation(AnnotationSet set,
                              Annotation oldAnnotation,
                              Long newStartOffset,
                              Long newEndOffset)
                       throws InvalidOffsetException
Changes the span of an existing annotation by creating a new annotation with the same ID, type and features but with the new start and end offsets.

Parameters:
set - the annotation set
oldAnnotation - the annotation to be moved
newStartOffset - the new start offset
newEndOffset - the new end offset
Throws:
InvalidOffsetException

getAnnotationSetCurrentlyEdited

public AnnotationSet getAnnotationSetCurrentlyEdited()
Specified by:
getAnnotationSetCurrentlyEdited in interface AnnotationVisualResource
Returns:
the annotation set currently edited

getOwner

public AnnotationEditorOwner getOwner()
Specified by:
getOwner in interface OwnedAnnotationEditor
Returns:
the owner

setOwner

public void setOwner(AnnotationEditorOwner owner)
Description copied from interface: OwnedAnnotationEditor
Sets the owner (i.e. controller) for this editor.

Specified by:
setOwner in interface OwnedAnnotationEditor
Parameters:
owner - the owner to set

setPinnedMode

public void setPinnedMode(boolean pinned)
Specified by:
setPinnedMode in interface OwnedAnnotationEditor
Parameters:
pinned - true if the window should not move when an annotation is selected.

setEditingEnabled

public void setEditingEnabled(boolean isEditingEnabled)
Description copied from interface: OwnedAnnotationEditor
Enable or disable the editing GUI components.

Specified by:
setEditingEnabled in interface OwnedAnnotationEditor
Parameters:
isEditingEnabled - true to enable the editing, false to disable it

cancelAction

public void cancelAction()
                  throws GateException
Does nothing, as this editor does not support cancelling and rollbacks.

Specified by:
cancelAction in interface AnnotationVisualResource
Throws:
GateException

canDisplayAnnotationType

public boolean canDisplayAnnotationType(String annotationType)
Returns true always as this editor is generic and can edit any annotation type.

Specified by:
canDisplayAnnotationType in interface AnnotationVisualResource

okAction

public void okAction()
              throws GateException
Does nothing as this editor works in auto-commit mode (changes are implemented immediately).

Specified by:
okAction in interface AnnotationVisualResource
Throws:
GateException

supportsCancel

public boolean supportsCancel()
Returns false, as this editor does not support cancel operations.

Specified by:
supportsCancel in interface AnnotationVisualResource
Returns:
true iff this editor can rollback changes.

changeOrientation

public void changeOrientation(ComponentOrientation orientation)
Description copied from interface: OwnedAnnotationEditor
Changes the orientation of components

Specified by:
changeOrientation in interface OwnedAnnotationEditor