home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Canvas;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.MediaTracker;
-
- class ScrollCanvas extends Canvas {
- Image sourceImage;
- int widthImage;
- int heightImage;
- int pos;
- Dimension offDimension;
- Image offImage;
- Graphics offGraphics;
- MediaTracker tracker;
-
- public ScrollCanvas(Image var1) {
- this.sourceImage = var1;
- this.tracker = new MediaTracker(this);
- this.tracker.addImage(var1, 0);
- ((Component)this).reshape(0, 0, 500, 100);
- }
-
- protected void finalize() throws Throwable {
- this.tracker = null;
- this.offGraphics = null;
- this.offImage = null;
- super.finalize();
- }
-
- public void scrollImage(int var1) {
- this.pos += var1;
- if (this.pos < -this.widthImage) {
- this.pos += this.widthImage;
- }
-
- }
-
- public void paintScreen(Graphics var1) {
- var1.drawImage(this.sourceImage, this.pos, 0, this);
- var1.drawImage(this.sourceImage, this.pos + this.widthImage, 0, this);
- }
-
- public void update(Graphics var1) {
- if ((this.tracker.statusAll(true) & 8) == 0) {
- var1.drawString("(c)1996 MYSTiC BYTES. HOlD oN...", 10, 50);
- } else {
- this.widthImage = this.sourceImage.getWidth(this);
- this.heightImage = this.sourceImage.getHeight(this);
- ((Component)this).reshape(0, 0, this.widthImage, this.heightImage);
- if (this.offGraphics == null || this.widthImage != this.offDimension.width || this.heightImage != this.offDimension.height) {
- this.offDimension = new Dimension(this.widthImage, this.heightImage);
- this.offImage = ((Component)this).createImage(this.widthImage, this.heightImage);
- this.offGraphics = this.offImage.getGraphics();
- }
-
- this.paintScreen(this.offGraphics);
- var1.drawImage(this.offImage, 0, 0, this);
- }
- }
-
- public void paint(Graphics var1) {
- this.update(var1);
- }
- }
-