Class TLspSelectControllerModel

java.lang.Object
com.luciad.view.lightspeed.controller.selection.TLspSelectControllerModel

public class TLspSelectControllerModel extends Object

Controller model for selection of objects in a view, used by the TLspSelectController.

How selection works

The class javadoc of the TLspSelectController explains how the select controller and this controller model work together to update the selection.

Customizing the selection behavior

Which domain objects are used as selection candidates

The object of which the selection is potentially updated are collected by the selectionCandidates(ALspSelectInput, Set, boolean, ILspView) method. When using the TLspSelectController, the controller calls the select(ALspSelectInput, Set, TLspSelectChoice, TLspSelectMode, ILspView) method which in turn calls the selectionCandidates(ALspSelectInput, Set, boolean, ILspView) method.

By overriding this method, you can use custom logic. An example is to only consider objects of which the bounds are completely contained in the selection rectangle instead of all objects with overlapping bounds.

Supporting custom selection update behavior

The update of the selection happens in the applySelection(ALspSelectInput, TLspSelectChoice, TLspSelectMode, List, ILspView) method.

This method delegates the actual updating of the selection to a ILspSelectionCandidateHandler. You can replace the existing ones (or register your own instance when you have a custom TLspSelectChoice) by calling the setSelectionCandidateHandlerFor(TLspSelectChoice, ILspSelectionCandidateHandler) method.

If that is not sufficient, you can always override the method to implement your own behavior.

An example customization is to show a dialog to the user when multiple selection candidates are available, and let the user decide which ones to select.

Since:
2012.0
See Also:
  • Constructor Details

    • TLspSelectControllerModel

      public TLspSelectControllerModel()
      Creates a new TLspSelectControllerModel with default settings.
  • Method Details

    • setSelectionCandidateHandlerFor

      public void setSelectionCandidateHandlerFor(TLspSelectChoice aChoice, ILspSelectionCandidateHandler aHandler)
      Registers aHandler as the selection candidate handler to use for aChoice.

      By default TLspSelectChoice.DEFAULT is mapped on a standard TLspDefaultSelectionCandidateHandler and TLspSelectChoice.CHOOSE is mapped on a default TLspPopupMenuSelectionCandidateHandler.

      Parameters:
      aChoice - The TLspSelectChoice to map the passed handler to.
      aHandler - The handler to be used for the passed choice.
    • getSensitivity

      public int getSensitivity()

      This method returns the sensitivity that will be used when selecting objects or labels.

      The sensitivity is the maximum distance at which the representation of an object can be removed from a selection point, such as the position of the mouse cursor, and still be considered a valid selection candidate. The distance is expressed in pixels.

      Returns:
      the sensitivity to be used for selecting objects, expressed in pixels.
      See Also:
    • setSensitivity

      public void setSensitivity(int aSensitivity)

      This method sets the sensitivity that should be used by painters to determine which object is selected by the input device (usually the mouse).

      The sensitivity is the maximum distance at which the representation of an object can be removed from a selection point, such as the position of the mouse cursor, and still be considered a valid selection candidate. The distance is expressed in pixels. Tweaking the selection sensitivity is especially useful when you are using less exact input methods like a touch screen.

      Parameters:
      aSensitivity - the sensitivity that will be used for selecting objects, expressed in pixels.
      See Also:
    • select

      public void select(ALspSelectInput aInput, Set<TLspPaintRepresentation> aRepresentations, TLspSelectChoice aChoice, TLspSelectMode aMode, ILspView aView)

      Selects (an) object(s) interacting with a rectangle in a view according to the TLspSelectChoice and TLspSelectMode.

      The default implementation of this method:

      1. Retrieves the candidate selection objects by calling selectionCandidates(ALspSelectInput, Set, boolean, ILspView).
      2. Updates the layer selection by calling applySelection(ALspSelectInput, TLspSelectChoice, TLspSelectMode, List, ILspView)
      Parameters:
      aInput - the selection input.
      aRepresentations - the paint representations to be taken into account when selecting objects.
      aChoice - the choice, this controls which of the possible selection candidates are taken into account. The default implementation only supports TLspSelectChoice.DEFAULT and TLspSelectChoice.CHOOSE.
      aMode - the mode, this controls how the selection is adapted for the remaining selection candidates.
      aView - the view to select in.
    • selectionCandidates

      public List<TLspDomainObjectContext> selectionCandidates(ALspSelectInput aInput, Set<TLspPaintRepresentation> aRepresentations, boolean aMultiple, ILspView aView)

      Returns the set of selection candidates that should be considered for selection based on the passed arguments.

      The default implementation:
      • Only considers objects painted in visible and selectable layers.
      • Orders the elements in the returned list from topmost object to lowest object.
      Parameters:
      aInput - the selection input.
      aRepresentations - the paint representations to be taken into account when selecting objects.
      aMultiple - flag that indicates whether or not multiple selection candidates are needed, this allows optimizations if only one is necessary.
      aView - the view to select in.
      Returns:
      a list of selection candidates (=objects that should be considered for selection according to the input parameters)
    • applySelection

      protected void applySelection(ALspSelectInput aInput, TLspSelectChoice aChoice, TLspSelectMode aMode, List<TLspDomainObjectContext> aSelectionCandidates, ILspView aView)

      Uses the passed arguments to change the selection of some or all of the objects in aSelectionCandidates

      The default implementation:
      Parameters:
      aInput - the selection input.
      aChoice - the choice, this controls which of the possible selection candidates are taken into account
      aMode - the mode, this controls how the selection is adapted for the remaining selection candidates.
      aSelectionCandidates - a list of objects for which a new selection state should be determined.
      aView - the view to select in.