gate.gui.docview
Class TextualDocumentView

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

public class TextualDocumentView
extends AbstractDocumentView

This class provides a central view for a textual document.

See Also:
Serialized Form

Nested Class Summary
protected  class TextualDocumentView.GateDocumentListener
           
 class TextualDocumentView.PermanentSelectionCaret
           
protected  class TextualDocumentView.SwingDocumentListener
           
protected  class TextualDocumentView.UpdateHighlightsAction
          Blinks the blinking highlights if any.
 
Field Summary
protected static int BLINK_DELAY
          The delay used by the blinker.
protected  List<AnnotationData> blinkingHighlightsToAdd
          Used internally to store the annotations for which blinking highlights need to be added.
protected  Set<AnnotationData> blinkingHighlightsToRemove
          Used internally to store the annotations for which blinking highlights need to be removed.
protected  Map<AnnotationData,gate.gui.docview.TextualDocumentView.HighlightData> blinkingTagsForAnnotations
          The annotations used for blinking highlights and their tags.
protected  TextualDocumentView.GateDocumentListener gateDocListener
           
protected static int HIGHLIGHT_DELAY
          The delay used by the highlights minder.
protected  Timer highlightsMinder
           
protected  List<gate.gui.docview.TextualDocumentView.HighlightData> highlightsToAdd
          This list stores the TextualDocumentView.HighlightData values for annotations pending highlighting
protected  List<gate.gui.docview.TextualDocumentView.HighlightData> highlightsToRemove
          This list stores the TextualDocumentView.HighlightData values for highlights that need to be removed
protected  JScrollPane scroller
          The scroll pane holding the text
protected  JTextArea textView
           
 
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
TextualDocumentView()
           
 
Method Summary
 Object addHighlight(AnnotationData aData, Color colour)
           
 List addHighlights(Collection<AnnotationData> annotations, Color colour)
          Adds several highlights in one go.
 void addHighlights(List<gate.gui.docview.TextualDocumentView.HighlightData> list)
          Same as addHighlights(java.util.Collection, java.awt.Color) but without the intermediate creation of HighlightData objects.
 void changeOrientation(ComponentOrientation orientation)
          Set the text orientation in the document.
 void cleanup()
          releases the memory allocated to this resource
 Component getGUI()
          Returns the actual UI component this view represents.
 JTextArea getTextView()
           
 int getType()
          Returns the type of this view.
protected  void initGUI()
          Implementers should override this method and use it for populating the GUI.
protected  void initListeners()
           
 void moveHighlight(Object tag, int newStart, int newEnd)
          Gives access to the highliter's change highlight operation.
protected  void registerHooks()
          This method will be called whenever the view becomes active.
 void removeHighlight(Object tag)
           
 void removeHighlights(Collection tags)
          Removes several highlights in one go.
 void scrollAnnotationToVisible(Annotation ann)
           
 void setEditable(boolean editable)
           
 void setSelectedAnnotations(List<AnnotationData> selectedAnnots)
          Removes all blinking highlights and shows the new ones, corresponding to the new set of selected annotations
 void setTarget(Object target)
          Stores the target (which should always be a Document) into the AbstractDocumentView.document field.
protected  void unregisterHooks()
          This method will be called whenever this view becomes inactive.
 
Methods inherited from class gate.gui.docview.AbstractDocumentView
getActions, getDocument, getHandle, getOwner, isActive, setActive, setHandle, setOwner
 
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.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

scroller

protected JScrollPane scroller
The scroll pane holding the text


gateDocListener

protected TextualDocumentView.GateDocumentListener gateDocListener

blinkingTagsForAnnotations

protected Map<AnnotationData,gate.gui.docview.TextualDocumentView.HighlightData> blinkingTagsForAnnotations
The annotations used for blinking highlights and their tags. A map from AnnotationData to tag(i.e. Object).


highlightsToAdd

protected List<gate.gui.docview.TextualDocumentView.HighlightData> highlightsToAdd
This list stores the TextualDocumentView.HighlightData values for annotations pending highlighting


highlightsToRemove

protected List<gate.gui.docview.TextualDocumentView.HighlightData> highlightsToRemove
This list stores the TextualDocumentView.HighlightData values for highlights that need to be removed


blinkingHighlightsToRemove

protected Set<AnnotationData> blinkingHighlightsToRemove
Used internally to store the annotations for which blinking highlights need to be removed.


blinkingHighlightsToAdd

protected List<AnnotationData> blinkingHighlightsToAdd
Used internally to store the annotations for which blinking highlights need to be added.


highlightsMinder

protected Timer highlightsMinder

textView

protected JTextArea textView

BLINK_DELAY

protected static final int BLINK_DELAY
The delay used by the blinker.

See Also:
Constant Field Values

HIGHLIGHT_DELAY

protected static final int HIGHLIGHT_DELAY
The delay used by the highlights minder.

See Also:
Constant Field Values
Constructor Detail

TextualDocumentView

public TextualDocumentView()
Method Detail

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

addHighlight

public Object addHighlight(AnnotationData aData,
                           Color colour)

addHighlights

public List addHighlights(Collection<AnnotationData> annotations,
                          Color colour)
Adds several highlights in one go. This method should be called from within the UI thread.

Parameters:
annotations - the collection of annotations for which highlights are to be added.
colour - the colour for the highlights.
Returns:
the list of tags for the added highlights. The order of the elements corresponds to the order defined by the iterator of the collection of annotations provided.

removeHighlight

public void removeHighlight(Object tag)

addHighlights

public void addHighlights(List<gate.gui.docview.TextualDocumentView.HighlightData> list)
Same as addHighlights(java.util.Collection, java.awt.Color) but without the intermediate creation of HighlightData objects.

Parameters:
list - list of HighlightData

removeHighlights

public void removeHighlights(Collection tags)
Removes several highlights in one go.

Parameters:
tags - the tags for the highlights to be removed

changeOrientation

public void changeOrientation(ComponentOrientation orientation)
Set the text orientation in the document.

Parameters:
orientation - either left to right or right to left

scrollAnnotationToVisible

public void scrollAnnotationToVisible(Annotation ann)

moveHighlight

public void moveHighlight(Object tag,
                          int newStart,
                          int newEnd)
                   throws BadLocationException
Gives access to the highliter's change highlight operation. Can be used to change the offset of an existing highlight.

Parameters:
tag - the tag for the highlight
newStart - new start offset.
newEnd - new end offset.
Throws:
BadLocationException

setSelectedAnnotations

public void setSelectedAnnotations(List<AnnotationData> selectedAnnots)
Removes all blinking highlights and shows the new ones, corresponding to the new set of selected annotations

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

getType

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

Returns:
an int value
See Also:
DocumentView.CENTRAL, DocumentView.HORIZONTAL, DocumentView.VERTICAL

setTarget

public void setTarget(Object target)
Stores the target (which should always be a Document) into the AbstractDocumentView.document field.

Specified by:
setTarget in interface VisualResource
Overrides:
setTarget in class AbstractDocumentView
Parameters:
target - the object (be it a Resource, DataStore or whatever) this viewer has to display

setEditable

public void setEditable(boolean editable)

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

getGUI

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

Returns:
a Component value.

initListeners

protected void initListeners()

unregisterHooks

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

Specified by:
unregisterHooks in class AbstractDocumentView

registerHooks

protected void registerHooks()
Description copied from class: AbstractDocumentView
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

getTextView

public JTextArea getTextView()
Returns:
the textView