org.faceless.pdf2.viewer2.feature
Class TextTool

java.lang.Object
  extended by org.faceless.pdf2.viewer2.ViewerFeature
      extended by org.faceless.pdf2.viewer2.ViewerWidget
          extended by org.faceless.pdf2.viewer2.ToggleViewerWidget
              extended by org.faceless.pdf2.viewer2.feature.TextTool
All Implemented Interfaces:
FocusListener, EventListener, DocumentPanelListener, PagePanelInteractionListener, PagePanelListener

public class TextTool
extends ToggleViewerWidget
implements DocumentPanelListener, PagePanelInteractionListener, PagePanelListener, FocusListener

This widget allows the document to be dragged and scrolled. This widget is selected by default if no other items in its group are selected.

This code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.

Since:
2.8.5

Field Summary
static int TYPE_BLOCK
          A parameter to setHighlightColor(java.awt.Paint, int) which will highlight the selected text using a solid block of (usually translucent) color
 
Constructor Summary
TextTool()
          Create a new TextTool object
 
Method Summary
 void action(ViewerEvent event)
          Toggle the active state of this widget by calling ToggleViewerWidget.setSelected(boolean)
 void copy()
          Copy the selected text (if any) to the System clipboard
 void documentUpdated(DocumentPanelEvent event)
          Called when an DocumentPanelEvent is raised
 void focusGained(FocusEvent event)
           
 void focusLost(FocusEvent event)
           
 void initialize(PDFViewer viewer)
          Called when the feature is first added to a viewer
 void pageAction(PagePanelInteractionEvent event)
          Handle mousePressed, mouseDragged and mouseMoved events on this page, which are used to select text.
 void pageUpdated(PagePanelEvent event)
          Called when a PagePanelEvent is raised
 void select(PageExtractor.Text text)
          Select the specified text.
 void selectAll()
          Select all the text on the page
 void setDraggable(boolean draggable)
           
 void setHighlightColor(Paint color, int type)
          Set the color of the selected text.
protected  void updateViewport(DocumentViewport vp, boolean selected)
          Called from ToggleViewerWidget.setSelected(boolean), this method is called in each viewport in use by the PDFViewer or DocumentPanel so it can update its status.
 
Methods inherited from class org.faceless.pdf2.viewer2.ToggleViewerWidget
getGroupName, getGroupOwner, getGroupSelection, getWidgets, isSelected, setGroupOwner, setSelected
 
Methods inherited from class org.faceless.pdf2.viewer2.ViewerWidget
getComponent, getViewer, isButtonEnabledByDefault, isMenuEnabledByDefault, setButton, setComponent, setDocumentRequired, setMenu, setMenu, setToolBarEnabled, setToolBarEnabledAlways, setToolBarFloatable, setToolBarFloating, toString
 
Methods inherited from class org.faceless.pdf2.viewer2.ViewerFeature
getAllFeatures, getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_BLOCK

public static final int TYPE_BLOCK
A parameter to setHighlightColor(java.awt.Paint, int) which will highlight the selected text using a solid block of (usually translucent) color

See Also:
Constant Field Values
Constructor Detail

TextTool

public TextTool()
Create a new TextTool object

Method Detail

setHighlightColor

public void setHighlightColor(Paint color,
                              int type)
Set the color of the selected text. The specified color should be translucent so the text behind it is still visible when selected.


setDraggable

public void setDraggable(boolean draggable)

initialize

public void initialize(PDFViewer viewer)
Description copied from class: ViewerFeature
Called when the feature is first added to a viewer

Overrides:
initialize in class ToggleViewerWidget

action

public void action(ViewerEvent event)
Description copied from class: ToggleViewerWidget
Toggle the active state of this widget by calling ToggleViewerWidget.setSelected(boolean)

Overrides:
action in class ToggleViewerWidget

updateViewport

protected void updateViewport(DocumentViewport vp,
                              boolean selected)
Description copied from class: ToggleViewerWidget
Called from ToggleViewerWidget.setSelected(boolean), this method is called in each viewport in use by the PDFViewer or DocumentPanel so it can update its status. By default it is a no-op.

Overrides:
updateViewport in class ToggleViewerWidget

focusGained

public void focusGained(FocusEvent event)
Specified by:
focusGained in interface FocusListener

focusLost

public void focusLost(FocusEvent event)
Specified by:
focusLost in interface FocusListener

documentUpdated

public void documentUpdated(DocumentPanelEvent event)
Description copied from interface: DocumentPanelListener
Called when an DocumentPanelEvent is raised

Specified by:
documentUpdated in interface DocumentPanelListener

pageUpdated

public void pageUpdated(PagePanelEvent event)
Description copied from interface: PagePanelListener
Called when a PagePanelEvent is raised

Specified by:
pageUpdated in interface PagePanelListener

copy

public void copy()
Copy the selected text (if any) to the System clipboard


selectAll

public void selectAll()
Select all the text on the page


select

public void select(PageExtractor.Text text)
Select the specified text. If the text is on a different page to the current one, the page is changed first, and either way the viewport may be repositiioned to display the specified text.

Parameters:
text - the Text item to display, or null to select no text
Throws:
IllegalArgumentException - if the text item is from a different PDF

pageAction

public void pageAction(PagePanelInteractionEvent event)
Handle mousePressed, mouseDragged and mouseMoved events on this page, which are used to select text. Text can be selected by clicking and dragging over it, or by double clicking (to select the current word) or triple clicking (to select the current line)

Specified by:
pageAction in interface PagePanelInteractionListener


Copyright © 2001-2008 Big Faceless Organization