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"

UML Diagram for "org.tquadrat.foundation.fx.FXUtils"

UML Diagram for "org.tquadrat.foundation.fx.FXUtils"
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    No instance allowed for this class!
  • Method Summary

    Modifier and Type
    Method
    Description
    static final double
    clamp(double min, double value, double max)
    Clamps the given value to be strictly between the min and max values.
    static final double
    nearest(double less, double value, double more)
    Returns either less or more depending on which one is closer to value.
    static final Window
    Retrieves the window owning the Button that fired the given ActionEvent.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 and max 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 than max, min, when it is less than min, or max when it is greater than that.
      Throws:
      IllegalArgumentException - min is greater than max.
      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 or more depending on which one is closer to value. If value 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

      public static final Window retrieveOwner(ActionEvent event) throws IllegalArgumentException
      Retrieves the window owning the Button that fired the given ActionEvent.
      Parameters:
      event - The action event.
      Returns:
      The owning window.
      Throws:
      IllegalArgumentException - The event was not fired by a Button.