Class SpringAnimation
- All Implemented Interfaces:
Proxy
Animation.
AdwSpringAnimation implements an animation driven by a physical model of a
spring described by SpringParams, with a resting position in
SpringAnimation:value-to, stretched to
SpringAnimation:value-from.
Since the animation is physically simulated, spring animations don't have a
fixed duration. The animation will stop when the simulated spring comes to a
rest - when the amplitude of the oscillations becomes smaller than
SpringAnimation:epsilon, or immediately when it reaches
SpringAnimation:value-to if
SpringAnimation:clamp is set to TRUE. The estimated duration can
be obtained with SpringAnimation:estimated-duration.
Due to the nature of spring-driven motion the animation can overshoot
SpringAnimation:value-to before coming to a rest. Whether the
animation will overshoot or not depends on the damping ratio of the spring.
See SpringParams for more information about specific damping ratio
values.
If SpringAnimation:clamp is TRUE, the animation will abruptly
end as soon as it reaches the final value, preventing overshooting.
Animations can have an initial velocity value, set via
SpringAnimation:initial-velocity, which adjusts the curve without
changing the duration. This makes spring animations useful for deceleration
at the end of gestures.
If the initial and final values are equal, and the initial velocity is not 0, the animation value will bounce and return to its resting position.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSpringAnimation.Builder<B extends SpringAnimation.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.gnome.adw.Animation
Animation.Animation$Impl, Animation.AnimationClass, Animation.DoneCallbackNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new SpringAnimation.SpringAnimation(MemorySegment address) Create a SpringAnimation proxy instance for the provided memory address.SpringAnimation(Widget widget, double from, double to, SpringParams springParams, AnimationTarget target) Creates a newAdwSpringAnimationonwidget. -
Method Summary
Modifier and TypeMethodDescriptionprotected SpringAnimationasParent()Returns this instance as if it were its parent type.static SpringAnimation.Builder<? extends SpringAnimation.Builder> builder()ASpringAnimation.Builderobject constructs aSpringAnimationwith the specified properties.doublecalculateValue(int time) Calculates the value this SpringAnimation will have attime.doublecalculateVelocity(int time) Calculates the velocity this SpringAnimation will have attime.booleangetClamp()Gets whether this SpringAnimation should be clamped.doubleGets the precision of the spring.intGets the estimated duration ofself,in milliseconds.doubleGets the initial velocity ofself.Gets the physical parameters of the spring ofself.static @Nullable TypegetType()Get the GType of the SpringAnimation classdoubleGets the value this SpringAnimation will animate from.doubleGets the value this SpringAnimation will animate to.doubleGets the current velocity ofself.voidsetClamp(boolean clamp) Sets whether this SpringAnimation should be clamped.voidsetEpsilon(double epsilon) Sets the precision of the spring.voidsetInitialVelocity(double velocity) Sets the initial velocity ofself.voidsetSpringParams(SpringParams springParams) Sets the physical parameters of the spring ofself.voidsetValueFrom(double value) Sets the value this SpringAnimation will animate from.voidsetValueTo(double value) Sets the value this SpringAnimation will animate to.Methods inherited from class org.gnome.adw.Animation
emitDone, getFollowEnableAnimationsSetting, getMemoryLayout, getState, getTarget, getValue, getWidget, onDone, pause, play, reset, resume, setFollowEnableAnimationsSetting, setTarget, skipMethods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
SpringAnimation
Create a SpringAnimation proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
SpringAnimation
public SpringAnimation(Widget widget, double from, double to, SpringParams springParams, AnimationTarget target) Creates a newAdwSpringAnimationonwidget.The animation will animate
targetfromfromtotowith the dynamics of a spring described byspringParams.- Parameters:
widget- a widget to create animation onfrom- a value to animate fromto- a value to animate tospringParams- physical parameters of the springtarget- a target value to animate
-
SpringAnimation
public SpringAnimation()Creates a new SpringAnimation.
-
-
Method Details
-
getType
Get the GType of the SpringAnimation class- Returns:
- the GType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
calculateValue
public double calculateValue(int time) Calculates the value this SpringAnimation will have attime.The time starts at 0 and ends at
SpringAnimation:estimated_duration.See also
calculateVelocity(int).- Parameters:
time- elapsed time, in milliseconds- Returns:
- the value at
time - Since:
- 1.3
-
calculateVelocity
public double calculateVelocity(int time) Calculates the velocity this SpringAnimation will have attime.The time starts at 0 and ends at
SpringAnimation:estimated_duration.See also
calculateValue(int).- Parameters:
time- elapsed time, in milliseconds- Returns:
- the velocity at
time - Since:
- 1.3
-
getClamp
public boolean getClamp()Gets whether this SpringAnimation should be clamped.- Returns:
- whether this SpringAnimation is clamped
-
getEpsilon
public double getEpsilon()Gets the precision of the spring.- Returns:
- the epsilon value
-
getEstimatedDuration
public int getEstimatedDuration()Gets the estimated duration ofself,in milliseconds.Can be
DURATION_INFINITEif the spring damping is set to 0.- Returns:
- the estimated duration
-
getInitialVelocity
public double getInitialVelocity()Gets the initial velocity ofself.- Returns:
- the initial velocity
-
getSpringParams
Gets the physical parameters of the spring ofself.- Returns:
- the spring parameters
-
getValueFrom
public double getValueFrom()Gets the value this SpringAnimation will animate from.- Returns:
- the value to animate from
-
getValueTo
public double getValueTo()Gets the value this SpringAnimation will animate to.- Returns:
- the value to animate to
-
getVelocity
public double getVelocity()Gets the current velocity ofself.- Returns:
- the current velocity
-
setClamp
public void setClamp(boolean clamp) Sets whether this SpringAnimation should be clamped.If set to
TRUE, the animation will abruptly end as soon as it reaches the final value, preventing overshooting.It won't prevent overshooting
SpringAnimation:value-fromif a relative negativeSpringAnimation:initial-velocityis set.- Parameters:
clamp- the new value
-
setEpsilon
public void setEpsilon(double epsilon) Sets the precision of the spring.The level of precision used to determine when the animation has come to a rest, that is, when the amplitude of the oscillations becomes smaller than this value.
If the epsilon value is too small, the animation will take a long time to stop after the animated value has stopped visibly changing.
If the epsilon value is too large, the animation will end prematurely.
The default value is 0.001.
- Parameters:
epsilon- the new value
-
setInitialVelocity
public void setInitialVelocity(double velocity) Sets the initial velocity ofself.Initial velocity affects only the animation curve, but not its duration.
- Parameters:
velocity- the initial velocity
-
setSpringParams
Sets the physical parameters of the spring ofself.- Parameters:
springParams- the new spring parameters
-
setValueFrom
public void setValueFrom(double value) Sets the value this SpringAnimation will animate from.The animation will start at this value and end at
SpringAnimation:value-to.- Parameters:
value- the value to animate from
-
setValueTo
public void setValueTo(double value) Sets the value this SpringAnimation will animate to.The animation will start at
SpringAnimation:value-fromand end at this value.- Parameters:
value- the value to animate to
-
builder
ASpringAnimation.Builderobject constructs aSpringAnimationwith the specified properties. Use the variousset...()methods to set properties, and finish construction withSpringAnimation.Builder.build().- Returns:
- the builder object
-