Class MapNavigator.ZoomAction
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
MapNavigator
Zooming works by:
- defining a location towards which to zoom (
ZoomAction#toLocation
) - defining how much to zoom (
ZoomAction#factor
)
Example: zoom in 50% (2x zoom)
Map.ViewMapTransformation viewMapTransformation = map.getViewMapTransformation(); Point point = viewMapTransformation.viewToMap(Map.LocationMode.ClosestSurface, toViewLocation); if (point != null) { map.getMapNavigator().newZoomAction().toLocation(point).factor(0.5).zoom(); }
-
Method Summary
Modifier and TypeMethodDescriptionanimate
(boolean animated) Specifies if the action should use an animation.void
close()
Specifies the duration of the animation.factor
(double factor) Sets the zoom factor.protected void
finalize()
targetScale
(MapScale targetScale) Sets the map scale to which to zoom to.toLocation
(Point toMapLocation) Sets the location (inMap
coordinates) towards which theMapNavigator
will zoom.void
zoom()
Executes the zoom action.
-
Method Details
-
finalize
protected void finalize() -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
toLocation
@NotNull public MapNavigator.ZoomAction toLocation(@NotNull Point toMapLocation) throws IllegalArgumentException Sets the location (inMap
coordinates) towards which theMapNavigator
will zoom.This property is mandatory. Not setting it will cause the
ZoomAction#zoom
method to throw an exception.- Parameters:
toMapLocation
- a location, defined in the reference of theMap
- Returns:
- this
- Throws:
IllegalArgumentException
- if the toMapLocation parameter is not in the map coordinate reference.
-
factor
Sets the zoom factor.A value larger than 1 will zoom out. A value between ]0, 1[ will zoom in.
For example: A zoom factor of 0.5 will move the camera twice as close to the target location. A value of 2.0 will move the camera away twice as far from the target location.
It is mandatory to set either this property, or the targetScale property. Not setting either of them will cause the
ZoomAction#zoom
method to throw an exception. If both methods are called, the one called last has precedence.- Parameters:
factor
- the zoom factor, a value between ]0, 1[ to zoom in and between ]1, +inf[ to zoom out.- Returns:
- this
- Throws:
IllegalArgumentException
- if the factor value is invalid.
-
targetScale
Sets the map scale to which to zoom to.It is mandatory to set either this property, or the factor property. Not setting either of them will cause the
ZoomAction#zoom
method to throw an exception. If both methods are called, the one called last has precedence.- Parameters:
targetScale
- the target scale to zoom to- Returns:
- this
-
animate
Specifies if the action should use an animation.- Parameters:
animated
- if this action should use an animation. The default is false.- Returns:
- this
-
duration
Specifies the duration of the animation.This parameter is only used if
animate(bool)
is called with true as argument.- Parameters:
duration
- the duration of the animation in milliseconds. The default is 2000 (=2 seconds)- Returns:
- this
-
zoom
Executes the zoom action.- Throws:
IllegalStateException
- if the action is not built correctly, for example if mandatory parameters are missing, or if incompatible parameters are configured.
-