java.lang.Object
org.tquadrat.foundation.fx.FXUtils
@ClassVersion(sourceVersion="$Id: FXUtils.java 1134 2024-05-20 16:53:16Z tquadrat $")
@API(status=STABLE,
since="0.4.2")
@UtilityClass
public final class FXUtils
extends Object
Some useful utility function for the work with JavaFX.
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: FXUtils.java 1134 2024-05-20 16:53:16Z tquadrat $
- Since:
- 0.4.2
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.fx.FXUtils"
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final doubleclamp(double min, double value, double max) Clamps the given value to be strictly between theminandmaxvalues.static final doublenearest(double less, double value, double more) Returns eitherlessormoredepending on which one is closer tovalue.static final WindowretrieveOwner(ActionEvent event) Retrieves the window owning theButtonthat fired the givenActionEvent.
-
Constructor Details
-
FXUtils
private FXUtils()No instance allowed for this class!
-
-
Method Details
-
clamp
@API(status=STABLE, since="0.4.6") public static final double clamp(double min, double value, double max) throws IllegalArgumentException Clamps the given value to be strictly between the
minandmaxvalues.Basically, this method does the same as
Math.clamp(double, double, double), only the sequence of the arguments is different.- Parameters:
min- The lower border.value- The value.max- The upper border.- Returns:
- The value if it is greater than
minand less thanmax,min, when it is less thanmin, ormaxwhen it is greater than that. - Throws:
IllegalArgumentException-minis greater thanmax.- Since:
- 0.4.6
-
nearest
@API(status=STABLE, since="0.4.6") public static final double nearest(double less, double value, double more) Returns either
lessormoredepending on which one is closer tovalue. Ifvalueis perfectly between them, then either may be returned.- Parameters:
less- The lower value.value- The reference value.more- The upper value.- Returns:
- The value that is closer to the reference.
- Since:
- 0.4.6
-
retrieveOwner
Retrieves the window owning theButtonthat fired the givenActionEvent.- Parameters:
event- The action event.- Returns:
- The owning window.
- Throws:
IllegalArgumentException- The event was not fired by aButton.
-
