Class AnimateElement
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AnimateTransformElement
<animate> element.
The <animate> element provides a way to animate an attribute of an element over time.
It is part of SVG's SMIL (Synchronized Multimedia Integration Language) animation support.
To use, create an AnimateElement and append it as a child of the element you want to animate.
Example:
CircleElement circle = new CircleElement().cx(50).cy(50).r(20);
circle.appendChild(new AnimateElement()
.attributeName("r")
.from(20)
.to(40)
.dur("1s")
.repeatCount("indefinite"));
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAccumulate mode options for repeated animations.static enumAdditive mode options for how the animation combines with the base value.static enumCalc mode options for animation interpolation.static enumFill mode options for what happens after the animation ends.static enumRestart behavior options for animations.Nested classes/interfaces inherited from class SvgElement
SvgElement.PreserveAspectRatio -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccumulate(AnimateElement.Accumulate accumulate) Sets how repeated animations accumulate.additive(AnimateElement.Additive additive) Sets how the animation combines with the base value.attributeName(String attributeName) Sets the name of the attribute to animate.Sets the begin time for the animation.Starts the animation.by(double by) Sets the change in value for relative animations (numeric).Sets the change in value for relative animations.calcMode(AnimateElement.CalcMode calcMode) Sets the calculation mode for interpolation.Sets the duration of the animation.Sets the duration of the animation using a Duration object.easeIn()Sets up ease-in spline interpolation for smooth acceleration.Sets up ease-in-out spline interpolation for smooth animations.easeOut()Sets up ease-out spline interpolation for smooth deceleration.Sets the end time for the animation.Ends the animation.fill(AnimateElement.FillMode fill) Sets what happens after the animation ends.freeze()Sets the animation to freeze at the end value after completion.from(double from) Sets the starting value for the animation (numeric).Sets the starting value for the animation.keySplines(double x1, double y1, double x2, double y2) Sets the bezier control points for spline interpolation (single spline).keySplines(String keySplines) Sets the bezier control points for spline interpolation.keyTimes(double... keyTimes) Sets the key times for keyframe animations.Sets the key times for keyframe animations.Sets the maximum duration for the animation.Sets the minimum duration for the animation.repeatCount(int repeatCount) Sets the repeat count for the animation.repeatCount(String repeatCount) Sets the repeat count for the animation.Sets the repeat duration for the animation.Sets the animation to repeat indefinitely.restart(AnimateElement.Restart restart) Sets the restart behavior for the animation.to(double to) Sets the ending value for the animation (numeric).Sets the ending value for the animation.values(double... values) Sets multiple values for keyframe animation.Sets multiple values for keyframe animation.Methods inherited from class SvgElement
emptySvgRoot, flushPendingAttributes, getOuterHTML, getPendingOrAttribute, getStyle, height, height, id, preserveAspectRatio, preserveAspectRatio, scheduleBeforeClientResponse, setAttribute, setWriteOnlyAttribute, size, size, viewBox, width, widthMethods inherited from class com.vaadin.flow.dom.Element
addAttachListener, addDetachListener, addEventListener, addPropertyChangeListener, addPropertyChangeListener, as, attachShadow, bindAttribute, bindProperty, bindText, callJsFunction, callJsFunction, createText, executeJs, executeJs, get, get, getAttribute, getAttributeNames, getChild, getChildCount, getChildren, getClassList, getComponent, getParent, getProperty, getProperty, getProperty, getProperty, getProperty, getPropertyBean, getPropertyBean, getPropertyNames, getPropertyRaw, getSelf, getShadowRoot, getTag, getText, getTextRecursively, getThemeList, hasAttribute, hasProperty, isEnabled, isTextNode, isVisible, removeAttribute, removeFromParent, removeFromTree, removeFromTree, removeProperty, scrollIntoView, scrollIntoView, setAttribute, setAttribute, setAttribute, setEnabled, setProperty, setProperty, setProperty, setPropertyBean, setPropertyJson, setPropertyList, setPropertyMap, setText, setVisible, toStringMethods inherited from class com.vaadin.flow.dom.Node
accept, appendChild, appendChild, appendVirtualChild, appendVirtualChild, ensureChildHasParent, equals, getNode, getParentNode, getStateProvider, hashCode, indexOfChild, insertChild, insertChild, isVirtualChild, removeAllChildren, removeChild, removeChild, removeChild, removeVirtualChild, removeVirtualChild, setChild
-
Constructor Details
-
AnimateElement
public AnimateElement() -
AnimateElement
-
-
Method Details
-
attributeName
Sets the name of the attribute to animate.- Parameters:
attributeName- the attribute name (e.g., "cx", "fill", "opacity")- Returns:
- this element for method chaining
-
from
Sets the starting value for the animation.- Parameters:
from- the starting value- Returns:
- this element for method chaining
-
from
Sets the starting value for the animation (numeric).- Parameters:
from- the starting value- Returns:
- this element for method chaining
-
to
Sets the ending value for the animation.- Parameters:
to- the ending value- Returns:
- this element for method chaining
-
to
Sets the ending value for the animation (numeric).- Parameters:
to- the ending value- Returns:
- this element for method chaining
-
by
Sets the change in value for relative animations.- Parameters:
by- the value change- Returns:
- this element for method chaining
-
by
Sets the change in value for relative animations (numeric).- Parameters:
by- the value change- Returns:
- this element for method chaining
-
values
Sets multiple values for keyframe animation.The values are semicolon-separated.
- Parameters:
values- the keyframe values (e.g., "0;50;100;50;0")- Returns:
- this element for method chaining
-
values
Sets multiple values for keyframe animation.- Parameters:
values- the keyframe values- Returns:
- this element for method chaining
-
dur
Sets the duration of the animation.- Parameters:
dur- the duration (e.g., "1s", "500ms", "indefinite")- Returns:
- this element for method chaining
-
dur
Sets the duration of the animation using a Duration object.The duration is converted to milliseconds for SVG.
- Parameters:
dur- the duration- Returns:
- this element for method chaining
-
begin
Sets the begin time for the animation.- Parameters:
begin- the begin time (e.g., "0s", "2s", "click", "mouseenter")- Returns:
- this element for method chaining
-
end
Sets the end time for the animation.- Parameters:
end- the end time- Returns:
- this element for method chaining
-
min
Sets the minimum duration for the animation.- Parameters:
min- the minimum duration- Returns:
- this element for method chaining
-
max
Sets the maximum duration for the animation.- Parameters:
max- the maximum duration- Returns:
- this element for method chaining
-
repeatCount
Sets the repeat count for the animation.- Parameters:
repeatCount- the number of repeats or "indefinite"- Returns:
- this element for method chaining
-
repeatCount
Sets the repeat count for the animation.- Parameters:
repeatCount- the number of repeats- Returns:
- this element for method chaining
-
repeatIndefinitely
Sets the animation to repeat indefinitely.- Returns:
- this element for method chaining
-
repeatDur
Sets the repeat duration for the animation.- Parameters:
repeatDur- the repeat duration (e.g., "10s", "indefinite")- Returns:
- this element for method chaining
-
fill
Sets what happens after the animation ends.- Parameters:
fill- the fill mode (REMOVE or FREEZE)- Returns:
- this element for method chaining
-
freeze
Sets the animation to freeze at the end value after completion.- Returns:
- this element for method chaining
-
calcMode
Sets the calculation mode for interpolation.- Parameters:
calcMode- the calculation mode- Returns:
- this element for method chaining
-
keyTimes
Sets the key times for keyframe animations.Values should be between 0 and 1, semicolon-separated. The number of key times must match the number of values.
- Parameters:
keyTimes- the key times (e.g., "0;0.25;0.5;0.75;1")- Returns:
- this element for method chaining
-
keyTimes
Sets the key times for keyframe animations.- Parameters:
keyTimes- the key times (values between 0 and 1)- Returns:
- this element for method chaining
-
keySplines
Sets the bezier control points for spline interpolation.Each set of control points is four numbers (x1 y1 x2 y2) for a cubic bezier. Sets are separated by semicolons. Number of sets = number of values - 1.
- Parameters:
keySplines- the key splines (e.g., "0.5 0 0.5 1; 0.5 0 0.5 1")- Returns:
- this element for method chaining
-
keySplines
Sets the bezier control points for spline interpolation (single spline).The four values define a cubic bezier curve: (x1, y1) is the first control point and (x2, y2) is the second control point. Values should be between 0 and 1.
Common easing curves:
- Ease: 0.25, 0.1, 0.25, 1.0
- Ease-in: 0.42, 0, 1.0, 1.0
- Ease-out: 0, 0, 0.58, 1.0
- Ease-in-out: 0.42, 0, 0.58, 1.0
- Parameters:
x1- x coordinate of first control point (0-1)y1- y coordinate of first control point (0-1)x2- x coordinate of second control point (0-1)y2- y coordinate of second control point (0-1)- Returns:
- this element for method chaining
-
easeInOut
Sets up ease-in-out spline interpolation for smooth animations.This is a convenience method that sets calcMode to SPLINE and applies an ease-in-out bezier curve.
- Returns:
- this element for method chaining
-
easeOut
Sets up ease-out spline interpolation for smooth deceleration.This is a convenience method that sets calcMode to SPLINE and applies an ease-out bezier curve (starts fast, ends slow).
- Returns:
- this element for method chaining
-
easeIn
Sets up ease-in spline interpolation for smooth acceleration.This is a convenience method that sets calcMode to SPLINE and applies an ease-in bezier curve (starts slow, ends fast).
- Returns:
- this element for method chaining
-
additive
Sets how the animation combines with the base value.- Parameters:
additive- the additive mode- Returns:
- this element for method chaining
-
accumulate
Sets how repeated animations accumulate.- Parameters:
accumulate- the accumulate mode- Returns:
- this element for method chaining
-
restart
Sets the restart behavior for the animation.- Parameters:
restart- the restart mode- Returns:
- this element for method chaining
-
beginElement
Starts the animation.This is particularly useful for dynamically added animations, which don't auto-start in browsers. Call this method after appending the animation element to its target element.
- Returns:
- this element for method chaining
-
endElement
Ends the animation.Causes the animation to end immediately, as if the end time had been reached.
- Returns:
- this element for method chaining
-