home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / WDESAMPL.BIN / AniArea.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-11-19  |  1.7 KB  |  61 lines

  1. import java.awt.Graphics;
  2. import java.awt.Image;
  3. import java.net.MalformedURLException;
  4. import java.net.URL;
  5. import java.util.StringTokenizer;
  6.  
  7. class AniArea extends ImageMapArea {
  8.    Image sourceImage;
  9.    int nFrames;
  10.    int[] coords;
  11.    int currentFrame;
  12.  
  13.    public void handleArg(String var1) {
  14.       StringTokenizer var2 = new StringTokenizer(var1, ", ");
  15.       String var3 = var2.nextToken();
  16.  
  17.       try {
  18.          this.sourceImage = super.parent.getImage(new URL(super.parent.getDocumentBase(), var3));
  19.          super.parent.addImage(this.sourceImage);
  20.       } catch (MalformedURLException var4) {
  21.       }
  22.  
  23.       this.nFrames = 0;
  24.       this.coords = new int[40];
  25.  
  26.       while(var2.hasMoreTokens()) {
  27.          this.coords[this.nFrames * 2] = Integer.parseInt(var2.nextToken());
  28.          this.coords[this.nFrames * 2 + 1] = Integer.parseInt(var2.nextToken());
  29.          ++this.nFrames;
  30.          if (this.nFrames > 19) {
  31.             return;
  32.          }
  33.       }
  34.  
  35.    }
  36.  
  37.    public boolean animate() {
  38.       if (super.entered) {
  39.          ((ImageMapArea)this).repaint();
  40.       }
  41.  
  42.       return super.entered;
  43.    }
  44.  
  45.    public void enter() {
  46.       this.currentFrame = 0;
  47.       super.parent.startAnimation();
  48.    }
  49.  
  50.    public void highlight(Graphics var1) {
  51.       if (super.entered) {
  52.          ((ImageMapArea)this).drawImage(var1, this.sourceImage, super.X - this.coords[this.currentFrame * 2], super.Y - this.coords[this.currentFrame * 2 + 1], super.X, super.Y, super.W, super.H);
  53.          ++this.currentFrame;
  54.          if (this.currentFrame >= this.nFrames) {
  55.             this.currentFrame = 0;
  56.          }
  57.       }
  58.  
  59.    }
  60. }
  61.