home *** CD-ROM | disk | FTP | other *** search
Java Source | 2017-09-21 | 2.3 KB | 135 lines |
- import browser.*;
- import browser.audio.*;
- import awt.*;
- import net.www.html.*;
- import java.io.*;
- import net.www.*;
- import java.util.*;
-
- // Animation Data Type
-
-
-
-
-
-
-
- // AnimationData ID
-
-
- // Animation Depth for no image (i.e. sound only data)
-
-
- class AnimationPlayer extends Applet implements Runnable {
-
- // test for MouseMove event
- int last_x = -1;
- int last_y = -1;
-
- static String imgdir = "images";
- static String snddir = "audio";
-
- boolean initialized = false;
-
- // various image file names
-
- // offscreen image & graphic context
- Image im = null;
- Graphics offscreen;
- int width, height;
-
- // Various Images
- Image background = null;
-
- IDChain dispobj = null;
-
- AnimationData adList[] = null;
- int maxAnimation = 0;
- Schedular sched[] = null;
- int maxSchedular = 0;
-
- public AnimationData getAnimationData(int n) {return adList[n];}
-
- void setupDisplayObject() {
- int i;
- for (i = 0; i < maxAnimation; i++) {
- if (adList[i] != null && adList[i].getDepth() >= 0) {
- dispobj.insertByDepth(new IDChain(i, 0, adList[i].getDepth()));
- }
- }
- }
-
- public void start() {
- startDisplay();
- repaint();
- }
-
- private void startDisplay() {
- int i;
- AnimationData ad;
-
- sched[0] = new Schedular(this, 0);
- for (i = 0; i < maxAnimation; i++) {
- if ((ad=adList[i]) == null) {
- continue;
- }
- if (ad.getType() == 1) {
- sched[0].reschedule(i);
- } else if (ad.getCurFrame() == -1) {
- ad.setCurFrame(0);
- }
- }
- sched[0].start();
- }
-
-
- public void run() {
- }
-
- public void stop() {
- int i;
- for (i=0; i < maxSchedular; i++) {
- if (sched[i] != null) {
- sched[i].stop();
- sched[i] = null;
- }
- }
- }
-
- public void paint(Graphics g) {
- update(g);
- }
-
- public void update(Graphics g) {
- offscreen.setForeground(Color.lightGray);
- offscreen.fillRect(0,0,width,height);
- offscreen.drawImage(background, 0, 0);
-
- IDChain p;
- AnimationData ad;
- Image img;
- for (p = dispobj.getNext(); p != null; p = p.getNext()) {
- ad = adList[p.getID()];
- if ((img=ad.getCurrentImage()) != null) {
- offscreen.drawImage(img, ad.x(), ad.y());
- }
- }
- g.drawImage(im,0,0);
- }
-
- public void insertSchedular(int id) {
- sched[id] = new Schedular(this, id);
- sched[id].reschedule(id);
- sched[id].start();
- }
-
- public void removeSchedular(int id) {
- if (sched[id] != null) {
- sched[id].stop();
- sched[id] = null;
- }
- }
-
- }
-
-