Class AnimationUtils

java.lang.Object
com.arbergashi.charts.util.AnimationUtils

public final class AnimationUtils extends Object
High-performance animation and interpolation utilities for ArberCharts.

Design goals:

  • EDT-friendly: pure functions, no global mutable state.
  • Stable timing: use System.nanoTime() for progress computation.
  • Small API surface: only what is required by the framework.
Since:
2025-06-01
Version:
1.0.0
Author:
Arber Gashi
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Easing function selector.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    easeInOut(double fraction)
    Cubic ease-in-out.
    static double
    easeInOutExpo(double fraction)
    Exponential ease-in-out.
    static double
    easeInOutQuad(double fraction)
    Quadratic ease-in-out.
    static double
    easeInOutSine(double fraction)
    Sine ease-in-out.
    static double
    getEasedProgressNanos(long startNanos, long durationMillis)
    Convenience: cubic eased progress.
    static double
    getEasedProgressNanos(long startNanos, long durationMillis, AnimationUtils.EasingType easingType)
    Convenience: eased progress with selectable easing.
    static double
    getProgressNanos(long startNanos, long durationMillis)
    Progress based on System.nanoTime().
    static boolean
    isFinishedNanos(long startNanos, long durationMillis)
    Returns true once progress reaches 1.0.
    static double
    lerp(double start, double end, double fraction)
    Linear interpolation (lerp).
    static float
    lerp(float start, float end, float fraction)
    Float lerp.
    static int
    lerp(int start, int end, double fraction)
    Int lerp (rounded).
    static long
    Monotonic timestamp suitable for animations.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • lerp

      public static double lerp(double start, double end, double fraction)
      Linear interpolation (lerp).
      Parameters:
      start - start value
      end - end value
      fraction - interpolation factor in [0..1]
    • lerp

      public static float lerp(float start, float end, float fraction)
      Float lerp.
    • lerp

      public static int lerp(int start, int end, double fraction)
      Int lerp (rounded).
    • easeInOut

      public static double easeInOut(double fraction)
      Cubic ease-in-out.
    • easeInOutQuad

      public static double easeInOutQuad(double fraction)
      Quadratic ease-in-out.
    • easeInOutExpo

      public static double easeInOutExpo(double fraction)
      Exponential ease-in-out.
    • easeInOutSine

      public static double easeInOutSine(double fraction)
      Sine ease-in-out.
    • nowNanos

      public static long nowNanos()
      Monotonic timestamp suitable for animations.
    • getProgressNanos

      public static double getProgressNanos(long startNanos, long durationMillis)
      Progress based on System.nanoTime().
    • isFinishedNanos

      public static boolean isFinishedNanos(long startNanos, long durationMillis)
      Returns true once progress reaches 1.0.
    • getEasedProgressNanos

      public static double getEasedProgressNanos(long startNanos, long durationMillis)
      Convenience: cubic eased progress.
    • getEasedProgressNanos

      public static double getEasedProgressNanos(long startNanos, long durationMillis, AnimationUtils.EasingType easingType)
      Convenience: eased progress with selectable easing.