Class TLspSelectController
- All Implemented Interfaces:
ILcdAWTEventListener
,ILspController
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.
How selection works
The selection controller works in multiple steps:- The controller interprets the user input: first, this controller gathers information about the selection intent of the user. For example whether the user wants to add or remove the object to/from the selection, whether the user wants to drag a rectangle to select multiple objects in one go, ... .
-
The controller model performs the actual update of the selection:
once all this information is gathered, it is passed to the select
method of the
TLspSelectControllerModel
.- The
TLspSelectControllerModel
will query the view and the layers for objects that match the mouse click (or the selection rectangle) in theTLspSelectControllerModel.selectionCandidates(ALspSelectInput, Set, boolean, ILspView)
method. - Once the controller model has found all the selection candidates, it will finally update the selection on the map in the
TLspSelectControllerModel.applySelection(ALspSelectInput, TLspSelectChoice, TLspSelectMode, List, ILspView)
method.
- The
Customizing the controller
(De)Activate rectangle selection mode
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.
Selecting objects by their labels or only by their bodies
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.
Overlapping objects: selecting the topmost element only or not
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.
Selecting or deselecting the selection candidates
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.
Replacing the controller model
The actual adjusting of the selection is done by theTLspSelectControllerModel
.
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.
Double click and right click pop-up menu
This controller has methods to:-
Specify an
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. - Specify an
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 byisContextClick(MouseEvent)
. A typical use-case of this is setting an action which shows a pop-up menu for the selected object when right-clicking.
Limitations
Selection is not supported whileTLspMagnifierController
is active on the view.- Since:
- 2012.0
-
Constructor Summary
ConstructorDescriptionCreate 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. -
Method Summary
Modifier and TypeMethodDescriptionReturns the right click action.Returns the controller model of this controller.Returns the double click action.int
This property defines the move threshold.handleAWTEventImpl
(AWTEvent aAWTEvent) Called byhandleAWTEvent
.handleFXEventImpl
(Event aEvent) Called byhandleFXEvent
.protected boolean
isContextClick
(MouseEvent aReleasedEvent) This method indicates whether or not thecontext action
should be called when the mouse is released.protected boolean
isContextClick
(MouseEvent aReleasedEvent) JavaFX equivalent ofisContextClick(javafx.scene.input.MouseEvent)
.protected boolean
isSelectByDraggedRectangle
(MouseEvent aPressedEvent) This method decides whether rectangle selection is activated or not.protected boolean
isSelectByDraggedRectangle
(MouseEvent aPressedEvent) JavaFX equivalent ofisSelectByDraggedRectangle(MouseEvent)
.protected TLspPaintProgress
paintImpl
(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) The specific implementation ofpaint
for this controller.protected TLspSelectChoice
selectChoice
(MouseEvent aMouseEvent, ALspSelectInput aInput, Set<TLspPaintRepresentation> aRepresentations) Returns theTLspSelectChoice
to use, a parameter that indicates how to select the actual candidates from a set of possible selection candidates.protected TLspSelectChoice
selectChoice
(MouseEvent aMouseEvent, ALspSelectInput aInput, Set<TLspPaintRepresentation> aRepresentations) JavaFX equivalent ofselectChoice(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
(MouseEvent aMouseEvent, ALspSelectInput aInput, Set<TLspPaintRepresentation> aRepresentations, TLspSelectChoice aChoice) JavaFX equivalent ofselectMode(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
(MouseEvent aMouseEvent, ALspSelectInput aInput, ILspView aView) JavaFX equivalent ofselectWhat(MouseEvent, ALspSelectInput, ILspView)
.void
setContextAction
(ILcdAction aContextAction) Sets the context action.void
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 ofstartInteraction
for this controller.protected void
terminateInteractionImpl
(ILspView aView) The specific implementation ofterminateInteraction
for this controller.Methods inherited from class com.luciad.view.lightspeed.controller.ALspController
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
-
Constructor Details
-
TLspSelectController
public TLspSelectController()Create a new TLspSelectController with a default name, short description, icon and controller model. -
TLspSelectController
Create a new TLspSelectController using the provided controller model.- Parameters:
aControllerModel
- the controller model.
-
-
Method Details
-
getControllerModel
Returns the controller model of this controller.- Returns:
- the controller model of this controller.
-
setControllerModel
Sets the controller model of this controller to the given model.- Parameters:
aModel
- the new controller model of this controller.
-
getMoveThreshold
public int getMoveThreshold()This property defines the move threshold. When a rectangle is dragged with a height or width smaller than the mouse pressed sensitivity it is not taken into account for painting.- Returns:
- The current sensitivity, in pixels.
- See Also:
-
setMoveThreshold
public 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.- Parameters:
aMouseDraggedSensitivity
- The new sensitivity, in pixels.- See Also:
-
startInteractionImpl
Description copied from class:ALspController
The specific implementation ofstartInteraction
for this controller.- Overrides:
startInteractionImpl
in classALspController
- Parameters:
aView
- the view to start interaction with.
-
terminateInteractionImpl
Description copied from class:ALspController
The specific implementation ofterminateInteraction
for this controller.- Overrides:
terminateInteractionImpl
in classALspController
- Parameters:
aView
- the view to terminate interaction with.
-
handleAWTEventImpl
Description copied from class:ALspController
Called byhandleAWTEvent
. Returnsnull
when the controller consumed the event or a partially consumed event when the controller partially consumed the event (which could happen withTLcdTouchEvent
s). When the controller did not use the given event, it is returned unaltered.- Specified by:
handleAWTEventImpl
in classALspController
- Parameters:
aAWTEvent
- the event to be handled.- Returns:
null
when the input event was consumed, the (possibly modified) input event when it was (partially) consumed.
-
handleFXEventImpl
Description copied from class:ALspController
Called byhandleFXEvent
. Returnsnull
when the controller consumed the event. When the controller did not use the given event, it is returned unaltered.- Overrides:
handleFXEventImpl
in classALspController
- Parameters:
aEvent
- the event to be handled.- Returns:
null
when the input event was consumed, the (possibly modified) input event when it was (partially) consumed.
-
paintImpl
protected TLspPaintProgress paintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) Description copied from class:ALspController
The specific implementation ofpaint
for this controller.- Overrides:
paintImpl
in classALspController
- Parameters:
aGLDrawable
- the drawable that should be painted onaView
- the view that is painted onaPaintPhase
- the current paint phase- Returns:
- whether or not the painting was finished
-
selectWhat
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, ...
The default behavior of this method is to return a set containing all available paint representations in the view.
- Parameters:
aMouseEvent
- The last mouse event that was involved in the selection change.aInput
- The selection input. This is aTLspSelectPointInput
in case of single click selection, or aTLspSelectRectangleInput
in case of rectangle selection.aView
- The view- Returns:
- a set of paint representations indicating which interact with the selection functionality.
-
selectWhat
protected Set<TLspPaintRepresentation> selectWhat(MouseEvent aMouseEvent, ALspSelectInput aInput, ILspView aView) JavaFX equivalent ofselectWhat(MouseEvent, ALspSelectInput, ILspView)
.- Parameters:
aMouseEvent
- The last mouse event that was involved in the selection change.aInput
- The selection input. This is aTLspSelectPointInput
in case of single click selection, or aTLspSelectRectangleInput
in case of rectangle selection.aView
- The view- Returns:
- a set of paint representations indicating which interact with the selection functionality.
- Since:
- 2019.0
-
selectChoice
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.The default behaviour is as follows:
- When the alt key is pressed
TLspSelectChoice.CHOOSE
is returned - Otherwise,
TLspSelectChoice.DEFAULT
is returned.
- Parameters:
aMouseEvent
- The last mouse event that was involved in the selection change.aInput
- The selection input.aRepresentations
- The paint representations interacting with selection.- Returns:
- The select choice
- When the alt key is pressed
-
selectChoice
protected TLspSelectChoice selectChoice(MouseEvent aMouseEvent, ALspSelectInput aInput, Set<TLspPaintRepresentation> aRepresentations) JavaFX equivalent ofselectChoice(javafx.scene.input.MouseEvent, ALspSelectInput, Set)
.- Parameters:
aMouseEvent
- The last mouse event that was involved in the selection change.aInput
- The selection input.aRepresentations
- The paint representations interacting with selection.- Returns:
- The select choice
- Since:
- 2019.0
-
selectMode
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. The default behaviour is as follows:- Pressing the shift key will favor the
TLspSelectMode.INVERT
overTLspSelectMode.REPLACE
. - When
context
clicking on top an an existing selection,TLspSelectMode.NO_CHANGE
will be selected.
- Parameters:
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.- Returns:
- The select mode.
- Pressing the shift key will favor the
-
selectMode
protected TLspSelectMode selectMode(MouseEvent aMouseEvent, ALspSelectInput aInput, Set<TLspPaintRepresentation> aRepresentations, TLspSelectChoice aChoice) JavaFX equivalent ofselectMode(MouseEvent, ALspSelectInput, Set, TLspSelectChoice)
.- Parameters:
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.- Returns:
- The select mode.
- Since:
- 2019.0
-
isSelectByDraggedRectangle
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.
- Parameters:
aPressedEvent
- the pressed event to be considered.- Returns:
- true for rectangle selection, false for delegating mouse drags.
-
isSelectByDraggedRectangle
JavaFX equivalent ofisSelectByDraggedRectangle(MouseEvent)
.- Parameters:
aPressedEvent
- the pressed event to be considered.- Returns:
- true for rectangle selection, false for delegating mouse drags.
- Since:
- 2019.0
-
isContextClick
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.
- Parameters:
aReleasedEvent
- the event used to evaluate- Returns:
- true if the context action should be triggered, false otherwise.
-
isContextClick
JavaFX equivalent ofisContextClick(javafx.scene.input.MouseEvent)
.- Parameters:
aReleasedEvent
- the event used to evaluate- Returns:
- true if the context action should be triggered, false otherwise.
- Since:
- 2019.0
-
getDoubleClickAction
Returns the double click action.- Returns:
- the double click action.
- See Also:
-
setDoubleClickAction
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
- Parameters:
aDoubleClickAction
- The double click action, or null.
-
getContextAction
Returns the right click action.- Returns:
- the right click action.
- See Also:
-
setContextAction
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). Usenull
(the default) to disable this feature.The context action will be triggered by a
TLcdActionAtLocationEvent
.- Parameters:
aContextAction
- The context action, or null.
-