Package javafx.scene.input
Class TouchPoint
java.lang.Object
javafx.scene.input.TouchPoint
- All Implemented Interfaces:
Serializable
Touch point represents a single point of a multi-touch action, typically
one finger touching a screen. It is contained in
TouchEvent
.
The touch point has its coordinates, state (see TouchPoint.State
) and ID. The
ID is sequential number of this touch point unique in scope of a single
multi-touch gesture.
Each touch point is by default delivered to a single node during its whole
trajectory - to the node on which it was pressed. There is a grabbing API
to modify this behavior. The above means that when touch point is pressed,
it is automatically grabbed by the top-most node on the press coordinates.
Any time during the gesture grab()
and ungrab()
methods
can be used to alter the event delivery target. When grabbed by a different
node, it will next time be targeted to it; when ungrabbed, it will be
always targeted to the top-most node on the current location.
- Since:
- JavaFX 2.2
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Represents current state of the touch point -
Constructor Summary
ConstructorDescriptionTouchPoint
(int id, TouchPoint.State state, double x, double y, double screenX, double screenY, EventTarget target, PickResult pickResult) Creates new instance of TouchPoint. -
Method Summary
Modifier and TypeMethodDescriptionboolean
belongsTo
(EventTarget target) Distinguishes between touch points targeted to the given node or some of its children from touch points targeted somewhere else.Gets event target which has grabbed this touch point.final int
getId()
Gets identifier of this touch point.final PickResult
Returns information about the pick.final double
Gets the horizontal position of the touch point relative to the origin of theScene
that contains the TouchEvent's source.final double
Gets the vertical position of the touch point relative to the origin of theScene
that contains the TouchEvent's source.final double
Gets the absolute horizontal position of the touch point.final double
Gets the absolute vertical position of the touch point.final TouchPoint.State
getState()
Gets state of this touch pointGets event target on which the touch event carrying this touch point is fired.final double
getX()
Gets the horizontal position of the touch point relative to the origin of the TouchEvent's source.final double
getY()
Gets the vertical position of the touch point relative to the origin of the TouchEvent's source.final double
getZ()
Depth position of the event relative to the origin of the MouseEvent's source.void
grab()
Grabs this touch point by current event source.void
grab
(EventTarget target) Grabs this touch point by the given target.toString()
Returns a string representation of thisTouchPoint
object.void
ungrab()
Ungrabs this touch point from its target.
-
Constructor Details
-
TouchPoint
public TouchPoint(int id, TouchPoint.State state, double x, double y, double screenX, double screenY, EventTarget target, PickResult pickResult) Creates new instance of TouchPoint.- Parameters:
id
- ID of the new touch pointstate
- state of the new touch pointx
- 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.target
- Node or other event target.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 target- Since:
- JavaFX 8.0
-
-
Method Details
-
belongsTo
Distinguishes between touch points targeted to the given node or some of its children from touch points targeted somewhere else. This allows for testing all touch points carried by one touch event on their relevance for a given node.- Parameters:
target
- Node or other event target to be tested- Returns:
- true if this touch point is targeted to the given target or some of its children
-
getGrabbed
Gets event target which has grabbed this touch point.- Returns:
- The current grabbed target, null if the touch point is ungrabbed
-
grab
public void grab()Grabs this touch point by current event source. Next event containing this touch point will be targeted to the same node whose event handler called this method. -
grab
Grabs this touch point by the given target. Next event containing this touch point will be targeted to it.- Parameters:
target
- Target by which to grab the touch point
-
ungrab
public void ungrab()Ungrabs this touch point from its target. Since the next event this touch point will be delivered to the top-most node picked on its respective location until it is grabbed again or released. -
getId
public final int getId()Gets identifier of this touch point. The number is sequential and unique in scope of one multi touch gesture. The first pressed touch point has id1
, each subsequently pressed touch points gets the next ordinal number until all touch points are released and the counter is reset.- Returns:
- the identifier of this touch point.
-
getState
Gets state of this touch point- Returns:
- state of this touch point
-
getX
public final double getX()Gets the horizontal position of the touch point relative to the origin of the TouchEvent's source.- Returns:
- the horizontal position of the touch point relative to the origin of the TouchEvent's source.
-
getY
public final double getY()Gets the vertical position of the touch point relative to the origin of the TouchEvent's source.- Returns:
- the vertical position of the touch point relative to the origin of the TouchEvent's source.
-
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 touch point.- Returns:
- the absolute horizontal position of the touch point
-
getScreenY
public final double getScreenY()Gets the absolute vertical position of the touch point.- Returns:
- the absolute vertical position of the touch point
-
getSceneX
public final double getSceneX()Gets the horizontal position of the touch point relative to the origin of theScene
that contains the TouchEvent's source. If the node is not in aScene
, then the value is relative to the boundsInParent of the root-most parent of the TouchEvent's node. Note that in 3D scene, this represents the flat coordinates after applying the projection transformations.- Returns:
- the horizontal position of the touch point relative to the
origin of the
Scene
that contains the TouchEvent's source
-
getSceneY
public final double getSceneY()Gets the vertical position of the touch point relative to the origin of theScene
that contains the TouchEvent's source. If the node is not in aScene
, then the value is relative to the boundsInParent of the root-most parent of the TouchEvent's node. Note that in 3D scene, this represents the flat coordinates after applying the projection transformations.- Returns:
- the vertical position of the touch point relative to the
origin of the
Scene
that contains the TouchEvent's source
-
getPickResult
Returns information about the pick.- Returns:
- new PickResult object that contains information about the pick
- Since:
- JavaFX 8.0
-
getTarget
Gets event target on which the touch event carrying this touch point is fired.- Returns:
- Event target for this touch point
-
toString
Returns a string representation of thisTouchPoint
object.
-