Automatically create an animation manager for the animated panel; modified
the code that interacts with AWT repaint mechanisms to play nicely and communicate AWT's repaint desires to the animation manager to be queued up with our normal repainting. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@883 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: AnimatedPanel.java,v 1.1 2002/01/11 16:17:33 shaper Exp $
|
// $Id: AnimatedPanel.java,v 1.2 2002/01/19 07:04:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media.animation;
|
package com.threerings.media.animation;
|
||||||
|
|
||||||
@@ -18,8 +18,14 @@ import com.threerings.media.Log;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The animated panel provides a useful extensible implementation of a
|
* The animated panel provides a useful extensible implementation of a
|
||||||
* {@link Canvas} that implements the {@link AnimatedView} interface.
|
* {@link Canvas} that implements the {@link AnimatedView} interface. It
|
||||||
* Sub-classes should override {@link #render} to draw their
|
* takes care of automatically creating an animation manager to manage the
|
||||||
|
* animations that take place within this panel. Derived classes should
|
||||||
|
* provide said animation manager with a reference to the sprite manager
|
||||||
|
* in use by the application, if needed (via {@link
|
||||||
|
* AnimationManager#setSpriteManager}).
|
||||||
|
*
|
||||||
|
* <p> Sub-classes should override {@link #render} to draw their
|
||||||
* panel-specific contents, and may choose to override {@link
|
* panel-specific contents, and may choose to override {@link
|
||||||
* #invalidateRects} and {@link #invalidateRect} to optimize their
|
* #invalidateRects} and {@link #invalidateRect} to optimize their
|
||||||
* internal rendering.
|
* internal rendering.
|
||||||
@@ -33,20 +39,17 @@ public class AnimatedPanel extends Canvas implements AnimatedView
|
|||||||
{
|
{
|
||||||
// set our attributes for optimal display performance
|
// set our attributes for optimal display performance
|
||||||
// setIgnoreRepaint(true);
|
// setIgnoreRepaint(true);
|
||||||
|
|
||||||
|
// create our animation manager
|
||||||
|
_animmgr = new AnimationManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void paint (Graphics g)
|
public void paint (Graphics g)
|
||||||
{
|
{
|
||||||
// Log.info("AnimatedPanel paint");
|
// we don't paint directly any more, we pass the dirty rect to the
|
||||||
update(g);
|
// animation manager to queue up along with our next repaint
|
||||||
}
|
_animmgr.addDirtyRect(g.getClipBounds());
|
||||||
|
|
||||||
// documentation inherited
|
|
||||||
public void update (Graphics g)
|
|
||||||
{
|
|
||||||
// Log.info("AnimatedPanel update");
|
|
||||||
paintImmediately();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,6 +136,9 @@ public class AnimatedPanel extends Canvas implements AnimatedView
|
|||||||
/** The number of buffers to use when rendering. */
|
/** The number of buffers to use when rendering. */
|
||||||
protected static final int BUFFER_COUNT = 2;
|
protected static final int BUFFER_COUNT = 2;
|
||||||
|
|
||||||
|
/** The animation manager we use in this panel. */
|
||||||
|
protected AnimationManager _animmgr;
|
||||||
|
|
||||||
/** The buffer strategy used for optimal animation rendering. */
|
/** The buffer strategy used for optimal animation rendering. */
|
||||||
protected BufferStrategy _strategy;
|
protected BufferStrategy _strategy;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user