public class MoveLabelInputMode extends MoveInputMode
IInputMode
that can be used to drag a ILabel
in a GraphControl
.
This implementation shows the possible candidate positions for a given label and allows the user to drag the label to one of these positions.
Constructor and Description |
---|
MoveLabelInputMode()
Creates a new instance that will move labels in the graph retrieved from the
InputModeContext . |
Modifier and Type | Method and Description |
---|---|
protected IHitTestable |
createLabelHitTestable()
Creates the hit testable that will be used to determine whether this mode may be activated.
|
protected IPositionHandler |
createLabelPositionHandler(ILabel label)
Creates the
position handler for the given label used in
isValidLabelHit(IInputModeContext, PointD) . |
IGraph |
getGraph()
Gets the
IGraph this mode is acting upon. |
IGraphSelection |
getGraphSelection()
Gets the
IGraphSelection this mode is acting upon. |
protected ILabel |
getHitLabel(IInputModeContext context,
PointD location)
Looks for a label that has been hit at the specified position.
|
ILabel |
getMovedLabel()
Gets the label that is currently moved or
null if there is no such label. |
boolean |
isUsingLabelModelParameterFinderEnabled()
Gets a value indicating whether or not using the
ILabelModelParameterFinder
to assign new label model parameters is allowed. |
protected boolean |
isValidLabelHit(IInputModeContext context,
PointD location)
Determines whether or not a valid label has been hit at the specified position.
|
protected void |
onDragCanceled(InputModeEventArgs inputModeEventArgs)
Clears the
PositionHandler property. |
protected void |
onDragFinished(InputModeEventArgs inputModeEventArgs)
Clears the
PositionHandler property. |
protected void |
onDragStarting(InputModeEventArgs inputModeEventArgs)
Registers the
PositionHandler created during the last createLabelPositionHandler(ILabel)
call. |
void |
setUsingLabelModelParameterFinderEnabled(boolean value)
Sets a value indicating whether or not using the
ILabelModelParameterFinder
to assign new label model parameters is allowed. |
protected boolean |
shouldMove(IInputModeContext context,
ILabel label)
Determines whether or not a label is allowed to be moved.
|
addDragCanceledListener, addDragCancelingListener, addDragFinishedListener, addDragFinishingListener, addDraggedListener, addDraggingListener, addDragStartedListener, addDragStartingListener, addQueryPositionHandlerListener, arm, cancel, createPositionHandlerInputModeContext, disarm, doStartDrag, getAffectedItems, getCancelRecognizer, getController, getDisableSnappingRecognizer, getDraggedRecognizer, getDraggedRecognizerTouch, getEnableSnappingRecognizer, getHitTestable, getHoverRecognizer, getInitialLocation, getInputModeContext, getMoveCursor, getPositionHandler, getPressedRecognizer, getPressedRecognizerTouch, getPriority, getReleasedRecognizer, getReleasedRecognizerTouch, getSnapContext, install, isDragging, isEnabled, isExclusive, isValidStartLocation, onCanceled, onConcurrencyControllerActivated, onConcurrencyControllerDeactivated, onDragCanceling, onDragFinishing, onDragged, onDragging, onDragStarted, onQueryPositionHandler, onStopped, removeDragCanceledListener, removeDragCancelingListener, removeDragFinishedListener, removeDragFinishingListener, removeDraggedListener, removeDraggingListener, removeDragStartedListener, removeDragStartingListener, removeQueryPositionHandlerListener, setCancelRecognizer, setDisableSnappingRecognizer, setDraggedRecognizer, setDraggedRecognizerTouch, setEnabled, setEnableSnappingRecognizer, setExclusive, setHitTestable, setHoverRecognizer, setMoveCursor, setPositionHandler, setPressedRecognizer, setPressedRecognizerTouch, setPriority, setReleasedRecognizer, setReleasedRecognizerTouch, setSnapContext, stop, uninstall
public MoveLabelInputMode()
InputModeContext
.getGraph()
protected IHitTestable createLabelHitTestable()
This implementation returns an instance that delegates to isValidLabelHit(IInputModeContext, PointD)
.
protected IPositionHandler createLabelPositionHandler(ILabel label)
position handler
for the given label used in
isValidLabelHit(IInputModeContext, PointD)
.
First, this implementation checks for a position handler in the label's
lookup
. If this fails, it creates a new label position handler for the given
label.
label
- The label to create a position handler for.public final IGraph getGraph()
IGraph
this mode is acting upon.public final IGraphSelection getGraphSelection()
IGraphSelection
this mode is acting upon.protected ILabel getHitLabel(IInputModeContext context, PointD location)
This implementation checks the GraphSelection
to see if there is exactly one selected
label. This label is returned if it is hit by the mouse and shouldMove(IInputModeContext, ILabel)
returns
true
. Otherwise, null
is returned.
context
- The context for the hit test.location
- The coordinates for the hit test.null
.isValidLabelHit(IInputModeContext, PointD)
,
shouldMove(IInputModeContext, ILabel)
public final ILabel getMovedLabel()
null
if there is no such label.
The value of this property is not null
only if this mode is currently active and performs a move operation, that
is between the DragStarting
and the
DragFinished
event handlers.
public final boolean isUsingLabelModelParameterFinderEnabled()
ILabelModelParameterFinder
to assign new label model parameters is allowed.
The default is true
This property has no effect if an IPositionHandler
is available in the label's
lookup
.
createLabelPositionHandler(ILabel)
,
setUsingLabelModelParameterFinderEnabled(boolean)
protected boolean isValidLabelHit(IInputModeContext context, PointD location)
This implementation calls getHitLabel(IInputModeContext, PointD)
to find the label at the specified location.
If a label is hit, the IPositionHandler
is created by createLabelPositionHandler(ILabel)
.
context
- The context for the hit test.location
- The coordinates for the hit test.true
if a valid label is hit and the label moving should be started here. Otherwise, false
.protected void onDragCanceled(InputModeEventArgs inputModeEventArgs)
PositionHandler
property.onDragCanceled
in class MoveInputMode
inputModeEventArgs
- The event argument that contains context information.protected void onDragFinished(InputModeEventArgs inputModeEventArgs)
PositionHandler
property.onDragFinished
in class MoveInputMode
inputModeEventArgs
- The event argument that contains context information.protected void onDragStarting(InputModeEventArgs inputModeEventArgs)
PositionHandler
created during the last createLabelPositionHandler(ILabel)
call.onDragStarting
in class MoveInputMode
inputModeEventArgs
- The event argument that contains context information.public final void setUsingLabelModelParameterFinderEnabled(boolean value)
ILabelModelParameterFinder
to assign new label model parameters is allowed.
The default is true
This property has no effect if an IPositionHandler
is available in the label's
lookup
.
value
- The UsingLabelModelParameterFinderEnabled to set.createLabelPositionHandler(ILabel)
,
isUsingLabelModelParameterFinderEnabled()
protected boolean shouldMove(IInputModeContext context, ILabel label)
This implementation returns false
if the parent input mode forbids
moving the label. Overriding implementations should query this implementation as base if this feature is desired.
context
- The context.label
- The label to be checked.true
if the label is allowed to move.getHitLabel(IInputModeContext, PointD)