Package com.luciad.controllers
Class ZoomEventHandler
java.lang.Object
com.luciad.controllers.ZoomEventHandler
- All Implemented Interfaces:
AutoCloseable
Handler that translates scroll or click gesture events to a zoom operation.
This is a reusable code block that a controller designer can use in its implementation.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected void
finalize()
onClickEvent
(ClickEvent clickEvent, Map map, boolean zoomIn) Zooms towards or from the mouse position of a click.onClickEvent
(ClickEvent clickEvent, Map map, boolean zoomIn, double zoomSpeed) Zooms towards or from the mouse position of a click.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.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.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.
-
Constructor Details
-
Method Details
-
finalize
protected void finalize() -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
onClickEvent
@NotNull public EventResult onClickEvent(@NotNull ClickEvent clickEvent, @NotNull Map map, boolean zoomIn, double zoomSpeed) throws NullPointerException Zooms towards or from the mouse position of a click.- Parameters:
clickEvent
- a click event, cannot benull
.map
- the map, cannot benull
.zoomIn
- true if zooming in, false otherwise.zoomSpeed
- the zoom speed. Must be a number greater than 0. Default value is 1.0.- Returns:
- whether the click event is consumed or not. Always
EventResult#Consumed
. - Throws:
NullPointerException
- when passingnull
for the map or the event.
-
onClickEvent
@NotNull public EventResult onClickEvent(@NotNull ClickEvent clickEvent, @NotNull Map map, boolean zoomIn) throws NullPointerException Zooms towards or from the mouse position of a click.- Parameters:
clickEvent
- a click event, cannot benull
.map
- the map, cannot benull
.zoomIn
- true if zooming in, false otherwise.- Returns:
- whether the click event is consumed or not. Always
EventResult#Consumed
. - Throws:
NullPointerException
- when passingnull
for the map or the event.
-
onScrollEvent
@NotNull public EventResult onScrollEvent(@NotNull ScrollEvent scrollEvent, @NotNull Map map, double zoomSpeed, boolean invertZoomDirection) throws NullPointerException Applies a zoom towards or from the mouse position using the wheel uses the given zoom speed, with 1 being the default zoom speed.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.
- Parameters:
scrollEvent
- a scroll event, cannot benull
.map
- the map, cannot benull
.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 negative- Returns:
- whether the scroll event is consumed or not. Always
EventResult#Consumed
. - Throws:
NullPointerException
- when passingnull
for the map or the event.
-
onScrollEvent
@NotNull public EventResult onScrollEvent(@NotNull ScrollEvent scrollEvent, @NotNull Map map, double zoomSpeed) throws NullPointerException Applies a zoom towards or from the mouse position using the wheel uses the given zoom speed, with 1 being the default zoom speed.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.
- Parameters:
scrollEvent
- a scroll event, cannot benull
.map
- the map, cannot benull
.zoomSpeed
- the zoom speed. Must be a number greater than 0. Default value is 1.0.- Returns:
- whether the scroll event is consumed or not. Always
EventResult#Consumed
. - Throws:
NullPointerException
- when passingnull
for the map or the event.
-
onScrollEvent
@NotNull public EventResult onScrollEvent(@NotNull ScrollEvent scrollEvent, @NotNull Map map) throws NullPointerException Applies a zoom towards or from the mouse position using the wheel uses the given zoom speed, with 1 being the default zoom speed.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.
- Parameters:
scrollEvent
- a scroll event, cannot benull
.map
- the map, cannot benull
.- Returns:
- whether the scroll event is consumed or not. Always
EventResult#Consumed
. - Throws:
NullPointerException
- when passingnull
for the map or the event.
-