Class MapNavigator.RotateAction

java.lang.Object
com.luciad.maps.MapNavigator.RotateAction
All Implemented Interfaces:
AutoCloseable
Enclosing class:
MapNavigator

public static final class MapNavigator.RotateAction extends Object implements AutoCloseable
Class that allows to build a rotate action and apply it, either directly or using an animation.

Rotating works by:

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 Details Link icon

    • finalize Link icon

      protected void finalize()
      Overrides:
      finalize in class Object
    • close Link icon

      public void close()
      Specified by:
      close in interface AutoCloseable
    • center Link icon

      @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 the Map
      Returns:
      this
      Throws:
      IllegalArgumentException - if the toMapLocation parameter is not in the map coordinate reference.
    • animate Link icon

      @NotNull public MapNavigator.RotateAction animate(boolean animated)
      Specifies if the action should use an animation.
      Parameters:
      animated - if this action should use an animation. The default is false.
      Returns:
      this
    • duration Link icon

      @NotNull public MapNavigator.RotateAction duration(@NotNull Duration 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 Link icon

      @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 (see Map#is3D).

      Parameters:
      deltaRotation - the 2D rotation that needs to be added to the initial rotation of the camera
      Returns:
      this
      Throws:
      IllegalArgumentException - if the Map is a 3D Map.
    • deltaYaw Link icon

      @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 (see Map#is3D).

      Parameters:
      deltaYaw - the yaw value that needs to be added to the initial yaw of the 3D camera.
      Returns:
      this
      Throws:
      IllegalArgumentException - if the Map is a 2D Map.
    • deltaPitch Link icon

      @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 (see Map#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 the Map is a 2D Map.
    • targetRotation Link icon

      @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 (see Map#is3D).

      Parameters:
      targetRotation - the target angle of the 2D camera rotation.
      Returns:
      this
      Throws:
      IllegalArgumentException - if the Map is a 3D Map.
    • targetYaw Link icon

      @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 (see Map#is3D).

      Parameters:
      targetYaw - the target yaw of the 3D camera
      Returns:
      this
      Throws:
      IllegalArgumentException - if the Map is a 2D Map.
    • targetPitch Link icon

      @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 (see Map#is3D).

      Parameters:
      targetPitch - the target pitch value of the 3D camera, expressed in degrees
      Returns:
      this
      Throws:
      IllegalArgumentException - if the Map is a 2D Map.
    • rotate Link icon

      public void rotate() throws IllegalStateException
      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.