Class ZoomEventHandler

java.lang.Object
com.luciad.controllers.ZoomEventHandler
All Implemented Interfaces:
AutoCloseable

public final class ZoomEventHandler extends Object implements 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 Details Link icon

    • ZoomEventHandler Link icon

      public ZoomEventHandler()
      Creates a new zoom event handler.
  • 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
    • onClickEvent Link icon

      @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 be null.
      map - the map, cannot be null.
      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 passing null for the map or the event.
    • onClickEvent Link icon

      @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 be null.
      map - the map, cannot be null.
      zoomIn - true if zooming in, false otherwise.
      Returns:
      whether the click event is consumed or not. Always EventResult#Consumed.
      Throws:
      NullPointerException - when passing null for the map or the event.
    • onScrollEvent Link icon

      @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 be null.
      map - the map, cannot be null.
      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 passing null for the map or the event.
    • onScrollEvent Link icon

      @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 be null.
      map - the map, cannot be null.
      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 passing null for the map or the event.
    • onScrollEvent Link icon

      @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 be null.
      map - the map, cannot be null.
      Returns:
      whether the scroll event is consumed or not. Always EventResult#Consumed.
      Throws:
      NullPointerException - when passing null for the map or the event.