com.levigo.jadice.swing.pageview
Class AreaSelectionTool

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.pageview.AreaSelectionTool
All Implemented Interfaces:
SelectionProvider, ModifierActivated, MenuContributor

public class AreaSelectionTool
extends com.levigo.jadice.swing.internal.tool.AbstractBaseTool
implements SelectionProvider, ModifierActivated

A Tool used to select rectangular areas within a page. Areas are created by clicking and dragging with the mouse. After creation, areas can be resized by dragging "handles" at the corners and edges of the rectangle and moved by clicking and dragging them. A selected area allows the page contents to be exported in various forms like rendered snapshot-images, textual content etc. (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 getSelections()/getSelection().


Nested Class Summary
 
Nested classes/interfaces inherited from class com.levigo.jadice.swing.tool.Tool
Tool.ActivationRequest
 
Field Summary
protected static String 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
AreaSelectionTool()
           
 
Method Summary
 void clearSelection()
           
 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()
           
protected  int getDispatchPriority()
          Return the dispatch priority for this tool.
 int getDragActionSwitchModifier()
           
 ExportHandler<Selection> getExportHandler()
           
 List<MenuContributor> getMenuContributors()
           
protected  Point getPreferredToolbarLocation()
           
 Selection getSelection()
           
 List<? extends Selection> getSelections()
           
protected  void handleMouseClicked(MouseEditEvent e, boolean isActive)
          Invoked when the mouse button has been clicked (pressed and released) on a component.
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 isDragDefaultsToExport()
           
protected  void render(RenderParameters parameters, boolean isActive)
          Renders the Tool's UI onto the given Graphics2D context using the given RenderControls.
 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 setDragActionSwitchModifier(int dragActionSwitchModifier)
          The modifier used to switch the meaning of a drag gesture between drag-and-drop export and selection translation.
 void setDragDefaultsToExport(boolean dragDefaultsToExport)
          Set whether a drag gesture defaults to a drag-and-drop export of the selection ( true) or a translation of the selected area (false).
 void setExportHandler(ExportHandler<Selection> exportHandler)
           
protected  void setManager(ToolManager manager)
          Receives the ToolManager instance, which the Tool implementation has been registered for.
 void setSelection(Selection selection)
           
protected  boolean toolbarShallBeActive()
           
 
Methods inherited from class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
activateToolbar, afterHandleEditEvent, autoscroll, beforeHandleEditEvent, checkForRenderGeometryChange, deactivateToolbar, endGesture, getActiveGesture, getCurrentPage, getUndoManager, handleEditEvent, handleEditEventPreDispatch, isEnableContextToolbar, serviceGesture, setEnableContextToolbar, shallHandleEditEvent, startGesture, switchFocus, updateToolbarLocation, updateToolbarVisibility
 
Methods inherited from class com.levigo.jadice.swing.tool.Tool
getActivationRequest, getActivationRequestForKeyPressed, getActivationRequestForMouseDragged, getCursor, getManager, getRenderPriority, handleKeyPressed, handleKeyReleased, handleKeyTyped, 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
 

Field Detail

SEL_BUS_PROPERTY_PREFIX

protected static final String SEL_BUS_PROPERTY_PREFIX
See Also:
Constant Field Values
Constructor Detail

AreaSelectionTool

public AreaSelectionTool()
Method Detail

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.

getDispatchPriority

protected int getDispatchPriority()
Description copied from class: Tool
Return the dispatch priority for this tool. Tools with higher dispatch priorities receive events earlier than tools with lower priorities. The priority should be in the range Tool.MIN_PRIORITY...Tool.MAX_PRIORITY. The default priority is equal to Tool.MAX_PRIORITY minus the render priority.

Overrides:
getDispatchPriority in class Tool
Returns:
the dispatch priority

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.

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

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

handleMouseClicked

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

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

isDragDefaultsToExport

public boolean isDragDefaultsToExport()

setDragDefaultsToExport

public void setDragDefaultsToExport(boolean dragDefaultsToExport)
Set whether a drag gesture defaults to a drag-and-drop export of the selection ( true) or a translation of the selected area (false). The non-default action is always accessible using the dragActionSwitchModifier modifier. Default: false

Parameters:
dragDefaultsToExport -

setDragActionSwitchModifier

public void setDragActionSwitchModifier(int dragActionSwitchModifier)
The modifier used to switch the meaning of a drag gesture between drag-and-drop export and selection translation. Default: InputEvent.SHIFT_DOWN_MASK

Parameters:
dragActionSwitchModifier -

getDragActionSwitchModifier

public int getDragActionSwitchModifier()

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 Tool

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 the left mouse button in conjunction with SHIFT

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)

render

protected void render(RenderParameters parameters,
                      boolean isActive)
Description copied from class: Tool
Renders the Tool's UI onto the given Graphics2D context using the given RenderControls.

This render method is called within the context and during the rendering of a single page. The page being rendered is passed to implementors of this method in order to be able to control and influence the page rendering.

Overrides:
render in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
Parameters:
parameters - the view component which is currently being rendered
isActive - whether the called tool is currently active

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

getSelection

public Selection getSelection()

getSelections

public List<? extends Selection> getSelections()
Specified by:
getSelections in interface SelectionProvider

setSelection

public void setSelection(Selection selection)

getMenuContributors

public List<MenuContributor> getMenuContributors()

getContextToolbar

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

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

getExportHandler

public ExportHandler<Selection> getExportHandler()

setExportHandler

public void setExportHandler(ExportHandler<Selection> exportHandler)

clearSelection

public void clearSelection()
Specified by:
clearSelection in interface SelectionProvider


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