org.icepdf.core.views.common
Class TextSelectionPageHandler

java.lang.Object
  extended by org.icepdf.core.views.common.SelectionBoxHandler
      extended by org.icepdf.core.views.common.TextSelectionPageHandler
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener

public class TextSelectionPageHandler
extends SelectionBoxHandler
implements javax.swing.event.MouseInputListener

Handles Paint and mouse/keyboard logic around text selection and search highlighting. there is on text handler isntance of each pageComponent used to dispaly the document.

The highlight colour by default is #FFF600 but can be set using color or hex values names using the system property "org.icepdf.core.views.page.text.highlightColor"

The highlight colour by default is #FFF600 but can be set using color or hex values names using the system property "org.icepdf.core.views.page.text.selectionColor"

Since:
4.0

Field Summary
static java.awt.Color highlightColor
           
static float selectionAlpha
          Tranparencey value used to simulate text highlighting.
static java.awt.Color selectionColor
           
 
Fields inherited from class org.icepdf.core.views.common.SelectionBoxHandler
currentRect, dash1, previousRectDrawn, rectToDraw, selectionBoxColour, stroke
 
Constructor Summary
TextSelectionPageHandler(AbstractPageViewComponent pageViewComponent, DocumentViewModel documentViewModel)
          New Text selection handler.
 
Method Summary
 void clearSelection()
           
 void mouseClicked(java.awt.event.MouseEvent e)
          When mouse is double clicked we select the word the mouse if over.
 void mouseDragged(java.awt.event.MouseEvent e)
          Invoked when a mouse button is pressed on a component and then dragged.
 void mouseEntered(java.awt.event.MouseEvent e)
          Invoked when the mouse enters a component.
 void mouseExited(java.awt.event.MouseEvent e)
          Invoked when the mouse exits a component.
 void mouseMoved(java.awt.event.MouseEvent e)
          Invoked when the mouse cursor has been moved onto a component but no buttons have been pushed.
 void mousePressed(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been pressed on a component.
 void mouseReleased(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been released on a component.
 void paintSelectedText(java.awt.Graphics g)
          Utility for painting the highlight and selected
 void setDocumentViewController(DocumentViewController documentViewController)
          Document view controller callback setup.
 void setSelectionRectangle(java.awt.Point cursorLocation, java.awt.Rectangle selection)
           
 
Methods inherited from class org.icepdf.core.views.common.SelectionBoxHandler
clearRectangle, getCurrentRect, getRectToDraw, paintSelectionBox, resetRectangle, setCurrentRect, setRectToDraw, setSelectionSize, updateDrawableRect, updateSelectionSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

selectionAlpha

public static final float selectionAlpha
Tranparencey value used to simulate text highlighting.

See Also:
Constant Field Values

selectionColor

public static java.awt.Color selectionColor

highlightColor

public static java.awt.Color highlightColor
Constructor Detail

TextSelectionPageHandler

public TextSelectionPageHandler(AbstractPageViewComponent pageViewComponent,
                                DocumentViewModel documentViewModel)
New Text selection handler. Make sure to correctly and and remove this mouse and text listeners.

Parameters:
pageViewComponent - page component that this handler is bound to.
documentViewModel - view model.
Method Detail

setDocumentViewController

public void setDocumentViewController(DocumentViewController documentViewController)
Document view controller callback setup. Has to be done after the contructor.

Parameters:
documentViewController - document controller callback.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
When mouse is double clicked we select the word the mouse if over. When the mouse is triple clicked we select the line of text that the mouse is over.

Specified by:
mouseClicked in interface java.awt.event.MouseListener

clearSelection

public void clearSelection()

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Invoked when a mouse button has been pressed on a component.

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Invoked when a mouse button has been released on a component.

Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Invoked when the mouse enters a component.

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Invoked when the mouse exits a component.

Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Invoked when a mouse button is pressed on a component and then dragged. MOUSE_DRAGGED events will continue to be delivered to the component where the drag originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).

Due to platform-dependent Drag&Drop implementations, MOUSE_DRAGGED events may not be delivered during a native Drag&Drop operation.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

setSelectionRectangle

public void setSelectionRectangle(java.awt.Point cursorLocation,
                                  java.awt.Rectangle selection)

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Invoked when the mouse cursor has been moved onto a component but no buttons have been pushed.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

paintSelectedText

public void paintSelectedText(java.awt.Graphics g)
Utility for painting the highlight and selected

Parameters:
g - graphics to paint to.