public class AreaSelectionTool extends com.levigo.jadice.swing.internal.tool.AbstractBaseTool implements SelectionProvider, ModifierActivated
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()
.Tool.ActivationRequest
Modifier and Type | Field and Description |
---|---|
protected static String |
SEL_BUS_PROPERTY_PREFIX |
activeGesture, currentPage, enableContextToolbar, isActive, lastRenderControls, lastRenderedPageBounds
DEFAULT_PRIORITY, MAX_PRIORITY, MIN_PRIORITY
Constructor and Description |
---|
AreaSelectionTool() |
Modifier and Type | Method and Description |
---|---|
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.ui.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() |
activateToolbar, afterHandleEditEvent, autoscroll, beforeHandleEditEvent, checkForRenderGeometryChange, deactivateToolbar, endGesture, getActiveGesture, getCurrentPage, getUndoManager, handleEditEvent, handleEditEventPreDispatch, isEnableContextToolbar, serviceGesture, setEnableContextToolbar, shallHandleEditEvent, startGesture, switchFocus, updateToolbarLocation, updateToolbarVisibility
getActivationRequest, getActivationRequestForKeyPressed, getActivationRequestForMouseDragged, getCursor, getManager, getRenderPriority, handleKeyPressed, handleKeyReleased, handleKeyTyped, handleMouseEntered, handleMouseExited, handleMouseMoved, handleMouseReleased, handleMouseWheelMoved, propagatePropertyChange, setCursor, setEnabled, setStatusFeedback
protected static final String SEL_BUS_PROPERTY_PREFIX
public void contribute(ContributionContext context, MenuBuilder contextMenu)
MenuContributor
MenuBuilder
.contribute
in interface MenuContributor
contribute
in class Tool
context
- the ContributionContext
which provides contribution context informationscontextMenu
- the MenuBuilder
to which the tool may contribute entries.protected int getDispatchPriority()
Tool
Tool.MIN_PRIORITY
...Tool.MAX_PRIORITY
.
The default priority is equal to Tool.MAX_PRIORITY
minus the render priority.getDispatchPriority
in class Tool
protected Tool.ActivationRequest getActivationFeedback(MouseEditEvent e)
Tool
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)
.getActivationFeedback
in class Tool
protected Tool.ActivationRequest getActivationRequestForMousePressed(MouseEditEvent e)
Tool
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.getActivationRequestForMousePressed
in class Tool
e
- the KeyEditEvent
Tool.ActivationRequest
or null
if the tool does not seek to be
auto-activated at this time.protected void handleMouseDragged(MouseEditEvent e, boolean isActive)
Tool
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.
handleMouseDragged
in class Tool
isActive
- whether this tool is currently activeprotected void handleMousePressed(MouseEditEvent e, boolean isActive)
Tool
handleMousePressed
in class Tool
isActive
- whether this tool is currently activeprotected void handleMouseClicked(MouseEditEvent e, boolean isActive)
Tool
handleMouseClicked
in class Tool
isActive
- whether this tool is currently activepublic boolean isDragDefaultsToExport()
public void setDragDefaultsToExport(boolean dragDefaultsToExport)
true
) or a translation of the selected area (false
). The non-default
action is always accessible using the dragActionSwitchModifier
modifier.
Default: false
public void setDragActionSwitchModifier(int dragActionSwitchModifier)
InputEvent.SHIFT_DOWN_MASK
public int getDragActionSwitchModifier()
protected void setManager(ToolManager manager)
Tool
ToolManager
instance, which the Tool
implementation has been
registered for. If the Tool
is deregistered
this
method will be called with null.setManager
in class Tool
public void setActivationModifiers(int activationModifiers)
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
setActivationModifiers
in interface ModifierActivated
ModifierActivated.setActivationModifiers(int)
public int getActivationModifiers()
getActivationModifiers
in interface ModifierActivated
ModifierActivated.setActivationModifiers(int)
protected void render(RenderParameters parameters, boolean isActive)
Tool
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.
render
in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
parameters
- the view component which is currently being renderedisActive
- whether the called tool is currently activeprotected void setActive(boolean active)
Tool
setActive
in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
public Selection getSelection()
public List<? extends Selection> getSelections()
getSelections
in interface SelectionProvider
public void setSelection(Selection selection)
public List<MenuContributor> getMenuContributors()
protected com.levigo.jadice.swing.internal.ui.HoverToolbar getContextToolbar()
getContextToolbar
in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
protected boolean toolbarShallBeActive()
toolbarShallBeActive
in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
protected Point getPreferredToolbarLocation()
getPreferredToolbarLocation
in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
public ExportHandler<Selection> getExportHandler()
public void setExportHandler(ExportHandler<Selection> exportHandler)
public void clearSelection()
clearSelection
in interface SelectionProvider
Copyright © 2024 levigo holding gmbh. All rights reserved.