home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Netobjs / Install.exe / data1.cab / Components / AdBanner / RotateTransition.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-12-16  |  1.9 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 var1 = 0; var1 < super.numOfFrames; ++var1) {
  22.          try {
  23.             Thread.sleep(100L);
  24.          } catch (InterruptedException var3) {
  25.          }
  26.  
  27.          this.Rotate();
  28.  
  29.          try {
  30.             Thread.sleep(100L);
  31.          } catch (InterruptedException var2) {
  32.          }
  33.  
  34.          super.frames[var1] = super.owner.createImage(new MemoryImageSource(super.imageWidth, super.imageHeight, super.workPixels, 0, super.imageWidth));
  35.          super.owner.prepareImage(super.frames[var1], super.owner);
  36.          this.currentAngle += this.angleIncrease;
  37.       }
  38.  
  39.       super.workPixels = null;
  40.    }
  41.  
  42.    final void Rotate() {
  43.       double var1 = (double)super.imageHeight / (double)2.0F * Math.sin((Math.PI / 2D) - this.currentAngle) + (double)super.imageHeight / (double)2.0F;
  44.       double var3 = (double)super.imageHeight / (double)2.0F * Math.sin(this.currentAngle) + (double)super.imageHeight / (double)2.0F;
  45.       int var5 = super.imageHeight - (int)(var3 * Math.sin(this.currentAngle));
  46.       float var6 = (float)var1 / (float)var5;
  47.       float var7 = (float)super.imageHeight - (float)var1 + var6 - 1.0F;
  48.  
  49.       for(int var8 = 0; var8 < var5; ++var8) {
  50.          System.arraycopy(super.owner.banners[super.owner.currentBanner].imagePixels, (int)var7 * super.imageWidth, super.workPixels, var8 * super.imageWidth, super.imageWidth);
  51.          var7 += var6;
  52.       }
  53.  
  54.       var6 = (float)var3 / (float)(super.imageHeight - var5);
  55.       var7 = 0.0F;
  56.  
  57.       for(int var9 = var5; var9 < super.imageHeight; ++var9) {
  58.          System.arraycopy(super.owner.banners[super.owner.nextBanner].imagePixels, (int)var7 * super.imageWidth, super.workPixels, var9 * super.imageWidth, super.imageWidth);
  59.          var7 += var6;
  60.       }
  61.  
  62.    }
  63. }
  64.