public interface IAnimation
Animator
.
Instances of classes implementing this interface change their state according to a relative animation time. The animation time is a double between 0 for the start of the animation and 1 for the end of the animation.
initialize()
.animate(double)
, usually with an increasing relative time parameter.
cleanup()
once.animate(double)
uses a relative time scheme, there might be an absolute time value for the preferred
duration of the whole sequence of animation steps. Since an IAnimation instance has no control on the number of animate(double)
calls or the intervals between them, the preferred duration is only a hint on how long the animation should take.
Clients can ask for that hint using PreferredDuration
and try to find a suitable
sequence of animate(double)
calls in order to fulfill the preference.
Modifier and Type | Method and Description |
---|---|
void |
animate(double time)
Does the animation according to the relative animation time.
|
void |
cleanup()
Cleans up after an animation has finished.
|
static IAnimation |
createEasedAnimation(IAnimation animation)
Creates an eased animation for the given base animation.
|
static IAnimation |
createEasedAnimation(IAnimation animation,
double easeIn)
Creates an eased animation for the given base animation.
|
static IAnimation |
createEasedAnimation(IAnimation animation,
double easeIn,
double easeOut)
Creates an eased animation for the given base animation.
|
static IAnimation |
createEdgeSegmentAnimation(IGraph graph,
IEdge edge,
IPoint[] endBends,
PointD endSourceLocation,
PointD endTargetLocation,
Duration preferredDuration)
Creates a new
IAnimation that animates the given edge 's bends from its current shape linearly to the
shape given by the endBends and final port locations. |
static IAnimation |
createGraphAnimation(IGraph graph,
IMapper<INode,IRectangle> targetNodeLayouts,
IMapper<IEdge,IPoint[]> targetBendLocations,
IMapper<IPort,IPortLocationModelParameter> targetPortLocations,
IMapper<ILabel,ILabelModelParameter> targetLayoutParameters,
Duration preferredDuration)
Creates a new
IAnimation that animates the given layout of all types of graph items. |
static IAnimation |
createLabelAnimation(IGraph graph,
ILabel label,
ILabelModelParameter targetLayoutParameter,
Duration preferredDuration)
Creates a new
IAnimation that animates the given label from its current layout linearly to the layout
given by the targetLayoutParameter . |
static IAnimation |
createNodeAnimation(IGraph graph,
INode node,
IRectangle targetLayout,
Duration preferredDuration)
Creates a new
IAnimation that animates the given node from its current layout to the new given
targetLayout . |
static IAnimation |
createParallelAnimation(IAnimation... animations)
Creates an
IAnimation according to the composite design pattern that animates multiple animations in parallel. |
static IAnimation |
createParallelAnimation(IAnimation firstAnimation,
Iterable<IAnimation> otherAnimations)
Creates an
IAnimation according to the composite design pattern that animates multiple animations in parallel to
this animation. |
static IAnimation |
createParallelAnimation(IAnimation firstAnimation,
Iterable<IAnimation> otherAnimations,
boolean isSynchronized)
Creates an
IAnimation according to the composite design pattern that animates multiple animations in parallel to
this animation. |
static IAnimation |
createParallelAnimation(Iterable<IAnimation> animations)
Creates an
IAnimation according to the composite design pattern that animates multiple animations in parallel. |
static IAnimation |
createParallelAnimation(Iterable<IAnimation> animations,
boolean isSynchronized)
Creates an
IAnimation according to the composite design pattern that animates multiple animations in parallel. |
static IAnimation |
createPathAnimation(GeneralPath path,
IMutablePoint animationPoint,
Duration preferredDuration)
Creates a new instance of an
IAnimation that animates the given IMutablePoint along a path. |
static IAnimation |
createPortAnimation(IGraph graph,
IPort port,
IPortLocationModelParameter targetLocationParameter,
Duration preferredDuration)
Creates a new
IAnimation that animates the given port from its current location to the new location
given by the targetLocationParameter . |
static IAnimation |
createTableAnimation(ITable table,
double[] columnLayout,
double[] rowLayout)
Creates a new
IAnimation for the given table that animates the table and its
stripes . |
Duration |
getPreferredDuration()
Gets the preferred duration of the animation.
|
void |
initialize()
Initializes the animation.
|
void animate(double time)
The animation starts with the time 0 and ends with time 1.
time
- the animation time [0,1]void cleanup()
static IAnimation createEasedAnimation(IAnimation animation)
The animation speed linearly increases upto a easeIn
and linearly decreases from
easeOut
. Between those two points, the animation speed is constant.
The duration of the ease in and ease out is determined by a mapping [0,1] → [0,1]. The mapping has to be increasing to preserve the order of the frames in the decorated animation. In general, we consider continuously differentiable functions f where integral of f′ equals 1 a suitable choice for the mapping.
animation
- The decorated animation.static IAnimation createEasedAnimation(IAnimation animation, double easeIn)
The animation speed linearly increases upto a easeIn
and linearly decreases from
easeOut
. Between those two points, the animation speed is constant.
The duration of the ease in and ease out is determined by a mapping [0,1] → [0,1]. The mapping has to be increasing to preserve the order of the frames in the decorated animation. In general, we consider continuously differentiable functions f where integral of f′ equals 1 a suitable choice for the mapping.
animation
- The decorated animation.easeIn
- The ratio for the ease-in time [0,1] where 0 is the start of the animation and 1 the end. 0.5
is the default
value.static IAnimation createEasedAnimation(IAnimation animation, double easeIn, double easeOut)
The animation speed linearly increases upto a easeIn
and linearly decreases from
easeOut
. Between those two points, the animation speed is constant.
The duration of the ease in and ease out is determined by a mapping [0,1] → [0,1]. The mapping has to be increasing to preserve the order of the frames in the decorated animation. In general, we consider continuously differentiable functions f where integral of f′ equals 1 a suitable choice for the mapping.
animation
- The decorated animation.easeIn
- The ratio for the ease-in time [0,1] where 0 is the start of the animation and 1 the end. 0.5
is the default
value.easeOut
- The ratio for the ease-out time [0,1] where 0 is the start of the animation and 1 the end. 0.5
is the default
value.static IAnimation createEdgeSegmentAnimation(IGraph graph, IEdge edge, IPoint[] endBends, PointD endSourceLocation, PointD endTargetLocation, Duration preferredDuration)
IAnimation
that animates the given edge
's bends from its current shape linearly to the
shape given by the endBends
and final port locations.
The bends of the edge layout are animated from their current location to their target locations. It is assumed that the
edge style is a polyline style and the control points are the bends accordingly. The animation works for other styles
too, but the effect might not be as expected. The number of bends in endBends
can be different to the current
number of bends. This will result in the animation automatically removing bends at the end of the animation or inserting
new bends accordingly at the beginning of the animation.
The source and target points are also animated to new locations. However, the ports will not be moved by this animation.
Instead a separate animation for the ports
is needed to actually move IPort
s at the ends of the edge if desired.
graph
- The graph the animated edge belongs to.edge
- The edge layout to animate.endBends
- The bend positions after the animation.endSourceLocation
- The absolute position of the source port after the animation.endTargetLocation
- The absolute position of the target port after the animation.preferredDuration
- The preferred duration of the animation in milliseconds.static IAnimation createGraphAnimation(IGraph graph, IMapper<INode,IRectangle> targetNodeLayouts, IMapper<IEdge,IPoint[]> targetBendLocations, IMapper<IPort,IPortLocationModelParameter> targetPortLocations, IMapper<ILabel,ILabelModelParameter> targetLayoutParameters, Duration preferredDuration)
IAnimation
that animates the given layout of all types of graph items.graph
- The graph for which the layout should be animated.targetNodeLayouts
- The node layouts after the animation.targetBendLocations
- The bend locations after the animation, for each edge the points are interpreted as the position of the bends along the
edge in the given order.targetLayoutParameters
- The label model parameters for each label after the animation.targetPortLocations
- The IPortLocationModelParameter
s for each IPort
in the graph that will be morphed.preferredDuration
- The preferred duration of the animation in milliseconds.static IAnimation createLabelAnimation(IGraph graph, ILabel label, ILabelModelParameter targetLayoutParameter, Duration preferredDuration)
IAnimation
that animates the given label
from its current layout linearly to the layout
given by the targetLayoutParameter
.
This animation will as a side effect assign the targetLayoutParameter
to the label at the
end of the animation
.
graph
- The graph that contains the labels.label
- The label to animate the parameter of.targetLayoutParameter
- The target parameter of the label.preferredDuration
- The preferred duration of the animation.IAnimation
.static IAnimation createNodeAnimation(IGraph graph, INode node, IRectangle targetLayout, Duration preferredDuration)
IAnimation
that animates the given node
from its current layout to the new given
targetLayout
.graph
- The graph the animated node belongs to.node
- The node whose Layout
to animate.targetLayout
- The expected node layout after the animation.preferredDuration
- The preferred duration of the animation.IAnimation
.static IAnimation createParallelAnimation(IAnimation... animations)
IAnimation
according to the composite design pattern that animates multiple animations in parallel.
The animations can be synchronized to the longest running animation.
animations
- The animations to run in parallel.static IAnimation createParallelAnimation(IAnimation firstAnimation, Iterable<IAnimation> otherAnimations)
IAnimation
according to the composite design pattern that animates multiple animations in parallel to
this animation.
The animations will be synchronized to the longest running animation.
firstAnimation
- The first animation to add the other animations to.otherAnimations
- The animations to run in parallel.static IAnimation createParallelAnimation(IAnimation firstAnimation, Iterable<IAnimation> otherAnimations, boolean isSynchronized)
IAnimation
according to the composite design pattern that animates multiple animations in parallel to
this animation.
The animations will be synchronized to the longest running animation.
firstAnimation
- The first animation to add the other animations to.otherAnimations
- The animations to run in parallel.isSynchronized
- Whether all child animations should be adjusted to have the same (maximum)
PreferredDuration
. By default this is enabled.static IAnimation createParallelAnimation(Iterable<IAnimation> animations)
IAnimation
according to the composite design pattern that animates multiple animations in parallel.
The animations can be synchronized to the longest running animation.
animations
- The animations to run in parallel.static IAnimation createParallelAnimation(Iterable<IAnimation> animations, boolean isSynchronized)
IAnimation
according to the composite design pattern that animates multiple animations in parallel.
The animations can be synchronized to the longest running animation.
animations
- The animations to run in parallel.isSynchronized
- Whether all child animations should be adjusted to have the same (maximum)
PreferredDuration
. By default this is enabled.static IAnimation createPathAnimation(GeneralPath path, IMutablePoint animationPoint, Duration preferredDuration)
IAnimation
that animates the given IMutablePoint
along a path.path
- The path to animate the point along.animationPoint
- The mutable point instance that will be manipulated by the animation.preferredDuration
- The preferred duration of the animation.static IAnimation createPortAnimation(IGraph graph, IPort port, IPortLocationModelParameter targetLocationParameter, Duration preferredDuration)
IAnimation
that animates the given port
from its current location to the new location
given by the targetLocationParameter
.
This animation will as a side effect assign the targetLocationParameter
to the port at the
end of the animation
.
graph
- The graph that contains the port.port
- The port to animate.targetLocationParameter
- The parameter to linearly interpolate to.preferredDuration
- The preferred duration
of this animation.IAnimation
.static IAnimation createTableAnimation(ITable table, double[] columnLayout, double[] rowLayout)
IAnimation
for the given table that animates the table and its
stripes
.
Note that only the sizes of leaf stripes, i.e. those without child stripes, are considered. The sizes of a stripe with children is implicitly determined by its contents.
For more control of the animation, implement a custom TableAnimation
and override method
TableAnimation.createStripeAnimation(com.yworks.yfiles.graph.IStripe, double)
.
table
- The table to animate.columnLayout
- The sizes of the leaf columns, in natural order.rowLayout
- The sizes of the leaf rows, in natural order.Duration getPreferredDuration()
void initialize()
Call this method once before subsequent calls to animate(double)
.