public class TLspSelectController extends ALspController
Controller that allows the user to select domain objects in the view using the mouse. The controller supports selection changes by clicking on the view or by dragging a rectangle.
In case you want to programmatically (de)select objects, query the selection or get informed about selection changes, you should use:
ILcdSelection.getSelectedObjects()
to retrieve the selected objects from a single layer.ILcdLayer.selectObject(Object, boolean, int)
to update the selected state of an object in a layer.ILcdSelection.addSelectionListener(ILcdSelectionListener)
to register a listener which is informed about selection changes in a single layer.ILcdSelection.addSelectionListener(ILcdSelectionListener)
to register a listener which is informed about selection changes in any of the layers contained in the view.TLspSelectControllerModel
.
TLspSelectControllerModel
will query the view and the layers for objects that match the mouse click (or the selection rectangle) in the TLspSelectControllerModel.selectionCandidates(ALspSelectInput, Set, boolean, ILspView)
method.TLspSelectControllerModel.applySelection(ALspSelectInput, TLspSelectChoice, TLspSelectMode, List, ILspView)
method.
This controller calls the isSelectByDraggedRectangle(MouseEvent)
to determine whether or not a MouseEvent
should be interpreted as a "select by dragging a rectangle".
Override this method if you want to change the default behavior.
This controller calls the selectWhat(MouseEvent, ALspSelectInput, ILspView)
method to determine which
paint representation states to consider when selecting objects.
This information is passed to the TLspSelectControllerModel
, and it is the responsibility of the controller model
to respect this choice.
This controller calls the selectChoice(MouseEvent, ALspSelectInput, Set)
method to determine how selection candidates
are selected when there are multiple candidates.
The resulting TLspSelectChoice
is passed to the controller model, and it is the controller model who decides
how to handle this choice.
This controller calls the selectMode(MouseEvent, ALspSelectInput, Set, TLspSelectChoice)
to determine what to do
with the selection candidates.
For example should the objects be added to the current selection, replace the current selection, ... .
The resulting TLspSelectMode
is passed to the controller model,
and it is the controller model who decides how to handle this mode.
TLspSelectControllerModel
.
You can customize the selection behavior by installing a custom
controller model instance on this model, or by specifying a custom controller model in the constructor.
ILcdAction
which should be triggered when a double click is performed (setDoubleClickAction(ILcdAction)
).
A typical use-case of this is setting an action which shows the properties of an object when double-clicking on it.
ILcdAction
which should be triggered when the user triggers a context action (setContextAction(ILcdAction)
).
Whether or not the mouse event should trigger a context action is determined by isContextClick(MouseEvent)
.
A typical use-case of this is setting an action which shows a pop-up menu for the selected object when right-clicking.
TLspMagnifierController
is active on the view.Constructor and Description |
---|
TLspSelectController()
Create a new TLspSelectController with a default name, short description, icon and controller
model.
|
TLspSelectController(TLspSelectControllerModel aControllerModel)
Create a new TLspSelectController using the provided controller model.
|
Modifier and Type | Method and Description |
---|---|
ILcdAction |
getContextAction()
Returns the right click action.
|
TLspSelectControllerModel |
getControllerModel()
Returns the controller model of this controller.
|
ILcdAction |
getDoubleClickAction()
Returns the double click action.
|
int |
getMoveThreshold()
This property defines the move threshold.
|
AWTEvent |
handleAWTEventImpl(AWTEvent aAWTEvent)
Called by
handleAWTEvent . |
javafx.event.Event |
handleFXEventImpl(javafx.event.Event aEvent)
Called by
handleFXEvent . |
protected boolean |
isContextClick(MouseEvent aReleasedEvent)
This method indicates whether or not the
context action should be called when the mouse is released. |
protected boolean |
isContextClick(javafx.scene.input.MouseEvent aReleasedEvent)
JavaFX equivalent of
isContextClick(javafx.scene.input.MouseEvent) . |
protected boolean |
isSelectByDraggedRectangle(MouseEvent aPressedEvent)
This method decides whether rectangle selection is activated or not.
|
protected boolean |
isSelectByDraggedRectangle(javafx.scene.input.MouseEvent aPressedEvent)
JavaFX equivalent of
isSelectByDraggedRectangle(MouseEvent) . |
protected TLspPaintProgress |
paintImpl(ILcdGLDrawable aGLDrawable,
ILspView aView,
TLspPaintPhase aPaintPhase)
The specific implementation of
paint for this controller. |
protected TLspSelectChoice |
selectChoice(MouseEvent aMouseEvent,
ALspSelectInput aInput,
Set<TLspPaintRepresentation> aRepresentations)
Returns the
TLspSelectChoice to use, a parameter that indicates how to select
the actual candidates from a set of possible selection candidates. |
protected TLspSelectChoice |
selectChoice(javafx.scene.input.MouseEvent aMouseEvent,
ALspSelectInput aInput,
Set<TLspPaintRepresentation> aRepresentations)
JavaFX equivalent of
selectChoice(javafx.scene.input.MouseEvent, ALspSelectInput, Set) . |
protected TLspSelectMode |
selectMode(MouseEvent aMouseEvent,
ALspSelectInput aInput,
Set<TLspPaintRepresentation> aRepresentations,
TLspSelectChoice aChoice)
Returns the mode that defines how the objects involved in the selection should interact
with the existing selection, for example add them, remove them, toggle their selection state,
etc.
|
protected TLspSelectMode |
selectMode(javafx.scene.input.MouseEvent aMouseEvent,
ALspSelectInput aInput,
Set<TLspPaintRepresentation> aRepresentations,
TLspSelectChoice aChoice)
JavaFX equivalent of
selectMode(MouseEvent, ALspSelectInput, Set, TLspSelectChoice) . |
protected Set<TLspPaintRepresentation> |
selectWhat(MouseEvent aMouseEvent,
ALspSelectInput aInput,
ILspView aView)
Returns the mode that defines by what objects can be selected: by their bodies, their
labels, ...
|
protected Set<TLspPaintRepresentation> |
selectWhat(javafx.scene.input.MouseEvent aMouseEvent,
ALspSelectInput aInput,
ILspView aView)
JavaFX equivalent of
selectWhat(MouseEvent, ALspSelectInput, ILspView) . |
void |
setContextAction(ILcdAction aContextAction)
Sets the context action.
|
void |
setControllerModel(TLspSelectControllerModel aModel)
Sets the controller model of this controller to the given model.
|
void |
setDoubleClickAction(ILcdAction aDoubleClickAction)
Sets the double click action.
|
void |
setMoveThreshold(int aMouseDraggedSensitivity)
Sets the minimal width or height that a user needs to drag the mouse before the rectangle is
taken into account for painting.
|
void |
startInteractionImpl(ILspView aView)
The specific implementation of
startInteraction for this controller. |
protected void |
terminateInteractionImpl(ILspView aView)
The specific implementation of
terminateInteraction for this controller. |
addPropertyChangeListener, addStatusListener, appendController, firePropertyChange, fireStatusEvent, getAWTFilter, getCursor, getFXCursor, getFXFilter, getIcon, getLayered, getName, getNextController, getShortDescription, getView, handleAWTEvent, handleFXEvent, paint, registerViewPropertyNameForReset, removePropertyChangeListener, removeStatusListener, setAWTFilter, setCursor, setFXCursor, setFXFilter, setIcon, setName, setShortDescription, startInteraction, terminateInteraction
public TLspSelectController()
public TLspSelectController(TLspSelectControllerModel aControllerModel)
aControllerModel
- the controller model.public TLspSelectControllerModel getControllerModel()
public void setControllerModel(TLspSelectControllerModel aModel)
aModel
- the new controller model of this controller.public int getMoveThreshold()
setMoveThreshold(int)
public void setMoveThreshold(int aMouseDraggedSensitivity)
aMouseDraggedSensitivity
- The new sensitivity, in pixels.getMoveThreshold()
public void startInteractionImpl(ILspView aView)
ALspController
startInteraction
for this controller.startInteractionImpl
in class ALspController
aView
- the view to start interaction with.protected void terminateInteractionImpl(ILspView aView)
ALspController
terminateInteraction
for this controller.terminateInteractionImpl
in class ALspController
aView
- the view to terminate interaction with.public AWTEvent handleAWTEventImpl(AWTEvent aAWTEvent)
ALspController
handleAWTEvent
.
Returns null
when the controller consumed the event or a partially consumed event
when the controller partially consumed the event (which could happen with
TLcdTouchEvent
s). When the controller did not use the given event, it is returned
unaltered.handleAWTEventImpl
in class ALspController
aAWTEvent
- the event to be handled.null
when the input event was consumed, the (possibly modified) input
event when it was (partially) consumed.public javafx.event.Event handleFXEventImpl(javafx.event.Event aEvent)
ALspController
handleFXEvent
.
Returns null
when the controller consumed the event. When the controller did not use the
given event, it is returned unaltered.handleFXEventImpl
in class ALspController
aEvent
- the event to be handled.null
when the input event was consumed, the (possibly modified) input
event when it was (partially) consumed.protected TLspPaintProgress paintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase)
ALspController
paint
for this controller.paintImpl
in class ALspController
aGLDrawable
- the drawable that should be painted onaView
- the view that is painted onaPaintPhase
- the current paint phaseprotected Set<TLspPaintRepresentation> selectWhat(MouseEvent aMouseEvent, ALspSelectInput aInput, ILspView aView)
Returns the mode that defines by what objects can be selected: by their bodies, their labels, ...
The default behavior of this method is to return a set containing all available paint representations in the view.
aMouseEvent
- The last mouse event that was involved in the selection change.aInput
- The selection input.
This is a TLspSelectPointInput
in case of single click selection,
or a TLspSelectRectangleInput
in case of rectangle selection.aView
- The viewprotected Set<TLspPaintRepresentation> selectWhat(javafx.scene.input.MouseEvent aMouseEvent, ALspSelectInput aInput, ILspView aView)
selectWhat(MouseEvent, ALspSelectInput, ILspView)
.aMouseEvent
- The last mouse event that was involved in the selection change.aInput
- The selection input.
This is a TLspSelectPointInput
in case of single click selection,
or a TLspSelectRectangleInput
in case of rectangle selection.aView
- The viewprotected TLspSelectChoice selectChoice(MouseEvent aMouseEvent, ALspSelectInput aInput, Set<TLspPaintRepresentation> aRepresentations)
Returns the TLspSelectChoice
to use, a parameter that indicates how to select
the actual candidates from a set of possible selection candidates.
The default behaviour is as follows:
TLspSelectChoice.CHOOSE
is returnedTLspSelectChoice.DEFAULT
is returned.aMouseEvent
- The last mouse event that was involved in the selection change.aInput
- The selection input.aRepresentations
- The paint representations interacting with selection.protected TLspSelectChoice selectChoice(javafx.scene.input.MouseEvent aMouseEvent, ALspSelectInput aInput, Set<TLspPaintRepresentation> aRepresentations)
selectChoice(javafx.scene.input.MouseEvent, ALspSelectInput, Set)
.aMouseEvent
- The last mouse event that was involved in the selection change.aInput
- The selection input.aRepresentations
- The paint representations interacting with selection.protected TLspSelectMode selectMode(MouseEvent aMouseEvent, ALspSelectInput aInput, Set<TLspPaintRepresentation> aRepresentations, TLspSelectChoice aChoice)
TLspSelectMode.INVERT
over TLspSelectMode.REPLACE
.context
clicking on top an an existing selection, TLspSelectMode.NO_CHANGE
will be selected.aMouseEvent
- The last mouse event that was involved in the selection change.aInput
- The selection input.aRepresentations
- The paint representations interacting with selection.aChoice
- The TLspSelectChoice that will be used.protected TLspSelectMode selectMode(javafx.scene.input.MouseEvent aMouseEvent, ALspSelectInput aInput, Set<TLspPaintRepresentation> aRepresentations, TLspSelectChoice aChoice)
selectMode(MouseEvent, ALspSelectInput, Set, TLspSelectChoice)
.aMouseEvent
- The last mouse event that was involved in the selection change.aInput
- The selection input.aRepresentations
- The paint representations interacting with selection.aChoice
- The TLspSelectChoice that will be used.protected boolean isSelectByDraggedRectangle(MouseEvent aPressedEvent)
This method decides whether rectangle selection is activated or not. It is called when the
mouse is pressed. If it returns true, drag events (over the sensitivity
) will be used to create a selection rectangle. If it
returns false, those drag events will be delegated to the next controller in the chain.
By default, this method will return true when the shift key is pressed at the time the mouse is pressed.
aPressedEvent
- the pressed event to be considered.protected boolean isSelectByDraggedRectangle(javafx.scene.input.MouseEvent aPressedEvent)
isSelectByDraggedRectangle(MouseEvent)
.aPressedEvent
- the pressed event to be considered.protected boolean isContextClick(MouseEvent aReleasedEvent)
This method indicates whether or not the context action
should be called when the mouse is released.
By default, this method returns true when the right mouse button is released.
aReleasedEvent
- the event used to evaluateprotected boolean isContextClick(javafx.scene.input.MouseEvent aReleasedEvent)
isContextClick(javafx.scene.input.MouseEvent)
.aReleasedEvent
- the event used to evaluatepublic ILcdAction getDoubleClickAction()
)
public void setDoubleClickAction(ILcdAction aDoubleClickAction)
Sets the double click action. This action is performed when the user double clicks. Use
null
(the default) to disable this feature.
The double click action will be triggered by a TLcdActionAtLocationEvent
aDoubleClickAction
- The double click action, or null.public ILcdAction getContextAction()
setContextAction(com.luciad.gui.ILcdAction)
public void setContextAction(ILcdAction aContextAction)
Sets the context action. This action is performed when isContextClick(java.awt.event.MouseEvent)
returns true
when the mouse is released. This is typically used for an action tightly integrated with
selection, for instance to show a popup menu for the selected object(s). Use null
(the default) to disable this feature.
The context action will be triggered by a TLcdActionAtLocationEvent
.
aContextAction
- The context action, or null.