Class TouchPoint
- All Implemented Interfaces:
Serializable
public final class TouchPoint extends Object implements Serializable
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 Type | Class | Description |
|---|---|---|
static enum |
TouchPoint.State |
Represents current state of the touch point |
Constructor Summary
| Constructor | Description |
|---|---|
TouchPoint |
Creates new instance of TouchPoint. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
belongsTo |
Distinguishes between touch points targeted to the given node or some of its children from touch points targeted somewhere else. |
EventTarget |
getGrabbed() |
Gets event target which has grabbed this touch point. |
final int |
getId() |
Gets identifier of this touch point. |
final PickResult |
getPickResult() |
Returns information about the pick. |
final double |
getSceneX() |
Gets the horizontal position of the touch point relative to the origin of the Scene that contains the TouchEvent's source. |
final double |
getSceneY() |
Gets the vertical position of the touch point relative to the origin of the Scene that contains the TouchEvent's source. |
final double |
getScreenX() |
Gets the absolute horizontal position of the touch point. |
final double |
getScreenY() |
Gets the absolute vertical position of the touch point. |
final TouchPoint.State |
getState() |
Gets state of this touch point |
EventTarget |
getTarget() |
Gets 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 |
Grabs this touch point by the given target. |
String |
toString() |
Returns a string representation of this TouchPoint 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)
- Parameters:
-
id- ID of the new touch point -
state- state of the new touch point -
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. -
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
public boolean belongsTo(EventTarget target)
- 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
public EventTarget getGrabbed()
- Returns:
- The current grabbed target, null if the touch point is ungrabbed
grab
public void grab()
grab
public void grab(EventTarget target)
- Parameters:
-
target- Target by which to grab the touch point
ungrab
public void ungrab()
getId
public final int getId()
1, 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
public final TouchPoint.State getState()
- Returns:
- state of this touch point
getX
public final double getX()
- Returns:
- the horizontal position of the touch point relative to the origin of the TouchEvent's source.
getY
public final double getY()
- Returns:
- the vertical position of the touch point relative to the origin of the TouchEvent's source.
getZ
public final double getZ()
- Returns:
- depth position of the event relative to the origin of the MouseEvent's source.
- Since:
- JavaFX 8.0
getScreenX
public final double getScreenX()
- Returns:
- the absolute horizontal position of the touch point
getScreenY
public final double getScreenY()
- Returns:
- the absolute vertical position of the touch point
getSceneX
public final double getSceneX()
Scene that contains the TouchEvent'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 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
Scenethat contains the TouchEvent's source
getSceneY
public final double getSceneY()
Scene that contains the TouchEvent'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 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
Scenethat contains the TouchEvent's source
getPickResult
public final PickResult getPickResult()
- Returns:
- new PickResult object that contains information about the pick
- Since:
- JavaFX 8.0
getTarget
public EventTarget getTarget()
- Returns:
- Event target for this touch point
toString
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.