com.levigo.jadice.search
Class TextSelectionTool

java.lang.Object
  extended by com.levigo.jadice.swing.tool.Tool
      extended by com.levigo.jadice.swing.internal.tool.AbstractBaseTool
          extended by com.levigo.jadice.swing.search.tool.AbstractSelectionRendererTool
              extended by com.levigo.jadice.search.TextSelectionTool
All Implemented Interfaces:
SelectionProvider, ModifierActivated, MenuContributor

public final class TextSelectionTool
extends AbstractSelectionRendererTool
implements ModifierActivated

A Tool used to select textual page content. Panning is performed upon mouse motion events during which the modifier state matches the one set with setActivationModifiers(int) (this defaults to the left mouse button). Beyond that, the number of mouse clicks used to initiate the selection determines the Granularity with which text is selected:

single click
single glyphs
double click
whole words
triple click
whole rows
more than three clicks
whole blocks
In order for text to be selectable it must satisfy certain conditions: In particular, text from raster images is not selectable without the use of an OCR provider. Selected text may be exported in various forms (see setExportHandler(ExportHandler)). In addition, other tools can attach functionality to selected areas by listening on the ToolManager for changes to properties starting with the string ToolManager.getToolPropertyPrefix(AreaSelectionTool.class) and querying AbstractSelectionRendererTool.getSelections().


Nested Class Summary
 
Nested classes/interfaces inherited from class com.levigo.jadice.swing.tool.Tool
Tool.ActivationRequest
 
Field Summary
 
Fields inherited from class com.levigo.jadice.swing.search.tool.AbstractSelectionRendererTool
DEFAULT_ACTIVE_SELECTION_COLOR, DEFAULT_SELECTION_COLOR, LINE_ENDING, SEL_BUS_PROPERTY_PREFIX
 
Fields inherited from class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
activeGesture, currentPage, enableContextToolbar, isActive, lastRenderControls, lastRenderedPageBounds
 
Fields inherited from class com.levigo.jadice.swing.tool.Tool
DEFAULT_PRIORITY, MAX_PRIORITY, MIN_PRIORITY
 
Constructor Summary
TextSelectionTool()
           
 
Method Summary
 void contribute(ContributionContext context, MenuBuilder contextMenu)
          This method is called in order to give the menu contributor a chance to contribute context menu entries via the supplied MenuBuilder.
protected  Tool.ActivationRequest getActivationFeedback(MouseEditEvent e)
          Provide feedback for the user about what would happen, if the mouse were pressed at the current location.
 int getActivationModifiers()
          Get the mask of modifier keys (Shift, Control, Alt etc.) and mouse buttons (left, right etc.) to be used to activate this tool.
protected  Tool.ActivationRequest getActivationRequestForMousePressed(MouseEditEvent e)
          Return the auto-activation request for this this tool in response to the given mouse press.
protected  com.levigo.jadice.swing.internal.gui.HoverToolbar getContextToolbar()
           
 ExportHandler<Selection> getExportHandler()
           
 List<MenuContributor> getMenuContributors()
           
protected  Point getPreferredToolbarLocation()
           
protected  Rectangle getUnionSelectionBounds(Page p, List<? extends Selection> selections)
           
protected  Rectangle getUnionSelectionBounds(Page p, List<? extends Selection> selections, RenderControls rc, Rectangle pageBounds)
           
protected  void handleMouseDragged(MouseEditEvent e, boolean isActive)
          Invoked when a mouse button is pressed on a component and then dragged.
protected  void handleMousePressed(MouseEditEvent e, boolean isActive)
          Invoked when a mouse button has been pressed on a component.
 boolean isEnableDragExport()
           
 boolean isEnableHoverToolbar()
           
 void setActivationModifiers(int activationModifiers)
          Set the mask of modifier keys (Shift, Control, Alt etc.) and mouse buttons (left, right etc.) to be used to activate this tool.
