org.xhtmlrenderer.swing
Class SelectionHighlighter

java.lang.Object
  extended by org.xhtmlrenderer.swing.SelectionHighlighter
All Implemented Interfaces:
MouseListener, MouseMotionListener, EventListener

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's DefaultCaret

Author:
Nick Reddel

Nested Class Summary
static class SelectionHighlighter.CopyAction
           
 class SelectionHighlighter.ViewModelInfo
           
 
Field Summary
protected  ChangeEvent changeEvent
           
static String copyAction
           
protected  EventListenerList listenerList
           
 
Constructor Summary
SelectionHighlighter()
           
 
Method Summary
 void addChangeListener(ChangeListener l)
           
protected  void adjustVisibility(Rectangle nloc)
           
protected  MouseEvent convertMouseEventToScale(MouseEvent e)
           
 void deinstall(XHTMLPanel panel)
           
protected  void fireStateChanged()
           
 XHTMLPanel getComponent()
           
 org.w3c.dom.ranges.Range getSelectionRange()
           
 void install(XHTMLPanel panel)
           
 void mouseClicked(MouseEvent e)
           
 void mouseDragged(MouseEvent e)
           
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
protected  void moveCaret(MouseEvent e)
           
 void moveDot(SelectionHighlighter.ViewModelInfo pos)
           
 String normalizeSpaces(String s)
           
 void removeChangeListener(ChangeListener l)
           
 void selectAll()
           
 void setDot(SelectionHighlighter.ViewModelInfo pos)
           
 void setHandler(TransferHandler handler)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listenerList

protected EventListenerList listenerList

changeEvent

protected transient ChangeEvent changeEvent

copyAction

public static final String copyAction
See Also:
Constant Field Values
Constructor Detail

SelectionHighlighter

public SelectionHighlighter()
Method Detail

addChangeListener

public void addChangeListener(ChangeListener l)

removeChangeListener

public void removeChangeListener(ChangeListener l)

fireStateChanged

protected void fireStateChanged()

install

public void install(XHTMLPanel panel)

deinstall

public void deinstall(XHTMLPanel panel)

setDot

public void setDot(SelectionHighlighter.ViewModelInfo pos)

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener

getComponent

public XHTMLPanel getComponent()

moveCaret

protected void moveCaret(MouseEvent e)

selectAll

public void selectAll()

moveDot

public void moveDot(SelectionHighlighter.ViewModelInfo pos)

normalizeSpaces

public String normalizeSpaces(String s)

getSelectionRange

public org.w3c.dom.ranges.Range getSelectionRange()

adjustVisibility

protected void adjustVisibility(Rectangle nloc)

convertMouseEventToScale

protected MouseEvent convertMouseEventToScale(MouseEvent e)

setHandler

public void setHandler(TransferHandler handler)


Copyright © 2013. All Rights Reserved.