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 double
clamp
(double min, double value, double max) Clamps the given value to be strictly between themin
andmax
values.static final double
nearest
(double less, double value, double more) Returns eitherless
ormore
depending on which one is closer tovalue
.static final Window
retrieveOwner
(ActionEvent event) Retrieves the window owning theButton
that 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
min
andmax
values.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
min
and less thanmax
,min
, when it is less thanmin
, ormax
when it is greater than that. - Throws:
IllegalArgumentException
-min
is 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
less
ormore
depending on which one is closer tovalue
. Ifvalue
is 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 theButton
that fired the givenActionEvent
.- Parameters:
event
- The action event.- Returns:
- The owning window.
- Throws:
IllegalArgumentException
- The event was not fired by aButton
.
-