Class Animator

java.lang.Object
org.vanted.animation.Animator

public class Animator
extends Object
Author:
- Patrick Shaw
  • Constructor Summary

    Constructors
    Constructor Description
    Animator​(Graph graph)
    Creates an animator will perform a single loop forever.
    Animator​(Graph graph, int noLoops)
    Creates an animator that will automatically calculate the loop duration to be the same as the animation who's loop duration is largest
    Animator​(Graph graph, int noLoops, double loopDuration)
    Creates an animator that needs to have its loop duration manually specified.
    Animator​(Graph graph, int noLoops, int loopDuration, TimeUnit timeUnit)
    Creates an animator that needs to have its loop duration manually specified.
    Animator​(Graph graph, int noLoops, LoopDuration loopDuration)
    Creates an animator that needs to have its loop duration manually specified.
    Animator​(Graph graph, NumberOfLoops noLoops)
    Creates an animator that will automatically calculate the loop duration to be the same as the animation who's loop duration is largest
  • Method Summary

    Modifier and Type Method Description
    void addAnimation​(Animation animation)
    Call this method any time you want to add an animation.
    Can be called while animations are taking place.
    Call it whenever you want.
    void addListener​(AnimatorListener listener)  
    int getFPS()
    Gets the number of times animations are updated per second.
    boolean getIsAutoLoopDuration()
    Sets whether the animator is automatically calculating the animator loop duration.
    double getLoopDuration()
    Get's the loop duration of the animation.
    int getNoLoops()
    Gets the number of times the animator will perform a loop.
    void removeAnimation​(Animation animation)
    Call this method any time you want to remove an animation.
    Can be called while animations are taking place.
    void removeListener​(AnimatorListener listener)  
    void reset()
    Stops the animation and rests it.
    void restart()
    Resets the animation and starts it again.
    void setFPS​(int fps)
    Sets the number of times animations are updated per second.
    void setIsAutoLoopDuration​(boolean isAutoCalculatingLoopDuration)
    Sets whether the animator is automatically calculating the animator loop duration.
    void setLoopDuration​(double loopDuration)
    Sets the duration of a loop.
    void setLoopDuration​(long time, TimeUnit timeUnit)
    Sets the duration of a loop.
    void setLoopDuration​(LoopDuration loopDuration)
    Sets the duration of a loop.
    void setNoLoops​(int noLoops)
    Sets the number of times the animator will perform a loop.
    void setNoLoops​(NumberOfLoops noLoops)
    The number of times the animator will perform a loop.
    void start()
    Starts the animator
    void stop()
    Stops the animator.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Animator

      public Animator​(Graph graph)
      Creates an animator will perform a single loop forever.
    • Animator

      public Animator​(Graph graph, int noLoops)
      Creates an animator that will automatically calculate the loop duration to be the same as the animation who's loop duration is largest
      Parameters:
      noLoops - The number of times the animator will perform.
    • Animator

      public Animator​(Graph graph, NumberOfLoops noLoops)
      Creates an animator that will automatically calculate the loop duration to be the same as the animation who's loop duration is largest
      Parameters:
      noLoops - The number of times the animator will perform.
    • Animator

      public Animator​(Graph graph, int noLoops, double loopDuration)
      Creates an animator that needs to have its loop duration manually specified.
      Parameters:
      noLoops - The number of times the animator will perform.
      loopDuration - How long each loop in the animator will last.
    • Animator

      public Animator​(Graph graph, int noLoops, int loopDuration, TimeUnit timeUnit)
      Creates an animator that needs to have its loop duration manually specified.
      Parameters:
      noLoops - The number of times the animator will perform.
      loopDuration - The magnitude of the loop duration.
      timeUnit - The time unit of the loop duration.
    • Animator

      public Animator​(Graph graph, int noLoops, LoopDuration loopDuration)
      Creates an animator that needs to have its loop duration manually specified.
      Parameters:
      noLoops - The number of times the animator will perform.
      loopDuration - How long each loop in the animator will last.
  • Method Details

    • setIsAutoLoopDuration

      public void setIsAutoLoopDuration​(boolean isAutoCalculatingLoopDuration)
      Sets whether the animator is automatically calculating the animator loop duration.
      Parameters:
      isAutoCalculatingLoopDuration - If True: The animator will always calculate the loop duration to be the same value as the animation who's loop duration is the largest.
      If False: The animator loop duration needs to be set manually.
    • getIsAutoLoopDuration

      public boolean getIsAutoLoopDuration()
      Sets whether the animator is automatically calculating the animator loop duration.
      Returns:
      If True: The animator will always calculate the loop duration to be the same value as the animation who's loop duration is the largest.
      If False: The animator loop duration needs to be set manually.
    • setFPS

      public void setFPS​(int fps)
      Sets the number of times animations are updated per second.
      Parameters:
      fps -
    • getFPS

      public int getFPS()
      Gets the number of times animations are updated per second.
      Parameters:
      fps -
    • getLoopDuration

      public double getLoopDuration()
      Get's the loop duration of the animation.
      Returns:
      The duration of the loop in milliseconds.
    • setLoopDuration

      public void setLoopDuration​(double loopDuration)
      Sets the duration of a loop.
      Parameters:
      duration - The loop duration in milliseconds.
    • setLoopDuration

      public void setLoopDuration​(LoopDuration loopDuration)
      Sets the duration of a loop.
    • setLoopDuration

      public void setLoopDuration​(long time, TimeUnit timeUnit)
      Sets the duration of a loop.
      Parameters:
      duration - The time magnitude.
      The - unit of time being used.
    • getNoLoops

      public int getNoLoops()
      Gets the number of times the animator will perform a loop.
      Parameters:
      noLoops - -1 = Infinite loop
      0 = Doesn't do anything
      1 = Will do the animation once
      2 = Will do the animation twice
    • setNoLoops

      public void setNoLoops​(int noLoops)
      Sets the number of times the animator will perform a loop.
      Parameters:
      noLoops - -1 = Infinite loop
      0 = Doesn't do anything
      1 = Will do the animation once
      2 = Will do the animation twice
    • setNoLoops

      public void setNoLoops​(NumberOfLoops noLoops)
      The number of times the animator will perform a loop.
    • addAnimation

      public void addAnimation​(Animation animation)
      Call this method any time you want to add an animation.
      Can be called while animations are taking place.
      Call it whenever you want.
    • removeAnimation

      public void removeAnimation​(Animation animation)
      Call this method any time you want to remove an animation.
      Can be called while animations are taking place. However,
      the attribute will not reset to it's original value prior
      to the animation if removed.
    • addListener

      public void addListener​(AnimatorListener listener)
    • removeListener

      public void removeListener​(AnimatorListener listener)
    • start

      public void start()
      Starts the animator
    • stop

      public void stop()
      Stops the animator.
    • restart

      public void restart()
      Resets the animation and starts it again.
    • reset

      public void reset()
      Stops the animation and rests it.