Module MaterialFX

Class AnimationUtils.PauseBuilder

java.lang.Object
io.github.palexdev.materialfx.utils.AnimationUtils.PauseBuilder
Enclosing class:
AnimationUtils

public static class AnimationUtils.PauseBuilder extends Object
Builder class to easily create a PauseTransition with fluent api.
  • Constructor Details

    • PauseBuilder

      public PauseBuilder()
  • Method Details

    • build

      public static AnimationUtils.PauseBuilder build()
      Returns:
      a new PauseBuilder instance. Equivalent to calling the constructor, it's just a way to omit the new keyword
    • setDelay

      public AnimationUtils.PauseBuilder setDelay(Duration duration)
    • setDelay

      public AnimationUtils.PauseBuilder setDelay(double millis)
    • setDuration

      public AnimationUtils.PauseBuilder setDuration(Duration duration)
      Sets the pause transition duration.
    • setDuration

      public AnimationUtils.PauseBuilder setDuration(double millis)
      Calls setDuration(Duration) by converting the given millis value with Duration.millis(double).
    • setOnFinished

      public AnimationUtils.PauseBuilder setOnFinished(EventHandler<ActionEvent> onFinished)
      Sets the action to perform when the pause transition ends.
    • getAnimation

      public PauseTransition getAnimation()
      Returns:
      the instance of the PauseTransition
    • runWhile

      public void runWhile(BooleanExpression booleanExpression, Runnable retryAction, Runnable onSuccessAction)
      This method can be considered an utility.

      A PauseTransition with the previously set duration runs while the given boolean boolean expression is false. When the expression is evaluated and it is false the given retryAction is run and the transition is restarted. When it ends the expression is re-evaluated. When the expression becomes true the onSuccessAction is run.

      So you have a PauseTransition that runs every tot unit of time and stops only when the given expression is true.
      Parameters:
      booleanExpression - the expression to check at a fixed time rate
      retryAction - the action to perform when the expression is false
      onSuccessAction - the action to perform when the expression is true
    • runWhile

      public void runWhile(BooleanExpression booleanExpression, Runnable retryAction, Runnable onSuccessAction, int maxRetryCount)
      Same method as runWhile(BooleanExpression, Runnable, Runnable) but instead of running until the given expression is true, it is limited to a maximum number of retries.
      Parameters:
      maxRetryCount - the max number of times the transition can be restarted