Class MapNavigator.RotateAction
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
MapNavigator
Rotating works by:
- defining a point around which to rotate the
Map
(RotateAction#center
) - defining the rotation to apply to the current
Map
rotation. There are different angles for 2D and 3D:
Example: Rotate the (2D) view
Map.ViewMapTransformation viewMapTransformation = map.getViewMapTransformation(); Point point = viewMapTransformation.viewToMap(Map.LocationMode.ClosestSurface, viewLocation); if (point != null) { map.getMapNavigator().newRotateAction().center(point).deltaRotation(new Azimuth(45)).rotate(); }
Example of an incremental rotate action (for example based on a mouse drag):
Map.ViewMapTransformation viewMapTransformation = map.getViewMapTransformation(); Point point = viewMapTransformation.viewToMap(Map.LocationMode.ClosestSurface, viewLocation); if (point != null) { rotateAction = map.getMapNavigator().newRotateAction().center(point); // When a drag event arrives rotateAction.deltaRotation(new Azimuth(originalViewLocation.getX() - eventLocation.getX())).rotate(); // When an other drag event arrives rotateAction.deltaRotation(new Azimuth(originalViewLocation.getX() - eventLocation.getX())).rotate(); // When the drag gesture stops: cleanup rotateAction.close(); }
-
Method Summary
Modifier and TypeMethodDescriptionanimate
(boolean animated) Specifies if the action should use an animation.Sets the center around which to rotate.void
close()
deltaPitch
(double deltaPitch) Sets the pitch value that needs to be added to the initial pitch of the 3D camera.deltaRotation
(Azimuth deltaRotation) Sets the 2D rotation that needs to be added to the initial rotation of the camera.Sets the yaw value that needs to be added to the initial yaw of the 3D camera.Specifies the duration of the animation.protected void
finalize()
void
rotate()
Applies the rotate action.targetPitch
(double targetPitch) Sets the target pitch value of the 3D camera.targetRotation
(Azimuth targetRotation) Sets the target angle of the 2D camera rotation.Sets the target yaw of the 3D camera.
-
Method Details
-
finalize
protected void finalize() -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
center
@NotNull public MapNavigator.RotateAction center(@NotNull Point centerMapLocation) throws IllegalArgumentException Sets the center around which to rotate.This property is mandatory. Not setting it will cause the
RotateAction#rotate
method to throw an exception.- Parameters:
centerMapLocation
- the center, defined in the reference of theMap
- Returns:
- this
- Throws:
IllegalArgumentException
- if the toMapLocation parameter is not in the map coordinate reference.
-
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
-
deltaRotation
@NotNull public MapNavigator.RotateAction deltaRotation(@NotNull Azimuth deltaRotation) throws IllegalArgumentException Sets the 2D rotation that needs to be added to the initial rotation of the camera.This method can only be called when the
Map
is a 2D map (seeMap#is3D
).- Parameters:
deltaRotation
- the 2D rotation that needs to be added to the initial rotation of the camera- Returns:
- this
- Throws:
IllegalArgumentException
- if theMap
is a 3DMap
.
-
deltaYaw
@NotNull public MapNavigator.RotateAction deltaYaw(@NotNull Azimuth deltaYaw) throws IllegalArgumentException Sets the yaw value that needs to be added to the initial yaw of the 3D camera.This method can only be called when the
Map
is a 3D map (seeMap#is3D
).- Parameters:
deltaYaw
- the yaw value that needs to be added to the initial yaw of the 3D camera.- Returns:
- this
- Throws:
IllegalArgumentException
- if theMap
is a 2DMap
.
-
deltaPitch
@NotNull public MapNavigator.RotateAction deltaPitch(double deltaPitch) throws IllegalArgumentException Sets the pitch value that needs to be added to the initial pitch of the 3D camera.Pitch is defined as the camera's tilt angle. A value of 0 points the camera towards the horizon (i.e. horizontally); -90 points straight down towards the ground and +90 points straight up.
This method can only be called when the
Map
is a 3D map (seeMap#is3D
).- Parameters:
deltaPitch
- the pitch value that needs to be added to the initial pitch of the 3D camera, expressed in degrees.- Returns:
- this
- Throws:
IllegalArgumentException
- if theMap
is a 2DMap
.
-
targetRotation
@NotNull public MapNavigator.RotateAction targetRotation(@NotNull Azimuth targetRotation) throws IllegalArgumentException Sets the target angle of the 2D camera rotation.After the rotate operation finishes, the map's rotation will equal this value.
This method can only be called when the
Map
is a 2D map (seeMap#is3D
).- Parameters:
targetRotation
- the target angle of the 2D camera rotation.- Returns:
- this
- Throws:
IllegalArgumentException
- if theMap
is a 3DMap
.
-
targetYaw
@NotNull public MapNavigator.RotateAction targetYaw(@NotNull Azimuth targetYaw) throws IllegalArgumentException Sets the target yaw of the 3D camera.After the rotate operation finishes, the map's yaw will equal this value.
This method can only be called when the
Map
is a 3D map (seeMap#is3D
).- Parameters:
targetYaw
- the target yaw of the 3D camera- Returns:
- this
- Throws:
IllegalArgumentException
- if theMap
is a 2DMap
.
-
targetPitch
@NotNull public MapNavigator.RotateAction targetPitch(double targetPitch) throws IllegalArgumentException Sets the target pitch value of the 3D camera.After the rotate operation finishes, the map's pitch will equal this value.
Pitch is defined as the camera's tilt angle. A value of 0 points the camera towards the horizon (i.e. horizontally); -90 points straight down towards the ground and +90 points straight up.
This method can only be called when the
Map
is a 3D map (seeMap#is3D
).- Parameters:
targetPitch
- the target pitch value of the 3D camera, expressed in degrees- Returns:
- this
- Throws:
IllegalArgumentException
- if theMap
is a 2DMap
.
-
rotate
Applies the rotate action.- Throws:
IllegalStateException
- if the action is not built correctly, for example if mandatory parameters are missing, or if incompatible parameters are configured.
-