gate.gui.docview
Class OntologyClassView

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

public class OntologyClassView
extends AbstractDocumentView
implements CreoleListener, OntologyModificationListener

Document view that displays an ontology class tree to annotate a document. tick the checkbox of a class to show the instances highlighted in the text selected class will be used when creating a new annotation from a text selection in the document take only the first 20 characters of the selection for the instance name and add a number if already existing allow multiple ontologies to be used at the same time put each ontology in a JPanel with triangle icons to hide/show the panel, hidden by default open only first level of classes when opening an ontology load lazily the ontology trees context menu for classes to hide/show them, saved in user configuration

See Also:
Serialized Form

Nested Class Summary
protected  class OntologyClassView.ClassTreeCellEditor
           
protected  class OntologyClassView.ClassTreeCellRenderer
           
protected  class OntologyClassView.MouseStoppedMovingAction
          Add the text selection to the filter instance table to enable creating a new instance from the selection or adding it as a new label to an existing instance.
protected  class OntologyClassView.TextMouseListener
          A mouse listener used for events in the text view.
 
Field Summary
protected static String ANNOTATION_TYPE
           
protected static String CLASS
           
protected  Map<OClass,Color> colorByClassMap
          Colors for class and their instances only if the latter exist.
protected  LinkedHashSet<String> hiddenClassesSet
          Classes to hide in the trees.
protected  Set<OClass> highlightedClasses
          Classes highlighted in the document with their checkboxes ticked in the class tree.
protected  Map<OClass,List> highlightsDataByClassMap
          HighlightData list for each class.
protected static String INSTANCE
           
protected  OntologyInstanceView instanceView
           
protected  OntologyItemComparator itemComparator
           
protected  JPanel mainPanel
           
protected  JLabel messageLabel
           
protected static int MOUSE_MOVEMENT_TIMER_DELAY
           
protected  Timer mouseMovementTimer
           
protected  OntologyClassView.MouseStoppedMovingAction mouseStoppedMovingAction
           
protected static String ONTOLOGY
           
protected  OClass selectedClass
          Class that has the lead selection in the focused ontology tree.
protected  String selectedSet
          Annotation set name where to read/save the instance annotations.
protected  JComboBox setComboBox
           
protected  JTextArea textArea
           
protected  OntologyClassView.TextMouseListener textMouseListener
           
protected  TextualDocumentView textView
           
protected  Map<Ontology,JTree> treeByOntologyMap
          Link trees with their ontologies.
protected  JPanel treesPanel
           
protected  OptionsMap userConfig
           
 
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
OntologyClassView()
           
 
Method Summary
protected  void addNodes(JTree tree, DefaultMutableTreeNode parent, Set<OClass> newChildren, boolean filterClasses)
          Add children nodes to the parent node in the tree.
protected  void buildClassTree(JTree tree, Ontology ontology)
          Build the class tree from the ontology.
 void cleanup()
          releases the memory allocated to this resource
 void datastoreClosed(CreoleEvent e)
          Called when a DataStore has been closed
 void datastoreCreated(CreoleEvent e)
          Called when a DataStore has been created
 void datastoreOpened(CreoleEvent e)
          Called when a DataStore has been opened
 Component getGUI()
          Returns the actual UI component this view represents.
 String getSelectedSet()
           
 int getType()
          Returns the type of this view.
 void highlightInstance(AnnotationSet set, Annotation annotation, OClass oClass, JTree tree)
          To see if it's worth using it to optimise highlights display.
protected  void initGUI()
          Implementers should override this method and use it for populating the GUI.
protected  void initListeners()
           
protected  void loadOntology(Ontology ontology)
          Add the ontology in a disclosure panel, closed at start.
 void ontologyReset(Ontology ontology)
          This method is called whenever ontology is reset.
