public static final class MapNavigator.RotateAction extends Object implements AutoCloseable
Rotating works by:
Map
(RotateAction#center
)
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();
}
Modifier and Type | Method and Description |
---|---|
MapNavigator.RotateAction |
animate(boolean animated)
Specifies if the action should use an animation.
|
MapNavigator.RotateAction |
center(Point centerMapLocation)
Sets the center around which to rotate.
|
void |
close() |
MapNavigator.RotateAction |
deltaPitch(double deltaPitch)
Sets the pitch value that needs to be added to the initial pitch of the 3D camera.
|
MapNavigator.RotateAction |
deltaRotation(Azimuth deltaRotation)
Sets the 2D rotation that needs to be added to the initial rotation of the camera.
|
MapNavigator.RotateAction |
deltaYaw(Azimuth deltaYaw)
Sets the yaw value that needs to be added to the initial yaw of the 3D camera.
|
MapNavigator.RotateAction |
duration(Duration duration)
Specifies the duration of the animation.
|
protected void |
finalize() |
void |
rotate()
Applies the rotate action.
|
MapNavigator.RotateAction |
targetPitch(double targetPitch)
Sets the target pitch value of the 3D camera.
|
MapNavigator.RotateAction |
targetRotation(Azimuth targetRotation)
Sets the target angle of the 2D camera rotation.
|
MapNavigator.RotateAction |
targetYaw(Azimuth targetYaw)
Sets the target yaw of the 3D camera.
|
public void close()
close
in interface AutoCloseable
@NotNull public MapNavigator.RotateAction center(@NotNull Point centerMapLocation) throws IllegalArgumentException
This property is mandatory. Not setting it will cause the RotateAction#rotate
method to throw an exception.
centerMapLocation
- the center, defined in the reference of the Map
IllegalArgumentException
- if the toMapLocation parameter is not in the map coordinate reference.@NotNull public MapNavigator.RotateAction animate(boolean animated)
animated
- if this action should use an animation. The default is false.@NotNull public MapNavigator.RotateAction duration(@NotNull Duration duration)
This parameter is only used if animate(bool)
is called with true as argument.
duration
- the duration of the animation in milliseconds. The default is 2000 (=2 seconds)@NotNull public MapNavigator.RotateAction deltaRotation(@NotNull Azimuth deltaRotation) throws IllegalArgumentException
This method can only be called when the Map
is a 2D map (see Map#is3D
).
deltaRotation
- the 2D rotation that needs to be added to the initial rotation of the cameraIllegalArgumentException
- if the Map
is a 3D Map
.@NotNull public MapNavigator.RotateAction deltaYaw(@NotNull Azimuth deltaYaw) throws IllegalArgumentException
This method can only be called when the Map
is a 3D map (see Map#is3D
).
deltaYaw
- the yaw value that needs to be added to the initial yaw of the 3D camera.IllegalArgumentException
- if the Map
is a 2D Map
.@NotNull public MapNavigator.RotateAction deltaPitch(double deltaPitch) throws IllegalArgumentException
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 (see Map#is3D
).
deltaPitch
- the pitch value that needs to be added to the initial pitch of the 3D camera, expressed in degrees.IllegalArgumentException
- if the Map
is a 2D Map
.@NotNull public MapNavigator.RotateAction targetRotation(@NotNull Azimuth targetRotation) throws IllegalArgumentException
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 (see Map#is3D
).
targetRotation
- the target angle of the 2D camera rotation.IllegalArgumentException
- if the Map
is a 3D Map
.@NotNull public MapNavigator.RotateAction targetYaw(@NotNull Azimuth targetYaw) throws IllegalArgumentException
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 (see Map#is3D
).
targetYaw
- the target yaw of the 3D cameraIllegalArgumentException
- if the Map
is a 2D Map
.@NotNull public MapNavigator.RotateAction targetPitch(double targetPitch) throws IllegalArgumentException
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 (see Map#is3D
).
targetPitch
- the target pitch value of the 3D camera, expressed in degreesIllegalArgumentException
- if the Map
is a 2D Map
.public void rotate() throws IllegalStateException
IllegalStateException
- if the action is not built correctly, for example if mandatory parameters are missing, or if incompatible parameters are configured.