public class FXClickDragTool extends AbstractTool<javafx.scene.Node>
ITool to handle click/drag interaction gestures.
As click and drag are 'overlapping' gestures (a click is part of each drag, which is composed out of click, drag, and release), these are handled together here, even while distinct interaction policies will be queried to handle the respective gesture parts.
During each click/drag interaction, the tool identifies respective
IVisualParts that serve as interaction targets for click and drag
respectively. They are identified via hit-testing on the visuals and the
availability of a corresponding AbstractFXOnClickPolicy or
AbstractFXOnDragPolicy (see
getTargetPart(IViewer, Node, Class)) and can even be temporarily
overwritten (see
overrideTargetForThisInteraction(EventTarget, IVisualPart)).
The FXClickDragTool handles the opening and closing of an transaction
operation via the FXDomain, to which it is adapted. It controls that
a single transaction operation is used for the complete interaction
(including the click and potential drag part), so all interaction results can
be undone in a single undo step.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.Class<AbstractFXOnClickPolicy> |
CLICK_TOOL_POLICY_KEY
The typeKey used to retrieve those policies that are able to handle the
click part of the click/drag interaction gesture.
|
static java.lang.Class<AbstractFXOnDragPolicy> |
DRAG_TOOL_POLICY_KEY
The typeKey used to retrieve those policies that are able to handle the
drag part of the click/drag interaction gesture.
|
pcsACTIVE_PROPERTY| Constructor and Description |
|---|
FXClickDragTool() |
| Modifier and Type | Method and Description |
|---|---|
protected java.util.Set<? extends AbstractFXOnClickPolicy> |
getClickPolicies(IVisualPart<javafx.scene.Node,? extends javafx.scene.Node> targetPart)
|
protected java.util.Set<? extends AbstractFXOnDragPolicy> |
getDragPolicies(IVisualPart<javafx.scene.Node,? extends javafx.scene.Node> targetPart)
|
protected <T extends IPolicy<javafx.scene.Node>> |
getTargetPart(IViewer<javafx.scene.Node> viewer,
javafx.scene.Node target,
java.lang.Class<T> policy)
Returns the target
IVisualPart for the given target Node
within the given IViewer that supports the given policy. |
void |
overrideTargetForThisInteraction(javafx.event.EventTarget target,
IVisualPart<javafx.scene.Node,? extends javafx.scene.Node> targetPart)
Registers the given
IVisualPart as the target part for all JavaFX
events which are send to the given EventTarget during the
currently active or next press-drag-release gesture. |
protected void |
registerListeners()
This method is called when a valid
IDomain is attached to this
tool so that you can register event listeners for various inputs
(keyboard, mouse) or model changes (selection, scroll offset / viewport). |
protected void |
unregisterListeners()
This method is called when the attached
IDomain is reset to
null so that you can unregister previously registered event
listeners. |
activate, addPropertyChangeListener, deactivate, getAdaptable, getDomain, isActive, removePropertyChangeListener, setAdaptablepublic static final java.lang.Class<AbstractFXOnClickPolicy> CLICK_TOOL_POLICY_KEY
public static final java.lang.Class<AbstractFXOnDragPolicy> DRAG_TOOL_POLICY_KEY
protected java.util.Set<? extends AbstractFXOnClickPolicy> getClickPolicies(IVisualPart<javafx.scene.Node,? extends javafx.scene.Node> targetPart)
targetPart - The IVisualPart of which the
AbstractFXOnClickPolicys are returned.Set containing all AbstractFXOnClickPolicys of
the given target IVisualPart.protected java.util.Set<? extends AbstractFXOnDragPolicy> getDragPolicies(IVisualPart<javafx.scene.Node,? extends javafx.scene.Node> targetPart)
targetPart - The IVisualPart of which the
AbstractFXOnDragPolicys are returned.Set containing all AbstractFXOnDragPolicys of
the given target IVisualPart.protected <T extends IPolicy<javafx.scene.Node>> IVisualPart<javafx.scene.Node,? extends javafx.scene.Node> getTargetPart(IViewer<javafx.scene.Node> viewer, javafx.scene.Node target, java.lang.Class<T> policy)
IVisualPart for the given target Node
within the given IViewer that supports the given policy.
If a target override was previously registered for the given Node
using overrideTargetForThisInteraction(EventTarget, IVisualPart)
, then the override target will be returned (and the override will be
removed).
T - The type of the policy that has to be supported.viewer - The IViewer which is searched for the target
IVisualPart.target - The target Node that received the input event.policy - The Class of the policy that has to be supported.IVisualPart that was determined.public void overrideTargetForThisInteraction(javafx.event.EventTarget target,
IVisualPart<javafx.scene.Node,? extends javafx.scene.Node> targetPart)
IVisualPart as the target part for all JavaFX
events which are send to the given EventTarget during the
currently active or next press-drag-release gesture.target - The JavaFX EventTarget for which the given target
should be used.targetPart - The IVisualPart to use as the target for all JavaFX
events directed at the given EventTarget.protected void registerListeners()
AbstractToolIDomain is attached to this
tool so that you can register event listeners for various inputs
(keyboard, mouse) or model changes (selection, scroll offset / viewport).registerListeners in class AbstractTool<javafx.scene.Node>protected void unregisterListeners()
AbstractToolIDomain is reset to
null so that you can unregister previously registered event
listeners.unregisterListeners in class AbstractTool<javafx.scene.Node>Copyright (c) 2014 itemis AG and others. All rights reserved.