public class Util
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
FIND_NODE_EXCLUDE
Tag used to exclude a node from finding
|
static java.lang.String |
FIND_NODE_RESPECT_DRAWING_ORDER
System property to force
findNode(Node, double, double) to respect the drawing order |
static boolean |
MNEMONICS_FIX
Boolean to indicate if mnemonic fixing is enabled
|
static java.lang.String |
OPTIMIZE_ATTACH
An application property to optimize the performances of attaching a
sub-graph to a Scene.
|
| Constructor and Description |
|---|
Util() |
| Modifier and Type | Method and Description |
|---|---|
static void |
attachNode(javafx.scene.Node node,
java.util.function.Consumer<javafx.scene.Node> attachToParent)
Attach the given node to an existing scene graph, via the given consumer.
|
static void |
attachNode(javafx.scene.Node node,
java.lang.Runnable attachToParent)
Attach the given node to an existing scene graph, via the given runnable.
|
static <T,E> Subscription |
bindContent(java.util.List<T> target,
javafx.collections.ObservableList<E> sourceList,
java.util.function.Function<E,T> converterFunction)
Deprecated.
use
FXObservableUtils#bindContent(List, ObservableList, Function) |
static javafx.beans.property.BooleanProperty |
createPseudoClassProperty(javafx.css.PseudoClass cls,
javafx.scene.Node node,
java.lang.String name,
boolean def)
creates a new pseudo class property.
|
static javafx.beans.property.BooleanProperty |
createPseudoClassProperty(java.lang.String pseudoClass,
javafx.scene.Node node,
java.lang.String name,
boolean def)
creates a new pseudo class property.
|
static javafx.beans.binding.DoubleBinding |
createTextHeightBinding(java.lang.String text,
javafx.beans.value.ObservableValue<javafx.scene.text.Font> font,
javafx.beans.value.ObservableValue<java.lang.Number> fontZoomFactor) |
static javafx.beans.binding.DoubleBinding |
createTextWidthBinding(javafx.beans.value.ObservableValue<java.lang.String> text,
javafx.beans.value.ObservableValue<javafx.scene.text.Font> font,
javafx.beans.value.ObservableValue<java.lang.Number> fontZoomFactor)
Create a binding for text width calculation.
|
static javafx.beans.binding.DoubleBinding |
createTextWidthBinding(java.lang.String text,
javafx.beans.value.ObservableValue<javafx.scene.text.Font> font,
javafx.beans.value.ObservableValue<java.lang.Number> fontZoomFactor) |
static void |
disableStyle(javafx.scene.Node node)
Disable styling on the given node, if
OPTIMIZE_ATTACH is
true. |
static java.lang.String |
dumpSceneGraph(javafx.scene.Node n)
Dump the scene graph to a formatted string
|
static void |
enterNestedEventLoop(java.lang.String id)
Enter a nested event loop
|
static void |
exitNestedEventLoop(java.lang.String id)
Exit the nested event loop
|
static javafx.scene.Node |
findNode(javafx.scene.Node n,
double screenX,
double screenY)
Find all node at the given x/y location starting the search from the
given node
|
static javafx.scene.Node |
findNode(javafx.stage.Window w,
double screenX,
double screenY)
Find a node in all windows
|
static javafx.scene.layout.Background |
getSimpleBackground(javafx.scene.paint.Paint p)
Create a simple background fill
|
static Size |
getSize(javafx.scene.text.Font font,
char c)
Get the size for the provided character
|
static double |
getTextHeight(java.lang.String text,
javafx.scene.text.Font font,
double fontZoomFactor) |
static double |
getTextWidth(java.lang.String text,
javafx.scene.text.Font font,
double fontZoomFactor)
Calculate the size of the text with the given font
|
static Subscription |
installHoverCallback(javafx.scene.Node node,
javafx.util.Duration delay,
java.util.function.Consumer<javafx.scene.input.MouseEvent> hoverConsumer)
Install a hover callback
|
static boolean |
isCopyEvent(javafx.scene.input.MouseEvent event) |
static <E extends javafx.event.Event> |
onEvent(java.lang.Runnable r)
Run the provided runnable when the event occurs
|
static <E extends javafx.event.Event> |
onEventConsume(java.util.function.BooleanSupplier r)
Run the provided supplier when the event occurs and if true is returned
consume the event
|
static void |
restoreStyle(javafx.scene.Node node)
Restore & reapply styling on the given node, if
OPTIMIZE_ATTACH is
true. |
static javafx.scene.Node |
toNode(StyledString s)
Create a scenegraph node from the styled string
|
static <T,E> java.util.List<T> |
transformList(java.util.List<? extends E> list,
java.util.function.Function<E,T> converterFunction)
Transform the list to another list
|
static <T> T |
waitUntil(<any> blockCondition)
Deprecated.
deprecated since 3.0 to to be replaced by
ThreadSynchronize#block(BlockCondition) |
static javafx.beans.value.ObservableValue<javafx.stage.Window> |
windowProperty(javafx.scene.Node n)
Get the window property of a node
|
public static final java.lang.String FIND_NODE_EXCLUDE
public static final java.lang.String FIND_NODE_RESPECT_DRAWING_ORDER
findNode(Node, double, double) to respect the drawing orderpublic static final boolean MNEMONICS_FIX
public static final java.lang.String OPTIMIZE_ATTACH
An application property to optimize the performances of attaching a sub-graph to a Scene.
Set this property to true to workaround performance issues
from https://bugs.openjdk.java.net/browse/JDK-8151756 and
https://bugs.openjdk.java.net/browse/JDK-8193445
public static java.lang.String dumpSceneGraph(javafx.scene.Node n)
n - the node to start withpublic static javafx.scene.Node toNode(StyledString s)
s - the stringpublic static javafx.scene.Node findNode(javafx.stage.Window w,
double screenX,
double screenY)
w - the preferred windowscreenX - the screen xscreenY - the screen ynullpublic static javafx.scene.Node findNode(javafx.scene.Node n,
double screenX,
double screenY)
n - the node to use as the startscreenX - the screen xscreenY - the screen ynullpublic static javafx.beans.value.ObservableValue<javafx.stage.Window> windowProperty(javafx.scene.Node n)
n - the node the window property to observepublic static <T,E> Subscription bindContent(java.util.List<T> target,
javafx.collections.ObservableList<E> sourceList,
java.util.function.Function<E,T> converterFunction)
FXObservableUtils#bindContent(List, ObservableList, Function)T - the target typeE - the source typetarget - the target listsourceList - the source listconverterFunction - the function used to convertpublic static <T,E> java.util.List<T> transformList(java.util.List<? extends E> list,
java.util.function.Function<E,T> converterFunction)
list - the listconverterFunction - the converter functionpublic static Subscription installHoverCallback(javafx.scene.Node node,
javafx.util.Duration delay,
java.util.function.Consumer<javafx.scene.input.MouseEvent> hoverConsumer)
node - the node the hover is installed ondelay - the delayhoverConsumer - the consumerpublic static void enterNestedEventLoop(java.lang.String id)
id - the id of the nested event looppublic static void exitNestedEventLoop(java.lang.String id)
id - the nested event loop@Deprecated public static <T> T waitUntil(<any> blockCondition)
ThreadSynchronize#block(BlockCondition)blockCondition - the conditionpublic static double getTextWidth(java.lang.String text,
javafx.scene.text.Font font,
double fontZoomFactor)
text - the textfont - the fontpublic static javafx.beans.binding.DoubleBinding createTextWidthBinding(javafx.beans.value.ObservableValue<java.lang.String> text,
javafx.beans.value.ObservableValue<javafx.scene.text.Font> font,
javafx.beans.value.ObservableValue<java.lang.Number> fontZoomFactor)
text - font - public static javafx.beans.binding.DoubleBinding createTextWidthBinding(java.lang.String text,
javafx.beans.value.ObservableValue<javafx.scene.text.Font> font,
javafx.beans.value.ObservableValue<java.lang.Number> fontZoomFactor)
public static double getTextHeight(java.lang.String text,
javafx.scene.text.Font font,
double fontZoomFactor)
public static javafx.beans.binding.DoubleBinding createTextHeightBinding(java.lang.String text,
javafx.beans.value.ObservableValue<javafx.scene.text.Font> font,
javafx.beans.value.ObservableValue<java.lang.Number> fontZoomFactor)
public static boolean isCopyEvent(javafx.scene.input.MouseEvent event)
public static Size getSize(javafx.scene.text.Font font,
char c)
font - the fontc - the characterpublic static javafx.scene.layout.Background getSimpleBackground(javafx.scene.paint.Paint p)
p - the paintpublic static javafx.beans.property.BooleanProperty createPseudoClassProperty(javafx.css.PseudoClass cls,
javafx.scene.Node node,
java.lang.String name,
boolean def)
A pseudo class property is a BooleanProperty which updates the containers pseudo class state on invalidation.
cls - the pseudo classnode - the container nodename - the properties name (not to confuse with the pseudo class
name, those may be different)def - the initial valuepublic static javafx.beans.property.BooleanProperty createPseudoClassProperty(java.lang.String pseudoClass,
javafx.scene.Node node,
java.lang.String name,
boolean def)
A pseudo class property is a BooleanProperty which updates the containers pseudo class state on invalidation.
Convenience method if you do not need to hold the instance of the PseudoClass
pseudoClass - the pseudo class stringnode - the container nodename - the properties name (not to confuse with the pseudo class
name, those may be different)def - the initial valuepublic static <E extends javafx.event.Event> javafx.event.EventHandler<E> onEvent(java.lang.Runnable r)
r - the runnablepublic static <E extends javafx.event.Event> javafx.event.EventHandler<E> onEventConsume(java.util.function.BooleanSupplier r)
r - the supplierpublic static void attachNode(javafx.scene.Node node,
java.util.function.Consumer<javafx.scene.Node> attachToParent)
efxclipse.optimize.attach system propertynode - The node to attach to an existing scene graphattachToParent - The method used to attach the node to the scene graph (e.g.
pane.getChildren()::add or
borderPane::setCenter)OPTIMIZE_ATTACHpublic static void attachNode(javafx.scene.Node node,
java.lang.Runnable attachToParent)
efxclipse.optimize.attach system propertynode - The node to attach to an existing scene graphattachToParent - The method used to attach the node to the scene graph (e.g.
() -> pane.getChildren().add(node) or
() -> borderPane.setCenter(node))OPTIMIZE_ATTACHpublic static void disableStyle(javafx.scene.Node node)
Disable styling on the given node, if OPTIMIZE_ATTACH is
true. This method can be called before attaching a sub-graph
to a scene, to increase performances. After invoking this method,
styling should be explicitly re-enabled with restoreStyle(Node)
If OPTIMIZE_ATTACH is false, this is a no-op.
This method will be applied recursively on the node's children.
node - The node for which styling should be disabledOPTIMIZE_ATTACHpublic static void restoreStyle(javafx.scene.Node node)
Restore & reapply styling on the given node, if OPTIMIZE_ATTACH is
true.
This method will be applied recursively on the node's children.
If OPTIMIZE_ATTACH is false, this is a no-op.
node - The node for which styling should be restored