org.icepdf.ri.common.tools
Class TextSelectionPageHandler

java.lang.Object
  extended by org.icepdf.ri.common.tools.CommonToolHandler
      extended by org.icepdf.ri.common.tools.SelectionBoxHandler
          extended by org.icepdf.ri.common.tools.TextSelection
              extended by org.icepdf.ri.common.tools.TextSelectionPageHandler
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener, ToolHandler
Direct Known Subclasses:
HighLightAnnotationHandler

public class TextSelectionPageHandler
extends TextSelection
implements ToolHandler

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
 
Fields inherited from class org.icepdf.ri.common.tools.TextSelection
bottomMargin, bottomMarginExclusion, enableMarginExclusion, enableMarginExclusionBorder, lastMouseLocation, lastMousePressedLocation, logger, pageLock, selectedCount, topMargin, topMarginExclusion
 
Fields inherited from class org.icepdf.ri.common.tools.SelectionBoxHandler
currentRect, dash1, previousRectDrawn, rectToDraw, selectionBoxColour, stroke
 
Fields inherited from class org.icepdf.ri.common.tools.CommonToolHandler
documentViewController, documentViewModel, pageViewComponent
 
Constructor Summary
TextSelectionPageHandler(DocumentViewController documentViewController, AbstractPageViewComponent pageViewComponent, DocumentViewModel documentViewModel)
          New Text selection handler.
 
Method Summary
protected  java.awt.Rectangle convertToPageSpace(java.util.ArrayList<java.awt.Shape> bounds, java.awt.geom.GeneralPath path)
          Convert the shapes that make up the annotation to page space so that they will scale correctly at different zooms.
 void installTool()
          Callback code that allows post construct task to take place when the tool is selected via the AbstractDocumentView.setToolMode(int) call.
 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 paintTool(java.awt.Graphics g)
          Paints the tools pre-annotation creation state.
 void setDocumentViewController(DocumentViewController documentViewController)
           
 void setSelectionRectangle(java.awt.Point cursorLocation, java.awt.Rectangle selection)
           
 void uninstallTool()
          Callback code that allows pre destroy task to take place when the tool is unselected via the AbstractDocumentView.setToolMode(int) call.
 
Methods inherited from class org.icepdf.ri.common.tools.TextSelection
calculateTextSelectionExclusion, clearSelection, clearSelectionState, lineSelectHandler, multiLineSelectHandler, paintSelectedText, paintTextBounds, selection, selectionEnd, selectionIcon, selectionStart, setBottomMargin, setTopMargin, wordLineSelection, wordSelectHandler
 
Methods inherited from class org.icepdf.ri.common.tools.SelectionBoxHandler
clearRectangle, getCurrentRect, getRectToDraw, isOverPageComponent, paintSelectionBox, resetRectangle, setCurrentRect, setRectToDraw, setSelectionSize, updateDrawableRect, updateSelectionSize
 
Methods inherited from class org.icepdf.ri.common.tools.CommonToolHandler
convertMouseToPageSpace, convertRectangleToPageSpace, convertToPageSpace, convertToPageSpace, getPageTransform, getPageTransform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextSelectionPageHandler

public TextSelectionPageHandler(DocumentViewController documentViewController,
                                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)

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

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

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

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

setSelectionRectangle

public void setSelectionRectangle(java.awt.Point cursorLocation,
                                  java.awt.Rectangle selection)
Overrides:
setSelectionRectangle in class TextSelection

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

installTool

public void installTool()
Description copied from interface: ToolHandler
Callback code that allows post construct task to take place when the tool is selected via the AbstractDocumentView.setToolMode(int) call.

Specified by:
installTool in interface ToolHandler

uninstallTool

public void uninstallTool()
Description copied from interface: ToolHandler
Callback code that allows pre destroy task to take place when the tool is unselected via the AbstractDocumentView.setToolMode(int) call.

Specified by:
uninstallTool in interface ToolHandler

paintTool

public void paintTool(java.awt.Graphics g)
Description copied from interface: ToolHandler
Paints the tools pre-annotation creation state.

Specified by:
paintTool in interface ToolHandler
Parameters:
g - graphics context

convertToPageSpace

protected java.awt.Rectangle convertToPageSpace(java.util.ArrayList<java.awt.Shape> bounds,
                                                java.awt.geom.GeneralPath path)
Convert the shapes that make up the annotation to page space so that they will scale correctly at different zooms.

Returns:
transformed bBox.