Class TLspSelectController

java.lang.Object
com.luciad.view.lightspeed.controller.ALspController
com.luciad.view.lightspeed.controller.selection.TLspSelectController
All Implemented Interfaces:
ILcdAWTEventListener, ILspController

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:

How selection works

The selection controller works in multiple steps:
  1. 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, ... .
  2. 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.
    1. The 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.
    2. 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.

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 the 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.

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 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.

Limitations

Selection is not supported while TLspMagnifierController is active on the view.
Since:
2012.0
  • Constructor Details

    • TLspSelectController

      public TLspSelectController()
      Create a new TLspSelectController with a default name, short description, icon and controller model.
    • TLspSelectController

      public TLspSelectController(TLspSelectControllerModel aControllerModel)
      Create a new TLspSelectController using the provided controller model.
      Parameters:
      aControllerModel - the controller model.
  • Method Details

    • getControllerModel

      public TLspSelectControllerModel getControllerModel()
      Returns the controller model of this controller.
      Returns:
      the controller model of this controller.
    • setControllerModel

      public void setControllerModel(TLspSelectControllerModel aModel)
      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

      public void startInteractionImpl(ILspView aView)
      Description copied from class: ALspController
      The specific implementation of startInteraction for this controller.
      Overrides:
      startInteractionImpl in class ALspController
      Parameters:
      aView - the view to start interaction with.
    • terminateInteractionImpl

      protected void terminateInteractionImpl(ILspView aView)
      Description copied from class: ALspController
      The specific implementation of terminateInteraction for this controller.
      Overrides:
      terminateInteractionImpl in class ALspController
      Parameters:
      aView - the view to terminate interaction with.
    • handleAWTEventImpl

      public AWTEvent handleAWTEventImpl(AWTEvent aAWTEvent)
      Description copied from class: ALspController
      Called by 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 TLcdTouchEvents). When the controller did not use the given event, it is returned unaltered.
      Specified by:
      handleAWTEventImpl in class ALspController
      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

      public Event handleFXEventImpl(Event aEvent)
      Description copied from class: ALspController
      Called by handleFXEvent. Returns null when the controller consumed the event. When the controller did not use the given event, it is returned unaltered.
      Overrides:
      handleFXEventImpl in class ALspController
      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 of paint for this controller.
      Overrides:
      paintImpl in class ALspController
      Parameters:
      aGLDrawable - the drawable that should be painted on
      aView - the view that is painted on
      aPaintPhase - 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 a TLspSelectPointInput in case of single click selection, or a TLspSelectRectangleInput 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)
      Parameters:
      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 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:

      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
    • selectChoice

      protected TLspSelectChoice selectChoice(MouseEvent aMouseEvent, ALspSelectInput aInput, Set<TLspPaintRepresentation> aRepresentations)
      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:

      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.
    • selectMode

      protected TLspSelectMode selectMode(MouseEvent aMouseEvent, ALspSelectInput aInput, Set<TLspPaintRepresentation> aRepresentations, TLspSelectChoice aChoice)
      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

      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.

      Parameters:
      aPressedEvent - the pressed event to be considered.
      Returns:
      true for rectangle selection, false for delegating mouse drags.
    • isSelectByDraggedRectangle

      protected boolean isSelectByDraggedRectangle(MouseEvent aPressedEvent)
      Parameters:
      aPressedEvent - the pressed event to be considered.
      Returns:
      true for rectangle selection, false for delegating mouse drags.
      Since:
      2019.0
    • isContextClick

      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.

      Parameters:
      aReleasedEvent - the event used to evaluate
      Returns:
      true if the context action should be triggered, false otherwise.
    • isContextClick

      protected boolean isContextClick(MouseEvent aReleasedEvent)
      Parameters:
      aReleasedEvent - the event used to evaluate
      Returns:
      true if the context action should be triggered, false otherwise.
      Since:
      2019.0
    • getDoubleClickAction

      public ILcdAction getDoubleClickAction()
      Returns the double click action.
      Returns:
      the double click action.
      See Also:
    • setDoubleClickAction

      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

      Parameters:
      aDoubleClickAction - The double click action, or null.
    • getContextAction

      public ILcdAction getContextAction()
      Returns the right click action.
      Returns:
      the right click action.
      See Also:
    • setContextAction

      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.

      Parameters:
      aContextAction - The context action, or null.