public class ReparentStripePositionHandler extends Object implements IPositionHandler
IPositionHandler
implementation that moves a stripe in the table hierarchy when the stripe is
dragged.
This class is used by default by both ReparentStripeInputMode
and StripeDropInputMode
to perform the
actual reparenting and insertion.
Constructor and Description |
---|
ReparentStripePositionHandler(IStripe movedStripe)
Creates a new instance of this position handler which moves .
|
Modifier and Type | Method and Description |
---|---|
void |
addStripeChangedListener(IEventHandler<StripeEventArgs> stripeChangedEvent)
Adds the given listener for the
StripeChanged event that occurs when a stripe state is changed by this input
mode. |
void |
cancelDrag(IInputModeContext context,
PointD originalLocation)
Called by clients to indicate that the dragging has been canceled by the user.
|
protected ICanvasObject |
createSourceGhostVisualization(IInputModeContext context)
Create a visualization for the source region of the reparent gesture.
|
protected ICanvasObject |
createTargetGhostVisualization(IInputModeContext context,
IStripe stripe)
Create a visualization for the target region of the reparent gesture.
|
protected StripeReparentPolicy |
determineGesture(IInputModeContext context,
IPoint location,
IStripe sourceStripe,
StripeSubregion targetSubregion,
RectD targetBounds)
Determine the reparent gesture that would result from the given parameters.
|
void |
dragFinished(IInputModeContext context,
PointD originalLocation,
PointD newLocation)
Called by clients to indicate that the repositioning has just been finished.
|
protected IInputModeContext |
getInputModeContext()
The current
IInputModeContext . |
IPoint |
getLocation()
Returns a view of the location of the item.
|
IStripe |
getMovedStripe()
Allows to query the moved stripe.
|
protected StripeSubregion |
getTargetSubregion(PointD location)
Finds the target stripe subregion at
location and its associated owner node. |
void |
handleMove(IInputModeContext context,
PointD originalLocation,
PointD newLocation)
Called by clients to indicate that the element has been dragged and its position should be updated.
|
void |
initializeDrag(IInputModeContext context)
Called by clients to indicate that the element is going to be dragged.
|
protected void |
onStripeChanged(StripeEventArgs args)
Called whenever a change in the oldTable hierarchy occurs through this position handler.
|
void |
removeStripeChangedListener(IEventHandler<StripeEventArgs> stripeChangedEvent)
Removes the given listener for the
StripeChanged event that occurs when a stripe state is changed by this input
mode. |
void |
setPosition(PointD location) |
protected ICanvasObject |
updateSourceVisualization(IInputModeContext context,
ICanvasObject targetVisualization,
IStripe targetStripe,
StripeReparentPolicy reparentPosition)
Modifies the source visualization itself.
|
protected ICanvasObject |
updateTargetVisualization(IInputModeContext context,
ICanvasObject targetVisualization,
IStripe targetStripe,
StripeReparentPolicy reparentPosition,
RectD targetBounds)
Modifies the target visualization itself.
|
protected RectD |
updateTargetVisualizationBounds(RectD originalTargetBounds,
StripeReparentPolicy reparentPosition,
IStripe targetStripe)
Updates the visualization bounds for the target visualization depending on the provided values.
|
public ReparentStripePositionHandler(IStripe movedStripe)
movedStripe
public final void addStripeChangedListener(IEventHandler<StripeEventArgs> stripeChangedEvent)
StripeChanged
event that occurs when a stripe state is changed by this input
mode.stripeChangedEvent
- The listener to add.removeStripeChangedListener(IEventHandler)
public final void cancelDrag(IInputModeContext context, PointD originalLocation)
IDragHandler
This method may be called after the initial IDragHandler.initializeDrag(IInputModeContext)
and zero or more invocations of
IDragHandler.handleMove(IInputModeContext, PointD, PointD)
. Implementations should reset the position of the items they
modify to their initial state. Alternatively to this method the IDragHandler.dragFinished(IInputModeContext, PointD, PointD)
method might be called.
cancelDrag
in interface IDragHandler
context
- The context to retrieve information about the drag from.originalLocation
- The value of the coordinate of the Location
property at the time of
IDragHandler.initializeDrag(IInputModeContext)
.protected ICanvasObject createSourceGhostVisualization(IInputModeContext context)
The default implementation uses the return value of IStripeInputVisualizationHelper.getVisualCreator(IInputModeContext, INode, StripeVisualizationType)
with type StripeVisualizationType.DRAG_SOURCE
.
context
- The current input mode contextupdateSourceVisualization(IInputModeContext, ICanvasObject, IStripe, StripeReparentPolicy)
protected ICanvasObject createTargetGhostVisualization(IInputModeContext context, IStripe stripe)
The default implementation uses the return value of IStripeInputVisualizationHelper.getVisualCreator(IInputModeContext, INode, StripeVisualizationType)
with type StripeVisualizationType.DROP_TARGET
.
context
- The current input mode contextstripe
- The stripe for which the visualization should be created.updateTargetVisualization(IInputModeContext, ICanvasObject, IStripe, StripeReparentPolicy, RectD)
protected StripeReparentPolicy determineGesture(IInputModeContext context, IPoint location, IStripe sourceStripe, StripeSubregion targetSubregion, RectD targetBounds)
The target region has already been determined by getTargetSubregion(PointD)
context
- The current input mode contextlocation
- The current drag locationsourceStripe
- The stripe that is movedtargetSubregion
- The stripe subregion for the target.targetBounds
- The target boundsStripeReparentPolicy
that specifies the operation to perform.public final void dragFinished(IInputModeContext context, PointD originalLocation, PointD newLocation)
IDragHandler
This method may be called after the initial IDragHandler.initializeDrag(IInputModeContext)
and zero or more invocations of
IDragHandler.handleMove(IInputModeContext, PointD, PointD)
. Alternatively to this method the IDragHandler.cancelDrag(IInputModeContext, PointD)
method might be called.
dragFinished
in interface IDragHandler
context
- The context to retrieve information about the drag from.originalLocation
- The value of the Location
property at the time of IDragHandler.initializeDrag(IInputModeContext)
.newLocation
- The coordinates in the world coordinate system that the client wants the handle to be at. Depending on the
implementation the Location
may or may not be modified to reflect the new value. This is the same
value as delivered in the last invocation of IDragHandler.handleMove(IInputModeContext, PointD, PointD)
protected final IInputModeContext getInputModeContext()
IInputModeContext
.public final IPoint getLocation()
IDragHandler
The point describes the current world coordinate of the element that can be modified by this handler.
getLocation
in interface IDragHandler
public final IStripe getMovedStripe()
protected StripeSubregion getTargetSubregion(PointD location)
location
and its associated owner node.location
- The hit location.StripeSubregion
that lies at location
, or null if no such region could be found.public final void handleMove(IInputModeContext context, PointD originalLocation, PointD newLocation)
IDragHandler
This method may be called more than once after an initial IDragHandler.initializeDrag(IInputModeContext)
and will the final
call will be followed by either one IDragHandler.dragFinished(IInputModeContext, PointD, PointD)
or one IDragHandler.cancelDrag(IInputModeContext, PointD)
call.
handleMove
in interface IDragHandler
context
- The context to retrieve information about the drag from.originalLocation
- The value of the Location
property at the time of IDragHandler.initializeDrag(IInputModeContext)
.newLocation
- The coordinates in the world coordinate system that the client wants the handle to be at. Depending on the
implementation the Location
may or may not be modified to reflect the new value.public final void initializeDrag(IInputModeContext context)
IDragHandler
This call will be followed by one or more calls to IDragHandler.handleMove(IInputModeContext, PointD, PointD)
, and a final IDragHandler.dragFinished(IInputModeContext, PointD, PointD)
or IDragHandler.cancelDrag(IInputModeContext, PointD)
.
initializeDrag
in interface IDragHandler
context
- The context to retrieve information about the drag from.protected void onStripeChanged(StripeEventArgs args)
public final void removeStripeChangedListener(IEventHandler<StripeEventArgs> stripeChangedEvent)
StripeChanged
event that occurs when a stripe state is changed by this input
mode.stripeChangedEvent
- The listener to remove.addStripeChangedListener(IEventHandler)
public final void setPosition(PointD location)
protected ICanvasObject updateSourceVisualization(IInputModeContext context, ICanvasObject targetVisualization, IStripe targetStripe, StripeReparentPolicy reparentPosition)
The default does not change targetVisualization
.
context
- The current input mode context.targetVisualization
- The canvas object for the target visualizationtargetStripe
- The target for the reparent gesturereparentPosition
- Where to place the stripe after reparenting.protected ICanvasObject updateTargetVisualization(IInputModeContext context, ICanvasObject targetVisualization, IStripe targetStripe, StripeReparentPolicy reparentPosition, RectD targetBounds)
The default implementation only hides targetVisualization
iff reparentPosition
is
StripeReparentPolicy.INVALID
.
context
- The current input mode context.targetVisualization
- The canvas object for the target visualization.targetStripe
- The target for the reparent gesture.reparentPosition
- The mode the describes the results of the reparent gesture.targetBounds
- The current visualization bounds that have been computed with
updateTargetVisualizationBounds(RectD, StripeReparentPolicy, IStripe)
protected RectD updateTargetVisualizationBounds(RectD originalTargetBounds, StripeReparentPolicy reparentPosition, IStripe targetStripe)
originalTargetBounds
- The target bounds prior to this method call.reparentPosition
- Where to place the stripe after the reparenting operations according to the reparent gesture.targetStripe
- The target stripe which has been determined by the input mode.