public final class SelectEventHandler extends Object implements AutoCloseable
The select mode can be configured using the SelectMode
enumeration.
Constructor and Description |
---|
SelectEventHandler(SelectMode selectMode)
Creates a new event handler that uses the given select mode.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
finalize() |
long |
getMargin()
Returns the margin used to detect if a feature is considered under the mouse cursor or not.
|
ISelectionCandidateChooser |
getSelectionCandidateChooser()
Returns the selection candidate chooser that is used to choose which features need to be selected when there are multiple selection candidates.
|
long |
getTouchMargin()
Returns the margin used to detect if a feature is considered under a touch point or not.
|
EventResult |
onClickEvent(ClickEvent clickEvent,
Map map)
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. |
EventResult |
onTouchLongPressEvent(TouchLongPressEvent touchLongPressEvent,
Map map)
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. |
void |
setMargin(long margin)
Sets the margin used to detect if a feature is considered under the mouse cursor or not.
|
void |
setSelectionCandidateChooser(ISelectionCandidateChooser selectionCandidateChooser) |
void |
setTouchMargin(long margin)
Sets the margin used to detect if a feature is considered under a touch point or not.
|
public SelectEventHandler(@NotNull SelectMode selectMode)
selectMode
- the mode.public void close()
close
in interface AutoCloseable
@NotNull public EventResult onClickEvent(@NotNull ClickEvent clickEvent, @NotNull Map map) throws NullPointerException
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.
clickEvent
- a click event. Cannot be null
.map
- the map. Cannot be null
.amount of clicks
is different than 1.NullPointerException
- when passing null
for the map or the event.setMargin
,
SelectEventHandler#setTouchMargin
,
setTouchMargin
@NotNull public EventResult onTouchLongPressEvent(@NotNull TouchLongPressEvent touchLongPressEvent, @NotNull Map map) throws NullPointerException
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.
touchLongPressEvent
- a touch long press event.map
- the map.NullPointerException
- when passing null
.setTouchMargin
public void setMargin(long margin)
By default, the margin is 1 pixel.
margin
- the margin, expressed in device independent pixelspublic long getMargin()
public void setTouchMargin(long margin)
By default, the margin is 5 pixels.
margin
- the margin, expressed in device independent pixelspublic long getTouchMargin()
public void setSelectionCandidateChooser(@Nullable ISelectionCandidateChooser selectionCandidateChooser)
@Nullable public ISelectionCandidateChooser getSelectionCandidateChooser()
SelectEventHandler#setSelectionCandidateChooser