Class AnimateTransformElement
- All Implemented Interfaces:
Serializable
<animateTransform> element.
The <animateTransform> element animates a transformation attribute
on a target element, allowing for animated translations, rotations, scaling, and skewing.
To use, create an AnimateTransformElement and append it as a child of the element you want to animate.
Example - Rotating animation:
GElement arrow = new GElement();
arrow.add(new PathElement().d("M0,-40 L5,0 L-5,0 Z"));
arrow.appendChild(new AnimateTransformElement()
.rotateFromTo(0, 360, 50, 50) // rotate around center (50,50)
.dur(Duration.ofSeconds(2))
.repeatIndefinitely());
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTransform types that can be animated.Nested classes/interfaces inherited from class AnimateElement
AnimateElement.Accumulate, AnimateElement.Additive, AnimateElement.CalcMode, AnimateElement.FillMode, AnimateElement.RestartNested 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.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.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.rotateFromTo(double fromAngle, double toAngle) Sets up a rotation animation from one angle to another, rotating around the origin.rotateFromTo(double fromAngle, double toAngle, double cx, double cy) Sets up a rotation animation from one angle to another, rotating around a specified center.rotateValues(String... angles) Sets up a rotation animation through multiple angles, rotating around a specified center.scaleFromTo(double fromScale, double toScale) Sets up a uniform scale animation.scaleFromTo(double fromSx, double fromSy, double toSx, double toSy) Sets up a non-uniform scale animation.to(double to) Sets the ending value for the animation (numeric).Sets the ending value for the animation.translateFromTo(double fromX, double fromY, double toX, double toY) Sets up a translation animation.Sets the type of transformation to animate.values(double... values) Sets multiple values for keyframe animation.Sets multiple values for keyframe animation.Methods inherited from class AnimateElement
attributeName, max, minMethods 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
-
AnimateTransformElement
public AnimateTransformElement()
-
-
Method Details
-
type
Sets the type of transformation to animate.- Parameters:
type- the transform type- Returns:
- this element for method chaining
-
from
Description copied from class:AnimateElementSets the starting value for the animation.- Overrides:
fromin classAnimateElement- Parameters:
from- the starting value- Returns:
- this element for method chaining
-
from
Description copied from class:AnimateElementSets the starting value for the animation (numeric).- Overrides:
fromin classAnimateElement- Parameters:
from- the starting value- Returns:
- this element for method chaining
-
to
Description copied from class:AnimateElementSets the ending value for the animation.- Overrides:
toin classAnimateElement- Parameters:
to- the ending value- Returns:
- this element for method chaining
-
to
Description copied from class:AnimateElementSets the ending value for the animation (numeric).- Overrides:
toin classAnimateElement- Parameters:
to- the ending value- Returns:
- this element for method chaining
-
by
Description copied from class:AnimateElementSets the change in value for relative animations.- Overrides:
byin classAnimateElement- Parameters:
by- the value change- Returns:
- this element for method chaining
-
by
Description copied from class:AnimateElementSets the change in value for relative animations (numeric).- Overrides:
byin classAnimateElement- Parameters:
by- the value change- Returns:
- this element for method chaining
-
values
Description copied from class:AnimateElementSets multiple values for keyframe animation.The values are semicolon-separated.
- Overrides:
valuesin classAnimateElement- Parameters:
values- the keyframe values (e.g., "0;50;100;50;0")- Returns:
- this element for method chaining
-
values
Description copied from class:AnimateElementSets multiple values for keyframe animation.- Overrides:
valuesin classAnimateElement- Parameters:
values- the keyframe values- Returns:
- this element for method chaining
-
dur
Description copied from class:AnimateElementSets the duration of the animation.- Overrides:
durin classAnimateElement- Parameters:
dur- the duration (e.g., "1s", "500ms", "indefinite")- Returns:
- this element for method chaining
-
dur
Description copied from class:AnimateElementSets the duration of the animation using a Duration object.The duration is converted to milliseconds for SVG.
- Overrides:
durin classAnimateElement- Parameters:
dur- the duration- Returns:
- this element for method chaining
-
begin
Description copied from class:AnimateElementSets the begin time for the animation.- Overrides:
beginin classAnimateElement- Parameters:
begin- the begin time (e.g., "0s", "2s", "click", "mouseenter")- Returns:
- this element for method chaining
-
end
Description copied from class:AnimateElementSets the end time for the animation.- Overrides:
endin classAnimateElement- Parameters:
end- the end time- Returns:
- this element for method chaining
-
repeatCount
Description copied from class:AnimateElementSets the repeat count for the animation.- Overrides:
repeatCountin classAnimateElement- Parameters:
repeatCount- the number of repeats or "indefinite"- Returns:
- this element for method chaining
-
repeatCount
Description copied from class:AnimateElementSets the repeat count for the animation.- Overrides:
repeatCountin classAnimateElement- Parameters:
repeatCount- the number of repeats- Returns:
- this element for method chaining
-
repeatIndefinitely
Description copied from class:AnimateElementSets the animation to repeat indefinitely.- Overrides:
repeatIndefinitelyin classAnimateElement- Returns:
- this element for method chaining
-
repeatDur
Description copied from class:AnimateElementSets the repeat duration for the animation.- Overrides:
repeatDurin classAnimateElement- Parameters:
repeatDur- the repeat duration (e.g., "10s", "indefinite")- Returns:
- this element for method chaining
-
fill
Description copied from class:AnimateElementSets what happens after the animation ends.- Overrides:
fillin classAnimateElement- Parameters:
fill- the fill mode (REMOVE or FREEZE)- Returns:
- this element for method chaining
-
freeze
Description copied from class:AnimateElementSets the animation to freeze at the end value after completion.- Overrides:
freezein classAnimateElement- Returns:
- this element for method chaining
-
calcMode
Description copied from class:AnimateElementSets the calculation mode for interpolation.- Overrides:
calcModein classAnimateElement- Parameters:
calcMode- the calculation mode- Returns:
- this element for method chaining
-
keyTimes
Description copied from class:AnimateElementSets 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.
- Overrides:
keyTimesin classAnimateElement- Parameters:
keyTimes- the key times (e.g., "0;0.25;0.5;0.75;1")- Returns:
- this element for method chaining
-
keyTimes
Description copied from class:AnimateElementSets the key times for keyframe animations.- Overrides:
keyTimesin classAnimateElement- Parameters:
keyTimes- the key times (values between 0 and 1)- Returns:
- this element for method chaining
-
keySplines
Description copied from class:AnimateElementSets 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.
- Overrides:
keySplinesin classAnimateElement- 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
Description copied from class:AnimateElementSets 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
- Overrides:
keySplinesin classAnimateElement- 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
Description copied from class:AnimateElementSets 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.
- Overrides:
easeInOutin classAnimateElement- Returns:
- this element for method chaining
-
easeOut
Description copied from class:AnimateElementSets 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).
- Overrides:
easeOutin classAnimateElement- Returns:
- this element for method chaining
-
easeIn
Description copied from class:AnimateElementSets 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).
- Overrides:
easeInin classAnimateElement- Returns:
- this element for method chaining
-
additive
Description copied from class:AnimateElementSets how the animation combines with the base value.- Overrides:
additivein classAnimateElement- Parameters:
additive- the additive mode- Returns:
- this element for method chaining
-
accumulate
Description copied from class:AnimateElementSets how repeated animations accumulate.- Overrides:
accumulatein classAnimateElement- Parameters:
accumulate- the accumulate mode- Returns:
- this element for method chaining
-
restart
Description copied from class:AnimateElementSets the restart behavior for the animation.- Overrides:
restartin classAnimateElement- Parameters:
restart- the restart mode- Returns:
- this element for method chaining
-
beginElement
Description copied from class:AnimateElementStarts 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.
- Overrides:
beginElementin classAnimateElement- Returns:
- this element for method chaining
-
endElement
Description copied from class:AnimateElementEnds the animation.Causes the animation to end immediately, as if the end time had been reached.
- Overrides:
endElementin classAnimateElement- Returns:
- this element for method chaining
-
rotateFromTo
Sets up a rotation animation from one angle to another, rotating around the origin.- Parameters:
fromAngle- the starting angle in degreestoAngle- the ending angle in degrees- Returns:
- this element for method chaining
-
rotateFromTo
Sets up a rotation animation from one angle to another, rotating around a specified center.- Parameters:
fromAngle- the starting angle in degreestoAngle- the ending angle in degreescx- the x coordinate of the rotation centercy- the y coordinate of the rotation center- Returns:
- this element for method chaining
-
rotateValues
Sets up a rotation animation through multiple angles, rotating around a specified center.This is useful for animating to a new angle when the starting angle might differ. The values should include the rotation center coordinates.
- Parameters:
angles- the angles to animate through (each as "angle cx cy")- Returns:
- this element for method chaining
-
translateFromTo
Sets up a translation animation.- Parameters:
fromX- starting X positionfromY- starting Y positiontoX- ending X positiontoY- ending Y position- Returns:
- this element for method chaining
-
scaleFromTo
Sets up a uniform scale animation.- Parameters:
fromScale- starting scale factortoScale- ending scale factor- Returns:
- this element for method chaining
-
scaleFromTo
Sets up a non-uniform scale animation.- Parameters:
fromSx- starting X scalefromSy- starting Y scaletoSx- ending X scaletoSy- ending Y scale- Returns:
- this element for method chaining
-