protected  void registerHooks()
          This method will be called whenever the view becomes active.
 void resourceAdded(Ontology ontology, OResource resource)
          This method is invoked whenever a resource (class/property/instance) is added to the ontology.
 void resourceLoaded(CreoleEvent e)
          Called when a new Resource has been loaded into the system
 void resourcePropertyValueChanged(Ontology ontology, OResource resource, RDFProperty property, Object value, int eventType)
          This method should be invoked when a property value is added or removed (specified by the event type).
 void resourceRelationChanged(Ontology ontology, OResource resource1, OResource resource2, int eventType)
          This method is invoked whenever a relation between two objects of the same class (e.g.
 void resourceRenamed(Resource resource, String oldName, String newName)
          Called when the creole register has renamed a resource.1
 void resourcesRemoved(Ontology ontology, String[] resources)
          This method is invoked whenever a resource (class/property/instance) is removed from the ontology.
 void resourceUnloaded(CreoleEvent e)
          Called when a Resource has been removed from the system
 void setClassHighlighted(OClass oClass, boolean isHighlighted)
           
protected  boolean setColorTreeNodesWhenInstancesFound(String setName)
          Extract annotations that have been created by this view and colored the corresponding tree class node if found.
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, setSelectedAnnotations, 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.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

textView

protected TextualDocumentView textView

textArea

protected JTextArea textArea

instanceView

protected OntologyInstanceView instanceView

mainPanel

protected JPanel mainPanel

messageLabel

protected JLabel messageLabel

treesPanel

protected JPanel treesPanel

setComboBox

protected JComboBox setComboBox

selectedClass

protected OClass selectedClass
Class that has the lead selection in the focused ontology tree.


highlightedClasses

protected Set<OClass> highlightedClasses
Classes highlighted in the document with their checkboxes ticked in the class tree.


colorByClassMap

protected Map<OClass,Color> colorByClassMap
Colors for class and their instances only if the latter exist.


highlightsDataByClassMap

protected Map<OClass,List> highlightsDataByClassMap
HighlightData list for each class.


treeByOntologyMap

protected Map<Ontology,JTree> treeByOntologyMap
Link trees with their ontologies.


hiddenClassesSet

protected LinkedHashSet<String> hiddenClassesSet
Classes to hide in the trees.


selectedSet

protected String selectedSet
Annotation set name where to read/save the instance annotations.


itemComparator

protected OntologyItemComparator itemComparator

mouseStoppedMovingAction

protected OntologyClassView.MouseStoppedMovingAction mouseStoppedMovingAction

textMouseListener

protected OntologyClassView.TextMouseListener textMouseListener

mouseMovementTimer

protected Timer mouseMovementTimer

MOUSE_MOVEMENT_TIMER_DELAY

protected static final int MOUSE_MOVEMENT_TIMER_DELAY
See Also:
Constant Field Values

userConfig

protected OptionsMap userConfig

ONTOLOGY

protected static final String ONTOLOGY
See Also:
Constant Field Values

CLASS

protected static final String CLASS
See Also:
Constant Field Values

INSTANCE

protected static final String INSTANCE
See Also:
Constant Field Values

ANNOTATION_TYPE

protected static final String ANNOTATION_TYPE
See Also:
Constant Field Values
Constructor Detail

OntologyClassView

public OntologyClassView()
Method Detail

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

initListeners

protected void initListeners()

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

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

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

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.

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

resourceLoaded

public void resourceLoaded(CreoleEvent e)
Description copied from interface: CreoleListener
Called when a new Resource has been loaded into the system

Specified by:
resourceLoaded in interface CreoleListener

resourceUnloaded

public void resourceUnloaded(CreoleEvent e)
Description copied from interface: CreoleListener
Called when a Resource has been removed from the system

Specified by:
resourceUnloaded in interface CreoleListener

datastoreOpened

public void datastoreOpened(CreoleEvent e)
Description copied from interface: CreoleListener
Called when a DataStore has been opened

Specified by:
datastoreOpened in interface CreoleListener

datastoreCreated

public void datastoreCreated(CreoleEvent e)
Description copied from interface: CreoleListener
Called when a DataStore has been created

Specified by:
datastoreCreated in interface CreoleListener

datastoreClosed

public void datastoreClosed(CreoleEvent e)
Description copied from interface: CreoleListener
Called when a DataStore has been closed

Specified by:
datastoreClosed in interface CreoleListener

resourceRenamed

public void resourceRenamed(Resource resource,
                            String oldName,
                            String newName)
Description copied from interface: CreoleListener
Called when the creole register has renamed a resource.1

Specified by:
resourceRenamed in interface CreoleListener

resourceRelationChanged

public void resourceRelationChanged(Ontology ontology,
                                    OResource resource1,
                                    OResource resource2,
                                    int eventType)
Description copied from interface: OntologyModificationListener
This method is invoked whenever a relation between two objects of the same class (e.g. OClass and OClass, RDFPRoeprty and RDFProeprty etc) is changed.

Specified by:
resourceRelationChanged in interface OntologyModificationListener
Parameters:
ontology - the source of the event
resource1 - the affected OResource
resource2 - the affected OResource
eventType - the type of an event (@see OConstants) for more details

resourcePropertyValueChanged

public void resourcePropertyValueChanged(Ontology ontology,
                                         OResource resource,
                                         RDFProperty property,
                                         Object value,
                                         int eventType)
Description copied from interface: OntologyModificationListener
This method should be invoked when a property value is added or removed (specified by the event type).

Specified by:
resourcePropertyValueChanged in interface OntologyModificationListener
Parameters:
ontology - the source of the event
resource - the affected resource whose property value is added or removed
property - the property whose value has been added or removed
value - the actual value that is added or removed. If the value is null - it indicates all the values related to the property are deleted.
eventType - type of the event (@see OConstants) for more details

resourcesRemoved

public void resourcesRemoved(Ontology ontology,
                             String[] resources)
Description copied from interface: OntologyModificationListener
This method is invoked whenever a resource (class/property/instance) is removed from the ontology.

Specified by:
resourcesRemoved in interface OntologyModificationListener
Parameters:
ontology - the source of the event
resources - an array of URIs of resources which were deleted (including the resource which was asked to be deleted).

resourceAdded

public void resourceAdded(Ontology ontology,
                          OResource resource)
Description copied from interface: OntologyModificationListener
This method is invoked whenever a resource (class/property/instance) is added to the ontology.

Specified by:
resourceAdded in interface OntologyModificationListener
Parameters:
ontology - the source of the event
resource - an instance of OResource, which was created as a result of addition of a resource.

ontologyReset

public void ontologyReset(Ontology ontology)
Description copied from interface: OntologyModificationListener
This method is called whenever ontology is reset. In other words when all resources of the ontology are deleted using the ontology.cleanup method.

Specified by:
ontologyReset in interface OntologyModificationListener

setColorTreeNodesWhenInstancesFound

protected boolean setColorTreeNodesWhenInstancesFound(String setName)
Extract annotations that have been created by this view and colored the corresponding tree class node if found.

Parameters:
setName - the annotation set name to search
Returns:
true if and only if at least one annotation has been found

loadOntology

protected void loadOntology(Ontology ontology)
Add the ontology in a disclosure panel, closed at start.

Parameters:
ontology - ontology to display

buildClassTree

protected void buildClassTree(JTree tree,
                              Ontology ontology)
Build the class tree from the ontology. Based on OntologyEditor.rebuildModel().

Parameters:
tree - tree to build
ontology - ontology to use

addNodes

protected void addNodes(JTree tree,
                        DefaultMutableTreeNode parent,
                        Set<OClass> newChildren,
                        boolean filterClasses)
Add children nodes to the parent node in the tree.

Parameters:
tree - tree to update
parent - parent node
newChildren - children classes to add
filterClasses - if children nodes contain hidden classes then don't add them.

setClassHighlighted

public void setClassHighlighted(OClass oClass,
                                boolean isHighlighted)

highlightInstance

public void highlightInstance(AnnotationSet set,
                              Annotation annotation,
                              OClass oClass,
                              JTree tree)
To see if it's worth using it to optimise highlights display.

Parameters:
set - set
annotation - annotation
oClass - class
tree - tree

getSelectedSet

public String getSelectedSet()