Package snap.view

Class ViewAnim

java.lang.Object
snap.view.ViewAnim
All Implemented Interfaces:
XMLArchiver.Archivable

public class ViewAnim extends Object implements XMLArchiver.Archivable
A class to animate View attributes.
  • Field Details

    • _startTime

      protected int _startTime
  • Constructor Details

    • ViewAnim

      public ViewAnim(View aView)
      Constructor.
    • ViewAnim

      protected ViewAnim(View aView, int aStart, int anEnd)
      Constructor.
  • Method Details

    • getView

      public View getView()
      Returns the View.
    • isRoot

      public boolean isRoot()
      Returns whether this ViewAnim is the root one.
    • getRoot

      public ViewAnim getRoot()
      Returns the root ViewAnim.
    • getRoot

      public ViewAnim getRoot(int aTime)
      Returns the root ViewAnim.
    • getParent

      public ViewAnim getParent()
      Returns the parent ViewAnim.
    • getStart

      public int getStart()
      Returns the start value.
    • getEnd

      public int getEnd()
      Returns the end value.
    • getFrameLength

      public int getFrameLength()
      Returns the length of the frame in milliseconds.
    • isEmpty

      public boolean isEmpty()
      Returns whether anim is empty/cleared.
    • getKeys

      public List<String> getKeys()
      Returns the keys.
    • getStartValue

      public Object getStartValue(String aKey)
      Returns the start value for given key.
    • setStartValue

      public void setStartValue(String aKey, Object aVal)
      Sets the start value for given key.
    • getEndVal

      public Object getEndVal(String aKey)
      Returns the end value for given key.
    • getAnims

      public List<ViewAnim> getAnims()
      Returns the list of child anims.
    • getAnim

      public ViewAnim getAnim(int aTime)
      Returns the anim for the given start/end.
    • getMaxTime

      public int getMaxTime()
      Returns the max time.
    • isPlaying

      public boolean isPlaying()
      Returns whether anim is playing.
    • isSuspended

      public boolean isSuspended()
      Returns whether anim should be playing, but didn't have access to ViewUpdater (probably wasn't showing).
    • play

      public void play()
      Play the anim.
    • stop

      public void stop()
      Stop the anim.
    • suspend

      protected void suspend()
      Suspends the anim. Called when anim was playing but view no longer showing. Should restart when conditions are right.
    • getTime

      public int getTime()
      Returns the current time.
    • setTime

      public void setTime(int aTime)
      Sets the current time.
    • updateValues

      protected void updateValues()
      Updates values for current time.
    • getValueForKeyAndTime

      protected Object getValueForKeyAndTime(String aKey, int aTime)
      Returns the value for given key and time.
    • interpolateValuesForRatio

      public Object interpolateValuesForRatio(Object aVal1, Object aVal2, double aRatio)
      Returns the interpolated value.
    • setX

      public ViewAnim setX(double aVal)
      Sets the X value.
    • setY

      public ViewAnim setY(double aVal)
      Sets the Y value.
    • setWidth

      public ViewAnim setWidth(double aVal)
      Sets the Width value.
    • setHeight

      public ViewAnim setHeight(double aVal)
      Sets the Height value.
    • setPrefWidth

      public ViewAnim setPrefWidth(double aVal)
      Sets the PrefWidth value.
    • setPrefHeight

      public ViewAnim setPrefHeight(double aVal)
      Sets the PrefHeight value.
    • setPrefSize

      public ViewAnim setPrefSize(double aW, double aH)
      Sets preferred size values.
    • setTransX

      public ViewAnim setTransX(double aVal)
      Sets the TransX value.
    • setTransY

      public ViewAnim setTransY(double aVal)
      Sets the TransY value.
    • setRotate

      public ViewAnim setRotate(double aVal)
      Sets the Rotate value.
    • setScale

      public ViewAnim setScale(double aVal)
      Sets the Scale X/Y values.
    • setScaleX

      public ViewAnim setScaleX(double aVal)
      Sets the ScaleX value.
    • setScaleY

      public ViewAnim setScaleY(double aVal)
      Sets the ScaleY value.
    • setFill

      public ViewAnim setFill(Paint aVal)
      Sets the Fill value.
    • setOpacity

      public ViewAnim setOpacity(double aVal)
      Sets the Opacity value.
    • setValue

      public ViewAnim setValue(String aKey, Object aValue)
      Returns the end value for given key.
    • setValue

      public ViewAnim setValue(String aKey, Object aVal0, Object aVal1)
      Returns the end value for given key.
    • findStartValue

      protected Object findStartValue(String aKey, Object aVal)
      Returns the start value for given end value by searching parents or asking view.
    • setLoops

      public ViewAnim setLoops()
      Sets the loop count.
    • getLoopCount

      public int getLoopCount()
      Returns the LoopCount.
    • setLoopCount

      public ViewAnim setLoopCount(int aValue)
      Sets the loop count.
    • getOnFrame

      public Runnable getOnFrame()
      Returns the runnable to be called on each frame.
    • setOnFrame

      public ViewAnim setOnFrame(Runnable aRun)
      Sets the runnable to be called on each frame.
    • getOnFinish

      public Runnable getOnFinish()
      Returns the function to be called when anim is finished.
    • setOnFinish

      public ViewAnim setOnFinish(Runnable aRun)
      Sets a function to be called when anim is finished.
    • needsFinish

      public ViewAnim needsFinish()
      Sets anim to finish when cleared.
    • startFast

      public ViewAnim startFast()
      Sets whether animation should start fast.
    • setLinear

      public ViewAnim setLinear()
      Sets animation to run with linear interpolator.
    • setInterpolator

      public ViewAnim setInterpolator(Interpolator anInterp)
      Sets whether to ease animation in
    • clear

      public ViewAnim clear()
      Clears the anim.
    • finish

      public ViewAnim finish()
      Finishes the anim.
    • startAutoRegisterChanges

      public void startAutoRegisterChanges(String... theProps)
      Watches given View for changes and registers animation.
    • stopAutoRegisterChanges

      public void stopAutoRegisterChanges()
      Stops watching and register changes.
    • autoRegisterPropChange

      public void autoRegisterPropChange(PropChange aPC)
      Register anim for changes.
    • getKeyFrameTimes

      public Integer[] getKeyFrameTimes()
      Returns the key frame times.
    • setAnimString

      public ViewAnim setAnimString(String animString)
      Configures this anim from given JSON/CSS style string, e.g.: "time: 300; scale: 2; time: 600; scale: 1; time: 1200; rotate: 360"
    • setProps

      public ViewAnim setProps(Object... propItems)
      Sets props from items which can be times, keys, values.
    • toString

      public String toString()
      Standard toString implementation.
      Overrides:
      toString in class Object
    • toXML

      public XMLElement toXML(XMLArchiver anArchiver)
      XML archival.
      Specified by:
      toXML in interface XMLArchiver.Archivable
    • toXMLAnim

      protected static void toXMLAnim(ViewAnim theAnim, XMLElement aXML)
      XML archival.
    • fromXML

      public ViewAnim fromXML(XMLArchiver anArchiver, XMLElement anElement)
      XML unarchival.
      Specified by:
      fromXML in interface XMLArchiver.Archivable
    • fromXMLLegacy

      public void fromXMLLegacy(XMLElement anElement)
      XML unarchival.
    • playDeep

      public static void playDeep(View aView)
      Play animations deep.
    • stopDeep

      public static void stopDeep(View aView)
      Stop animations deep.
    • getTimeDeep

      public static int getTimeDeep(View aView)
      Returns the anim time.
    • setTimeDeep

      public static void setTimeDeep(View aView, int aValue)
      Sets the anim time deep.