Source of DBAnimationApplet.java


  1: import java.awt.*;
  2: 
  3: public abstract class DBAnimationApplet
  4:     extends AnimationApplet {
  5: 
  6:   final public void update(Graphics g) {
  7:     if (doubleBuffered) {
  8:       paintFrame(offscreen);
  9:       g.drawImage(im, 0, 0, this);
 10:     } else {
 11:       // super.update();
 12:     }
 13:   }
 14: 
 15:   final public void paint(Graphics g) {
 16:     paintFrame(g);
 17:   }
 18: 
 19:   final public void init() {
 20:     d = getSize();
 21:     im = createImage(d.width, d.height);
 22:     offscreen = im.getGraphics();
 23:     initAnimator();
 24:   }
 25: 
 26:   protected void initAnimator() {}
 27: 
 28:   abstract protected void paintFrame(Graphics g);
 29: 
 30:   protected DBAnimationApplet(boolean doubleBuffered) {
 31:     this.doubleBuffered = doubleBuffered;
 32:   }
 33: 
 34:   protected DBAnimationApplet() {
 35:     this.doubleBuffered = true;
 36:   }
 37: 
 38:   protected boolean doubleBuffered;
 39:   protected Dimension d;
 40:   protected Image im;
 41:   protected Graphics offscreen;
 42: 
 43: }
 44: