public class IlvManagerAnimator extends Object
IlvManagerAnimator
allows you to animate the content changes
in an IlvManager
. It can also animate the transformer changes of the
IlvManagerView
attached to the manager.
The animator must be attached to an IlvManager
.
The animator can be used in a single-threaded application or in a multithreaded application. You are recommended to use multithreading for smoother redrawing.
Single-threaded applications are only possible if the manager views are
embedded in a Swing component, for instance
IlvJManagerViewPanel
or
IlvJScrollManagerView
. In this case, the animation
runs directly in the AWT event thread.
In a single-threaded application, the mechanism works as follows:
recordState
. This records
the start positions of all objects involved in the animation.
IlvManager.moveObject(ilog.views.IlvGraphic, double, double, boolean)
).
animate
to animate the changes to the manager.
This will draw an animated movement for the objects from the positions
recorded by recordState
to the new object positions.
While the animation in single-threaded applications is restricted to manager views embedded in Swing components, multithreaded applications can also use AWT components not wrapped in Swing components.
Multithreaded applications often draw the animated movement more smoothly than single-threaded applications.
In a multithreaded application, the mechanism works as follows:
IlvManagerAnimator.start
. This animation thread
performs the changes to the IlvManager
.
recordState
to record the start
positions of all objects involved in the animation.
IlvManager.moveObject(ilog.views.IlvGraphic, double, double, boolean)
).
animate
within the animation thread to animate the
changes to the manager.
This will draw an animated movement for the objects from the positions
recorded by recordState
to the new object positions.
Constructor and Description |
---|
IlvManagerAnimator(IlvManager manager)
Creates a new
IlvManagerAnimator and attaches it to the
specified manager. |
IlvManagerAnimator(IlvManager manager,
boolean resizingObjects)
Creates a new
IlvManagerAnimator and attaches it to the
specified manager. |
Modifier and Type | Method and Description |
---|---|
protected void |
afterAnimationStep(int i)
Called at the end of the ith animation step.
|
void |
animate()
Animates all objects in the manager that is displayed in the attached
manager view.
|
void |
animateToImages(ImageConsumer imageConsumer,
IlvManagerView view)
If this method is called instead of
animate() , the animation is
dumped into a sequence of images. |
void |
animateToImages(ImageConsumer imageConsumer,
int width,
int height,
IlvTransformer transformer)
If this method is called instead of
animate() , the animation is
dumped into a sequence of images. |
protected boolean |
animStep(int i)
Performs one animation step that moves all objects in the manager.
|
void |
attach(IlvManager manager)
Attaches the animator to a manager.
|
protected IlvObjectAnimator |
createGraphicAnimator(IlvGraphic node)
This method is called when a new animator property for an
IlvGraphic that is a node in the graph is needed. |
protected IlvObjectAnimator |
createLinkImageAnimator(IlvLinkImage link)
This method is called when a new animator property for an
IlvLinkImage that is a link in the graph is needed. |
protected IlvObjectAnimator |
createObjectAnimator(IlvGraphic graphic)
This method is called when a new animator property for a graphic is
needed.
|
void |
detach()
Detaches the animator from its manager.
|
int |
getAnimationAccelerationRate()
Returns the number of steps during which the animation speeds up at
the beginning of the animation and the number of steps during which
the animation slows down at the end of the animation.
|
int |
getAnimationDelay()
Returns the interval between drawing steps during animation.
|
int |
getAnimationRate()
Returns the animation rate.
|
Thread |
getAnimationThread()
Returns the animation thread.
|
IlvManager |
getManager()
Returns the animated manager.
|
IlvObjectAnimator |
getObjectAnimator(IlvGraphic graphic,
boolean create)
Returns the object animator of a graphic.
|
boolean |
isMultiThreading()
Returns
true if the animator runs in its own thread. |
boolean |
isResizingObjects()
Returns
true if the animator resizes the objects. |
boolean |
isRunning()
Returns
true if animation is currently running. |
void |
recordState()
Records the current state of all objects in the manager that is displayed
in the attached manager view.
|
void |
setAnimationAccelerationRate(int rate)
Sets the number of steps during which the animation speeds
up at the beginning of the animation and the number of steps
during which the animation slows down at the end of the animation.
|
void |
setAnimationDelay(int delayTime)
Sets the interval between drawing steps during animation,
in milliseconds.
|
void |
setAnimationRate(int rate)
Sets the animation rate, that is, the number of drawing steps performed
to animate a smooth movement from start state to end state.
|
void |
setResizingObjects(boolean resizing)
If
resizing is true , the width
and height of the graphic objects are changed linearly
from the initial size to the final size. |
void |
start(Runnable runnable)
Starts the animation thread.
|
void |
start(Thread thread)
Starts the animation thread.
|
void |
unrecordState()
Clears the animation state of the manager.
|
public IlvManagerAnimator(IlvManager manager)
IlvManagerAnimator
and attaches it to the
specified manager.attach(ilog.views.IlvManager)
,
detach()
public IlvManagerAnimator(IlvManager manager, boolean resizingObjects)
IlvManagerAnimator
and attaches it to the
specified manager.manager
- The specified manager.resizingObjects
- If true
, the graphic objects are moved
and resized during animation.
If false
, the objects are only moved;
their size is left unchanged.attach(ilog.views.IlvManager)
,
detach()
public void attach(IlvManager manager)
If the animation is multithreaded, this method should not be called by the animation thread but only by the main thread.
manager
- The manager.IlvManagerView.setDoubleBuffering(boolean)
,
detach()
public void detach()
detach
is called. This method restores the initial state of
the manager views and detaches all object animators from the objects
managed by the manager.
If animation is multithreaded, this method should not be called by the animation thread but only by the main thread.
attach(ilog.views.IlvManager)
public IlvObjectAnimator getObjectAnimator(IlvGraphic graphic, boolean create)
create
flag is true
, this method will create
a new object animator if there is no animator yet for the specified graphic.protected IlvObjectAnimator createObjectAnimator(IlvGraphic graphic)
createGraphicAnimator
or
createLinkImageAnimator
.
Customers that create their own object animators can override this method to create an object animator different from the default animators.
protected IlvObjectAnimator createGraphicAnimator(IlvGraphic node)
IlvGraphic
that is a node in the graph is needed.
The default implementation returns a new instance of class
IlvGraphicAnimator
, which is able to animate changes to the
bounding box of a node.
Customers that create their own object animators can override this method
to create an object animator different from the default animators.
protected IlvObjectAnimator createLinkImageAnimator(IlvLinkImage link)
IlvLinkImage
that is a link in the graph is needed.
The default implementation returns a new instance of class
IlvLinkImageAnimator
, which is able to animate changes to the
shape of a link.
Customers that create their own object animators can override this method
to create an object animator different from the default animators.
public IlvManager getManager()
attach(ilog.views.IlvManager)
,
detach()
public void setAnimationRate(int rate)
The default is 20.
getAnimationRate()
,
setAnimationDelay(int)
public int getAnimationRate()
setAnimationRate(int)
public void setAnimationAccelerationRate(int rate)
The default is 0, which means no acceleration or deceleration occurs (animated objects always move with constant speed).
rate
- The number of acceleration and deceleration steps.setAnimationRate(int)
,
getAnimationAccelerationRate()
public int getAnimationAccelerationRate()
setAnimationAccelerationRate(int)
public void setAnimationDelay(int delayTime)
The default is 50 milliseconds.
getAnimationDelay()
,
setAnimationRate(int)
public int getAnimationDelay()
setAnimationDelay(int)
public void setResizingObjects(boolean resizing)
resizing
is true
, the width
and height of the graphic objects are changed linearly
from the initial size to the final size. If resizing
is false
, the objects are only moved.
The default value is true
.
isResizingObjects()
public boolean isResizingObjects()
true
if the animator resizes the objects.
setResizingObjects(boolean)
public boolean isMultiThreading()
true
if the animator runs in its own thread.start(java.lang.Runnable)
public Thread getAnimationThread()
start(java.lang.Runnable)
public void start(Runnable runnable)
public void start(Thread thread)
public boolean isRunning()
true
if animation is currently running.
This method returns true
immediately after
start(Runnable)
or start(Thread)
has been called.
It returns false
when animate()
has finished or when
unrecordState()
has been called.start(Runnable)
,
start(Thread)
,
animate()
,
unrecordState()
public void recordState()
Any call to recordState
should be followed either by a
call to animate
or by a call to unrecordState
.
Both clear the animation status of the manager.
getManager()
,
animate()
,
unrecordState()
public void unrecordState()
animate
if you have called
recordState
but you want to cancel animation.
Example:
IlvManagerAnimator animator = ... animator.recordState(); try { ... changes to the manager ... } finally { if (wantAnimation) animator.animate(); else animator.unrecordState(); }
getManager()
,
animate()
,
recordState()
public void animate()
setAnimationRate(int)
.
If the animation is multithreaded, a separate drawing thread is
responsible for the paint refresh of the manager view.
If the animation is single-threaded, the manager view is locked and
is painted immediately, during animation, by setting the draw
mode IlvManagerView.DIRECT_REDRAW
.
protected boolean animStep(int i)
true
if animation must continue, that
is, if the objects have not yet reached their final state.
animate()
,
setAnimationRate(int)
protected void afterAnimationStep(int i)
public void animateToImages(ImageConsumer imageConsumer, int width, int height, IlvTransformer transformer)
animate()
, the animation is
dumped into a sequence of images. Notice that dumping is usually very
slow. The specified image consumer receives the images through
setPixels
. When each single frame
is completed, imageComplete
is
called on the image consumer passing the status
ImageConsumer.SINGLEFRAMEDONE
. When the entire animation is
completed, imageComplete
is called
on the image consumer passing the status
ImageConsumer.STATICIMAGEDONE
.imageConsumer
- The consumer of the image frames.width
- The width of the imagesheight
- The height of the imagestransformer
- The initial transformer of the animation.
The transformer may change during the animation.public void animateToImages(ImageConsumer imageConsumer, IlvManagerView view)
animate()
, the animation is
dumped into a sequence of images. Notice that dumping is usually very
slow. The input image consumer receives the images through
setPixels
. When each single frame
is completed, imageComplete
is
called on the image consumer passing the status
ImageConsumer.SINGLEFRAMEDONE
. When the entire animation is
completed, imageComplete
is called
on the image consumer passing the status
ImageConsumer.STATICIMAGEDONE
.imageConsumer
- The consumer of the image frames.view
- The view used to display the animation.
The resulting images have the width and height of this view.
This must be a view of the manager to be
animated. The view need not be visible. If the view is
visible, it must not be touched or resized during
animation.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.