protected  void setActive(boolean active)
          Receive notification from the tool manager about the tool's active state.
 void setEnableDragExport(boolean enableDragExport)
          Set whether to enable the export of selected text using a drag-and-drop transfer.
 void setEnableHoverToolbar(boolean enableHoverToolbar)
          Set whether to enable the hover toolbar which contains functions pertaining to the selection.
 void setExportHandler(ExportHandler<Selection> exportHandler)
           
protected  void setManager(ToolManager manager)
          Receives the ToolManager instance, which the Tool implementation has been registered for.
 void setRemoveOnClick(boolean removeOnClick)
          specifies if the selection should be removed on a single click using the mouse.
 void setSelections(List<Selection> s)
           
protected  boolean shallHandleEditEvent(boolean isActive, EditEvent e)
           
protected  boolean shallRemoveOnClick(MouseEditEvent e)
           
protected  boolean toolbarShallBeActive()
           
 
Methods inherited from class com.levigo.jadice.swing.search.tool.AbstractSelectionRendererTool
afterHandleEditEvent, clearSelection, doGetSelections, doSetActiveSelection, doSetSelections, getActiveSelection, getActiveSelectionColor, getSelectedText, getSelectionColor, getSelections, handleEditEvent, isRemoveOnClick, render, renderSelections, setActiveSelectionColor, setSelectionColor, updateTextSelection
 
Methods inherited from class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
activateToolbar, autoscroll, beforeHandleEditEvent, checkForRenderGeometryChange, deactivateToolbar, endGesture, getActiveGesture, getCurrentPage, getUndoManager, handleEditEventPreDispatch, isEnableContextToolbar, serviceGesture, setEnableContextToolbar, startGesture, switchFocus, updateToolbarLocation, updateToolbarVisibility
 
Methods inherited from class com.levigo.jadice.swing.tool.Tool
getActivationRequest, getActivationRequestForKeyPressed, getActivationRequestForMouseDragged, getCursor, getDispatchPriority, getManager, getRenderPriority, handleKeyPressed, handleKeyReleased, handleKeyTyped, handleMouseClicked, handleMouseEntered, handleMouseExited, handleMouseMoved, handleMouseReleased, handleMouseWheelMoved, propagatePropertyChange, setCursor, setEnabled, setStatusFeedback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextSelectionTool

public TextSelectionTool()
Method Detail

shallHandleEditEvent

protected boolean shallHandleEditEvent(boolean isActive,
                                       EditEvent e)
Overrides:
shallHandleEditEvent in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool

handleMouseDragged

protected void handleMouseDragged(MouseEditEvent e,
                                  boolean isActive)
Description copied from class: Tool
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.

Overrides:
handleMouseDragged in class Tool
isActive - whether this tool is currently active

getActivationFeedback

protected Tool.ActivationRequest getActivationFeedback(MouseEditEvent e)
Description copied from class: Tool
Provide feedback for the user about what would happen, if the mouse were pressed at the current location. This method is called while handling MouseEvent.MOUSE_MOVED events. If this method returns null no feedback is provided at all. The activation request returned from this method is the same object that is used during Tool.getActivationRequestForKeyPressed(KeyEditEvent) to signal the auto-activation candidacy. This method should only return an activation request if it will actually candidate for auto-activation later on using Tool.getActivationRequestForMousePressed(MouseEditEvent) or Tool.getActivationRequestForMouseDragged(MouseEditEvent).

Overrides:
getActivationFeedback in class Tool

getActivationRequestForMousePressed

protected Tool.ActivationRequest getActivationRequestForMousePressed(MouseEditEvent e)
Description copied from class: Tool
Return the auto-activation request for this this tool in response to the given mouse press. If the tool returns an Tool.ActivationRequest, it becomes eligible for auto-activation. However, the final decision about which tool will actually be activated is up to the ToolActivationPolicy used be the tool manager.

Overrides:
getActivationRequestForMousePressed in class Tool
Parameters:
e - the KeyEditEvent
Returns:
an Tool.ActivationRequest or null if the tool does not seek to be auto-activated at this time.

