Package org.xhtmlrenderer.swing
Class SelectionHighlighter
java.lang.Object
org.xhtmlrenderer.swing.SelectionHighlighter
- All Implemented Interfaces:
MouseListener
,MouseMotionListener
,EventListener
@ParametersAreNonnullByDefault
public class SelectionHighlighter
extends Object
implements MouseMotionListener, MouseListener
A simple Selection and Highlighter class for
XHTMLPanel
.
The current selection is available as a DOM Range via getSelectionRange. There is also a Swing
action to copy the selection contents to the clipboard:
SelectionHighlighter.CopyAction
, which
should be installed on the SelectionHighlighter
Usage: create the XHTMLPanel, create an instance of this class then call install. See also: /demos/samples/src/SelectionHighlighterTest.java
With thanks to Swing'sDefaultCaret
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
private class
private static final record
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChangeEvent
static final String
private DocumentRange
private DocumentTraversal
private Document
private TransferHandler
private String
private Range
private final EventListenerList
private XHTMLPanel
private static final String
private Map<Node,
List<InlineText>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
private void
Adjusts the caret location based on the MouseEvent.(package private) void
private void
Adjusts the focus, if necessary.protected void
adjustVisibility
(Rectangle nloc) private boolean
protected MouseEvent
(package private) void
copy()
private static NodeFilter
createFilter
(Range range, Range acceptRange) private boolean
void
deinstall
(XHTMLPanel panel) protected void
private Box
getBoxForElement
(Element elt) (package private) List<InlineLayoutBox>
private List<InlineText>
private int
getTextWidth
(LayoutContext c, CalculatedStyle cs, String s) (package private) SelectionHighlighter.ViewModelInfo
void
install
(XHTMLPanel panel) void
void
void
void
void
void
void
protected void
void
private String
private void
void
void
void
void
setHandler
(TransferHandler handler) private void
private void
-
Field Details
-
PARA_EQUIV
- See Also:
-
panel
-
dotInfo
-
markInfo
-
listenerList
-
changeEvent
-
docRange
-
lastSelectionRange
-
docTraversal
-
elementBoxMap
-
textInlineMap
-
lastHighlightedString
-
handler
-
document
-
copyAction
- See Also:
-
-
Constructor Details
-
SelectionHighlighter
public SelectionHighlighter()
-
-
Method Details
-
addChangeListener
-
removeChangeListener
-
fireStateChanged
protected void fireStateChanged() -
install
-
deinstall
-
checkDocument
private boolean checkDocument() -
setDot
-
mouseDragged
- Specified by:
mouseDragged
in interfaceMouseMotionListener
-
mouseMoved
- Specified by:
mouseMoved
in interfaceMouseMotionListener
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
- Specified by:
mouseExited
in interfaceMouseListener
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
-
adjustCaretAndFocus
-
adjustCaret
Adjusts the caret location based on the MouseEvent. -
positionCaret
-
adjustFocus
private void adjustFocus()Adjusts the focus, if necessary. -
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
-
getComponent
-
moveCaret
-
selectAll
public void selectAll() -
moveDot
-
updateHighlights
private void updateHighlights() -
createFilter
-
normalizeSpaces
-
createMaps
private boolean createMaps() -
getInlineTextsForText
-
getBoxForElement
-
updateSystemSelection
private void updateSystemSelection() -
copy
void copy() -
getInlineLayoutBoxes
-
infoFromPoint
-
getTextWidth
-
getSelectionRange
-
adjustVisibility
-
convertMouseEventToScale
-
setHandler
-