public class NodeUtil
extends java.lang.Object
Utility class that provides methods to simplify node handling. Possible use cases are searching for nodes at specific locations, adding/removing nodes to/from parents (Parent interface does not give write access to children).
Modifier and Type | Method and Description |
---|---|
static void |
addToParent(javafx.scene.Parent p,
javafx.scene.Node n)
Adds the given node to the specified parent.
|
static javafx.scene.Node |
getNode(javafx.scene.Parent p,
double sceneX,
double sceneY,
java.lang.Class<?> nodeClass)
Returns the first node at the given location that is an instance of the
specified class object.
|
static java.util.List<javafx.scene.Node> |
nodesThatImplement(java.util.List<javafx.scene.Node> nodes,
java.lang.Class<?> cls) |
static java.util.List<javafx.scene.Node> |
nodesWithParent(javafx.scene.Parent p,
java.util.List<javafx.scene.Node> nodes) |
static void |
removeFromParent(javafx.scene.Node n)
Removes the specified node from its parent.
|
public static void removeFromParent(javafx.scene.Node n)
Removes the specified node from its parent.
n
- the node to removejava.lang.IllegalArgumentException
- if an unsupported parent class has been
specified or the parent is <code>null</code>public static void addToParent(javafx.scene.Parent p, javafx.scene.Node n)
Adds the given node to the specified parent.
p
- parentn
- nodejava.lang.IllegalArgumentException
- if an unsupported parent class has been
specified or the parent is <code>null</code>public static javafx.scene.Node getNode(javafx.scene.Parent p, double sceneX, double sceneY, java.lang.Class<?> nodeClass)
Returns the first node at the given location that is an instance of the specified class object. The search is performed recursively until either a node has been found or a leaf node is reached.
p
- parent nodesceneX
- x coordinatesceneY
- y coordinatenodeClass
- node class to search forpublic static java.util.List<javafx.scene.Node> nodesWithParent(javafx.scene.Parent p, java.util.List<javafx.scene.Node> nodes)
public static java.util.List<javafx.scene.Node> nodesThatImplement(java.util.List<javafx.scene.Node> nodes, java.lang.Class<?> cls)