public class CasAnnotationViewer extends JPanel
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.Modifier and Type | Class and Description |
---|---|
class |
CasAnnotationViewer.DefaultEntityResolver
Trivial entity resolver that's applied if the user turns on entity mode without
specifying their own entity resolver.
|
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
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 |
---|---|
protected void |
addAnnotationToTree(AnnotationFS aAnnotation)
Adds an annotation to the selected annotations tree.
|
void |
applyBoldfaceToKeywords(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(List<String> aNotChecked)
Assign initially checked to the specified types, pairing up down the lists
|
void |
assignColorsFromList(List<Color> aColors,
List<String> aTypeNames)
Assign colors to the specified types, pairing up down the lists
|
void |
configureViewForXmlFragmentsQuery(String aQuery)
Configures the viewer appropriately for displaying a hit against an XML fragments query.
|
void |
configureViewForXmlFragmentsQuery(String aQuery,
String aTypeNamespace)
Configures the viewer appropriately for displaying a hit against an XML fragments query.
|
protected JTree |
getSelectedAnnotationTree()
Gets the selected annotation tree component.
|
List<String> |
getUserTypes() |
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(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 |
setHiddenFeatures(String[] aFeatureNames)
Configures the viewer to hide certain features in the annotation deatail pane.
|
void |
setHiddenTypes(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(String[] aTypeNames)
Set the list of types that occur most frequently.
|
void |
setInitiallySelectedTypes(String[] aTypeNames)
Configures the initially selected types in the viewer.
|
void |
setRightToLeftTextOrientation(boolean aRightToLeft)
Sets the text orientation.
|
void |
setSize(Dimension d) |
void |
setUserTypes(List<String> userTypes) |
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, 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
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, 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 void setUserTypes(List<String> userTypes)
userTypes
- The userTypes to set.public void setHighFrequencyTypes(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(String[] aDisplayedTypeNames)
setHiddenTypes(String[])
.aDisplayedTypeNames
- names of types that are to be highlighted. Null indicates that all types in the CAS
should be highlighted.public void setHiddenTypes(String[] aTypeNames)
aTypeNames
- names of types that are never to be highlighted.public void setInitiallySelectedTypes(String[] aTypeNames)
aTypeNames
- array of fully-qualified names of types to be initially selectedpublic void setHiddenFeatures(String[] aFeatureNames)
aFeatureNames
- array of (short) feature names to be hiddenpublic 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)
aHideUnselected
- public void setCAS(CAS aCAS)
display()
.aCAS
- the CSA to be viewedpublic void applyBoldfaceToKeywords(String[] aWords)
setCAS(CAS)
. It wil apply only to the current
document, and will be reset on the next call to setCAS(CAS)
.aWords
- array of words to highlight in boldface.public void applyBoldfaceToSpans(int[] aSpans)
setCAS(CAS)
. It wil apply only to the current document, and will be reset on the
next call to setCAS(CAS)
.aSpans
- spans to appear in boldface (begin1, end1, begin2, end2, ...)public void configureViewForXmlFragmentsQuery(String aQuery, String aTypeNamespace)
setInitiallySelectedTypes(String[])
with the list of types mentioned in the query and applyBoldfaceToKeywords(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(String aQuery)
setInitiallySelectedTypes(String[])
with the list of types mentioned in the query and applyBoldfaceToKeywords(String[])
on
any keywords mentioned in the query.aQuery
- an XML fragments querypublic void assignCheckedFromList(List<String> aNotChecked)
aNotChecked
- list of types not to be initially checked JMPpublic void assignColorsFromList(List<Color> aColors, List<String> aTypeNames)
aColors
- list of colorsaTypeNames
- list of type names JMPprotected void addAnnotationToTree(AnnotationFS aAnnotation)
aAnnotation
- the annotation to addpublic void setSize(Dimension d)
setSize
in class Component
Component.setSize(Dimension)
protected JTree getSelectedAnnotationTree()
Copyright © 2006–2017 The Apache Software Foundation. All rights reserved.