Class SelectEventHandler

java.lang.Object
com.luciad.controllers.SelectEventHandler
All Implemented Interfaces:
AutoCloseable

public final class SelectEventHandler extends Object implements AutoCloseable
Handler that translates click gesture events to a select operation.

The select mode can be configured using the SelectMode enumeration.

  • Constructor Details

    • SelectEventHandler

      public SelectEventHandler(@NotNull SelectMode selectMode)
      Creates a new event handler that uses the given select mode.
      Parameters:
      selectMode - the mode.
  • Method Details

    • finalize

      protected void finalize()
      Overrides:
      finalize in class Object
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • onClickEvent

      @NotNull public EventResult onClickEvent(@NotNull ClickEvent clickEvent, @NotNull Map map) throws NullPointerException
      Changes the FeatureState#selected() state of features located under the event location directly or delegates the selection to the handler if it has been set.

      This allows the display of a context menu when multiple features are below the cursor, for example.

      Parameters:
      clickEvent - a click event. Cannot be null.
      map - the map. Cannot be null.
      Returns:
      whether the click event is consumed or not. The event is not consumed if the amount of clicks is different than 1.
      Throws:
      NullPointerException - when passing null for the map or the event.
      See Also:
    • onTouchLongPressEvent

      @NotNull public EventResult onTouchLongPressEvent(@NotNull TouchLongPressEvent touchLongPressEvent, @NotNull Map map) throws NullPointerException
      Changes the FeatureState#selected() state of features located under the event location directly or delegates the selection to the handler if it has been set.

      This allows the display of a context menu when multiple features are below the cursor, for example.

      Parameters:
      touchLongPressEvent - a touch long press event.
      map - the map.
      Returns:
      whether the event is consumed or not.
      Throws:
      NullPointerException - when passing null.
      See Also:
      • setTouchMargin for the margin applied to the touch point position to detect which features are considered.
    • setMargin

      public void setMargin(long margin)
      Sets the margin used to detect if a feature is considered under the mouse cursor or not.

      By default, the margin is 1 pixel.

      Parameters:
      margin - the margin, expressed in device independent pixels
    • getMargin

      public long getMargin()
      Returns the margin used to detect if a feature is considered under the mouse cursor or not.
      Returns:
      the margin used to detect if a feature is considered under the mouse cursor or not.
    • setTouchMargin

      public void setTouchMargin(long margin)
      Sets the margin used to detect if a feature is considered under a touch point or not.

      By default, the margin is 5 pixels.

      Parameters:
      margin - the margin, expressed in device independent pixels
    • getTouchMargin

      public long getTouchMargin()
      Returns the margin used to detect if a feature is considered under a touch point or not.
      Returns:
      the margin used to detect if a feature is considered under a touch point or not.
    • setSelectionCandidateChooser

      public void setSelectionCandidateChooser(@Nullable ISelectionCandidateChooser selectionCandidateChooser)
      Sets the selection candidate chooser that is used to choose which features need to be selected when there are multiple selection candidates.

      This selection chooser can for example be implemented by showing a popup menu that allows you to choose the feature to select. By default, this handler is null and no selection is requested.

      Parameters:
      selectionCandidateChooser - the candidate chooser.
    • getSelectionCandidateChooser

      @Nullable public ISelectionCandidateChooser getSelectionCandidateChooser()
      Returns the selection candidate chooser that is used to choose which features need to be selected when there are multiple selection candidates.
      Returns:
      the candidate chooser if any.
      See Also: