org.apache.uima.tools.viewer
public class CasAnnotationViewer extends javax.swing.JPanel implements java.awt.event.ActionListener, java.awt.event.MouseListener, javax.swing.event.TreeWillExpandListener, javax.swing.event.TreeExpansionListener, java.awt.event.ItemListener
JPanel
and so can be reused within any Swing application.
To launch the viewer, call the setCAS(CAS)
method with the CAS to be viewed.
The viewer is configurable via the following methods:
setConsistentColors(boolean)
- if set to true (default), the color assigned to any
annotation type will be the same across all documents. If set to false, colors may vary across
documents.setDisplayedTypes(String[])
- specifies a set of types that will be highlighted in
the viewer's text pane.setHiddenTypes(String[])
- specifies a set of types that will NOT be highlighted in
the viewer's text pane.setHiddenFeatures(String[])
- specifies a set of features that will never shown in
the viewer's annotation details tree.setHighFrequencyTypes(String[])
- this can be used to specify a set of types that
occur frequently. These types will the be assigned the most distinguishable colors.setInitiallySelectedTypes(String[])
- this can be used to specify a set of types
that will initially be selected (i.e. have their checkboxes checked) in the viewer. The default
is for all types to be initially selected.setRightToLeftTextOrientation(boolean)
- switches the text pane from left-to-right
(default) to right-to-left mode. This is needed to support languages such as Arabic and Hebrew,
which are read from right to left.javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
CasAnnotationViewer()
Creates a CAS Annotation Viewer.
|
CasAnnotationViewer(boolean aEntityViewEnabled)
Deprecated.
use the zero-argument constructor and call
setEntityViewEnabled(boolean) |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e) |
protected void |
addAnnotationToTree(AnnotationFS aAnnotation)
Adds an annotation to the selected annotations tree.
|
void |
applyBoldfaceToKeywords(java.lang.String[] aWords)
Causes the specified words to appear in boldface wherever they occur in the document.
|
void |
applyBoldfaceToSpans(int[] aSpans)
Causes the specified spans to appear in boldface.
|
void |
assignCheckedFromList(java.util.ArrayList aNotChecked)
Assign initially checked to the specified types, pairing up down the lists
|
void |
assignColorsFromList(java.util.List aColors,
java.util.ArrayList aTypeNames)
Assign colors to the specified types, pairing up down the lists
|
void |
configureViewForXmlFragmentsQuery(java.lang.String aQuery)
Configures the viewer appropriately for displaying a hit against an XML fragments query.
|
void |
configureViewForXmlFragmentsQuery(java.lang.String aQuery,
java.lang.String aTypeNamespace)
Configures the viewer appropriately for displaying a hit against an XML fragments query.
|
protected javax.swing.JTree |
getSelectedAnnotationTree()
Gets the selected annotation tree component.
|
java.util.ArrayList |
getUserTypes() |
void |
itemStateChanged(java.awt.event.ItemEvent e) |
void |
mouseClicked(java.awt.event.MouseEvent e) |
void |
mouseEntered(java.awt.event.MouseEvent e) |
void |
mouseExited(java.awt.event.MouseEvent e) |
void |
mousePressed(java.awt.event.MouseEvent e) |
void |
mouseReleased(java.awt.event.MouseEvent e) |
void |
setCAS(CAS aCAS)
Sets the CAS to be viewed.
|
void |
setConsistentColors(boolean aConsistent)
Sets whether colors will be consistent in all documents viewed using this viewer.
|
void |
setDisplayedTypes(java.lang.String[] aDisplayedTypeNames)
Set the list of types that will be highlighted in the viewer.
|
void |
setEntityResolver(EntityResolver aEntityResolver)
Sets the
EntityResolver to use when the viewer is in entity mode. |
void |
setEntityViewEnabled(boolean aEnabled)
Configures whether the viewer will allow the user to switch to "Entity" view, which highlight
entities rather than annotations.
|
void |
setHiddenFeatures(java.lang.String[] aFeatureNames)
Configures the viewer to hide certain features in the annotation deatail pane.
|
void |
setHiddenTypes(java.lang.String[] aTypeNames)
Set the list of types that will NOT be highlighted in the viewer.
|
void |
setHideUnselectedCheckboxes(boolean aHideUnselected)
Sets whether unselected (unchecked) checkboxes will be hidden entirely from the legend.
|
void |
setHighFrequencyTypes(java.lang.String[] aTypeNames)
Set the list of types that occur most frequently.
|
void |
setInitiallySelectedTypes(java.lang.String[] aTypeNames)
Configures the initially selected types in the viewer.
|
void |
setRightToLeftTextOrientation(boolean aRightToLeft)
Sets the text orientation.
|
void |
setSize(java.awt.Dimension d) |
void |
setUserTypes(java.util.ArrayList userTypes) |
void |
treeCollapsed(javax.swing.event.TreeExpansionEvent event) |
void |
treeExpanded(javax.swing.event.TreeExpansionEvent event) |
void |
treeWillCollapse(javax.swing.event.TreeExpansionEvent event) |
void |
treeWillExpand(javax.swing.event.TreeExpansionEvent event) |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, setVisible, unregisterKeyboardAction, update
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, transferFocusDownCycle, validate, validateTree
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, isShowing, 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, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public CasAnnotationViewer()
@Deprecated public CasAnnotationViewer(boolean aEntityViewEnabled)
setEntityViewEnabled(boolean)
public java.util.ArrayList getUserTypes()
public void setUserTypes(java.util.ArrayList userTypes)
userTypes
- The userTypes to set.public void setHighFrequencyTypes(java.lang.String[] aTypeNames)
aTypeNames
- names of types that are occur frequently. Ideally these should be ordered by
frequency, with the most frequent being first.public void setDisplayedTypes(java.lang.String[] aDisplayedTypeNames)
setHiddenTypes(String[])
.aTypeNames
- names of types that are to be highlighted. Null indicates that all types in the CAS
should be highlighted.public void setHiddenTypes(java.lang.String[] aTypeNames)
aTypeNames
- names of types that are never to be highlighted.public void setInitiallySelectedTypes(java.lang.String[] aTypeNames)
aTypeNames
- array of fully-qualified names of types to be initially selectedpublic void setHiddenFeatures(java.lang.String[] aFeatureNames)
aFeatureName
- array of (short) feature names to be hiddenpublic void setEntityViewEnabled(boolean aEnabled)
setEntityResolver(EntityResolver)
method has been called with a user-supplied
class that can determine which annotations refer to the same entity.aDisplayEntities
- true to enable entity viewing mode, false to allow annotation viewing only.
The default is false.public void setEntityResolver(EntityResolver aEntityResolver)
EntityResolver
to use when the viewer is in entity mode.
Entity mode must be turned on using the setEntityViewEnabled(boolean)
method.aEntityResolver
- user-supplied class that can determine which annotations correspond
to the same entity.public void setConsistentColors(boolean aConsistent)
setHighFrequencyTypes(String[])
, the colors for those types will always be
consistent, regardless of the value passed to this method.aConsistent
- true (the default) causes colors to be consistent across documents, false allows them
to varypublic void setRightToLeftTextOrientation(boolean aRightToLeft)
aRightToLeft
- true to put the viewer in right-to-left mode, false for left-to-right (the default).public void setHideUnselectedCheckboxes(boolean aHideUnselected)
aConsistent
- true (the default) causes colors to be consistent across documents, false allows them
to varypublic void setCAS(CAS aCAS)
display()
.aCAS
- the CSA to be viewedpublic void applyBoldfaceToKeywords(java.lang.String[] aWords)
#setCAS()
. It wil apply only to the current
document, and will be reset on the next call to #setCAS()
.aWords
- array of words to highlight in boldface.public void applyBoldfaceToSpans(int[] aSpans)
#setCAS()
. It wil apply only to the current document, and will be reset on the
next call to #setCAS()
.aSpans
- spans to appear in boldface (begin1, end1, begin2, end2, ...)public void configureViewForXmlFragmentsQuery(java.lang.String aQuery, java.lang.String aTypeNamespace)
setInitiallySelectedTypes(String[])
with the list of types mentioned in the query and #applyBoldfaceToKeyword(String[])
on
any keywords mentioned in the query.aQuery
- an XML fragments queryaTypeNamespace
- namespace to prepend to the element names in the query in order to form
fully-qualified CAS type names. This is optional; if not specified, type namespaces
are ignored and any type whose local name matches the query will be selected.public void configureViewForXmlFragmentsQuery(java.lang.String aQuery)
setInitiallySelectedTypes(String[])
with the list of types mentioned in the query and #applyBoldfaceToKeyword(String[])
on
any keywords mentioned in the query.aQuery
- an XML fragments querypublic void assignCheckedFromList(java.util.ArrayList aNotChecked)
aNotChecked
- list of types not to be initially checked JMPpublic void assignColorsFromList(java.util.List aColors, java.util.ArrayList aTypeNames)
aColors
- list of colorsaTypeNames
- list of type names JMPprotected void addAnnotationToTree(AnnotationFS aAnnotation)
aAnnotation
- the annotation to addpublic void setSize(java.awt.Dimension d)
setSize
in class java.awt.Component
Component.setSize(Dimension)
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void treeWillCollapse(javax.swing.event.TreeExpansionEvent event) throws javax.swing.tree.ExpandVetoException
treeWillCollapse
in interface javax.swing.event.TreeWillExpandListener
javax.swing.tree.ExpandVetoException
public void treeWillExpand(javax.swing.event.TreeExpansionEvent event) throws javax.swing.tree.ExpandVetoException
treeWillExpand
in interface javax.swing.event.TreeWillExpandListener
javax.swing.tree.ExpandVetoException
public void treeCollapsed(javax.swing.event.TreeExpansionEvent event)
treeCollapsed
in interface javax.swing.event.TreeExpansionListener
public void treeExpanded(javax.swing.event.TreeExpansionEvent event)
treeExpanded
in interface javax.swing.event.TreeExpansionListener
public void itemStateChanged(java.awt.event.ItemEvent e)
itemStateChanged
in interface java.awt.event.ItemListener
protected javax.swing.JTree getSelectedAnnotationTree()
Copyright © 2014. All Rights Reserved.