setSelections

public void setSelections(List<Selection> s)

handleMousePressed

protected void handleMousePressed(MouseEditEvent e,
                                  boolean isActive)
Description copied from class: Tool
Invoked when a mouse button has been pressed on a component.

Overrides:
handleMousePressed in class Tool
isActive - whether this tool is currently active

setRemoveOnClick

public void setRemoveOnClick(boolean removeOnClick)
specifies if the selection should be removed on a single click using the mouse.

Overrides:
setRemoveOnClick in class AbstractSelectionRendererTool
Parameters:
removeOnClick - true if the selection should be removed on click

shallRemoveOnClick

protected boolean shallRemoveOnClick(MouseEditEvent e)
Overrides:
shallRemoveOnClick in class AbstractSelectionRendererTool

contribute

public void contribute(ContributionContext context,
                       MenuBuilder contextMenu)
Description copied from interface: MenuContributor
This method is called in order to give the menu contributor a chance to contribute context menu entries via the supplied MenuBuilder.

Specified by:
contribute in interface MenuContributor
Overrides:
contribute in class Tool
Parameters:
context - the ContributionContext which provides contribution context informations
contextMenu - the MenuBuilder to which the tool may contribute entries.

setEnableDragExport

public void setEnableDragExport(boolean enableDragExport)
Set whether to enable the export of selected text using a drag-and-drop transfer.

Parameters:
enableDragExport -

isEnableDragExport

public boolean isEnableDragExport()

toolbarShallBeActive

protected boolean toolbarShallBeActive()
Overrides:
toolbarShallBeActive in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool

getPreferredToolbarLocation

protected Point getPreferredToolbarLocation()
Overrides:
getPreferredToolbarLocation in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool

getUnionSelectionBounds

protected Rectangle getUnionSelectionBounds(Page p,
                                            List<? extends Selection> selections)

getUnionSelectionBounds

protected Rectangle getUnionSelectionBounds(Page p,
                                            List<? extends Selection> selections,
                                            RenderControls rc,
                                            Rectangle pageBounds)

getContextToolbar

protected com.levigo.jadice.swing.internal.gui.HoverToolbar getContextToolbar()
Overrides:
getContextToolbar in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool

setEnableHoverToolbar

public void setEnableHoverToolbar(boolean enableHoverToolbar)
Set whether to enable the hover toolbar which contains functions pertaining to the selection.

Parameters:
enableHoverToolbar -

isEnableHoverToolbar

public boolean isEnableHoverToolbar()

setManager

protected void setManager(ToolManager manager)
Description copied from class: Tool
Receives the ToolManager instance, which the Tool implementation has been registered for. If the Tool is deregistered this method will be called with null.

Overrides:
setManager in class AbstractSelectionRendererTool

getMenuContributors

public List<MenuContributor> getMenuContributors()

getExportHandler

public ExportHandler<Selection> getExportHandler()

setExportHandler

public void setExportHandler(ExportHandler<Selection> exportHandler)

setActivationModifiers

public void setActivationModifiers(int activationModifiers)
Set the mask of modifier keys (Shift, Control, Alt etc.) and mouse buttons (left, right etc.) to be used to activate this tool. The modifier mask must be compatible with InputEvent.getModifiersEx(), i.e. it must use the InputEvent constants containing _DOWN_ in their name.

Default: use just the left mouse button.

Specified by:
setActivationModifiers in interface ModifierActivated
See Also:
ModifierActivated.setActivationModifiers(int)

getActivationModifiers

public int getActivationModifiers()
Get the mask of modifier keys (Shift, Control, Alt etc.) and mouse buttons (left, right etc.) to be used to activate this tool.

Specified by:
getActivationModifiers in interface ModifierActivated
Returns:
the modifier and button mask
See Also:
ModifierActivated.setActivationModifiers(int)

setActive

protected void setActive(boolean active)
Description copied from class: Tool
Receive notification from the tool manager about the tool's active state.

Overrides:
setActive in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.