Class ContentRenderPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.text.JTextComponent
                          |
                          +--javax.swing.JEditorPane
                                |
                                +--javax.swing.JTextPane
                                      |
                                      +--ContentRenderPane
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.awt.dnd.Autoscroll, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, javax.swing.Scrollable, java.io.Serializable

public class ContentRenderPane
extends javax.swing.JTextPane
implements java.awt.event.ActionListener, java.awt.print.Printable, java.awt.dnd.Autoscroll

Provides a flattened view of a portion of an XML document, with fontification and styling.

Version:
$2007-05-01 03:24:30 mdh$
Author:
Malcolm D. Hyman
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JEditorPane
javax.swing.JEditorPane.AccessibleJEditorPane, javax.swing.JEditorPane.AccessibleJEditorPaneHTML, javax.swing.JEditorPane.JEditorPaneAccessibleHypertextSupport
 
Inner classes inherited from class javax.swing.text.JTextComponent
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.KeyBinding
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static java.awt.Insets defaultScrollInsets
           
protected  javax.swing.text.DefaultStyledDocument doc
           
protected  java.awt.Insets scrollInsets
           
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ContentRenderPane(ContentOwner owner, java.lang.String xmlFilename, boolean primary, boolean allowClose)
          Four-argument constructor.
ContentRenderPane(ContentOwner owner, java.lang.String xmlFilename, boolean primary, boolean allowClose, MorphologyTool morph, boolean async)
          Six-argument constructor for specifying initial MorphologyTool.
 
Method Summary
 void abort()
          Bails out of a time-consuming operation by raising bailFlag.
 void actionPerformed(java.awt.event.ActionEvent evt)
          This method handles the action commands generated by the popup menu.
 void addMorphAnalysis(java.lang.String variant, java.lang.String lang)
          Allows the user to add a morphological analysis.
 void adjustEditOffsets(int delta, DOMTextOffset dto)
          Adjust editTable after an edit.
 void autoscroll(java.awt.Point location)
           
 void buildMorphWidgets()
          Initially creates the widgets used for adding morphology.
 void checkTerm(java.lang.String word)
          Displays information from the termlist database.
 void cleanup()
          Cleans up, when it's time for us to give up the ghost.
 void clear()
          Creates a new document; clears nodeOffsets table and all highlights.
 void commitEdits()
          Commits edits (if needed).
static int computeWordNum(java.lang.String s, int loc, java.lang.String lang)
          For a location loc in s, returns n, where n means that l is located within the nth word in s.
 void contextMenu(int x, int y)
          Pops up a context menu when the mouse is clicked in the ContentRenderPane.
 javax.swing.text.Style copyAttributes(javax.swing.text.Style copyStyle, javax.swing.text.Style origStyle)
          Adds attributes from one style to another.
 void copyTermInstances()
          Copies term instances at cursor to system clipboard.
 javax.swing.text.StyleContext defineStyles()
          Creates some named styles in the current fontSize.
 boolean dropInLinks(java.io.Reader reader, java.lang.String mimeType)
          Allows links to be dragged into the document.
 void enterEditMode()
          Enters edit mode.
 void finalize()
           
 java.awt.Insets getAutoscrollInsets()
           
static java.awt.Color getColor(java.lang.String name)
          Gets a color from from Arboreal properties.
 org.w3c.dom.Node[] getDisplayedNodes()
          Returns the array of Nodes displayed in this pane.
 javax.swing.tree.TreePath[] getDisplayedPaths()
          Returns the array of TreePaths displayed in this pane.
 DOMTextOffset getDOMTextOffset(int ofs)
          Returns a DOMTextOffset object, which is used for editing.
 boolean getDragModifierFlag()
          Returns true if the drag modifier key (currently defined for all platforms as SHIFT) is depressed.
 int getFontSize()
          Returns the current font size.
 HighlightState getHighlightState()
          Returns the current highlight state.
 ContentRenderPane.LinkOffset getLinkNodeForOffset(int ofs)
          Returns a LinkOffset object that contains the linking DOM containing ofs -- or null if ofs isn't located within a linking node.
 LinkTool getLinkTool()
          Gets the LinkTool associated with this ContentRenderPane.
 javax.swing.tree.TreePath[] getMappedPaths()
          Returns an array of TreePaths in the master text, which are mapped to the displayed paths.
 MorphologyTool getMorphology()
          Returns the morphology tool used by this ContentRenderPane.
 NodeOffset getNodeForOffset(int ofs)
          Returns a NodeOffset object that contains the DOM node to which ofs in the ContentRenderPane belongs and the Amalgamation of text for that node, if the node is a container.
