Class GestureEvent

All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
RotateEvent, ScrollEvent, SwipeEvent, ZoomEvent

public class GestureEvent
extends InputEvent
An event indicating gesture input. Gestures are typically caused by direct (touch screen) or indirect (track pad) touch events.

Delivery of gestures is dependent on the capabilities of the underlying platform and connected input devices. For instance on a PC with mouse and keyboard there is no way of producing a rotating gesture.

Since:
JavaFX 2.2
See Also:
Serialized Form
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static EventType<GestureEvent> ANY
    Common supertype for all gestures.

    Fields inherited from class javafx.event.Event

    consumed, eventType, NULL_SOURCE_TARGET, target

    Fields inherited from class java.util.EventObject

    source
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected GestureEvent​(Object source, EventTarget target, EventType<? extends GestureEvent> eventType)
    Deprecated.
    Do not use this constructor.
    protected GestureEvent​(Object source, EventTarget target, EventType<? extends GestureEvent> eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, boolean inertia, PickResult pickResult)
    Constructs new GestureEvent event.
    protected GestureEvent​(EventType<? extends GestureEvent> eventType)
    Deprecated.
    Do not use this constructor.
    protected GestureEvent​(EventType<? extends GestureEvent> eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, boolean inertia, PickResult pickResult)
    Constructs new GestureEvent event with empty source and target
  • Method Summary

    Modifier and Type Method Description
    GestureEvent copyFor​(Object newSource, EventTarget newTarget)
    Creates and returns a copy of this event with the specified event source and target.
    EventType<? extends GestureEvent> getEventType()
    Gets the event type of this event.
    PickResult getPickResult()
    Returns information about the pick.
    double getSceneX()
    Gets the horizontal position of the event relative to the origin of the Scene that contains the event's source.
    double getSceneY()
    Gets the vertical position of the event relative to the origin of the Scene that contains the event's source.
    double getScreenX()
    Gets the absolute horizontal position of the event.
    double getScreenY()
    Gets the absolute vertical position of the event.
    double getX()
    Gets the horizontal position of the event relative to the origin of the event's source.
    double getY()
    Gets the vertical position of the event relative to the origin of the event's source.
    double getZ()
    Depth position of the event relative to the origin of the MouseEvent's source.
    boolean isAltDown()
    Indicates whether or not the Alt modifier is down on this event.
    boolean isControlDown()
    Indicates whether or not the Control modifier is down on this event.
    boolean isDirect()
    Indicates whether this gesture is caused by a direct or indirect input device.
    boolean isInertia()
    Indicates if this event represents an inertia of an already finished gesture.
    boolean isMetaDown()
    Indicates whether or not the Meta modifier is down on this event.
    boolean isShiftDown()
    Indicates whether or not the Shift modifier is down on this event.
    boolean isShortcutDown()
    Indicates whether or not the host platform common shortcut modifier is down on this event.
    String toString()
    Returns a string representation of this GestureEvent object.

    Methods inherited from class javafx.event.Event

    clone, consume, fireEvent, getTarget, isConsumed

    Methods inherited from class java.util.EventObject

    getSource

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • GestureEvent

      @Deprecated(since="8") protected GestureEvent​(EventType<? extends GestureEvent> eventType)
      Deprecated.
      Do not use this constructor. Constructs empty event.
      Creates a new instance of GestureEvent.
      Parameters:
      eventType - Type of the event
    • GestureEvent

      @Deprecated(since="8") protected GestureEvent​(Object source, EventTarget target, EventType<? extends GestureEvent> eventType)
      Deprecated.
      Do not use this constructor. Constructs empty event.
      Creates a new instance of GestureEvent.
      Parameters:
      source - Event source
      target - Event target
      eventType - Type of the event
    • GestureEvent

      protected GestureEvent​(Object source, EventTarget target, EventType<? extends GestureEvent> eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, boolean inertia, PickResult pickResult)
      Constructs new GestureEvent event.
      Parameters:
      source - the source of the event. Can be null.
      target - the target of the event. Can be null.
      eventType - The type of the event.
      x - The x with respect to the scene.
      y - The y with respect to the scene.
      screenX - The x coordinate relative to screen.
      screenY - The y coordinate relative to screen.
      shiftDown - true if shift modifier was pressed.
      controlDown - true if control modifier was pressed.
      altDown - true if alt modifier was pressed.
      metaDown - true if meta modifier was pressed.
      direct - true if the event was caused by direct input device. See isDirect()
      inertia - if represents inertia of an already finished gesture.
      pickResult - pick result. Can be null, in this case a 2D pick result without any further values is constructed based on the scene coordinates and the target
      Since:
      JavaFX 8.0
    • GestureEvent

      protected GestureEvent​(EventType<? extends GestureEvent> eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, boolean inertia, PickResult pickResult)
      Constructs new GestureEvent event with empty source and target
      Parameters:
      eventType - The type of the event.
      x - The x with respect to the scene.
      y - The y with respect to the scene.
      screenX - The x coordinate relative to screen.
      screenY - The y coordinate relative to screen.
      shiftDown - true if shift modifier was pressed.
      controlDown - true if control modifier was pressed.
      altDown - true if alt modifier was pressed.
      metaDown - true if meta modifier was pressed.
      direct - true if the event was caused by direct input device. See isDirect()
      inertia - if represents inertia of an already finished gesture.
      pickResult - pick result. Can be null, in this case a 2D pick result without any further values is constructed based on the scene coordinates
      Since:
      JavaFX 8.0
  • Method Details

    • copyFor

      public GestureEvent copyFor​(Object newSource, EventTarget newTarget)
      Creates and returns a copy of this event with the specified event source and target. If the source or target is set to null, it is replaced by the NULL_SOURCE_TARGET value.
      Overrides:
      copyFor in class Event
      Parameters:
      newSource - the new source of the copied event
      newTarget - the new target of the copied event
      Returns:
      the event copy with the new source and target
    • getX

      public final double getX()
      Gets the horizontal position of the event relative to the origin of the event's source.
      Returns:
      the horizontal position of the event relative to the origin of the event's source.
      See Also:
      isDirect()
    • getY

      public final double getY()
      Gets the vertical position of the event relative to the origin of the event's source.
      Returns:
      the vertical position of the event relative to the origin of the event's source.
      See Also:
      isDirect()
    • getZ

      public final double getZ()
      Depth position of the event relative to the origin of the MouseEvent's source.
      Returns:
      depth position of the event relative to the origin of the MouseEvent's source.
      Since:
      JavaFX 8.0
    • getScreenX

      public final double getScreenX()
      Gets the absolute horizontal position of the event.
      Returns:
      the absolute horizontal position of the event
      See Also:
      isDirect()
    • getScreenY

      public final double getScreenY()
      Gets the absolute vertical position of the event.
      Returns:
      the absolute vertical position of the event
      See Also:
      isDirect()
    • getSceneX

      public final double getSceneX()
      Gets the horizontal position of the event relative to the origin of the Scene that contains the event's source. If the node is not in a Scene, then the value is relative to the boundsInParent of the root-most parent of the event's node. Note that in 3D scene, this represents the flat coordinates after applying the projection transformations.
      Returns:
      the horizontal position of the event relative to the origin of the Scene that contains the event's source
      See Also:
      isDirect()
    • getSceneY

      public final double getSceneY()
      Gets the vertical position of the event relative to the origin of the Scene that contains the event's source. If the node is not in a Scene, then the value is relative to the boundsInParent of the root-most parent of the event's node. Note that in 3D scene, this represents the flat coordinates after applying the projection transformations.
      Returns:
      the vertical position of the event relative to the origin of the Scene that contains the event's source
      See Also:
      isDirect()
    • isShiftDown

      public final boolean isShiftDown()
      Indicates whether or not the Shift modifier is down on this event.
      Returns:
      true if the Shift modifier is down on this event
    • isControlDown

      public final boolean isControlDown()
      Indicates whether or not the Control modifier is down on this event.
      Returns:
      true if the Control modifier is down on this event
    • isAltDown

      public final boolean isAltDown()
      Indicates whether or not the Alt modifier is down on this event.
      Returns:
      true if the Alt modifier is down on this event
    • isMetaDown

      public final boolean isMetaDown()
      Indicates whether or not the Meta modifier is down on this event.
      Returns:
      true if the Meta modifier is down on this event
    • isDirect

      public final boolean isDirect()
      Indicates whether this gesture is caused by a direct or indirect input device. With direct input device the gestures are performed directly at the concrete coordinates, a typical example would be a touch screen. With indirect device the gestures are performed indirectly and usually mouse cursor position is used as the gesture coordinates, a typical example would be a track pad.
      Returns:
      true if this event is caused by a direct input device
    • isInertia

      public boolean isInertia()
      Indicates if this event represents an inertia of an already finished gesture.
      Returns:
      true if this is an inertia event
    • getPickResult

      public final PickResult getPickResult()
      Returns information about the pick.
      Returns:
      new PickResult object that contains information about the pick
      Since:
      JavaFX 8.0
    • isShortcutDown

      public final boolean isShortcutDown()
      Indicates whether or not the host platform common shortcut modifier is down on this event. This common shortcut modifier is a modifier key which is used commonly in shortcuts on the host platform. It is for example control on Windows and meta (command key) on Mac.
      Returns:
      true if the shortcut modifier is down, false otherwise
    • toString

      public String toString()
      Returns a string representation of this GestureEvent object.
      Overrides:
      toString in class EventObject
      Returns:
      a string representation of this GestureEvent object.
    • getEventType

      public EventType<? extends GestureEvent> getEventType()
      Description copied from class: Event
      Gets the event type of this event. Objects of the same Event class can have different event types. These event types further specify what kind of event occurred.
      Overrides:
      getEventType in class InputEvent
      Returns:
      the event type