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 |
addStyleClass(javafx.scene.Node node,
java.lang.String styleclass)
This method is used to prevent the remove-add constructs on styleclasses.
|
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 void |
removeFromParent(javafx.scene.Node n)
Removes the specified node from its parent.
|
static void |
removeStyleClass(javafx.scene.Node node,
java.lang.String styleclass)
The remove operation is already "cheap", so this method is here to only mirror the addStyleClass (which is not cheap)
|
static double |
sceneX(javafx.scene.Node node) |
static double |
sceneY(javafx.scene.Node node) |
static double |
screenX(javafx.scene.Node node) |
static double |
screenY(javafx.scene.Node node) |
static double |
snapWH(double position,
double offset)
This method prevents blurry horizontal or vertical lines, use snapWH(x, w) instead of w.
|
static javafx.beans.binding.DoubleBinding |
snapWH(javafx.beans.value.ObservableNumberValue position,
javafx.beans.value.ObservableNumberValue offset,
javafx.beans.Observable... dependencies)
This is the snapXY method for using in a binding, for example:
p1.bind( snapXY( p2.multiply(0.1) ));
|
static double |
snapXY(double position)
This method prevents blurry horizontal or vertical lines, use snapXY(x) instead of x.
|
static javafx.beans.binding.DoubleBinding |
snapXY(javafx.beans.value.ObservableNumberValue position)
This is the snapXY method for using in a binding, for example:
p1.bind( snapXY( p2.multiply(0.1) ));
|
static double |
xInParent(javafx.scene.Node node,
javafx.scene.Node parent) |
static double |
yInParent(javafx.scene.Node node,
javafx.scene.Node parent) |
public static double xInParent(javafx.scene.Node node,
javafx.scene.Node parent)
node - public static double yInParent(javafx.scene.Node node,
javafx.scene.Node parent)
node - public static double screenX(javafx.scene.Node node)
node - public static double screenY(javafx.scene.Node node)
node - public static double sceneX(javafx.scene.Node node)
node - public static double sceneY(javafx.scene.Node node)
node - 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 fornull if no such node
existpublic static double snapXY(double position)
This method prevents blurry horizontal or vertical lines, use snapXY(x) instead of x.
position - (x or y)public static javafx.beans.binding.DoubleBinding snapXY(javafx.beans.value.ObservableNumberValue position)
This is the snapXY method for using in a binding, for example: p1.bind( snapXY( p2.multiply(0.1) ));
position - (x or y)public static double snapWH(double position,
double offset)
This method prevents blurry horizontal or vertical lines, use snapWH(x, w) instead of w.
position - (x or y)offset - (width or height)public static javafx.beans.binding.DoubleBinding snapWH(javafx.beans.value.ObservableNumberValue position,
javafx.beans.value.ObservableNumberValue offset,
javafx.beans.Observable... dependencies)
This is the snapXY method for using in a binding, for example: p1.bind( snapXY( p2.multiply(0.1) ));
position - (x or y)offset - (width or height)dependencies - public static void addStyleClass(javafx.scene.Node node,
java.lang.String styleclass)
This method is used to prevent the remove-add constructs on styleclasses. This prevents CSS reprocessed unnecessary, because that is a time consuming process.
node - styleclass - public static void removeStyleClass(javafx.scene.Node node,
java.lang.String styleclass)
The remove operation is already "cheap", so this method is here to only mirror the addStyleClass (which is not cheap)
node - styleclass -