static int getOffsetOfWord(java.lang.String s, int n, java.lang.String lang)
          Returns the offset of the nth word in s (or null if there are fewer than n words in s.
 ContentOwner getOwner()
          Returns the owner of this ContentRenderPane.
 java.awt.Insets getScrollInsets()
           
 boolean getShowTags()
          Returns the value of showTags.
 SuperAmalgamation getSuperAmalgamation(org.w3c.dom.Node n)
          Gets a SuperAmalgamation on node n.
 java.lang.String getWordAtCaret()
          Returns the word in which the caret is located, or the word to left of the caret (if the caret is not within a word).
static java.lang.String getWordByNum(java.lang.String s, int n, java.lang.String lang)
          Returns the nth word in s (or null if there are fewer than n words in s.
 java.lang.String getXLinksForDisplayedNodes()
          Returns links for the displayed nodes.
 void hideContextMenu()
          Hides the context menu.
 void highlight(int startOfs, Amalgamation amalg)
          Highlights all occurrences of a string or regex in an Amalgamation.
 boolean isBusy()
          Returns true if the ContentRenderPane is currently busy.
 boolean isCaretInText()
          Determines whether the caret is located in the amalgamated text of some node.
 boolean isEditAllowed()
          Returns true if editing is allowed at the insertion point.
 boolean isInArborPanel()
          Returns true if this ContentRenderPane appears within an ArborPanel.
 boolean isInEditMode()
          Returns true if the pane is in "Edit" mode.
 boolean isNodeAtCaretMapped()
          Returns true if the node in which the caret is located is mapped to a node in the master text.
 boolean isPrimary()
          Returns true if this is the primary content pane for the master text.
 java.lang.Object[] lookupTerm(java.lang.String word, boolean disableAdd)
          Looks for term instances involving the given word, and using the currently attached TermTool.
 void lowerDragModifierFlag()
          Lowers the drag modifier flag.
 void markAsLinkPane(boolean value)
          Sets this pane as a "link pane."
 void markTerms(org.w3c.dom.Node n, DocSpec spec)
          Marks technical terms within a sentence, using a hash of technical term instances.
 void markTerms(org.w3c.dom.Node clink, org.w3c.dom.Node n, DocSpec spec)
          Marks technical terms within a sentence, using a link from a foreign document.
 void markWord(org.w3c.dom.Node container, java.lang.String word, int number, java.lang.String lang, SuperAmalgamation samalg)
          Adds a word highlight.
 ContentRenderPane.Run newRun(java.lang.Object style, java.lang.String content)
          Generates a new Run of text and tracks the generated document length.
 void openExternalLinks()
          Allows the users to view the targets of all links present in the selection in the corresponding JTree(s).
 void paint(java.awt.Graphics g)
          Overrides paint(), so that an ignorable exception can be caught.
 void paintHighlights(boolean clear)
          Paints find and term highlights.
 int print(java.awt.Graphics pg, java.awt.print.PageFormat pageFormat, int pageIndex)
          This method is part of the Printable interface.
 void queryCommitEdits()
          Queries the user whether s/he wishes to commit or cancel edits.
 void rebuildContextMenu()
          Rebuilds the context menu, after a ContentRenderPane has been dissociated from a tree (master text) view.
 void remapNodes()
          Remaps nodes.
 void render(org.w3c.dom.Node[] nodes, boolean clear)
          This version renders an array of nodes.
 void render(org.w3c.dom.Node node, boolean clear)
          Renders the content of a node in the XML DOM, with fontification and styling.
 void render(javax.swing.tree.TreePath[] paths, boolean clear)
          This version of render() renders multiple nodes, which are specified as a list of TreePaths.
 void render(javax.swing.tree.TreePath path, boolean clear)
          Renders the content of a node specified by a TreePath, with fontification and styling.
 void repaintHighlights()
          Updates the colors of highlighters and repaints.
 void replaceSelection(java.lang.String content)
          Overrides replaceSelection() in JEditorPane.
 ContentRenderPane replicate(boolean forcePrimary)
          Like clone(), but I didn't feel like dealing with the necessary casting (and use of the Cloneable interface).
 boolean rerenderIfNeeded()
          Rerenders the content if needed.
 void saveEdits()
          Commits edits and stops edit mode.
 void scrollRectToVisible(java.awt.Rectangle aRect)
          Overrides JComponent.scrollRectToVisible(), so as to disable scrolling generated in DefaultCaret.adjustVisibility().
 void setBlankLineMode(boolean value)
          Sets a flag that determines whether blank lines are rendered between individual containers.
 void setDropInProgress(boolean value)
          Sets the dropInProgress property.
 void setFontSize(int fontSize)
          Sets the current font size, within the range {MIN_FONT_SIZE..MAX_FONT_SIZE}.
 void setHighlightState(HighlightState highlightState)
          Installs a highlight, specified by a HighlightState.
 void setLinkingNodes(org.w3c.dom.Node[] linkingNodes)
          Sets linkingNodes, which contains the nodes that link to the displayed nodes.
 void setLinkTool(LinkTool linkTool)
          Sets the LinkTool associated with this ContentRenderPane.
 void setResultsMode(boolean value)
          In "results mode", XML tags are not shown, but IDs are displayed in green (if they exist).
 void setScrollInsets(java.awt.Insets insets)
           
 void setShowTags(boolean value)
          Sets the value of showTags.
 void setStyleContext(javax.swing.text.StyleContext sc)
          Sets the style context.
 void setTermHighlight(org.w3c.dom.Node node)
          Sets the term whose instances are shaded (in addition to the standard boxing).
 void setTermTool(TermTool terms)
          Attaches the given TermTool.
 void toggleShowTags()
          Toggles the value of showTags.
 void undoEdit()
          Cancels and reverses active edit.
 void useTermTool(java.lang.String command)
          Given the action command command, attaches the appropriate TermTool and calls checkTerm().
 void writeContents()
          Writes the contents of this pane to a user-selected file as a text file in UTF-8 encoding.
 void zapAllHighlights()
          Zaps all highlights.
 void zapHighlightPainters(javax.swing.text.Highlighter.HighlightPainter[] zap)
          Zaps highlights painted by the specified painters.
 void zapTermHighlights()
          This is a convenience method, since other classes should have to deal with the subtleties of zapHighlightPainters.
 void zapWordHighlights()
          This is a convenience method, since other classes should have to deal with the subtleties of zapHighlightPainters.
 
Methods inherited from class javax.swing.JTextPane
addStyle, createDefaultEditorKit, getCharacterAttributes, getInputAttributes, getLogicalStyle, getParagraphAttributes, getStyle, getStyledDocument, getStyledEditorKit, getUIClassID, insertComponent, insertIcon, paramString, removeStyle, setCharacterAttributes, setDocument, setEditorKit, setLogicalStyle, setParagraphAttributes, setStyledDocument
 
Methods inherited from class javax.swing.JEditorPane
addHyperlinkListener, createEditorKitForContentType, fireHyperlinkUpdate, getAccessibleContext, getContentType, getEditorKit, getEditorKitClassNameForContentType, getEditorKitForContentType, getPage, getPreferredSize, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getStream, getText, isFocusCycleRoot, isManagingFocus, processComponentKeyEvent, processKeyEvent, read, registerEditorKitForContentType, registerEditorKitForContentType, removeHyperlinkListener, scrollToReference, setContentType, setEditorKitForContentType, setPage, setPage, setText
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getActions, getCaret, getCaretColor, getCaretPosition, getDisabledTextColor, getDocument, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getUI, isEditable, isFocusTraversable, loadKeymap, modelToView, moveCaretPosition, paste, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, select, selectAll, setCaret, setCaretColor, setCaretPosition, setDisabledTextColor, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isLightweightComponent, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processFocusEvent, processKeyBinding, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

doc

protected javax.swing.text.DefaultStyledDocument doc

defaultScrollInsets

public static final java.awt.Insets defaultScrollInsets

scrollInsets

protected java.awt.Insets scrollInsets
Constructor Detail

ContentRenderPane

public ContentRenderPane(ContentOwner owner,
                         java.lang.String xmlFilename,
                         boolean primary,
                         boolean allowClose)
Four-argument constructor.
Parameters:
owner - ContentOwner
xmlFilename - XML filename
primary - is this the primary content pane?
allowClose - allow "Close" in context menu

ContentRenderPane

public ContentRenderPane(ContentOwner owner,
                         java.lang.String xmlFilename,
                         boolean primary,
                         boolean allowClose,
                         MorphologyTool morph,
                         boolean async)
Six-argument constructor for specifying initial MorphologyTool.
Parameters:
owner - ContentOwner
xmlFilename - XML filename
primary - is this the primary content pane?
morph - morphology tool
async - use asynchronous layout
Method Detail

replaceSelection

public void replaceSelection(java.lang.String content)
Overrides replaceSelection() in JEditorPane.
Overrides:
replaceSelection in class javax.swing.JTextPane
Parameters:
content - content to replace

adjustEditOffsets

public void adjustEditOffsets(int delta,
                              DOMTextOffset dto)
Adjust editTable after an edit.
Parameters:
delta - length change
dto - current DOMTextOffset

setDropInProgress

public void setDropInProgress(boolean value)
Sets the dropInProgress property.
Parameters:
value - true if DnD drop onto this target in progress

dropInLinks

public boolean dropInLinks(java.io.Reader reader,
                           java.lang.String mimeType)
Allows links to be dragged into the document.
Parameters:
reader - reader that supplies term instances in XML fragment
mimeType - mimetype of dropped links
Returns:
true if links were inserted

queryCommitEdits

public void queryCommitEdits()
Queries the user whether s/he wishes to commit or cancel edits.

commitEdits

public void commitEdits()
Commits edits (if needed).

saveEdits

public void saveEdits()
Commits edits and stops edit mode.

undoEdit

public void undoEdit()
Cancels and reverses active edit.

remapNodes

public void remapNodes()
Remaps nodes.

isPrimary

public boolean isPrimary()
Returns true if this is the primary content pane for the master text.
Returns:
is this the primary content pane?

markAsLinkPane

public void markAsLinkPane(boolean value)
Sets this pane as a "link pane."
Parameters:
value - true if link pane

defineStyles

public javax.swing.text.StyleContext defineStyles()
Creates some named styles in the current fontSize.

setStyleContext

public void setStyleContext(javax.swing.text.StyleContext sc)
Sets the style context.
Parameters:
sc - new style context

getFontSize

public int getFontSize()
Returns the current font size.
Returns:
current font size (in points)

setFontSize

public void setFontSize(int fontSize)
Sets the current font size, within the range {MIN_FONT_SIZE..MAX_FONT_SIZE}.
Parameters:
fontSize - new font size

setBlankLineMode

public void setBlankLineMode(boolean value)
Sets a flag that determines whether blank lines are rendered between individual containers.
Parameters:
value - true to display extra blank lines

setHighlightState

public void setHighlightState(HighlightState highlightState)
Installs a highlight, specified by a HighlightState.
Parameters:
highlightState - highlight state information

getHighlightState

public HighlightState getHighlightState()
Returns the current highlight state.
Returns:
highlight state information

setTermHighlight

public void setTermHighlight(org.w3c.dom.Node node)
Sets the term whose instances are shaded (in addition to the standard boxing).
Parameters:
node - term element in termlist DOM

zapHighlightPainters

public void zapHighlightPainters(javax.swing.text.Highlighter.HighlightPainter[] zap)
Zaps highlights painted by the specified painters.
Parameters:
zap - array of highlight painters

zapAllHighlights

public void zapAllHighlights()
Zaps all highlights. Unfortunately, we need this method for the reason that removeAllHighlights() in DefaultHighlighter does not allow for mixed layered/non-layered highlights. If we were to call removeAllHighlights() there would be exceptions thrown.

zapTermHighlights

public void zapTermHighlights()
This is a convenience method, since other classes should have to deal with the subtleties of zapHighlightPainters.

zapWordHighlights

public void zapWordHighlights()
This is a convenience method, since other classes should have to deal with the subtleties of zapHighlightPainters.

setLinkTool

public void setLinkTool(LinkTool linkTool)
Sets the LinkTool associated with this ContentRenderPane.
Parameters:
linkTool - LinkTool

getLinkTool

public LinkTool getLinkTool()
Gets the LinkTool associated with this ContentRenderPane.
Returns:
LinkTool

setLinkingNodes

public void setLinkingNodes(org.w3c.dom.Node[] linkingNodes)
Sets linkingNodes, which contains the nodes that link to the displayed nodes.
Parameters:
linkingNodes - linking nodes

toggleShowTags

public void toggleShowTags()
Toggles the value of showTags.

getShowTags

public boolean getShowTags()
Returns the value of showTags.
Returns:
true if tags are shown

setShowTags

public void setShowTags(boolean value)
Sets the value of showTags.
Parameters:
value - true if tags are to be shown

setResultsMode

public void setResultsMode(boolean value)
In "results mode", XML tags are not shown, but IDs are displayed in green (if they exist).
Parameters:
value - true for results mode

isBusy

public boolean isBusy()
Returns true if the ContentRenderPane is currently busy.
Returns:
true if busy

abort

public void abort()
Bails out of a time-consuming operation by raising bailFlag.

render

public void render(javax.swing.tree.TreePath[] paths,
                   boolean clear)
This version of render() renders multiple nodes, which are specified as a list of TreePaths.
Parameters:
paths - paths to relevant nodes
clear - true if pane should be cleared first

render

public void render(org.w3c.dom.Node[] nodes,
                   boolean clear)
This version renders an array of nodes.
Parameters:
nodes - nodes to be rendered
clear - true if pane should be cleared first

render

public void render(javax.swing.tree.TreePath path,
                   boolean clear)
Renders the content of a node specified by a TreePath, with fontification and styling.
Parameters:
path - path to relevant node
clear - true if pane should be cleared first

render

public void render(org.w3c.dom.Node node,
                   boolean clear)
Renders the content of a node in the XML DOM, with fontification and styling.
Parameters:
node - node of DOM tree
clear - true if pane should be cleared first

highlight

public void highlight(int startOfs,
                      Amalgamation amalg)
Highlights all occurrences of a string or regex in an Amalgamation.
Parameters:
startOfs - offset for beginning of given node
amalg - amalgamation of text nodes

markTerms

public void markTerms(org.w3c.dom.Node n,
                      DocSpec spec)
Marks technical terms within a sentence, using a hash of technical term instances.
Parameters:
n - container or subcontainer
spec - document specification

markTerms

public void markTerms(org.w3c.dom.Node clink,
                      org.w3c.dom.Node n,
                      DocSpec spec)
Marks technical terms within a sentence, using a link from a foreign document.
Parameters:
clink - term instance node
n - container or subcontainer
spec - document specification

getSuperAmalgamation

public SuperAmalgamation getSuperAmalgamation(org.w3c.dom.Node n)
Gets a SuperAmalgamation on node n.
Parameters:
n - container node
Returns:
SuperAmalgamation

markWord

public void markWord(org.w3c.dom.Node container,
                     java.lang.String word,
                     int number,
                     java.lang.String lang,
                     SuperAmalgamation samalg)
Adds a word highlight.
Parameters:
container - the container node
word - the word (variant form)
number - occurrence number of word
lang - language of the word
samalg - SuperAmalgamation on the container

computeWordNum

public static int computeWordNum(java.lang.String s,
                                 int loc,
                                 java.lang.String lang)
For a location loc in s, returns n, where n means that l is located within the nth word in s.
Parameters:
s - source
loc - offset in target
lang - language of s
Returns:
count of word containing l in s

getWordByNum

public static java.lang.String getWordByNum(java.lang.String s,
                                            int n,
                                            java.lang.String lang)
Returns the nth word in s (or null if there are fewer than n words in s.
Parameters:
s - source
n - word number
lang - language of s
Returns:
word

getOffsetOfWord

public static int getOffsetOfWord(java.lang.String s,
                                  int n,
                                  java.lang.String lang)
Returns the offset of the nth word in s (or null if there are fewer than n words in s.
Parameters:
s - source
n - word number
lang - language of s
Returns:
offset of n word

rerenderIfNeeded

public boolean rerenderIfNeeded()
Rerenders the content if needed. (Makes use of editTable).
Returns:
true if rerender was needed

clear

public void clear()
Creates a new document; clears nodeOffsets table and all highlights.

paintHighlights

public void paintHighlights(boolean clear)
Paints find and term highlights.
Parameters:
clear - true if word highlight should be cleared

copyAttributes

public javax.swing.text.Style copyAttributes(javax.swing.text.Style copyStyle,
                                             javax.swing.text.Style origStyle)
Adds attributes from one style to another.
Parameters:
copyStyle - style to serve as base for copy
origStyle - style with attributes to copy
Returns:
style copy

newRun

public ContentRenderPane.Run newRun(java.lang.Object style,
                                    java.lang.String content)
Generates a new Run of text and tracks the generated document length.
Parameters:
style - a style or style name (from current style context)
content - text content

rebuildContextMenu

public void rebuildContextMenu()
Rebuilds the context menu, after a ContentRenderPane has been dissociated from a tree (master text) view.

hideContextMenu

public void hideContextMenu()
Hides the context menu.

getDragModifierFlag

public boolean getDragModifierFlag()
Returns true if the drag modifier key (currently defined for all platforms as SHIFT) is depressed.
Returns:
true if drag modifier held down

lowerDragModifierFlag

public void lowerDragModifierFlag()
Lowers the drag modifier flag.

getDOMTextOffset

public DOMTextOffset getDOMTextOffset(int ofs)
Returns a DOMTextOffset object, which is used for editing.
Returns:
DOM text correlation object

getNodeForOffset

public NodeOffset getNodeForOffset(int ofs)
Returns a NodeOffset object that contains the DOM node to which ofs in the ContentRenderPane belongs and the Amalgamation of text for that node, if the node is a container.
Returns:
node offset table entry

isCaretInText

public boolean isCaretInText()
Determines whether the caret is located in the amalgamated text of some node. This method sets the following global variables:

This method behaves differently when in edit mode.

Returns:
true if caret in amalgamated text

getWordAtCaret

public java.lang.String getWordAtCaret()
Returns the word in which the caret is located, or the word to left of the caret (if the caret is not within a word). (Fails, and beeps, if if no word can be located.)
Returns:
word in which caret is located (or null)

getLinkNodeForOffset

public ContentRenderPane.LinkOffset getLinkNodeForOffset(int ofs)
Returns a LinkOffset object that contains the linking DOM containing ofs -- or null if ofs isn't located within a linking node.
Returns:
link offset table entry

isNodeAtCaretMapped

public boolean isNodeAtCaretMapped()
Returns true if the node in which the caret is located is mapped to a node in the master text. As a side effect, currentMappedNodes is set to the list of mapped nodes (or null).
Returns:
true if current node is mapped

openExternalLinks

public void openExternalLinks()
Allows the users to view the targets of all links present in the selection in the corresponding JTree(s).

print

public int print(java.awt.Graphics pg,
                 java.awt.print.PageFormat pageFormat,
                 int pageIndex)
          throws java.awt.print.PrinterException
This method is part of the Printable interface.
Specified by:
print in interface java.awt.print.Printable

repaintHighlights

public void repaintHighlights()
Updates the colors of highlighters and repaints.

getColor

public static java.awt.Color getColor(java.lang.String name)
Gets a color from from Arboreal properties.
Parameters:
name - symbolic color name
Returns:
color

contextMenu

public void contextMenu(int x,
                        int y)
Pops up a context menu when the mouse is clicked in the ContentRenderPane.
Parameters:
x - x coordinate
y - y coordinate

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
This method handles the action commands generated by the popup menu.
Specified by:
actionPerformed in interface java.awt.event.ActionListener

isInArborPanel

public boolean isInArborPanel()
Returns true if this ContentRenderPane appears within an ArborPanel.
Returns:
true if contained in ArborPanel

getMorphology

public MorphologyTool getMorphology()
Returns the morphology tool used by this ContentRenderPane.
Returns:
current MorphologyTool

buildMorphWidgets

public void buildMorphWidgets()
Initially creates the widgets used for adding morphology.

addMorphAnalysis

public void addMorphAnalysis(java.lang.String variant,
                             java.lang.String lang)
Allows the user to add a morphological analysis.
Parameters:
variant - variant form (in text)
lang - language code

enterEditMode

public void enterEditMode()
Enters edit mode.

isInEditMode

public boolean isInEditMode()
Returns true if the pane is in "Edit" mode.
Returns:
true if in "Edit" mode

isEditAllowed

public boolean isEditAllowed()
Returns true if editing is allowed at the insertion point.
Returns:
true if editing allowed

copyTermInstances

public void copyTermInstances()
Copies term instances at cursor to system clipboard. Data are in XML format.

useTermTool

public void useTermTool(java.lang.String command)
Given the action command command, attaches the appropriate TermTool and calls checkTerm().
Parameters:
command - term command

setTermTool

public void setTermTool(TermTool terms)
Attaches the given TermTool.
Parameters:
terms - term tool

lookupTerm

public java.lang.Object[] lookupTerm(java.lang.String word,
                                     boolean disableAdd)
Looks for term instances involving the given word, and using the currently attached TermTool.
Parameters:
word - word to check in terminology database
disableAdd - don't open term editor if not found
Returns:
a blobject, with multiple parameters

checkTerm

public void checkTerm(java.lang.String word)
Displays information from the termlist database.
Parameters:
word - word to check in terminology database

replicate

public ContentRenderPane replicate(boolean forcePrimary)
Like clone(), but I didn't feel like dealing with the necessary casting (and use of the Cloneable interface). Martha, by the way, has some very interesting material on cloning (the human kind). (vide Amazon)
Parameters:
forcePrimary - force copy to be marked as primary
Returns:
a functional copy of this ContentRenderPane

writeContents

public void writeContents()
Writes the contents of this pane to a user-selected file as a text file in UTF-8 encoding.

getDisplayedNodes

public org.w3c.dom.Node[] getDisplayedNodes()
Returns the array of Nodes displayed in this pane.
Returns:
displayed nodes

getDisplayedPaths

public javax.swing.tree.TreePath[] getDisplayedPaths()
Returns the array of TreePaths displayed in this pane.
Returns:
displayed paths

getMappedPaths

public javax.swing.tree.TreePath[] getMappedPaths()
Returns an array of TreePaths in the master text, which are mapped to the displayed paths.
Returns:
mapped paths

getXLinksForDisplayedNodes

public java.lang.String getXLinksForDisplayedNodes()
Returns links for the displayed nodes. If a valid WordTokenTable exists, then links are generated that point to the selected words and their containers.
Returns:
string of XPaths

getOwner

public ContentOwner getOwner()
Returns the owner of this ContentRenderPane.
Returns:
owner

cleanup

public void cleanup()
Cleans up, when it's time for us to give up the ghost.

scrollRectToVisible

public void scrollRectToVisible(java.awt.Rectangle aRect)
Overrides JComponent.scrollRectToVisible(), so as to disable scrolling generated in DefaultCaret.adjustVisibility().
Overrides:
scrollRectToVisible in class javax.swing.JComponent
Parameters:
aRect - rectangle to be made visible (ignored here!)

finalize

public void finalize()
              throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object

paint

public void paint(java.awt.Graphics g)
Overrides paint(), so that an ignorable exception can be caught.
Overrides:
paint in class javax.swing.JComponent
Parameters:
g - graphics context

setScrollInsets

public void setScrollInsets(java.awt.Insets insets)

getScrollInsets

public java.awt.Insets getScrollInsets()

getAutoscrollInsets

public java.awt.Insets getAutoscrollInsets()
Specified by:
getAutoscrollInsets in interface java.awt.dnd.Autoscroll

autoscroll

public void autoscroll(java.awt.Point location)
Specified by:
autoscroll in interface java.awt.dnd.Autoscroll