public interface IlvOptimizedAnimatedGraphic
IlvOptimizedAnimatedGraphic
must be
implemented by subclasses of IlvGraphic
that want to
provide two ways to draw an object: one for regular drawing,
the other for drawing during animation.
Animation mode is automatically enabled at the beginning of
animation, and disabled at the end of animation by the manager
animator.
This is useful if regular drawing is very slow, because as a consequence
animation will be slow. For example, instead of drawing a complex icon
during animation, it may be sufficient to draw only a rectangle as an
approximation.
Example:
public class MyIcon extends IlvIcon implements IlvOptimizedAnimatedGraphic { boolean animationDrawingMode = false; public void setAnimationDrawingMode(boolean flag) { animationDrawingMode = flag; } public void draw(Graphics dst, IlvTransformer t) { if (animationDrawingMode) { // fast: draw only rectangle. This is used during animation. dst.setColor(Color.black); IlvRect rect = boundingBox(t); dst.drawRect(rect.xFloor(), rect.yFloor(), rect.widthFloor()+1, rect.heightFloor()+1); } else { // slow: draw all details super.draw(dst, t); } } }
IlvManagerAnimator
Modifier and Type | Method and Description |
---|---|
void |
setAnimationDrawingMode(boolean flag)
Puts the object in animation mode.
|
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.