edu.uchsc.ccp.knowtator
Class KnowtatorManager

java.lang.Object
  extended by edu.uchsc.ccp.knowtator.KnowtatorManager
All Implemented Interfaces:
AnnotationCreatedListener, CurrentAnnotationsChangedListener, TextSourceChangeListener, EventListener

public class KnowtatorManager
extends Object
implements CurrentAnnotationsChangedListener, AnnotationCreatedListener, TextSourceChangeListener


Constructor Summary
KnowtatorManager(KnowtatorProjectUtil kpu)
           
 
Method Summary
 void addActiveFilter(SimpleInstance filter)
           
 void annotationCreated(AnnotationCreatedEvent event)
           
 void consolidateAnnotation(SimpleInstance deleteAnnotation, SimpleInstance consolidateAnnotation)
           
 SimpleInstance createAnnotation(Instance selectedClsOrInstance)
          calls createAnnotation(selectedClsOrInstance, true)
 SimpleInstance createAnnotation(Instance selectedClsOrInstance, boolean selectCreatedAnnotation)
           
 void currentAnnotationsChanged(CurrentAnnotationsChangeEvent cace)
           
 void deleteAnnotation(SimpleInstance annotation)
           
 void deleteSelectedAnnotation()
           
 void duplicateSelectedAnnotation()
           
 boolean fastAnnotateToolBarContains(Frame frame)
          Finds out if the given frame is being shown in the fast annotate tool bar.
 List<SimpleInstance> getActiveFilters()
           
 Comparator<SimpleInstance> getAnnotationComparator()
           
 AnnotationUtil getAnnotationUtil()
           
 BrowserTextUtil getBrowserTextUtil()
           
 List<SimpleInstance> getColorAssignments()
           
 int getConsensusModeProgress()
           
 int getConsolidatedAnnotationCountForFrame(Frame frame)
           
 int getCurrentAnnotationCountForFrame(Frame frame)
           
 List<SimpleInstance> getCurrentAnnotationsForFrame(Frame frame)
           
 List<SimpleInstance> getCurrentFilteredAnnotations()
          Returns the annotations for the current text source that satisfy the currently selected filter.
 List<SimpleInstance> getCurrentPartiallyFilteredAnnotations()
          returns the annotations for the current text source that satisfy the currently selected filter ignoring the type constraint.
 List<SimpleInstance> getCurrentSelectableFilteredAnnotations()
           
 DisplayColors getDisplayColors()
           
 boolean getFadeUnselectedAnnotations()
           
 Frame getFastAnnotateFrame()
           
 FilterUtil getFilterUtil()
           
 KnowledgeBase getKnowledgeBase()
           
 KnowtatorProjectUtil getKnowtatorProjectUtil()
           
 SimpleInstance getLastSelectedAnnotation()
           
 MentionUtil getMentionUtil()
           
 SimpleInstance getNextAnnotation()
           
 Comparator<SimpleInstance> getPositionComparator(SimpleInstance annotation)
           
 SimpleInstance getPreviousAnnotation()
           
 ColorFrameRenderer getRenderer()
           
 List<Cls> getRootClses()
           
 SimpleInstance getSelectedAnnotation()
          This is the preferred way to obtain the currently selected annotation
 SimpleInstance getSelectedAnnotationSet()
           
 SimpleInstance getSelectedAnnotator()
           
 Cls getSelectedCls()
          This is the preferred way to obtain the currently selected cls (i.e.
 SimpleInstance getSelectedFilter()
           
 List<Span> getSelectedSpans()
          This is the preferred way to obtain the currently selected spans (i.e.
 SpanUtil getSpanUtil()
           
 Slot getSubtextSlot()
           
 KnowtatorTextPane getTextPane()
           
 TextSourceUtil getTextSourceUtil()
           
 String getTokenRegex()
           
 int getVerticalDistance(SimpleInstance annotation1, SimpleInstance annotation2)
           
 List<SimpleInstance> getVisibleFilteredAnnotations()
           
 Span getVisibleSpan()
           
 boolean isAnnotationVisible(SimpleInstance annotation)
           
 boolean isConsensusMode()
           
 boolean isFastAnnotateMode()
           
 void quitFastAnnotate()
           
 void refreshAnnotationsDisplay(boolean scrollToSelection)
           
 void removeFastAnnotateFrame(Frame frame)
          Removes the given frame (class) from the fast annotate tool bar.
 void restartConsensusMode()
           
 void selectNextAnnotation()
          The "next" annotation is defined as the annotation (if it exists) that is of the same type as the currently selected annotation that is 'next' according to the sort order defined by the currently selected comparator.
 void selectPreviousAnnotation()
          The "previous" annotation is defined as the annotation (if it exists) that is of the same type as the currently selected annotation that is 'next' according to the sort order defined by the currently selected comparator.
 void setActiveFilters(Collection<SimpleInstance> activeFilters)
           
 void setAnnotationComparator(Comparator<SimpleInstance> annotationComparator)
           
 void setFastAnnotateFrame(Frame fastAnnotateFrame)
           
 void setNotifyText(String text)
           
 void setSelectedAnnotation(SimpleInstance annotation)
          This is the preferred way to set the curently selected annotation.
 void setSelectedAnnotationSet(SimpleInstance annotationSet)
           
 void setSelectedAnnotator(SimpleInstance annotator)
           
 void setSelectedCls(Cls cls)
          This is the preferred way to set the curently selected cls (i.e.
 void setSelectedFilter(SimpleInstance filter)
           
 void setSelectedSpans(List<Span> selectedSpans)
          This is the preferred way to set the currently selected spans.
 void setTextPane(KnowtatorTextPane textPane)
           
 void setTextViewer(TextViewer textViewer)
           
 void startFastAnnotate()
           
 void startFastAnnotate(Frame fastAnnotateFrame)
          This method allows you to start fast annotation mode and set the fast annotation class in one convenient method.
 void textSourceChanged(TextSourceChangeEvent event)
           
 void updateCurrentAnnotations()
           
 void updateVisibleFilteredAnnotations()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KnowtatorManager

public KnowtatorManager(KnowtatorProjectUtil kpu)
Method Detail

getKnowledgeBase

public KnowledgeBase getKnowledgeBase()

setNotifyText

public void setNotifyText(String text)

getCurrentAnnotationsForFrame

public List<SimpleInstance> getCurrentAnnotationsForFrame(Frame frame)

getCurrentAnnotationCountForFrame

public int getCurrentAnnotationCountForFrame(Frame frame)

getConsolidatedAnnotationCountForFrame

public int getConsolidatedAnnotationCountForFrame(Frame frame)

getNextAnnotation

public SimpleInstance getNextAnnotation()
Returns:
the next annotation
See Also:
selectNextAnnotation()

getPreviousAnnotation

public SimpleInstance getPreviousAnnotation()
Returns:
the previous annotation
See Also:
selectPreviousAnnotation()

getCurrentFilteredAnnotations

public List<SimpleInstance> getCurrentFilteredAnnotations()
Returns the annotations for the current text source that satisfy the currently selected filter.


getVisibleFilteredAnnotations

public List<SimpleInstance> getVisibleFilteredAnnotations()

getCurrentPartiallyFilteredAnnotations

public List<SimpleInstance> getCurrentPartiallyFilteredAnnotations()
returns the annotations for the current text source that satisfy the currently selected filter ignoring the type constraint.


getCurrentSelectableFilteredAnnotations

public List<SimpleInstance> getCurrentSelectableFilteredAnnotations()

updateCurrentAnnotations

public void updateCurrentAnnotations()

updateVisibleFilteredAnnotations

public void updateVisibleFilteredAnnotations()

getSelectedCls

public Cls getSelectedCls()
This is the preferred way to obtain the currently selected cls (i.e. the cls selected in the annotation schema pane/tree.)

Returns:
the currently selected cls.

setSelectedCls

public void setSelectedCls(Cls cls)
This is the preferred way to set the curently selected cls (i.e. the cls that is highlighted in the annotation schema pane/tree.) This method will call the appropriate event firing method in EventHandler.

Parameters:
cls -

getSelectedAnnotation

public SimpleInstance getSelectedAnnotation()
This is the preferred way to obtain the currently selected annotation

Returns:
the currently selected annotation.

getLastSelectedAnnotation

public SimpleInstance getLastSelectedAnnotation()
Returns:
the currently selected annotation if it is not null. Otherwise, it returns the previously selected annotation or null if there has never been an annotation selected.

setSelectedAnnotation

public void setSelectedAnnotation(SimpleInstance annotation)
This is the preferred way to set the curently selected annotation. This method will call the appropriate event firing method in EventHandler.

Parameters:
annotation -

selectNextAnnotation

public void selectNextAnnotation()
The "next" annotation is defined as the annotation (if it exists) that is of the same type as the currently selected annotation that is 'next' according to the sort order defined by the currently selected comparator.


selectPreviousAnnotation

public void selectPreviousAnnotation()
The "previous" annotation is defined as the annotation (if it exists) that is of the same type as the currently selected annotation that is 'next' according to the sort order defined by the currently selected comparator.


getSelectedSpans

public List<Span> getSelectedSpans()
This is the preferred way to obtain the currently selected spans (i.e. the spans selected in the text pane.)

Returns:
a list of currenly selected spans highlighted by the user

setSelectedSpans

public void setSelectedSpans(List<Span> selectedSpans)
This is the preferred way to set the currently selected spans. This method will call the appropriate event firing method in EventHandler.

Parameters:
selectedSpans -
See Also:
EventHandler.fireSelectedSpanChanged(List)

getColorAssignments

public List<SimpleInstance> getColorAssignments()

getRootClses

public List<Cls> getRootClses()

getSelectedAnnotator

public SimpleInstance getSelectedAnnotator()

setSelectedAnnotator

public void setSelectedAnnotator(SimpleInstance annotator)

getSelectedAnnotationSet

public SimpleInstance getSelectedAnnotationSet()

setSelectedAnnotationSet

public void setSelectedAnnotationSet(SimpleInstance annotationSet)

getTokenRegex

public String getTokenRegex()

currentAnnotationsChanged

public void currentAnnotationsChanged(CurrentAnnotationsChangeEvent cace)
Specified by:
currentAnnotationsChanged in interface CurrentAnnotationsChangedListener

annotationCreated

public void annotationCreated(AnnotationCreatedEvent event)
Specified by:
annotationCreated in interface AnnotationCreatedListener

refreshAnnotationsDisplay

public void refreshAnnotationsDisplay(boolean scrollToSelection)
Parameters:
scrollToSelection - please see javadoc for RefreshAnnotationsDisplayListener
See Also:
RefreshAnnotationsDisplayListener.refreshAnnotationsDisplay(boolean)

deleteSelectedAnnotation

public void deleteSelectedAnnotation()

deleteAnnotation

public void deleteAnnotation(SimpleInstance annotation)

duplicateSelectedAnnotation

public void duplicateSelectedAnnotation()

createAnnotation

public SimpleInstance createAnnotation(Instance selectedClsOrInstance)
calls createAnnotation(selectedClsOrInstance, true)

Parameters:
selectedClsOrInstance - - a Cls or Instance frame in Protege that specifies the type of annotation to create. all other settings for the new annotation will be derived from the current settings and selections.
Returns:
the created annotation

createAnnotation

public SimpleInstance createAnnotation(Instance selectedClsOrInstance,
                                       boolean selectCreatedAnnotation)
Parameters:
selectedClsOrInstance -
selectCreatedAnnotation - determines whether the newly created annotation should be selected. If the new annotation is a slot filler, then you might not want it to be selected as the annotation of focus for Knowtator.
Returns:
the created annotation or null if something went wrong.

getAnnotationUtil

public AnnotationUtil getAnnotationUtil()

getBrowserTextUtil

public BrowserTextUtil getBrowserTextUtil()

getDisplayColors

public DisplayColors getDisplayColors()

getFilterUtil

public FilterUtil getFilterUtil()

getMentionUtil

public MentionUtil getMentionUtil()

getSpanUtil

public SpanUtil getSpanUtil()

getTextSourceUtil

public TextSourceUtil getTextSourceUtil()

getKnowtatorProjectUtil

public KnowtatorProjectUtil getKnowtatorProjectUtil()

getRenderer

public ColorFrameRenderer getRenderer()

getTextPane

public KnowtatorTextPane getTextPane()

setTextPane

public void setTextPane(KnowtatorTextPane textPane)

getAnnotationComparator

public Comparator<SimpleInstance> getAnnotationComparator()

getPositionComparator

public Comparator<SimpleInstance> getPositionComparator(SimpleInstance annotation)

setAnnotationComparator

public void setAnnotationComparator(Comparator<SimpleInstance> annotationComparator)

getFastAnnotateFrame

public Frame getFastAnnotateFrame()
Returns:
the fast annotation cls. May return null if it has not been set yet (or set to null).

setFastAnnotateFrame

public void setFastAnnotateFrame(Frame fastAnnotateFrame)

startFastAnnotate

public void startFastAnnotate()

startFastAnnotate

public void startFastAnnotate(Frame fastAnnotateFrame)
This method allows you to start fast annotation mode and set the fast annotation class in one convenient method. If this method is called when KnowtatorManager.isFastAnnotateMode() is true, then this method has the same effect as calling setFastAnnotateCls.

Parameters:
fastAnnotateFrame - the class with which to annotate with
See Also:
isFastAnnotateMode(), setFastAnnotateFrame(Frame)

removeFastAnnotateFrame

public void removeFastAnnotateFrame(Frame frame)
Removes the given frame (class) from the fast annotate tool bar.

Parameters:
frame - The frame (or Cls) to be removed.

fastAnnotateToolBarContains

public boolean fastAnnotateToolBarContains(Frame frame)
Finds out if the given frame is being shown in the fast annotate tool bar.

Parameters:
frame - The frame to lookup
Returns:
True if the frame (Cls) is being shown in the tool bar, returns false otherwise.

quitFastAnnotate

public void quitFastAnnotate()

isFastAnnotateMode

public boolean isFastAnnotateMode()

setSelectedFilter

public void setSelectedFilter(SimpleInstance filter)
                       throws ConsensusException
Throws:
ConsensusException

getSelectedFilter

public SimpleInstance getSelectedFilter()

getActiveFilters

public List<SimpleInstance> getActiveFilters()

setActiveFilters

public void setActiveFilters(Collection<SimpleInstance> activeFilters)

addActiveFilter

public void addActiveFilter(SimpleInstance filter)

getFadeUnselectedAnnotations

public boolean getFadeUnselectedAnnotations()

getSubtextSlot

public Slot getSubtextSlot()

restartConsensusMode

public void restartConsensusMode()
                          throws ConsensusException
Throws:
ConsensusException

isConsensusMode

public boolean isConsensusMode()

getConsensusModeProgress

public int getConsensusModeProgress()

textSourceChanged

public void textSourceChanged(TextSourceChangeEvent event)
Specified by:
textSourceChanged in interface TextSourceChangeListener

consolidateAnnotation

public void consolidateAnnotation(SimpleInstance deleteAnnotation,
                                  SimpleInstance consolidateAnnotation)

setTextViewer

public void setTextViewer(TextViewer textViewer)

isAnnotationVisible

public boolean isAnnotationVisible(SimpleInstance annotation)

getVisibleSpan

public Span getVisibleSpan()

getVerticalDistance

public int getVerticalDistance(SimpleInstance annotation1,
                               SimpleInstance annotation2)