Package snap.view
Class ViewAnim
java.lang.Object
snap.view.ViewAnim
- All Implemented Interfaces:
XMLArchiver.Archivable
A class to animate View attributes.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Register anim for changes.clear()
Clears the anim.protected Object
findStartValue
(String aKey, Object aVal) Returns the start value for given end value by searching parents or asking view.finish()
Finishes the anim.fromXML
(XMLArchiver anArchiver, XMLElement anElement) XML unarchival.void
fromXMLLegacy
(XMLElement anElement) XML unarchival.getAnim
(int aTime) Returns the anim for the given start/end.getAnims()
Returns the list of child anims.int
getEnd()
Returns the end value.Returns the end value for given key.int
Returns the length of the frame in milliseconds.Integer[]
Returns the key frame times.getKeys()
Returns the keys.int
Returns the LoopCount.int
Returns the max time.Returns the function to be called when anim is finished.Returns the runnable to be called on each frame.Returns the parent ViewAnim.getRoot()
Returns the root ViewAnim.getRoot
(int aTime) Returns the root ViewAnim.int
getStart()
Returns the start value.getStartValue
(String aKey) Returns the start value for given key.int
getTime()
Returns the current time.static int
getTimeDeep
(View aView) Returns the anim time.protected Object
getValueForKeyAndTime
(String aKey, int aTime) Returns the value for given key and time.getView()
Returns the View.interpolateValuesForRatio
(Object aVal1, Object aVal2, double aRatio) Returns the interpolated value.boolean
isEmpty()
Returns whether anim is empty/cleared.boolean
Returns whether anim is playing.boolean
isRoot()
Returns whether this ViewAnim is the root one.boolean
Returns whether anim should be playing, but didn't have access to ViewUpdater (probably wasn't showing).Sets anim to finish when cleared.void
play()
Play the anim.static void
Play animations deep.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"Sets the Fill value.setHeight
(double aVal) Sets the Height value.setInterpolator
(Interpolator anInterp) Sets whether to ease animation inSets animation to run with linear interpolator.setLoopCount
(int aValue) Sets the loop count.setLoops()
Sets the loop count.setOnFinish
(Runnable aRun) Sets a function to be called when anim is finished.setOnFrame
(Runnable aRun) Sets the runnable to be called on each frame.setOpacity
(double aVal) Sets the Opacity value.setPrefHeight
(double aVal) Sets the PrefHeight value.setPrefSize
(double aW, double aH) Sets preferred size values.setPrefWidth
(double aVal) Sets the PrefWidth value.Sets props from items which can be times, keys, values.setRotate
(double aVal) Sets the Rotate value.setScale
(double aVal) Sets the Scale X/Y values.setScaleX
(double aVal) Sets the ScaleX value.setScaleY
(double aVal) Sets the ScaleY value.void
setStartValue
(String aKey, Object aVal) Sets the start value for given key.void
setTime
(int aTime) Sets the current time.static void
setTimeDeep
(View aView, int aValue) Sets the anim time deep.setTransX
(double aVal) Sets the TransX value.setTransY
(double aVal) Sets the TransY value.Returns the end value for given key.Returns the end value for given key.setWidth
(double aVal) Sets the Width value.setX
(double aVal) Sets the X value.setY
(double aVal) Sets the Y value.void
startAutoRegisterChanges
(String... theProps) Watches given View for changes and registers animation.Sets whether animation should start fast.void
stop()
Stop the anim.void
Stops watching and register changes.static void
Stop animations deep.protected void
suspend()
Suspends the anim.toString()
Standard toString implementation.toXML
(XMLArchiver anArchiver) XML archival.protected static void
toXMLAnim
(ViewAnim theAnim, XMLElement aXML) XML archival.protected void
Updates values for current time.
-
Field Details
-
_startTime
protected int _startTime
-
-
Constructor Details
-
ViewAnim
Constructor. -
ViewAnim
Constructor.
-
-
Method Details
-
getView
Returns the View. -
isRoot
public boolean isRoot()Returns whether this ViewAnim is the root one. -
getRoot
Returns the root ViewAnim. -
getRoot
Returns the root 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
Returns the keys. -
getStartValue
Returns the start value for given key. -
setStartValue
Sets the start value for given key. -
getEndVal
Returns the end value for given key. -
getAnims
Returns the list of child anims. -
getAnim
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
Returns the value for given key and time. -
interpolateValuesForRatio
Returns the interpolated value. -
setX
Sets the X value. -
setY
Sets the Y value. -
setWidth
Sets the Width value. -
setHeight
Sets the Height value. -
setPrefWidth
Sets the PrefWidth value. -
setPrefHeight
Sets the PrefHeight value. -
setPrefSize
Sets preferred size values. -
setTransX
Sets the TransX value. -
setTransY
Sets the TransY value. -
setRotate
Sets the Rotate value. -
setScale
Sets the Scale X/Y values. -
setScaleX
Sets the ScaleX value. -
setScaleY
Sets the ScaleY value. -
setFill
Sets the Fill value. -
setOpacity
Sets the Opacity value. -
setValue
Returns the end value for given key. -
setValue
Returns the end value for given key. -
findStartValue
Returns the start value for given end value by searching parents or asking view. -
setLoops
Sets the loop count. -
getLoopCount
public int getLoopCount()Returns the LoopCount. -
setLoopCount
Sets the loop count. -
getOnFrame
Returns the runnable to be called on each frame. -
setOnFrame
Sets the runnable to be called on each frame. -
getOnFinish
Returns the function to be called when anim is finished. -
setOnFinish
Sets a function to be called when anim is finished. -
needsFinish
Sets anim to finish when cleared. -
startFast
Sets whether animation should start fast. -
setLinear
Sets animation to run with linear interpolator. -
setInterpolator
Sets whether to ease animation in -
clear
Clears the anim. -
finish
Finishes the anim. -
startAutoRegisterChanges
Watches given View for changes and registers animation. -
stopAutoRegisterChanges
public void stopAutoRegisterChanges()Stops watching and register changes. -
autoRegisterPropChange
Register anim for changes. -
getKeyFrameTimes
Returns the key frame times. -
setAnimString
Configures this anim from given JSON/CSS style string, e.g.: "time: 300; scale: 2; time: 600; scale: 1; time: 1200; rotate: 360" -
setProps
Sets props from items which can be times, keys, values. -
toString
Standard toString implementation. -
toXML
XML archival.- Specified by:
toXML
in interfaceXMLArchiver.Archivable
-
toXMLAnim
XML archival. -
fromXML
XML unarchival.- Specified by:
fromXML
in interfaceXMLArchiver.Archivable
-
fromXMLLegacy
XML unarchival. -
playDeep
Play animations deep. -
stopDeep
Stop animations deep. -
getTimeDeep
Returns the anim time. -
setTimeDeep
Sets the anim time deep.
-