Package com.luciad.controllers
Class SelectEventHandler
java.lang.Object
com.luciad.controllers.SelectEventHandler
- All Implemented Interfaces:
AutoCloseable
Handler that translates click gesture events to a select operation.
The select mode can be configured using the SelectMode enumeration.
-
Constructor Summary
ConstructorsConstructorDescriptionSelectEventHandler(SelectMode selectMode) Creates a new event handler that uses the given select mode. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanprotected voidfinalize()longReturns the margin used to detect if a feature is considered under the mouse cursor or not.Returns the selection candidate chooser that is used to choose which features need to be selected when there are multiple selection candidates.longReturns the margin used to detect if a feature is considered under a touch point or not.inthashCode()onClickEvent(ClickEvent clickEvent, Map map) Changes theFeatureState#selected()state of features located under the event location directly or delegates the selection to thehandlerif it has been set.onTouchLongPressEvent(TouchLongPressEvent touchLongPressEvent, Map map) Changes theFeatureState#selected()state of features located under the event location directly or delegates the selection to thehandlerif it has been set.voidsetMargin(long margin) Sets the margin used to detect if a feature is considered under the mouse cursor or not.voidsetSelectionCandidateChooser(ISelectionCandidateChooser selectionCandidateChooser) Sets the selection candidate chooser that is used to choose which features need to be selected when there are multiple selection candidates.voidsetTouchMargin(long margin) Sets the margin used to detect if a feature is considered under a touch point or not.
-
Constructor Details
-
SelectEventHandler
Creates a new event handler that uses the given select mode.- Parameters:
selectMode- the mode.
-
-
Method Details
-
finalize
protected void finalize() -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
onClickEvent
@NotNull public EventResult onClickEvent(@NotNull ClickEvent clickEvent, @NotNull Map map) throws NullPointerException Changes theFeatureState#selected()state of features located under the event location directly or delegates the selection to thehandlerif 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 benull.map- the map. Cannot benull.- Returns:
- whether the click event is consumed or not. The event is not consumed if the
amount of clicksis different than 1. - Throws:
NullPointerException- when passingnullfor the map or the event.- See Also:
-
onTouchLongPressEvent
@NotNull public EventResult onTouchLongPressEvent(@NotNull TouchLongPressEvent touchLongPressEvent, @NotNull Map map) throws NullPointerException Changes theFeatureState#selected()state of features located under the event location directly or delegates the selection to thehandlerif 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 passingnull.- See Also:
-
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
nulland no selection is requested.- Parameters:
selectionCandidateChooser- the candidate chooser.
-
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:
-
hashCode
public int hashCode() -
equals
-