- java.lang.Object
-
- javafx.scene.input.TouchPoint
-
- All Implemented Interfaces:
Serializable
public final class TouchPoint extends Object implements Serializable
Touch point represents a single point of a multi-touch action, typically one finger touching a screen. It is contained inTouchEvent
.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()
andungrab()
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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TouchPoint.State
Represents current state of the touch point
-
Constructor Summary
Constructors Constructor Description TouchPoint(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 Type Method Description boolean
belongsTo(EventTarget target)
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.int
getId()
Gets identifier of this touch point.PickResult
getPickResult()
Returns information about the pick.double
getSceneX()
Gets the horizontal position of the touch point relative to the origin of theScene
that contains the TouchEvent's source.double
getSceneY()
Gets the vertical position of the touch point relative to the origin of theScene
that contains the TouchEvent's source.double
getScreenX()
Gets the absolute horizontal position of the touch point.double
getScreenY()
Gets the absolute vertical position of the touch point.TouchPoint.State
getState()
Gets state of this touch pointEventTarget
getTarget()
Gets event target on which the touch event carrying this touch point is fired.double
getX()
Gets the horizontal position of the touch point relative to the origin of the TouchEvent's source.double
getY()
Gets the vertical position of the touch point relative to the origin of the TouchEvent's source.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.String
toString()
Returns a string representation of thisTouchPoint
object.void
ungrab()
Ungrabs this touch point from its target.
-
-
-
Constructor Detail
-
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 Detail
-
belongsTo
public boolean belongsTo(EventTarget target)
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
public EventTarget 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
public void grab(EventTarget target)
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
public final TouchPoint.State 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
public final PickResult getPickResult()
Returns information about the pick.- Returns:
- new PickResult object that contains information about the pick
- Since:
- JavaFX 8.0
-
getTarget
public EventTarget getTarget()
Gets event target on which the touch event carrying this touch point is fired.- Returns:
- Event target for this touch point
-
-