public class FXUtils
extends java.lang.Object
FXUtils
class contains utility methods for working with JavaFX:
IGeometry
s from/to different JavaFX coordinate
systems (localToParent(Node, IGeometry)
,
localToScene(Node, IGeometry)
, localToScene(Node, Point)
,
parentToLocal(Node, IGeometry)
,
sceneToLocal(Node, IGeometry)
)Node
(getLocalToSceneTx(Node)
,
getSceneToLocalTx(Node)
)getPointerLocation()
)
forceCursorUpdate(Scene)
)Node
s at a specific position within the JavaFX
scene graph (getNodesAt(Node, double, double)
)Constructor and Description |
---|
FXUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
forceCursorUpdate(javafx.scene.Scene scene)
Forces the JavaFX runtime to update the mouse cursor.
|
static AffineTransform |
getLocalToSceneTx(javafx.scene.Node node)
Returns an
AffineTransform which represents the transformation
matrix to transform geometries from the local coordinate system of the
given Node into the coordinate system of the Scene . |
static java.util.List<javafx.scene.Node> |
getNodesAt(javafx.scene.Node root,
double sceneX,
double sceneY)
Performs picking on the scene graph beginning at the specified root node
and processing its transitive children.
|
static Point |
getPointerLocation()
Returns the current pointer location.
|
static AffineTransform |
getSceneToLocalTx(javafx.scene.Node node)
Returns the scene-to-local transform for the given
Node . |
static IGeometry |
localToParent(javafx.scene.Node n,
IGeometry g)
Transforms the given
IGeometry from the local coordinate system
of the given Node into the coordinate system of the Node
's parent. |
static IGeometry |
localToScene(javafx.scene.Node n,
IGeometry g)
Transforms the given
IGeometry from the local coordinate system
of the given Node into scene coordinates. |
static Point |
localToScene(javafx.scene.Node n,
Point p)
Transforms the given
Point from the local coordinate system of
the given Node into scene coordinates. |
static IGeometry |
parentToLocal(javafx.scene.Node n,
IGeometry g)
Transforms the given
IGeometry from the parent coordinate system
of the given Node into the local coordinate system of the
Node . |
static IGeometry |
sceneToLocal(javafx.scene.Node n,
IGeometry g)
Transforms the given
IGeometry from scene coordinates to the
local coordinate system of the given Node . |
public static void forceCursorUpdate(javafx.scene.Scene scene)
scene
- The Scene
to update the cursor for.public static AffineTransform getLocalToSceneTx(javafx.scene.Node node)
AffineTransform
which represents the transformation
matrix to transform geometries from the local coordinate system of the
given Node
into the coordinate system of the Scene
.
JavaFX Node
provides a (lazily computed) local-to-scene-transform
property which we could access to get that transform. Unfortunately, this
property is not updated correctly, i.e. its value can differ from the
actual local-to-scene-transform. Therefore, we compute the
local-to-scene-transform for the given node here by concatenating the
local-to-parent-transforms along the hierarchy.
Note that in situations where you do not need the actual transform, but
instead perform a transformation, you can use the
Node#localToScene(...)
methods on the
node directly, because it does not make use of the
local-to-scene-transform property, but uses localToParent() internally.
node
- The JavaFX Node
for which the local-to-scene
transformation matrix is to be computed.AffineTransform
representing the local-to-scene
transformation matrix for the given Node
.public static java.util.List<javafx.scene.Node> getNodesAt(javafx.scene.Node root, double sceneX, double sceneY)
sceneX
- The x-coordinate of the position to pick nodes at, interpreted
in scene coordinate space.sceneY
- The y-coordinate of the position to pick nodes at, interpreted
in scene coordinate space.root
- The root node at which to start with pickingNode
s which contain the the given coordinate.public static Point getPointerLocation()
public static AffineTransform getSceneToLocalTx(javafx.scene.Node node)
Node
.node
- The Node
for which the scene-to-local transform is
returned.Node
.public static IGeometry localToParent(javafx.scene.Node n, IGeometry g)
IGeometry
from the local coordinate system
of the given Node
into the coordinate system of the Node
's parent.public static IGeometry localToScene(javafx.scene.Node n, IGeometry g)
IGeometry
from the local coordinate system
of the given Node
into scene coordinates.public static Point localToScene(javafx.scene.Node n, Point p)
Point
from the local coordinate system of
the given Node
into scene coordinates.public static IGeometry parentToLocal(javafx.scene.Node n, IGeometry g)
IGeometry
from the parent coordinate system
of the given Node
into the local coordinate system of the
Node
.Copyright (c) 2014 itemis AG and others. All rights reserved.