Package org.apache.uima.tools.viewer
Class CasAnnotationViewer
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.apache.uima.tools.viewer.CasAnnotationViewer
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
public class CasAnnotationViewer extends javax.swing.JPanel
A Swing component that displays annotations in a text pane with highlighting. There is also a tree view for display details of annotations on which the user clicks. This class extendsJPanel
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.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
CasAnnotationViewer.AnnotationTreeCellRenderer
The Class AnnotationTreeCellRenderer.class
CasAnnotationViewer.DefaultEntityResolver
Trivial entity resolver that's applied if the user turns on entity mode without specifying their own entity resolver.private static class
CasAnnotationViewer.FsTreeNodeObject
Inner class containing data for a tree node representing a FeatureStructure.private static class
CasAnnotationViewer.TypeTreeNodeObject
Inner class containing data for a tree node representing a Type.private static class
CasAnnotationViewer.VerticallyScrollablePanel
A panel that is to be placed in a JScrollPane that can only scroll vertically.-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description private javax.swing.JRadioButton
annotationModeButton
The annotation mode button.private java.lang.String[]
boldFaceKeyWords
The bold face key words.private int[]
boldFaceSpans
The bold face spans.private static float
BRIGHT
The Constant BRIGHT.private CAS
cas
The cas.private static java.awt.Color[]
COLORS
The Constant COLORS.private static java.lang.String[]
DEFAULT_HIDDEN_FEATURES
The default hidden features.private boolean
disableSofaSelectionComboBoxStateChangeAction
The disable sofa selection combo box state change action.private java.util.Set<java.lang.String>
displayedTypeNames
The displayed type names.private javax.swing.JScrollPane
entityCheckBoxScrollPane
The entity check box scroll pane.private CasAnnotationViewer.VerticallyScrollablePanel
entityCheckBoxVerticalScrollPanel
The entity check box vertical scroll panel.private javax.swing.JRadioButton
entityModeButton
The entity mode button.private EntityResolver
entityResolver
The entity resolver.private java.util.Map<EntityResolver.Entity,javax.swing.JCheckBox>
entityToCheckBoxMap
The entity to check box map.private java.util.Map<java.lang.String,java.awt.Color>
featureColorMap
The feature color map.private javax.swing.JRadioButton
featureModeButton
The feature mode button.private java.util.Map<java.lang.String,javax.swing.JRadioButton>
featureRadioButtonMap
The feature radio button map.private javax.swing.JScrollPane
featureRadioButtonScrollPane
The feature radio button scroll pane.private CasAnnotationViewer.VerticallyScrollablePanel
featureRadioButtonVerticalScrollPanel
The feature radio button vertical scroll panel.private java.util.Map<java.lang.String,javax.swing.JCheckBox>
featureValueCheckBoxMap
The feature value check box map.private javax.swing.JScrollPane
featureValueCheckBoxScrollPane
The feature value check box scroll pane.private CasAnnotationViewer.VerticallyScrollablePanel
featureValueCheckBoxVerticalScrollPanel
The feature value check box vertical scroll panel.private java.util.Map<java.lang.String,java.awt.Color>
featureValueColorMap
The feature value color map.private Type
fsArrayType
The fs array type.private java.util.Set<java.lang.String>
hiddenFeatureNames
The hidden feature names.private java.util.Set<java.lang.String>
hiddenTypeNames
The hidden type names.private boolean
hideUnselectedCheckBoxes
The hide unselected check boxes.private java.util.List<java.lang.String>
highFrequencyTypes
The high frequency types.private javax.swing.JSplitPane
horizontalSplitPane
The horizontal split pane.private java.util.Set<java.lang.String>
initiallySelectedTypeNames
The initially selected type names.private static short
MODE_ANNOTATIONS
The Constant MODE_ANNOTATIONS.private static short
MODE_ENTITIES
The Constant MODE_ENTITIES.private static short
MODE_FEATURES
The Constant MODE_FEATURES.private javax.swing.JTree
selectedAnnotationTree
The selected annotation tree.private javax.swing.tree.DefaultTreeModel
selectedAnnotationTreeModel
The selected annotation tree model.private static long
serialVersionUID
The Constant serialVersionUID.private javax.swing.JButton
showHideUnselectedButton
The show hide unselected button.private javax.swing.JComboBox
sofaSelectionComboBox
The sofa selection combo box.private javax.swing.JPanel
sofaSelectionPanel
The sofa selection panel.private Type
stringType
The string type.private javax.swing.JTabbedPane
tabbedChoicePane
The tabbed choice pane.private javax.swing.JTextPane
textPane
The text pane.private javax.swing.JScrollPane
textScrollPane
The text scroll pane.private javax.swing.JScrollPane
typeCheckBoxScrollPane
The type check box scroll pane.private CasAnnotationViewer.VerticallyScrollablePanel
typeCheckBoxVerticalScrollPanel
The type check box vertical scroll panel.private java.util.Map<java.lang.String,java.awt.Color>
typeColorMap
The type color map.private java.util.Map<Type,javax.swing.JRadioButton>
typeRadioButtonMap
The type radio button map.private javax.swing.JScrollPane
typeRadioButtonScrollPane
The type radio button scroll pane.private CasAnnotationViewer.VerticallyScrollablePanel
typeRadioButtonVerticalScrollPanel
The type radio button vertical scroll panel.private java.util.Set<java.lang.String>
typesNotChecked
The types not checked.private TypeSystem
typeSystem
The type system.private java.util.Map<Type,javax.swing.JCheckBox>
typeToCheckBoxMap
The type to check box map.private boolean
useConsistentColors
The use consistent colors.private java.util.List<java.lang.String>
userTypes
The user types.private javax.swing.JSplitPane
verticalSplitPane
The vertical split pane.private short
viewMode
The view mode.-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description CasAnnotationViewer()
Creates a CAS Annotation Viewer.CasAnnotationViewer(boolean aEntityViewEnabled)
Deprecated.use the zero-argument constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addAnnotationToTree(AnnotationFS aAnnotation)
Adds an annotation to the selected annotations tree.private void
addFeatureRadioButtons()
Adds the feature radio buttons.private void
addFeatureTreeNodes(javax.swing.tree.DefaultMutableTreeNode aParentNode, FeatureStructure aFS)
Adds the feature tree nodes.private void
addFeatureValueCheckBoxes()
Adds the feature value check boxes.private void
addTypeCheckBoxes()
Adds the type check boxes.private void
addTypeRadioButtons()
Adds the type radio buttons.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.List<java.lang.String> aNotChecked)
Assign initially checked to the specified types, pairing up down the lists.void
assignColorsFromList(java.util.List<java.awt.Color> aColors, java.util.List<java.lang.String> aTypeNames)
Assign colors to the specified types, pairing up down the lists.private void
assignTypeColors(java.util.List<java.lang.String> aTypeNames)
Assign colors to the specified types.private static java.lang.String
checkString(java.lang.String stringValue, java.lang.String defaultIfNull, int maxLength)
Check if a string is null or longer than specified limit.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.private void
createAnnotationModeButton()
Creates the annotation mode button.private javax.swing.JPanel
createControlPanel()
Creates the control panel.private javax.swing.JButton
createDeselectAllButton()
Creates the deselect all button.private void
createEntityCheckBoxPane()
Creates the entity check box pane.private void
createEntityModeButton()
Creates the entity mode button.private void
createFeatureModeButton()
Creates the feature mode button.private void
createFeatureRadioButtonPane()
Creates the feature radio button pane.private void
createFeatureValueCheckBoxPane()
Creates the feature value check box pane.private void
createHorizontalSplitPane()
Creates the horizontal split pane.private javax.swing.JButton
createSelectAllButton()
Creates the select all button.private javax.swing.JPanel
createSelectButtonPanel()
Creates the select button panel.private void
createSelectedAnnotationTree()
Creates the selected annotation tree.private void
createShowHideUnselectedButton()
Creates the show hide unselected button.private void
createSofaSelectionComboBox()
Creates the sofa selection combo box.private void
createSofaSelectionPanel()
Creates the sofa selection panel.private javax.swing.JTabbedPane
createTabbedChoicePane()
Creates the tabbed choice pane.private void
createTextScrollPane()
Creates the text scroll pane.private javax.swing.JPanel
createTreePanel()
Creates the tree panel.private void
createTypeCheckBoxPane()
Creates the type check box pane.private void
createTypeRadioButtonPane()
Creates the type radio button pane.private void
createVerticalSplitPane()
Creates the vertical split pane.private javax.swing.JPanel
createViewModePanel()
Creates the view mode panel.private javax.swing.JPanel
createViewPanel()
Creates the view panel.private void
display()
Creates/updates the display.private void
displayAnnotationView()
Creates the annotation display.private void
displayEntityView()
Creates the entity display.private void
displayFeatureView()
Create/update the feature view.private void
doBoldFace()
Applies boldface as per the mBoldfaceKeywords and mBoldfaceSpans fields.private void
doBoldFaceByKeyWords()
Do bold face by key words.private void
doBoldFaceBySpans()
Do bold face by spans.private java.lang.String
getFeatureValueInString(FeatureStructure aFS, Feature feature)
Get feature value in string, if value is not another annotation and not an array of annotations.protected javax.swing.JTree
getSelectedAnnotationTree()
Gets the selected annotation tree component.java.util.List<java.lang.String>
getUserTypes()
Gets the user types.private void
initializeSofaSelectionPanel()
Initialize sofa selection panel.private boolean
isMatch(Annotation annotation)
Check if an annotation matches the filters set by the user.private void
processOneAnnotationInAnnotationView(javax.swing.text.StyledDocument doc, AnnotationFS annotation)
Process one annotation in annotation view.private void
processOneAnnotationInEntityView(javax.swing.text.StyledDocument doc, Annotation annotation)
Process one annotation in entity view.private boolean
processOneAnnotationInFeatureView(javax.swing.text.StyledDocument doc, Annotation annotation, boolean firstType)
Examine an annotation and add type/feature/value-related controls if necessary.private boolean
processOneFeature(javax.swing.text.StyledDocument doc, Annotation annotation, Feature feature, boolean firstFeature)
Examine one feature of the given annotation and create the feature-related controls.private boolean
processOneFeatureValue(javax.swing.text.StyledDocument doc, Annotation annotation, Feature feature)
Examine one feature of the given annotation and create the feature-value-related controls.private void
reset()
Reset.private void
resetEntityCheckBoxPanel()
Reset entity check box panel.private void
resetFeaturePanel()
Reset feature panel.private void
resetFeatureValuePanel()
Reset feature value panel.private void
resetSelectedAnnotationTree()
Reset selected annotation tree.private void
resetTabbedPane()
Re-populate the tabbed pane's tabs depending on the current view mode.private void
resetTypeCheckBoxPanel()
Reset type check box panel.private void
resetTypeColorMap()
Reset type color map.private void
resetTypeRadioButtonPanel()
Reset type radio button panel.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 theEntityResolver
to use when the viewer is in entity mode.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)
Sets the size.void
setUserTypes(java.util.List<java.lang.String> userTypes)
Sets the user types.private static boolean
typeNamesContains(java.util.Set<java.lang.String> names, java.lang.String name)
Does wildcard matching to determine if a give type name is "contained" in a Set of type names.private void
updateSelectedAnnotationTree(int aPosition)
Refreshes the selected annotation tree.private static boolean
wildCardMatch(java.lang.String name, java.lang.String pattern)
Helper for#typeNamesContains(HashSet, String)
.-
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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
-
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, 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, 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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
The Constant serialVersionUID.- See Also:
- Constant Field Values
-
MODE_ANNOTATIONS
private static final short MODE_ANNOTATIONS
The Constant MODE_ANNOTATIONS.- See Also:
- Constant Field Values
-
MODE_ENTITIES
private static final short MODE_ENTITIES
The Constant MODE_ENTITIES.- See Also:
- Constant Field Values
-
MODE_FEATURES
private static final short MODE_FEATURES
The Constant MODE_FEATURES.- See Also:
- Constant Field Values
-
DEFAULT_HIDDEN_FEATURES
private static java.lang.String[] DEFAULT_HIDDEN_FEATURES
The default hidden features.
-
BRIGHT
private static final float BRIGHT
The Constant BRIGHT.- See Also:
- Constant Field Values
-
COLORS
private static final java.awt.Color[] COLORS
The Constant COLORS.
-
cas
private CAS cas
The cas.
-
typeSystem
private TypeSystem typeSystem
The type system.
-
stringType
private Type stringType
The string type.
-
fsArrayType
private Type fsArrayType
The fs array type.
-
useConsistentColors
private boolean useConsistentColors
The use consistent colors.
-
highFrequencyTypes
private java.util.List<java.lang.String> highFrequencyTypes
The high frequency types.
-
boldFaceKeyWords
private java.lang.String[] boldFaceKeyWords
The bold face key words.
-
boldFaceSpans
private int[] boldFaceSpans
The bold face spans.
-
hiddenFeatureNames
private java.util.Set<java.lang.String> hiddenFeatureNames
The hidden feature names.
-
hiddenTypeNames
private java.util.Set<java.lang.String> hiddenTypeNames
The hidden type names.
-
displayedTypeNames
private java.util.Set<java.lang.String> displayedTypeNames
The displayed type names.
-
initiallySelectedTypeNames
private java.util.Set<java.lang.String> initiallySelectedTypeNames
The initially selected type names.
-
hideUnselectedCheckBoxes
private boolean hideUnselectedCheckBoxes
The hide unselected check boxes.
-
userTypes
private java.util.List<java.lang.String> userTypes
The user types.
-
typesNotChecked
private java.util.Set<java.lang.String> typesNotChecked
The types not checked.
-
typeColorMap
private java.util.Map<java.lang.String,java.awt.Color> typeColorMap
The type color map.
-
featureColorMap
private java.util.Map<java.lang.String,java.awt.Color> featureColorMap
The feature color map.
-
entityResolver
private EntityResolver entityResolver
The entity resolver.
-
viewMode
private short viewMode
The view mode.
-
typeToCheckBoxMap
private java.util.Map<Type,javax.swing.JCheckBox> typeToCheckBoxMap
The type to check box map.
-
entityToCheckBoxMap
private java.util.Map<EntityResolver.Entity,javax.swing.JCheckBox> entityToCheckBoxMap
The entity to check box map.
-
horizontalSplitPane
private javax.swing.JSplitPane horizontalSplitPane
The horizontal split pane.
-
verticalSplitPane
private javax.swing.JSplitPane verticalSplitPane
The vertical split pane.
-
textPane
private javax.swing.JTextPane textPane
The text pane.
-
textScrollPane
private javax.swing.JScrollPane textScrollPane
The text scroll pane.
-
typeRadioButtonMap
private java.util.Map<Type,javax.swing.JRadioButton> typeRadioButtonMap
The type radio button map.
-
featureRadioButtonMap
private java.util.Map<java.lang.String,javax.swing.JRadioButton> featureRadioButtonMap
The feature radio button map.
-
featureValueCheckBoxMap
private java.util.Map<java.lang.String,javax.swing.JCheckBox> featureValueCheckBoxMap
The feature value check box map.
-
featureValueColorMap
private java.util.Map<java.lang.String,java.awt.Color> featureValueColorMap
The feature value color map.
-
showHideUnselectedButton
private javax.swing.JButton showHideUnselectedButton
The show hide unselected button.
-
selectedAnnotationTree
private javax.swing.JTree selectedAnnotationTree
The selected annotation tree.
-
selectedAnnotationTreeModel
private javax.swing.tree.DefaultTreeModel selectedAnnotationTreeModel
The selected annotation tree model.
-
annotationModeButton
private javax.swing.JRadioButton annotationModeButton
The annotation mode button.
-
entityModeButton
private javax.swing.JRadioButton entityModeButton
The entity mode button.
-
featureModeButton
private javax.swing.JRadioButton featureModeButton
The feature mode button.
-
sofaSelectionPanel
private javax.swing.JPanel sofaSelectionPanel
The sofa selection panel.
-
sofaSelectionComboBox
private javax.swing.JComboBox sofaSelectionComboBox
The sofa selection combo box.
-
disableSofaSelectionComboBoxStateChangeAction
private boolean disableSofaSelectionComboBoxStateChangeAction
The disable sofa selection combo box state change action.
-
tabbedChoicePane
private javax.swing.JTabbedPane tabbedChoicePane
The tabbed choice pane.
-
typeCheckBoxScrollPane
private javax.swing.JScrollPane typeCheckBoxScrollPane
The type check box scroll pane.
-
typeCheckBoxVerticalScrollPanel
private CasAnnotationViewer.VerticallyScrollablePanel typeCheckBoxVerticalScrollPanel
The type check box vertical scroll panel.
-
entityCheckBoxScrollPane
private javax.swing.JScrollPane entityCheckBoxScrollPane
The entity check box scroll pane.
-
entityCheckBoxVerticalScrollPanel
private CasAnnotationViewer.VerticallyScrollablePanel entityCheckBoxVerticalScrollPanel
The entity check box vertical scroll panel.
-
typeRadioButtonScrollPane
private javax.swing.JScrollPane typeRadioButtonScrollPane
The type radio button scroll pane.
-
typeRadioButtonVerticalScrollPanel
private CasAnnotationViewer.VerticallyScrollablePanel typeRadioButtonVerticalScrollPanel
The type radio button vertical scroll panel.
-
featureRadioButtonScrollPane
private javax.swing.JScrollPane featureRadioButtonScrollPane
The feature radio button scroll pane.
-
featureRadioButtonVerticalScrollPanel
private CasAnnotationViewer.VerticallyScrollablePanel featureRadioButtonVerticalScrollPanel
The feature radio button vertical scroll panel.
-
featureValueCheckBoxScrollPane
private javax.swing.JScrollPane featureValueCheckBoxScrollPane
The feature value check box scroll pane.
-
featureValueCheckBoxVerticalScrollPanel
private CasAnnotationViewer.VerticallyScrollablePanel featureValueCheckBoxVerticalScrollPanel
The feature value check box vertical scroll panel.
-
-
Constructor Detail
-
CasAnnotationViewer
public CasAnnotationViewer()
Creates a CAS Annotation Viewer.
-
CasAnnotationViewer
@Deprecated public CasAnnotationViewer(boolean aEntityViewEnabled)
Deprecated.use the zero-argument constructorInstantiates a new cas annotation viewer.- Parameters:
aEntityViewEnabled
- the a entity view enabled
-
-
Method Detail
-
createControlPanel
private javax.swing.JPanel createControlPanel()
Creates the control panel.- Returns:
- the j panel
-
createSelectButtonPanel
private javax.swing.JPanel createSelectButtonPanel()
Creates the select button panel.- Returns:
- the j panel
-
createViewPanel
private javax.swing.JPanel createViewPanel()
Creates the view panel.- Returns:
- the j panel
-
createViewModePanel
private javax.swing.JPanel createViewModePanel()
Creates the view mode panel.- Returns:
- the j panel
-
createFeatureModeButton
private void createFeatureModeButton()
Creates the feature mode button.
-
createEntityModeButton
private void createEntityModeButton()
Creates the entity mode button.
-
createAnnotationModeButton
private void createAnnotationModeButton()
Creates the annotation mode button.
-
createSofaSelectionPanel
private void createSofaSelectionPanel()
Creates the sofa selection panel.
-
createSofaSelectionComboBox
private void createSofaSelectionComboBox()
Creates the sofa selection combo box.
-
createShowHideUnselectedButton
private void createShowHideUnselectedButton()
Creates the show hide unselected button.
-
createDeselectAllButton
private javax.swing.JButton createDeselectAllButton()
Creates the deselect all button.- Returns:
- the j button
-
createSelectAllButton
private javax.swing.JButton createSelectAllButton()
Creates the select all button.- Returns:
- the j button
-
resetTabbedPane
private void resetTabbedPane()
Re-populate the tabbed pane's tabs depending on the current view mode.
-
createHorizontalSplitPane
private void createHorizontalSplitPane()
Creates the horizontal split pane.
-
createTreePanel
private javax.swing.JPanel createTreePanel()
Creates the tree panel.- Returns:
- the j panel
-
createSelectedAnnotationTree
private void createSelectedAnnotationTree()
Creates the selected annotation tree.
-
createVerticalSplitPane
private void createVerticalSplitPane()
Creates the vertical split pane.
-
createTabbedChoicePane
private javax.swing.JTabbedPane createTabbedChoicePane()
Creates the tabbed choice pane.- Returns:
- the j tabbed pane
-
createFeatureValueCheckBoxPane
private void createFeatureValueCheckBoxPane()
Creates the feature value check box pane.
-
createFeatureRadioButtonPane
private void createFeatureRadioButtonPane()
Creates the feature radio button pane.
-
createTypeRadioButtonPane
private void createTypeRadioButtonPane()
Creates the type radio button pane.
-
createEntityCheckBoxPane
private void createEntityCheckBoxPane()
Creates the entity check box pane.
-
createTypeCheckBoxPane
private void createTypeCheckBoxPane()
Creates the type check box pane.
-
createTextScrollPane
private void createTextScrollPane()
Creates the text scroll pane.
-
getUserTypes
public java.util.List<java.lang.String> getUserTypes()
Gets the user types.- Returns:
- Returns the userTypes.
-
setUserTypes
public void setUserTypes(java.util.List<java.lang.String> userTypes)
Sets the user types.- Parameters:
userTypes
- The userTypes to set.
-
setHighFrequencyTypes
public void setHighFrequencyTypes(java.lang.String[] aTypeNames)
Set the list of types that occur most frequently. This method assigns the most distinguishable colors to these types.- Parameters:
aTypeNames
- names of types that are occur frequently. Ideally these should be ordered by frequency, with the most frequent being first.
-
setDisplayedTypes
public void setDisplayedTypes(java.lang.String[] aDisplayedTypeNames)
Set the list of types that will be highlighted in the viewer. Types not in this list will not appear in the legend and will never be highlighted. If this method is not called, the default is to show all types in the CAS (except those specifically hidden by a call tosetHiddenTypes(String[])
.- Parameters:
aDisplayedTypeNames
- names of types that are to be highlighted. Null indicates that all types in the CAS should be highlighted.
-
setHiddenTypes
public void setHiddenTypes(java.lang.String[] aTypeNames)
Set the list of types that will NOT be highlighted in the viewer.- Parameters:
aTypeNames
- names of types that are never to be highlighted.
-
setInitiallySelectedTypes
public void setInitiallySelectedTypes(java.lang.String[] aTypeNames)
Configures the initially selected types in the viewer. If not called, all types will be initially selected.- Parameters:
aTypeNames
- array of fully-qualified names of types to be initially selected
-
setHiddenFeatures
public void setHiddenFeatures(java.lang.String[] aFeatureNames)
Configures the viewer to hide certain features in the annotation deatail pane.- Parameters:
aFeatureNames
- array of (short) feature names to be hidden
-
setEntityResolver
public void setEntityResolver(EntityResolver aEntityResolver)
Sets theEntityResolver
to use when the viewer is in entity mode.- Parameters:
aEntityResolver
- user-supplied class that can determine which annotations correspond to the same entity.
-
setConsistentColors
public void setConsistentColors(boolean aConsistent)
Sets whether colors will be consistent in all documents viewed using this viewer. If set to true, assignments of color to annotation type will persist across documents; if false, colors will be reassigned in each new document. (Note that if high frequency types are set viasetHighFrequencyTypes(String[])
, the colors for those types will always be consistent, regardless of the value passed to this method.- Parameters:
aConsistent
- true (the default) causes colors to be consistent across documents, false allows them to vary
-
setRightToLeftTextOrientation
public void setRightToLeftTextOrientation(boolean aRightToLeft)
Sets the text orientation. The default is left-to-right, but needs to be set to right-to-left to properly display some languages, most notably Arabic and Hebrew.- Parameters:
aRightToLeft
- true to put the viewer in right-to-left mode, false for left-to-right (the default).
-
setHideUnselectedCheckboxes
public void setHideUnselectedCheckboxes(boolean aHideUnselected)
Sets whether unselected (unchecked) checkboxes will be hidden entirely from the legend. This mode makes for a cleaner legend at the expense of making it more difficult to toggle which types are selected. There's also a button in the GUI that lets the user change this setting.- Parameters:
aHideUnselected
- the new hide unselected checkboxes
-
setCAS
public void setCAS(CAS aCAS)
Sets the CAS to be viewed. This must be called beforedisplay()
.- Parameters:
aCAS
- the CSA to be viewed
-
initializeSofaSelectionPanel
private void initializeSofaSelectionPanel()
Initialize sofa selection panel.
-
reset
private void reset()
Reset.
-
resetSelectedAnnotationTree
private void resetSelectedAnnotationTree()
Reset selected annotation tree.
-
resetEntityCheckBoxPanel
private void resetEntityCheckBoxPanel()
Reset entity check box panel.
-
resetTypeCheckBoxPanel
private void resetTypeCheckBoxPanel()
Reset type check box panel.
-
resetFeatureValuePanel
private void resetFeatureValuePanel()
Reset feature value panel.
-
resetFeaturePanel
private void resetFeaturePanel()
Reset feature panel.
-
resetTypeRadioButtonPanel
private void resetTypeRadioButtonPanel()
Reset type radio button panel.
-
resetTypeColorMap
private void resetTypeColorMap()
Reset type color map.
-
applyBoldfaceToKeywords
public void applyBoldfaceToKeywords(java.lang.String[] aWords)
Causes the specified words to appear in boldface wherever they occur in the document. This is case-insensitive. Call this method aftersetCAS(CAS)
. It wil apply only to the current document, and will be reset on the next call tosetCAS(CAS)
.- Parameters:
aWords
- array of words to highlight in boldface.
-
applyBoldfaceToSpans
public void applyBoldfaceToSpans(int[] aSpans)
Causes the specified spans to appear in boldface. This is case-insensitive. Call this method aftersetCAS(CAS)
. It wil apply only to the current document, and will be reset on the next call tosetCAS(CAS)
.- Parameters:
aSpans
- spans to appear in boldface (begin1, end1, begin2, end2, ...)
-
configureViewForXmlFragmentsQuery
public void configureViewForXmlFragmentsQuery(java.lang.String aQuery, java.lang.String aTypeNamespace)
Configures the viewer appropriately for displaying a hit against an XML fragments query. This does not use a sophisticated algorithm for determining the location of the document that matched the query. Currently all it does is callsetInitiallySelectedTypes(String[])
with the list of types mentioned in the query andapplyBoldfaceToKeywords(String[])
on any keywords mentioned in the query.- Parameters:
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.
-
configureViewForXmlFragmentsQuery
public void configureViewForXmlFragmentsQuery(java.lang.String aQuery)
Configures the viewer appropriately for displaying a hit against an XML fragments query. This does not use a sophisticated algorithm for determining the location of the document that matched the query. Currently all it does is callsetInitiallySelectedTypes(String[])
with the list of types mentioned in the query andapplyBoldfaceToKeywords(String[])
on any keywords mentioned in the query.- Parameters:
aQuery
- an XML fragments query
-
assignCheckedFromList
public void assignCheckedFromList(java.util.List<java.lang.String> aNotChecked)
Assign initially checked to the specified types, pairing up down the lists.- Parameters:
aNotChecked
- list of types not to be initially checked JMP
-
assignColorsFromList
public void assignColorsFromList(java.util.List<java.awt.Color> aColors, java.util.List<java.lang.String> aTypeNames)
Assign colors to the specified types, pairing up down the lists.- Parameters:
aColors
- list of colorsaTypeNames
- list of type names JMP
-
assignTypeColors
private void assignTypeColors(java.util.List<java.lang.String> aTypeNames)
Assign colors to the specified types.- Parameters:
aTypeNames
- list of type names
-
display
private void display()
Creates/updates the display. This is called when setCAS() is called and again each time to user's mode or checkbox selections change.
-
displayFeatureView
private void displayFeatureView()
Create/update the feature view.
-
addFeatureValueCheckBoxes
private void addFeatureValueCheckBoxes()
Adds the feature value check boxes.
-
addFeatureRadioButtons
private void addFeatureRadioButtons()
Adds the feature radio buttons.
-
addTypeRadioButtons
private void addTypeRadioButtons()
Adds the type radio buttons.
-
processOneAnnotationInFeatureView
private boolean processOneAnnotationInFeatureView(javax.swing.text.StyledDocument doc, Annotation annotation, boolean firstType)
Examine an annotation and add type/feature/value-related controls if necessary.- Parameters:
doc
- the docannotation
- the annotationfirstType
- If true, the annotation being examined has the first type-related radio button that needs to be created and also set as selected.- Returns:
- If true, the annotation being examined has its type being selected, its feature-related radio buttons being displayed and one of its features being selected, and the feature's value is selected. So that the next annotation of different type will not have its features being displayed in the control panel.
-
processOneFeature
private boolean processOneFeature(javax.swing.text.StyledDocument doc, Annotation annotation, Feature feature, boolean firstFeature)
Examine one feature of the given annotation and create the feature-related controls.- Parameters:
doc
- the docannotation
- the annotationfeature
- the featurefirstFeature
- the first feature- Returns:
- true, if successful
-
processOneFeatureValue
private boolean processOneFeatureValue(javax.swing.text.StyledDocument doc, Annotation annotation, Feature feature)
Examine one feature of the given annotation and create the feature-value-related controls.- Parameters:
doc
- the docannotation
- the annotationfeature
- the feature- Returns:
- true, if successful
-
displayAnnotationView
private void displayAnnotationView()
Creates the annotation display.
-
addTypeCheckBoxes
private void addTypeCheckBoxes()
Adds the type check boxes.
-
processOneAnnotationInAnnotationView
private void processOneAnnotationInAnnotationView(javax.swing.text.StyledDocument doc, AnnotationFS annotation)
Process one annotation in annotation view.- Parameters:
doc
- the docannotation
- the annotation
-
displayEntityView
private void displayEntityView()
Creates the entity display.
-
processOneAnnotationInEntityView
private void processOneAnnotationInEntityView(javax.swing.text.StyledDocument doc, Annotation annotation)
Process one annotation in entity view.- Parameters:
doc
- the docannotation
- the annotation
-
updateSelectedAnnotationTree
private void updateSelectedAnnotationTree(int aPosition)
Refreshes the selected annotation tree.- Parameters:
aPosition
- the currently selected offset into the document. All annotations overlapping this point will be rendered in the tree.
-
isMatch
private boolean isMatch(Annotation annotation)
Check if an annotation matches the filters set by the user. If true, the annotation will be added to the annotation tree display panel.- Parameters:
annotation
- the annotation- Returns:
- true, if is match
-
addAnnotationToTree
protected void addAnnotationToTree(AnnotationFS aAnnotation)
Adds an annotation to the selected annotations tree. Annotations in the tree are grouped by type.- Parameters:
aAnnotation
- the annotation to add
-
addFeatureTreeNodes
private void addFeatureTreeNodes(javax.swing.tree.DefaultMutableTreeNode aParentNode, FeatureStructure aFS)
Adds the feature tree nodes.- Parameters:
aParentNode
- the a parent nodeaFS
- the a FS
-
getFeatureValueInString
private java.lang.String getFeatureValueInString(FeatureStructure aFS, Feature feature)
Get feature value in string, if value is not another annotation and not an array of annotations.- Parameters:
aFS
- the a FSfeature
- the feature- Returns:
- the feature value in string
-
checkString
private static java.lang.String checkString(java.lang.String stringValue, java.lang.String defaultIfNull, int maxLength)
Check if a string is null or longer than specified limit. If null, use default value. If longer than specified limit, take only the leading substring that would fit in the limit.- Parameters:
stringValue
- the string valuedefaultIfNull
- the default if nullmaxLength
- the max length- Returns:
- the string
-
typeNamesContains
private static boolean typeNamesContains(java.util.Set<java.lang.String> names, java.lang.String name)
Does wildcard matching to determine if a give type name is "contained" in a Set of type names.- Parameters:
names
- Type names, which may include wildcards (e.g, uima.tt.*)name
- A type name- Returns:
- True iff name matches a name in type names
-
wildCardMatch
private static boolean wildCardMatch(java.lang.String name, java.lang.String pattern)
Helper for#typeNamesContains(HashSet, String)
.- Parameters:
name
- A litteral stringpattern
- A string that includes one or more *'s as wildcards- Returns:
- True iff the string matches the pattern.
-
setSize
public void setSize(java.awt.Dimension d)
Sets the size.- Overrides:
setSize
in classjava.awt.Component
- Parameters:
d
- the new size- See Also:
Component.setSize(Dimension)
-
doBoldFace
private void doBoldFace()
Applies boldface as per the mBoldfaceKeywords and mBoldfaceSpans fields.
-
doBoldFaceBySpans
private void doBoldFaceBySpans()
Do bold face by spans.
-
doBoldFaceByKeyWords
private void doBoldFaceByKeyWords()
Do bold face by key words.
-
getSelectedAnnotationTree
protected javax.swing.JTree getSelectedAnnotationTree()
Gets the selected annotation tree component.- Returns:
- the tree that displays annotation details about annotations overlapping the point where the user last clicked in the text.
-
-