public final class ZoomEventHandler extends Object implements AutoCloseable
This is a reusable code block that a controller designer can use in its implementation.
Constructor and Description |
---|
ZoomEventHandler()
Creates a new zoom event handler.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
finalize() |
EventResult |
onClickEvent(ClickEvent clickEvent,
Map map,
boolean zoomIn)
Zooms towards or from the mouse position of a click.
|
EventResult |
onClickEvent(ClickEvent clickEvent,
Map map,
boolean zoomIn,
double zoomSpeed)
Zooms towards or from the mouse position of a click.
|
EventResult |
onScrollEvent(ScrollEvent scrollEvent,
Map map)
Applies a zoom towards or from the mouse position using the wheel uses the given zoom speed, with 1 being the default zoom speed.
|
EventResult |
onScrollEvent(ScrollEvent scrollEvent,
Map map,
double zoomSpeed)
Applies a zoom towards or from the mouse position using the wheel uses the given zoom speed, with 1 being the default zoom speed.
|
EventResult |
onScrollEvent(ScrollEvent scrollEvent,
Map map,
double zoomSpeed,
boolean invertZoomDirection)
Applies a zoom towards or from the mouse position using the wheel uses the given zoom speed, with 1 being the default zoom speed.
|
public void close()
close
in interface AutoCloseable
@NotNull public EventResult onClickEvent(@NotNull ClickEvent clickEvent, @NotNull Map map, boolean zoomIn, double zoomSpeed) throws NullPointerException
clickEvent
- a click event, cannot be null
.map
- the map, cannot be null
.zoomIn
- true if zooming in, false otherwise.zoomSpeed
- the zoom speed. Must be a number greater than 0. Default value is 1.0.EventResult#Consumed
.NullPointerException
- when passing null
for the map or the event.@NotNull public EventResult onClickEvent(@NotNull ClickEvent clickEvent, @NotNull Map map, boolean zoomIn) throws NullPointerException
clickEvent
- a click event, cannot be null
.map
- the map, cannot be null
.zoomIn
- true if zooming in, false otherwise.EventResult#Consumed
.NullPointerException
- when passing null
for the map or the event.@NotNull public EventResult onScrollEvent(@NotNull ScrollEvent scrollEvent, @NotNull Map map, double zoomSpeed, boolean invertZoomDirection) throws NullPointerException
For example: 0.5 zooms twice as slow, 2 zooms twice as much. The direction of the scroll is used to determine the direction of this action.
scrollEvent
- a scroll event, cannot be null
.map
- the map, cannot be null
.zoomSpeed
- the zoom speed. Must be a number greater than 0. Default value is 1.0.invertZoomDirection
- to invert the zoom direction. By default, this method will zoom in when the verticals scrolling delta is positive, and zoom out when it is negativeEventResult#Consumed
.NullPointerException
- when passing null
for the map or the event.@NotNull public EventResult onScrollEvent(@NotNull ScrollEvent scrollEvent, @NotNull Map map, double zoomSpeed) throws NullPointerException
For example: 0.5 zooms twice as slow, 2 zooms twice as much. The direction of the scroll is used to determine the direction of this action.
scrollEvent
- a scroll event, cannot be null
.map
- the map, cannot be null
.zoomSpeed
- the zoom speed. Must be a number greater than 0. Default value is 1.0.EventResult#Consumed
.NullPointerException
- when passing null
for the map or the event.@NotNull public EventResult onScrollEvent(@NotNull ScrollEvent scrollEvent, @NotNull Map map) throws NullPointerException
For example: 0.5 zooms twice as slow, 2 zooms twice as much. The direction of the scroll is used to determine the direction of this action.
scrollEvent
- a scroll event, cannot be null
.map
- the map, cannot be null
.EventResult#Consumed
.NullPointerException
- when passing null
for the map or the event.