TWrapped
- The exact type of the wrapped implementation.public abstract class ConstrainedDragHandler<TWrapped extends IDragHandler> extends Object implements IDragHandler
IDragHandler
interface that can be used to constrain the movement of an existing
instance.Modifier | Constructor and Description |
---|---|
protected |
ConstrainedDragHandler(TWrapped wrappedHandler)
Initializes a new instance of the
ConstrainedDragHandler class that delegates to the wrappedHandler . |
Modifier and Type | Method and Description |
---|---|
void |
cancelDrag(IInputModeContext context,
PointD originalLocation)
Cancels the move operation and calls
onCanceled(IInputModeContext, PointD) . |
protected abstract PointD |
constrainNewLocation(IInputModeContext context,
PointD originalLocation,
PointD newLocation)
Callback that needs to implement the constraints for the new location.
|
void |
dragFinished(IInputModeContext context,
PointD originalLocation,
PointD newLocation)
Handles the finish operation and invokes
onFinished(IInputModeContext, PointD, PointD) . |
IPoint |
getLocation()
Delegates to the
WrappedHandler 's Location property. |
protected TWrapped |
getWrappedHandler()
Gets the wrapped handler to which calls will be ultimately delegated.
|
void |
handleMove(IInputModeContext context,
PointD originalLocation,
PointD newLocation)
Handles the move operation and subsequently calls
onMoved(IInputModeContext, PointD, PointD) . |
void |
initializeDrag(IInputModeContext context)
Initializes the drag operation and subsequently calls
onInitialized(IInputModeContext, PointD) . |
protected void |
onCanceled(IInputModeContext context,
PointD originalLocation)
Called when the
cancelDrag(IInputModeContext, PointD) method has been called. |
protected void |
onFinished(IInputModeContext context,
PointD originalLocation,
PointD newLocation)
Called when the
dragFinished(IInputModeContext, PointD, PointD) method has been called. |
protected void |
onInitialized(IInputModeContext context,
PointD originalLocation)
Called when the
initializeDrag(IInputModeContext) method has been called. |
protected void |
onMoved(IInputModeContext context,
PointD originalLocation,
PointD newLocation)
Called when the
handleMove(IInputModeContext, PointD, PointD) operation has been performed. |
protected ConstrainedDragHandler(TWrapped wrappedHandler)
ConstrainedDragHandler
class that delegates to the wrappedHandler
.wrappedHandler
- The handler to wrap.public final void cancelDrag(IInputModeContext context, PointD originalLocation)
onCanceled(IInputModeContext, PointD)
.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
initializeDrag(IInputModeContext)
.protected abstract PointD constrainNewLocation(IInputModeContext context, PointD originalLocation, PointD newLocation)
context
- The context in which the drag will be performed.originalLocation
- The value of the Location
property at the time of 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.newLocation
.public final void dragFinished(IInputModeContext context, PointD originalLocation, PointD newLocation)
onFinished(IInputModeContext, PointD, PointD)
.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 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 handleMove(IInputModeContext, PointD, PointD)
public IPoint getLocation()
WrappedHandler
's Location
property.getLocation
in interface IDragHandler
protected final TWrapped getWrappedHandler()
public final void handleMove(IInputModeContext context, PointD originalLocation, PointD newLocation)
onMoved(IInputModeContext, PointD, PointD)
.
This method will use the constrainNewLocation(IInputModeContext, PointD, PointD)
callback to let subclasses
constrain the movement.
handleMove
in interface IDragHandler
context
- The context in which the drag will be performed.originalLocation
- The value of the Location
property at the time of 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)
onInitialized(IInputModeContext, PointD)
.initializeDrag
in interface IDragHandler
context
- The context in which the drag will be performed.protected void onCanceled(IInputModeContext context, PointD originalLocation)
cancelDrag(IInputModeContext, PointD)
method has been called.context
- The input mode context.originalLocation
- The original location.protected void onFinished(IInputModeContext context, PointD originalLocation, PointD newLocation)
dragFinished(IInputModeContext, PointD, PointD)
method has been called.context
- The input mode context.originalLocation
- The original location.newLocation
- The new location.protected void onInitialized(IInputModeContext context, PointD originalLocation)
initializeDrag(IInputModeContext)
method has been called.context
- The input mode context.originalLocation
- The original location.protected void onMoved(IInputModeContext context, PointD originalLocation, PointD newLocation)
handleMove(IInputModeContext, PointD, PointD)
operation has been performed.context
- The input mode context.originalLocation
- The original location.newLocation
- The new location.