home *** CD-ROM | disk | FTP | other *** search
/ NetObjects Fusion 7 / Fusion7.iso / NetObjects Fusion / data1.cab / Language_Resource_-_English / Components / AdBanner / RotateTransition.class (.txt) < prev    next >
Encoding:
Java Class File  |  2002-10-18  |  2.1 KB  |  64 lines

  1. import java.awt.image.MemoryImageSource;
  2.  
  3. public class RotateTransition extends BannerTransition {
  4.    static final double SIN_45_DEGREES = 0.707106781;
  5.    int rotateAmount;
  6.    int location;
  7.    double currentAngle;
  8.    double angleIncrease;
  9.    double perpen;
  10.  
  11.    public RotateTransition() {
  12.       super.numOfFrames = 8;
  13.    }
  14.  
  15.    public void finishInit() {
  16.       super.delay = 200;
  17.       this.angleIncrease = (Math.PI / 2D) * ((double)1.0F / (double)(super.numOfFrames + 1));
  18.       this.currentAngle = this.angleIncrease;
  19.       this.perpen = (double)super.imageHeight / (double)2.0F * 0.707106781;
  20.  
  21.       for(int f = 0; f < super.numOfFrames; ++f) {
  22.          try {
  23.             Thread.sleep(100L);
  24.          } catch (InterruptedException var6) {
  25.          }
  26.  
  27.          this.Rotate();
  28.  
  29.          try {
  30.             Thread.sleep(100L);
  31.          } catch (InterruptedException var5) {
  32.          }
  33.  
  34.          super.frames[f] = super.owner.createImage(new MemoryImageSource(super.imageWidth, super.imageHeight, super.workPixels, 0, super.imageWidth));
  35.          super.owner.prepareImage(super.frames[f], super.owner);
  36.          this.currentAngle += this.angleIncrease;
  37.       }
  38.  
  39.       super.workPixels = null;
  40.    }
  41.  
  42.    final void Rotate() {
  43.       double top_Banner_h = (double)super.imageHeight / (double)2.0F * Math.sin((Math.PI / 2D) - this.currentAngle) + (double)super.imageHeight / (double)2.0F;
  44.       double bottom_Banner_h = (double)super.imageHeight / (double)2.0F * Math.sin(this.currentAngle) + (double)super.imageHeight / (double)2.0F;
  45.       int location = super.imageHeight - (int)(bottom_Banner_h * Math.sin(this.currentAngle));
  46.       float adder = (float)top_Banner_h / (float)location;
  47.       float position = (float)super.imageHeight - (float)top_Banner_h + adder - 1.0F;
  48.  
  49.       for(int y = 0; y < location; ++y) {
  50.          System.arraycopy(super.owner.banners[super.owner.currentBanner].imagePixels, (int)position * super.imageWidth, super.workPixels, y * super.imageWidth, super.imageWidth);
  51.          position += adder;
  52.       }
  53.  
  54.       adder = (float)bottom_Banner_h / (float)(super.imageHeight - location);
  55.       position = 0.0F;
  56.  
  57.       for(int y = location; y < super.imageHeight; ++y) {
  58.          System.arraycopy(super.owner.banners[super.owner.nextBanner].imagePixels, (int)position * super.imageWidth, super.workPixels, y * super.imageWidth, super.imageWidth);
  59.          position += adder;
  60.       }
  61.  
  62.    }
  63. }
  64.