public class MarqueeSelectionInputMode extends Object implements IInputMode
IInputMode
implementation that can handle marquee selections performed by the user with a mouse.
This implementation will request the mutex as soon as it recognizes a mouse drag.
This mode is Exclusive
by default.
Modifier and Type | Field and Description |
---|---|
static ResourceKey |
MARQUEE_RECTANGLE_TEMPLATE_KEY
A
ResourceKey that can be used to store a IVisualTemplate that can be used to create the visual that
will be used to draw the marquee box. |
Constructor and Description |
---|
MarqueeSelectionInputMode()
Creates a new instance of the marquee selection mode.
|
Modifier and Type | Method and Description |
---|---|
void |
addDragCanceledListener(IEventHandler<MarqueeSelectionEventArgs> dragCanceledEvent)
Adds the given listener for the
DragCanceled event that occurs when the drag has been canceled. |
void |
addDragCancelingListener(IEventHandler<MarqueeSelectionEventArgs> dragCancelingEvent)
Adds the given listener for the
DragCanceling event that occurs before the drag will be canceled. |
void |
addDragFinishedListener(IEventHandler<MarqueeSelectionEventArgs> dragFinishedEvent)
Adds the given listener for the
DragFinished event that occurs the drag has been finished. |
void |
addDragFinishingListener(IEventHandler<MarqueeSelectionEventArgs> dragFinishingEvent)
Adds the given listener for the
DragFinishing event that occurs before the drag will be finished. |
void |
addDraggedListener(IEventHandler<MarqueeSelectionEventArgs> draggedEvent)
Adds the given listener for the
Dragged event that occurs at the end of every drag. |
void |
addDraggingListener(IEventHandler<MarqueeSelectionEventArgs> draggingEvent)
Adds the given listener for the
Dragging event that occurs at the start of every drag. |
void |
addDragStartedListener(IEventHandler<MarqueeSelectionEventArgs> dragStartedEvent)
Adds the given listener for the
DragStarted event that occurs once the drag is initialized and has started. |
void |
addDragStartingListener(IEventHandler<MarqueeSelectionEventArgs> dragStartingEvent)
Adds the given listener for the
DragStarting event that occurs once the drag is starting. |
void |
cancel()
Cancels any pending marquee selection.
|
protected MarqueeSelectionEventArgs |
createInputModeEventArgs()
Helper method that yields a suitably configured
InputModeEventArgs for this input
mode. |
IEventRecognizer |
getCancelRecognizer()
Gets the "cancel" recognizer.
|
protected ConcurrencyController |
getController()
Returns the installed
Controller . |
IEventRecognizer |
getDraggedRecognizer()
Gets the "dragged" recognizer.
|
IEventRecognizer |
getDraggedRecognizerTouch()
Gets the "dragged" recognizer for touch input.
|
IInputModeContext |
getInputModeContext()
Returns the context instance this mode is currently installed in or
null if this instance is not installed. |
Cursor |
getMarqueeCursor()
Gets the cursor to use during the dragging of the marquee.
|
IEventRecognizer |
getPressedRecognizer()
Gets the "pressed" state recognizer.
|
IEventRecognizer |
getPressedRecognizerTouch()
Gets the "pressed" state recognizer for touch input.
|
int |
getPriority()
The priority of this input mode.
|
IEventRecognizer |
getReleasedRecognizer()
Gets the "released" recognizer.
|
IEventRecognizer |
getReleasedRecognizerTouch()
Gets the "released" recognizer for touch input.
|
RectD |
getSelectionRectangle()
Gets the current or last marquee selection rectangle.
|
IVisualTemplate |
getTemplate()
Gets the template that is used for the visualization of the marquee rectangle.
|
void |
install(IInputModeContext context,
ConcurrencyController controller)
Installs this mode into the given context that is provided by the canvas.
|
boolean |
isEnabled()
Gets the enabled state of this input mode.
|
boolean |
isExclusive()
Gets a value indicating whether this mode will be the only one running when it has the mutex.
|
protected void |
onCanceled()
Called after
cancel() has been called. |
protected void |
onConcurrencyControllerActivated()
|
protected void |
onConcurrencyControllerDeactivated()
|
protected void |
onDragCanceled(MarqueeSelectionEventArgs inputModeEventArgs)
Triggers the
DragCanceled event. |
protected void |
onDragCanceling(MarqueeSelectionEventArgs inputModeEventArgs)
Triggers the
DragCanceling event. |
protected void |
onDragFinished(MarqueeSelectionEventArgs inputModeEventArgs)
Callback triggered once the drag has been finalized.
|
protected void |
onDragFinishing(MarqueeSelectionEventArgs inputModeEventArgs)
Callback triggered before the drag will be finalized.
|
protected void |
onDragged(MarqueeSelectionEventArgs inputModeEventArgs)
Callback triggered at the end of each drag.
|
protected void |
onDragging(MarqueeSelectionEventArgs inputModeEventArgs)
Callback triggered at the start of each drag.
|
protected void |
onDragStarted(MarqueeSelectionEventArgs inputModeEventArgs)
Triggers the
DragStarted event. |
protected void |
onDragStarting(MarqueeSelectionEventArgs inputModeEventArgs)
Triggers the
DragStarting event. |
protected void |
onStopped()
Called after
stop() has been called. |
void |
removeDragCanceledListener(IEventHandler<MarqueeSelectionEventArgs> dragCanceledEvent)
Removes the given listener for the
DragCanceled event that occurs when the drag has been canceled. |
void |
removeDragCancelingListener(IEventHandler<MarqueeSelectionEventArgs> dragCancelingEvent)
Removes the given listener for the
DragCanceling event that occurs before the drag will be canceled. |
void |
removeDragFinishedListener(IEventHandler<MarqueeSelectionEventArgs> dragFinishedEvent)
Removes the given listener for the
DragFinished event that occurs the drag has been finished. |
void |
removeDragFinishingListener(IEventHandler<MarqueeSelectionEventArgs> dragFinishingEvent)
Removes the given listener for the
DragFinishing event that occurs before the drag will be finished. |
void |
removeDraggedListener(IEventHandler<MarqueeSelectionEventArgs> draggedEvent)
Removes the given listener for the
Dragged event that occurs at the end of every drag. |
void |
removeDraggingListener(IEventHandler<MarqueeSelectionEventArgs> draggingEvent)
Removes the given listener for the
Dragging event that occurs at the start of every drag. |
void |
removeDragStartedListener(IEventHandler<MarqueeSelectionEventArgs> dragStartedEvent)
Removes the given listener for the
DragStarted event that occurs once the drag is initialized and has started. |
void |
removeDragStartingListener(IEventHandler<MarqueeSelectionEventArgs> dragStartingEvent)
Removes the given listener for the
DragStarting event that occurs once the drag is starting. |
void |
setCancelRecognizer(IEventRecognizer value)
Sets the "cancel" recognizer.
|
void |
setDraggedRecognizer(IEventRecognizer value)
Sets the "dragged" recognizer.
|
void |
setDraggedRecognizerTouch(IEventRecognizer value)
Sets the "dragged" recognizer for touch input.
|
void |
setEnabled(boolean value)
Sets the enabled state of this input mode.
|
void |
setExclusive(boolean value)
Sets a value indicating whether this mode will be the only one running when it has the mutex.
|
void |
setMarqueeCursor(Cursor value)
Sets the cursor to use during the dragging of the marquee.
|
void |
setPressedRecognizer(IEventRecognizer value)
Sets the "pressed" state recognizer.
|
void |
setPressedRecognizerTouch(IEventRecognizer value)
Sets the "pressed" state recognizer for touch input.
|
void |
setPriority(int value)
The priority of this input mode.
|
void |
setReleasedRecognizer(IEventRecognizer value)
Sets the "released" recognizer.
|
void |
setReleasedRecognizerTouch(IEventRecognizer value)
Sets the "released" recognizer for touch input.
|
void |
setTemplate(IVisualTemplate value)
Sets the template that is used for the visualization of the marquee rectangle.
|
boolean |
stop()
Called by the client in order to stop a current editing progress.
|
void |
uninstall(IInputModeContext context)
Uninstalls this mode from the given context.
|
public static final ResourceKey MARQUEE_RECTANGLE_TEMPLATE_KEY
ResourceKey
that can be used to store a IVisualTemplate
that can be used to create the visual that
will be used to draw the marquee box.public MarqueeSelectionInputMode()
public final void addDragCanceledListener(IEventHandler<MarqueeSelectionEventArgs> dragCanceledEvent)
DragCanceled
event that occurs when the drag has been canceled.dragCanceledEvent
- The listener to add.removeDragCanceledListener(IEventHandler)
public final void addDragCancelingListener(IEventHandler<MarqueeSelectionEventArgs> dragCancelingEvent)
DragCanceling
event that occurs before the drag will be canceled.dragCancelingEvent
- The listener to add.removeDragCancelingListener(IEventHandler)
public final void addDragFinishedListener(IEventHandler<MarqueeSelectionEventArgs> dragFinishedEvent)
DragFinished
event that occurs the drag has been finished.dragFinishedEvent
- The listener to add.removeDragFinishedListener(IEventHandler)
public final void addDragFinishingListener(IEventHandler<MarqueeSelectionEventArgs> dragFinishingEvent)
DragFinishing
event that occurs before the drag will be finished.dragFinishingEvent
- The listener to add.removeDragFinishingListener(IEventHandler)
public final void addDraggedListener(IEventHandler<MarqueeSelectionEventArgs> draggedEvent)
Dragged
event that occurs at the end of every drag.draggedEvent
- The listener to add.removeDraggedListener(IEventHandler)
public final void addDraggingListener(IEventHandler<MarqueeSelectionEventArgs> draggingEvent)
Dragging
event that occurs at the start of every drag.draggingEvent
- The listener to add.removeDraggingListener(IEventHandler)
public final void addDragStartedListener(IEventHandler<MarqueeSelectionEventArgs> dragStartedEvent)
DragStarted
event that occurs once the drag is initialized and has started.dragStartedEvent
- The listener to add.removeDragStartedListener(IEventHandler)
public final void addDragStartingListener(IEventHandler<MarqueeSelectionEventArgs> dragStartingEvent)
DragStarting
event that occurs once the drag is starting.dragStartingEvent
- The listener to add.removeDragStartingListener(IEventHandler)
public void cancel()
cancel
in interface IInputMode
protected MarqueeSelectionEventArgs createInputModeEventArgs()
InputModeEventArgs
for this input
mode.public final IEventRecognizer getCancelRecognizer()
This recognizer recognizes the cancel action during the marquee selection.
setCancelRecognizer(IEventRecognizer)
protected final ConcurrencyController getController()
Controller
.public final IEventRecognizer getDraggedRecognizer()
This recognizer instance determines when the user is dragging the marquee.
setDraggedRecognizer(IEventRecognizer)
public final IEventRecognizer getDraggedRecognizerTouch()
This recognizer instance determines when the user is dragging the marquee.
setDraggedRecognizerTouch(IEventRecognizer)
public final IInputModeContext getInputModeContext()
IInputMode
null
if this instance is not installed.
Note that this instance should not be passed down to subordinate modes or instances. Instead a corresponding context
that has this instance set as the ParentInputMode
should be used.
getInputModeContext
in interface IInputMode
public final Cursor getMarqueeCursor()
The default is Cursors.Cross
setMarqueeCursor(Cursor)
public final IEventRecognizer getPressedRecognizer()
This recognizer instance will be used to determine when the user begins to draw the marquee.
setPressedRecognizer(IEventRecognizer)
public final IEventRecognizer getPressedRecognizerTouch()
This recognizer instance will be used to determine when the user begins to draw the marquee.
setPressedRecognizerTouch(IEventRecognizer)
public final int getPriority()
IInputMode
The priority will influence the order in which the modes will be installed
into the canvas control. The lower the priority value, the earlier it will be installed. If two modes are installed
using the same priority value, the first one will be installed earlier.
getPriority
in interface IInputMode
public final IEventRecognizer getReleasedRecognizer()
This instance determines when the user has finished creating the marquee.
setReleasedRecognizer(IEventRecognizer)
public final IEventRecognizer getReleasedRecognizerTouch()
This instance determines when the user has finished creating the marquee.
setReleasedRecognizerTouch(IEventRecognizer)
public final RectD getSelectionRectangle()
public final IVisualTemplate getTemplate()
setTemplate(IVisualTemplate)
public void install(IInputModeContext context, ConcurrencyController controller)
In general a mode can only be installed into a single canvas at all times.
This method is called to initialize this instance. Subclasses should override this method to register the corresponding event handler delegates for the various input events they need to register with.
Overriding implementations should call the base implementation, first.
install
in interface IInputMode
context
- The context that this instance shall be installed into. The same instance will be passed to this instance during
IInputMode.uninstall(IInputModeContext)
. A reference to the context may be kept and queried during the time
the mode is installed.controller
- The Controller
for this mode.IInputMode.uninstall(IInputModeContext)
public boolean isEnabled()
Clients can use this property to disable or reenable this instance. This will set the Enabled
property of the installed Controller
so a disabled instance should never try to acquire the
input mutex.
setEnabled(boolean)
public final boolean isExclusive()
The value of this property will be delegated to the Exclusive
property of
the Controller
.
If this mode is marked as exclusive and has the mutex, all other modes added
to the same MultiplexingInputMode
will be deactivated. Otherwise it will always run
concurrently with all other modes.
setExclusive(boolean)
protected void onCanceled()
cancel()
has been called.
Can be overridden in subclasses to perform additional actions after the mode has been canceled.
This implementation does nothing.
protected void onConcurrencyControllerActivated()
Active
property of the installed ConcurrencyController
has been set to true
.
Can be overridden in subclasses to perform additional actions after the mode has been activated.
Overriding implementations should call the base implementation.
protected void onConcurrencyControllerDeactivated()
Active
property of the installed ConcurrencyController
has been set to false
.
Can be overridden in subclasses to perform additional actions after the mode has been deactivated.
Overriding implementations should call the base implementation.
protected void onDragCanceled(MarqueeSelectionEventArgs inputModeEventArgs)
DragCanceled
event.inputModeEventArgs
- The event argument that contains context information.protected void onDragCanceling(MarqueeSelectionEventArgs inputModeEventArgs)
DragCanceling
event.inputModeEventArgs
- The event argument that contains context information.protected void onDragFinished(MarqueeSelectionEventArgs inputModeEventArgs)
This method triggers the DragFinished
event.
inputModeEventArgs
- The event argument that contains context information.protected void onDragFinishing(MarqueeSelectionEventArgs inputModeEventArgs)
This method triggers the DragFinishing
event.
inputModeEventArgs
- The event argument that contains context information.protected void onDragged(MarqueeSelectionEventArgs inputModeEventArgs)
This method triggers the Dragged
event.
inputModeEventArgs
- The event argument that contains context information.protected void onDragging(MarqueeSelectionEventArgs inputModeEventArgs)
This method triggers the Dragging
event.
inputModeEventArgs
- The event argument that contains context information.protected void onDragStarted(MarqueeSelectionEventArgs inputModeEventArgs)
DragStarted
event.inputModeEventArgs
- The event argument that contains context information.protected void onDragStarting(MarqueeSelectionEventArgs inputModeEventArgs)
DragStarting
event.inputModeEventArgs
- The event argument that contains context information.protected void onStopped()
stop()
has been called.
Can be overridden in subclasses to perform additional actions after the mode has been stopped.
This implementation does nothing.
public final void removeDragCanceledListener(IEventHandler<MarqueeSelectionEventArgs> dragCanceledEvent)
DragCanceled
event that occurs when the drag has been canceled.dragCanceledEvent
- The listener to remove.addDragCanceledListener(IEventHandler)
public final void removeDragCancelingListener(IEventHandler<MarqueeSelectionEventArgs> dragCancelingEvent)
DragCanceling
event that occurs before the drag will be canceled.dragCancelingEvent
- The listener to remove.addDragCancelingListener(IEventHandler)
public final void removeDragFinishedListener(IEventHandler<MarqueeSelectionEventArgs> dragFinishedEvent)
DragFinished
event that occurs the drag has been finished.dragFinishedEvent
- The listener to remove.addDragFinishedListener(IEventHandler)
public final void removeDragFinishingListener(IEventHandler<MarqueeSelectionEventArgs> dragFinishingEvent)
DragFinishing
event that occurs before the drag will be finished.dragFinishingEvent
- The listener to remove.addDragFinishingListener(IEventHandler)
public final void removeDraggedListener(IEventHandler<MarqueeSelectionEventArgs> draggedEvent)
Dragged
event that occurs at the end of every drag.draggedEvent
- The listener to remove.addDraggedListener(IEventHandler)
public final void removeDraggingListener(IEventHandler<MarqueeSelectionEventArgs> draggingEvent)
Dragging
event that occurs at the start of every drag.draggingEvent
- The listener to remove.addDraggingListener(IEventHandler)
public final void removeDragStartedListener(IEventHandler<MarqueeSelectionEventArgs> dragStartedEvent)
DragStarted
event that occurs once the drag is initialized and has started.dragStartedEvent
- The listener to remove.addDragStartedListener(IEventHandler)
public final void removeDragStartingListener(IEventHandler<MarqueeSelectionEventArgs> dragStartingEvent)
DragStarting
event that occurs once the drag is starting.dragStartingEvent
- The listener to remove.addDragStartingListener(IEventHandler)
public final void setCancelRecognizer(IEventRecognizer value)
This recognizer recognizes the cancel action during the marquee selection.
value
- The "cancel" recognizer.getCancelRecognizer()
public final void setDraggedRecognizer(IEventRecognizer value)
This recognizer instance determines when the user is dragging the marquee.
value
- The "dragged" recognizer.getDraggedRecognizer()
public final void setDraggedRecognizerTouch(IEventRecognizer value)
This recognizer instance determines when the user is dragging the marquee.
value
- The "dragged" recognizer for touch events.getDraggedRecognizerTouch()
public void setEnabled(boolean value)
Clients can use this property to disable or reenable this instance. This will set the Enabled
property of the installed Controller
so a disabled instance should never try to acquire the
input mutex.
value
- The Enabled to set.isEnabled()
public final void setExclusive(boolean value)
The value of this property will be delegated to the Exclusive
property of
the Controller
.
If this mode is marked as exclusive and has the mutex, all other modes added
to the same MultiplexingInputMode
will be deactivated. Otherwise it will always run
concurrently with all other modes.
value
- The Exclusive to set.isExclusive()
public final void setMarqueeCursor(Cursor value)
The default is Cursors.Cross
value
- The MarqueeCursor to set.getMarqueeCursor()
public final void setPressedRecognizer(IEventRecognizer value)
This recognizer instance will be used to determine when the user begins to draw the marquee.
value
- The "pressed" recognizer.getPressedRecognizer()
public final void setPressedRecognizerTouch(IEventRecognizer value)
This recognizer instance will be used to determine when the user begins to draw the marquee.
value
- The "pressed" recognizer for touch events.getPressedRecognizerTouch()
public final void setPriority(int value)
The priority will influence the order in which the modes will be installed
into the canvas control. The lower the priority value, the earlier it will be installed. If two modes are installed
using the same priority value, the first one will be installed earlier.
value
- The Priority to set.getPriority()
public final void setReleasedRecognizer(IEventRecognizer value)
This instance determines when the user has finished creating the marquee.
value
- The "released" recognizer.getReleasedRecognizer()
public final void setReleasedRecognizerTouch(IEventRecognizer value)
This instance determines when the user has finished creating the marquee.
value
- The "released" recognizer for touch events.getReleasedRecognizerTouch()
public final void setTemplate(IVisualTemplate value)
value
- The template.getTemplate()
public boolean stop()
IInputMode
This should stop the current edit, if one is in progress and possibly commit all of the changes. If stopping is not
possible, this method can return false
stop
in interface IInputMode
true
if and only if the editing has been stopped or there was no edit in progressIInputMode.cancel()
public void uninstall(IInputModeContext context)
This code should clean up all changes made to the canvas in the IInputMode.install(IInputModeContext, ConcurrencyController)
method. After a mode has been uninstalled it can be installed again into the same or another canvas.
Overriding implementations should call the base implementation after their own code.
uninstall
in interface IInputMode
context
- The context to deregister from. This is the same instance that had been passed to IInputMode.install(IInputModeContext, ConcurrencyController)
during installation.