Class Glider

java.lang.Object
com.github.yellowstonegames.smooth.Glider
Direct Known Subclasses:
AngleGlider, CoordGlider, FloatGlider, IntColorGlider, SequenceGlider, VectorGlider

public class Glider extends Object
A general-purpose group of smoothly-changing values, either float or int, using any rules for the smooth-movement interpolations (specifiable by FloatSmoother and IntSmoother functions).
  • Field Details

    • changers

      public final com.github.tommyettinger.ds.HolderSet<Glider.Changer, String> changers
    • change

      protected float change
    • interpolation

      protected com.github.tommyettinger.digital.Interpolations.Interpolator interpolation
    • completeRunner

      protected Runnable completeRunner
  • Constructor Details

    • Glider

      public Glider()
    • Glider

      public Glider(Glider.Changer changer)
    • Glider

      public Glider(Glider.Changer... changers)
    • Glider

      public Glider(com.github.tommyettinger.digital.Interpolations.Interpolator interpolation, Glider.Changer changer)
    • Glider

      public Glider(com.github.tommyettinger.digital.Interpolations.Interpolator interpolation, Glider.Changer... changers)
    • Glider

      public Glider(com.github.tommyettinger.digital.Interpolations.Interpolator interpolation, Runnable completeRunner, Glider.Changer changer)
    • Glider

      public Glider(com.github.tommyettinger.digital.Interpolations.Interpolator interpolation, Runnable completeRunner, Glider.Changer... changers)
    • Glider

      public Glider(Glider other)
  • Method Details

    • addChanger

      public Glider addChanger(Glider.Changer changer)
    • addChangers

      public Glider addChangers(Glider.Changer... changers)
    • addChangers

      public Glider addChangers(Collection<Glider.Changer> changers)
    • removeChanger

      public Glider removeChanger(String name)
    • merge

      public Glider merge(Glider other)
      Adds all Changers in other to this Glider, and potentially changes the runner so that it performs other's runner, if non-null, after this Glider's runner (or just run's other's if this has none).
      Parameters:
      other - another Glider to merge into this one; will not be changed, but this may share references
      Returns:
      this, after modifications, for chaining
    • getFloat

      public float getFloat(String name)
      Gets the current float value for the Changer with the given name by interpolating between its start and end float values. The interpolation will be applied to change before it is passed to the Changer's Glider.Changer.interpolatorF. If this cannot locate a Changer by the given name, this returns Float.NaN.
      Parameters:
      name - the name of the Changer to look up
      Returns:
      the current float value of the located Changer, or Float.NaN if lookup fails
    • getInt

      public int getInt(String name)
      Gets the current int value for the Changer with the given name by interpolating between its start and end int values. The interpolation will be applied to change before it is passed to the Changer's Glider.Changer.interpolatorI. If this cannot locate a Changer by the given name, this returns Integer.MIN_VALUE.
      Parameters:
      name - the name of the Changer to look up
      Returns:
      the current int value of the located Changer, or Integer.MIN_VALUE if lookup fails
    • getChange

      public float getChange()
    • setChange

      public void setChange(float change)
    • getStartFloat

      public float getStartFloat(String name)
      Looks up the start float value for the Changer with the given name. If this cannot locate a Changer by the given name, this returns Float.NaN.
      Parameters:
      name - the name of the Changer to look up
      Returns:
      the start float value of the located Changer, or Float.NaN if lookup fails
    • setStartFloat

      public void setStartFloat(String name, float start)
      Sets the start float value for the Changer with the given name to start. If this cannot locate a Changer by the given name, this does nothing. Otherwise, sets the Changer's start float value and also sets change to 0.
      Parameters:
      name - the name of the Changer to look up
      start - value to use for the located Changer's start float
    • getEndFloat

      public float getEndFloat(String name)
      Looks up the end float value for the Changer with the given name. If this cannot locate a Changer by the given name, this returns Float.NaN.
      Parameters:
      name - the name of the Changer to look up
      Returns:
      the end float value of the located Changer, or Float.NaN if lookup fails
    • setEndFloat

      public void setEndFloat(String name, float end)
      Sets the end float value for the Changer with the given name to end. If this cannot locate a Changer by the given name, this does nothing. Otherwise, sets the Changer's end float value and also sets change to 0.
      Parameters:
      name - the name of the Changer to look up
      end - value to use for the located Changer's end float
    • getStartInt

      public int getStartInt(String name)
      Looks up the start int value for the Changer with the given name. If this cannot locate a Changer by the given name, this returns Integer.MIN_VALUE.
      Parameters:
      name - the name of the Changer to look up
      Returns:
      the start int value of the located Changer, or Integer.MIN_VALUE if lookup fails
    • setStartInt

      public void setStartInt(String name, int start)
      Sets the start int value for the Changer with the given name to start. If this cannot locate a Changer by the given name, this does nothing. Otherwise, sets the Changer's start int value and also sets change to 0.
      Parameters:
      name - the name of the Changer to look up
      start - value to use for the located Changer's start int
    • getEndInt

      public int getEndInt(String name)
      Looks up the end int value for the Changer with the given name. If this cannot locate a Changer by the given name, this returns Integer.MIN_VALUE.
      Parameters:
      name - the name of the Changer to look up
      Returns:
      the end int value of the located Changer, or Integer.MIN_VALUE if lookup fails
    • setEndInt

      public void setEndInt(String name, int end)
      Sets the end int value for the Changer with the given name to end. If this cannot locate a Changer by the given name, this does nothing. Otherwise, sets the Changer's end int value and also sets change to 0.
      Parameters:
      name - the name of the Changer to look up
      end - value to use for the located Changer's end int
    • getInterpolation

      public com.github.tommyettinger.digital.Interpolations.Interpolator getInterpolation()
    • setInterpolation

      public void setInterpolation(com.github.tommyettinger.digital.Interpolations.Interpolator interpolation)
    • getCompleteRunner

      public Runnable getCompleteRunner()
    • setCompleteRunner

      public void setCompleteRunner(Runnable completeRunner)
    • onComplete

      public void onComplete()
    • resetToCurrent

      public void resetToCurrent()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object