java.lang.Object
io.github.palexdev.materialfx.utils.NodeUtils
Utility class which provides convenience methods for working with Nodes
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddPrefHeight(Region region, double value) Convenience method for adding the desired value to the region's prefHeightstatic voidaddPrefWidth(Region region, double value) Convenience method for adding the desired value to the region's prefWidthstatic voidcenterNodeInAnchorPane(Node node, double topBottom, double leftRight) Centers the specified node in anAnchorPane.static voidfireDummyEvent(Node node) Convenience method for programmatically fire a dummy MOUSE_PRESSED event on the desired node.getAllNodes(Parent root) Recursively gets all nodes that are descendants of the given root.static doublegetNodeHeight(Node node) Retrieves the node height if it isn't still laid out.static SizeBeangetNodeSizes(Node node) Retrieves the node's width and height if it isn't still laid outstatic doublegetNodeWidth(Node node) Retrieves the node width if it isn't still laid out.static doublegetRegionHeight(Region region) Retrieves the region height if it isn't still laid out.static doublegetRegionWidth(Region region) Retrieves the region width if it isn't still laid out.static ScreengetScreenFor(Node node) static booleaninHierarchy(MouseEvent event, Node node) Checks if the specified node is in hierarchy of the pressed node,PickResult.getIntersectedNode().static booleaninHierarchy(Node node, MouseEvent event) Checks if the pressed node is in the hierarchy of the specified node,PickResult.getIntersectedNode().static booleaninHierarchy(Node node, Node element) Checks if the specified element is in the hierarchy of the specified node.static booleanisPseudoClassActive(Control control, PseudoClass pseudoClass) Checks if the givenPseudoClassis currently active on the givenControl.static booleanisRightAlignment(Pos alignment) Checks if the given alignment is set to RIGHT(any).static voidmakeRegionCircular(Region region) Makes the given region circular.static voidmakeRegionCircular(Region region, double radius) Makes the given region circular with the specified radius.static CornerRadiiparseCornerRadius(Region region) Tries to parse tje given Region's corner radius.static voidsetBackground(Region region, Paint fill) Sets the background of the given region to the given color.static voidsetBackground(Region region, Paint fill, CornerRadii radius) Sets the background of the given region to the given color, with the given radius.static voidsetBackground(Region region, Paint fill, CornerRadii radius, Insets insets) Sets the background of the given region to the given color, with the given radius and insets.static voidupdateBackground(Region region, Paint fill) Changes the background color of aRegionto the desired one.static voidupdateBackground(Region region, Paint fill, Insets backgroundInsets) Changes the background color of aRegionto the desired one and lets specify the background insets.static voidupdateBackground(Region region, Paint fill, CornerRadii cornerRadii, Insets backgroundInsets) static voidwaitForScene(Node node, Runnable action, boolean addListenerIfNotNull, boolean isOneShot) Convenience method to execute a given action after that the given node has been laid out and its scene is not null anymore.static voidwaitForSkin(Control control, Runnable action, boolean addListenerIfNotNull, boolean isOneShot) Convenience method to execute a given action after that the given control has been laid out and its skin is not null anymore.
-
Method Details
-
updateBackground
Changes the background color of aRegionto the desired one.- Parameters:
region- The region to change the background color tofill- The desired color
-
updateBackground
Changes the background color of aRegionto the desired one and lets specify the background insets.- Parameters:
region- The region to change the background color tofill- The desired colorbackgroundInsets- The background insets to use
-
updateBackground
public static void updateBackground(Region region, Paint fill, CornerRadii cornerRadii, Insets backgroundInsets) -
setBackground
Sets the background of the given region to the given color. -
setBackground
Sets the background of the given region to the given color, with the given radius. -
setBackground
Sets the background of the given region to the given color, with the given radius and insets. -
parseCornerRadius
Tries to parse tje given Region's corner radius.To be more precise it tries to parse both the background and the border radius. The background radius is prioritized over the border one but in case the background is null or empty then the border one is used.
In case of both null or empty returns
CornerRadii.EMPTY. -
centerNodeInAnchorPane
Centers the specified node in anAnchorPane. -
inHierarchy
Checks if the specified element is in the hierarchy of the specified node. -
inHierarchy
Checks if the pressed node is in the hierarchy of the specified node,PickResult.getIntersectedNode(). -
inHierarchy
Checks if the specified node is in hierarchy of the pressed node,PickResult.getIntersectedNode(). -
makeRegionCircular
Makes the given region circular.Notice: the region's pref width and height must be set and be equals
- Parameters:
region- The given region
-
makeRegionCircular
Makes the given region circular with the specified radius.Notice: the region's pref width and height must be set and be equals
- Parameters:
region- The given regionradius- The wanted radius
-
getRegionHeight
Retrieves the region height if it isn't still laid out.- Parameters:
region- the Region of which to know the height- Returns:
- the calculated height
-
getRegionWidth
Retrieves the region width if it isn't still laid out.- Parameters:
region- the Region of which to know the width- Returns:
- the calculated width
-
getNodeHeight
Retrieves the node height if it isn't still laid out.- Parameters:
node- the Node of which to know the height- Returns:
- the calculated height
-
getNodeWidth
Retrieves the node width if it isn't still laid out.- Parameters:
node- the Node of which to know the width- Returns:
- the calculated width
-
getNodeSizes
Retrieves the node's width and height if it isn't still laid out- Parameters:
node- the Node of which to know the sizes- Returns:
- the computed width and height as a
SizeBean
-
addPrefWidth
Convenience method for adding the desired value to the region's prefWidth -
addPrefHeight
Convenience method for adding the desired value to the region's prefHeight -
fireDummyEvent
Convenience method for programmatically fire a dummy MOUSE_PRESSED event on the desired node. -
isRightAlignment
Checks if the given alignment is set to RIGHT(any). -
getAllNodes
Recursively gets all nodes that are descendants of the given root. -
waitForSkin
public static void waitForSkin(Control control, Runnable action, boolean addListenerIfNotNull, boolean isOneShot) Convenience method to execute a given action after that the given control has been laid out and its skin is not null anymore. If the skin is not null when called, the action is executed immediately.The listener is added only if the skin is null or the addListenerIfNotNull parameter is true.
- Parameters:
control- the control to check for skin initializationaction- the action to perform when the skin is not nulladdListenerIfNotNull- to specify if the listener should be added anyway even if the scene is not nullisOneShot- to specify if the listener added to the skin property should be removed after it is not null anymore
-
waitForScene
public static void waitForScene(Node node, Runnable action, boolean addListenerIfNotNull, boolean isOneShot) Convenience method to execute a given action after that the given node has been laid out and its scene is not null anymore. If the scene is not null when called, the action is executed immediately.The listener is added only if the scene is null or the addListenerIfNotNull parameter is true.
- Parameters:
node- the node to check for scene initializationaction- the action to perform when the scene is not nulladdListenerIfNotNull- to specify if the listener should be added anyway even if the scene is not nullisOneShot- to specify if the listener added to the scene property should be removed after it is not null anymore
-
isPseudoClassActive
Checks if the givenPseudoClassis currently active on the givenControl. -
getScreenFor
-