home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / Screw Java Applet Commercial v1.0 / screw2.exe / sample2 / screw.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-02-26  |  9.1 KB  |  512 lines

  1. import java.applet.Applet;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Event;
  5. import java.awt.Frame;
  6. import java.awt.Graphics;
  7. import java.awt.Image;
  8. import java.awt.MediaTracker;
  9. import java.awt.image.ImageObserver;
  10. import java.awt.image.MemoryImageSource;
  11. import java.awt.image.PixelGrabber;
  12. import java.net.URL;
  13.  
  14. public class screw extends Applet implements Runnable {
  15.    // $FF: renamed from: rn java.lang.Thread
  16.    Thread field_0;
  17.    Color bgc;
  18.    int bgi;
  19.    // $FF: renamed from: i int
  20.    int field_1;
  21.    // $FF: renamed from: j int
  22.    int field_2;
  23.    int num;
  24.    int durum;
  25.    // $FF: renamed from: cw int
  26.    int field_3;
  27.    // $FF: renamed from: ch int
  28.    int field_4;
  29.    int dly;
  30.    // $FF: renamed from: fd int
  31.    int field_5;
  32.    // $FF: renamed from: ci int
  33.    int field_6 = 1;
  34.    // $FF: renamed from: md int
  35.    int field_7;
  36.    int md2;
  37.    int cit;
  38.    // $FF: renamed from: wp int
  39.    int field_8 = 100;
  40.    // $FF: renamed from: tm int
  41.    int field_9;
  42.    int crr = 1;
  43.    // $FF: renamed from: w int
  44.    int field_10;
  45.    // $FF: renamed from: h int
  46.    int field_11;
  47.    // $FF: renamed from: X int
  48.    int field_12;
  49.    // $FF: renamed from: Y int
  50.    int field_13;
  51.    // $FF: renamed from: sc int
  52.    int field_14;
  53.    int inout;
  54.    // $FF: renamed from: mx int
  55.    int field_15;
  56.    // $FF: renamed from: my int
  57.    int field_16;
  58.    int acisay;
  59.    int modd;
  60.    double alfasin;
  61.    double alfa;
  62.    Image[] img;
  63.    // $FF: renamed from: oi java.awt.Image
  64.    Image field_17;
  65.    Image offi;
  66.    // $FF: renamed from: bs java.lang.String
  67.    String field_18 = "";
  68.    String errstr = "";
  69.    String regcode = "";
  70.    String target_frame = "_self";
  71.    String infostr = "";
  72.    String ialign = "";
  73.    String ivalign = "";
  74.    MediaTracker tracker;
  75.    String[] links;
  76.    String[] stb;
  77.    int[] imgw;
  78.    int[] imgh;
  79.    // $FF: renamed from: pg java.awt.image.PixelGrabber
  80.    PixelGrabber field_19;
  81.    // $FF: renamed from: dt int[][]
  82.    int[][] field_20;
  83.    MemoryImageSource MIS;
  84.    Graphics offg2;
  85.    int[] isle;
  86.    // $FF: renamed from: rg boolean
  87.    boolean field_21 = false;
  88.    boolean whb = false;
  89.    // $FF: renamed from: u java.net.URL
  90.    URL field_22;
  91.    int[] dur;
  92.    double[] acd;
  93.  
  94.    public void init() {
  95.       this.field_10 = -1;
  96.       this.field_11 = -1;
  97.       this.whb = false;
  98.       ((Component)this).setBackground(Color.white);
  99.       this.bgi = this.method_0(((Applet)this).getParameter("bgcolor"), 16, 0);
  100.       this.dly = this.method_0(((Applet)this).getParameter("transition_delay"), 10, 100);
  101.       this.field_8 = this.method_0(((Applet)this).getParameter("delay"), 10, 1000);
  102.       this.field_14 = this.method_0(((Applet)this).getParameter("step_count"), 10, 20);
  103.       this.modd = this.method_0(((Applet)this).getParameter("mode"), 10, 0);
  104.       this.modd %= 2;
  105.       this.bgc = new Color(this.bgi);
  106.       this.tracker = new MediaTracker(this);
  107.       this.field_1 = 1;
  108.       this.regcode = ((Applet)this).getParameter("regcode");
  109.       if (this.regcode != null && this.regcode.equals("screw45yrh4")) {
  110.          this.field_21 = true;
  111.       }
  112.  
  113.       this.target_frame = ((Applet)this).getParameter("target_frame");
  114.       this.infostr = ((Applet)this).getParameter("info");
  115.       this.ivalign = ((Applet)this).getParameter("image_valign");
  116.       this.ialign = ((Applet)this).getParameter("image_align");
  117.  
  118.       while(true) {
  119.          this.field_18 = ((Applet)this).getParameter("image" + this.field_1);
  120.          if (this.field_18 == null) {
  121.             --this.field_1;
  122.             if (this.field_1 < 0) {
  123.                this.field_1 = 0;
  124.             }
  125.             break;
  126.          }
  127.  
  128.          if (!this.field_18.endsWith(".gif") && !this.field_18.endsWith(".jpg")) {
  129.             --this.field_1;
  130.             if (this.field_1 < 0) {
  131.                this.field_1 = 0;
  132.             }
  133.             break;
  134.          }
  135.  
  136.          ++this.field_1;
  137.       }
  138.  
  139.       this.num = this.field_1;
  140.       this.img = new Image[this.num + 1];
  141.       this.links = new String[this.num + 1];
  142.       this.stb = new String[this.num + 1];
  143.       this.imgw = new int[this.num + 1];
  144.       this.imgh = new int[this.num + 1];
  145.       this.dur = new int[this.num + 1];
  146.  
  147.       for(this.field_1 = 1; this.field_1 <= this.num; ++this.field_1) {
  148.          this.img[this.field_1] = ((Applet)this).getImage(((Applet)this).getCodeBase(), "" + ((Applet)this).getParameter("image" + this.field_1));
  149.          this.tracker.addImage(this.img[this.field_1], this.field_1 % 5);
  150.          this.links[this.field_1] = ((Applet)this).getParameter("link" + this.field_1);
  151.          this.stb[this.field_1] = ((Applet)this).getParameter("status_bar_msg" + this.field_1);
  152.          if (this.links[this.field_1] == null) {
  153.             this.dur[this.field_1] = 0;
  154.          } else {
  155.             this.dur[this.field_1] = 1;
  156.             if (this.links[this.field_1].equals("") || this.links[this.field_1].equals(" ") || this.links[this.field_1].equals("no")) {
  157.                this.dur[this.field_1] = 0;
  158.             }
  159.          }
  160.       }
  161.  
  162.       this.durum = 0;
  163.    }
  164.  
  165.    // $FF: renamed from: fi (java.lang.String, int, int) int
  166.    public int method_0(String var1, int var2, int var3) {
  167.       int var4 = 0;
  168.  
  169.       try {
  170.          var4 = Integer.parseInt(var1, var2);
  171.       } catch (Exception var5) {
  172.          var4 = var3;
  173.       }
  174.  
  175.       return var4;
  176.    }
  177.  
  178.    public void ssts() {
  179.       if (this.whb && this.inout == 1) {
  180.          if (!this.field_21) {
  181.             ((Applet)this).showStatus("  Unregistered version of Screw Java applet. URL: japplets.tripod.com");
  182.             return;
  183.          }
  184.  
  185.          if (this.stb[this.crr] != null) {
  186.             ((Applet)this).showStatus("" + this.stb[this.crr]);
  187.          }
  188.       }
  189.  
  190.    }
  191.  
  192.    public void smc() {
  193.       if (this.whb && this.inout == 1) {
  194.          if (this.dur[this.crr] == 0) {
  195.             ((Frame)((Component)this).getParent()).setCursor(0);
  196.             return;
  197.          }
  198.  
  199.          ((Frame)((Component)this).getParent()).setCursor(12);
  200.       }
  201.  
  202.    }
  203.  
  204.    public boolean mouseEnter(Event var1, int var2, int var3) {
  205.       if (this.whb) {
  206.          if (this.durum != 2) {
  207.             return true;
  208.          }
  209.  
  210.          if (this.num <= 0) {
  211.             return true;
  212.          }
  213.  
  214.          this.inout = 1;
  215.          this.ssts();
  216.          ((Component)this).repaint();
  217.          this.smc();
  218.       }
  219.  
  220.       return true;
  221.    }
  222.  
  223.    public boolean mouseExit(Event var1, int var2, int var3) {
  224.       if (this.whb) {
  225.          this.inout = 0;
  226.          ((Applet)this).showStatus("");
  227.          ((Frame)((Component)this).getParent()).setCursor(0);
  228.       }
  229.  
  230.       return true;
  231.    }
  232.  
  233.    public boolean mouseUp(Event var1, int var2, int var3) {
  234.       if (this.whb) {
  235.          if (this.dur[this.crr] == 0) {
  236.             return true;
  237.          }
  238.  
  239.          try {
  240.             if (this.links[this.crr].startsWith("http://")) {
  241.                this.field_22 = new URL("" + this.links[this.crr]);
  242.             } else {
  243.                this.field_22 = new URL(((Applet)this).getCodeBase(), "" + this.links[this.crr]);
  244.             }
  245.          } catch (Exception var4) {
  246.             return true;
  247.          }
  248.  
  249.          ((Applet)this).getAppletContext().showDocument(this.field_22, this.target_frame);
  250.       }
  251.  
  252.       return true;
  253.    }
  254.  
  255.    public void update(Graphics var1) {
  256.       if (this.whb) {
  257.          if (this.durum == 2) {
  258.             this.field_17.flush();
  259.             this.offg2.drawImage(this.field_17, this.field_12, this.field_13, (ImageObserver)null);
  260.          }
  261.  
  262.          this.paint(var1);
  263.       }
  264.  
  265.    }
  266.  
  267.    public void paint(Graphics var1) {
  268.       if (this.whb) {
  269.          if (this.durum == 2) {
  270.             var1.drawImage(this.offi, 0, 0, this);
  271.             return;
  272.          }
  273.  
  274.          var1.setColor(Color.white);
  275.          var1.fillRect(0, 0, this.field_10, this.field_11);
  276.          var1.setColor(Color.black);
  277.          if (this.durum == 0) {
  278.             var1.drawString("Loading...", 10, 20);
  279.          }
  280.  
  281.          if (this.durum == 1) {
  282.             var1.drawString("Images", 10, 20);
  283.             var1.drawString("not found.", 10, 36);
  284.          }
  285.  
  286.          if (this.durum == 3) {
  287.             var1.drawString("Images must be", 10, 20);
  288.             var1.drawString("the same size.", 10, 36);
  289.          }
  290.  
  291.          if (this.durum == 4) {
  292.             var1.drawString("Info parameter", 10, 20);
  293.             var1.drawString("error.", 10, 36);
  294.          }
  295.       }
  296.  
  297.    }
  298.  
  299.    public void start() {
  300.       if (this.field_0 == null || !this.field_0.isAlive()) {
  301.          this.field_0 = new Thread(this);
  302.       }
  303.  
  304.       this.field_0.start();
  305.    }
  306.  
  307.    public void stop() {
  308.       if (this.field_0 != null) {
  309.          this.field_0.stop();
  310.          this.field_0 = null;
  311.       }
  312.  
  313.    }
  314.  
  315.    public void destroy() {
  316.       this.field_0 = null;
  317.    }
  318.  
  319.    public void run() {
  320.       ((Component)this).show();
  321.       this.field_10 = ((Component)this).size().width;
  322.       this.field_11 = ((Component)this).size().height;
  323.       if (!this.whb) {
  324.          this.offi = ((Component)this).createImage(this.field_10, this.field_11);
  325.          this.offg2 = this.offi.getGraphics();
  326.          this.offg2.setColor(this.bgc);
  327.          this.offg2.fillRect(0, 0, this.field_10, this.field_11);
  328.       }
  329.  
  330.       this.whb = true;
  331.       this.durum = 0;
  332.  
  333.       try {
  334.          this.tracker.waitForAll();
  335.       } catch (InterruptedException var10) {
  336.       }
  337.  
  338.       if (this.tracker.isErrorAny()) {
  339.          this.durum = 1;
  340.          ((Component)this).repaint();
  341.       } else {
  342.          for(this.field_1 = 1; this.field_1 <= this.num; ++this.field_1) {
  343.             this.imgw[this.field_1] = this.img[this.field_1].getWidth(this);
  344.             this.imgh[this.field_1] = this.img[this.field_1].getHeight(this);
  345.             if (this.field_1 > 1 && (this.imgw[this.field_1] != this.imgw[this.field_1 - 1] || this.imgh[this.field_1] != this.imgh[this.field_1 - 1])) {
  346.                this.durum = 3;
  347.                ((Component)this).repaint();
  348.                return;
  349.             }
  350.  
  351.             this.field_3 = this.imgw[this.field_1];
  352.             this.field_4 = this.imgh[this.field_1];
  353.          }
  354.  
  355.          if (this.ialign != null) {
  356.             if (this.field_3 < this.field_10) {
  357.                this.field_12 = 0;
  358.                if (this.ialign.equals("center")) {
  359.                   this.field_12 = (this.field_10 - this.field_3) / 2;
  360.                }
  361.  
  362.                if (this.ialign.equals("right")) {
  363.                   this.field_12 = this.field_10 - this.field_3;
  364.                }
  365.             } else {
  366.                this.field_12 = 0;
  367.                if (this.ialign.equals("center")) {
  368.                   this.field_12 = -1 * ((this.field_3 - this.field_10) / 2);
  369.                }
  370.  
  371.                if (this.ialign.equals("right")) {
  372.                   this.field_12 = this.field_10 - this.field_3;
  373.                }
  374.             }
  375.          }
  376.  
  377.          if (this.ivalign != null && this.field_4 < this.field_11) {
  378.             if (this.ivalign.equals("center")) {
  379.                this.field_13 = (this.field_11 - this.field_4) / 2;
  380.             }
  381.  
  382.             if (this.ivalign.equals("bottom")) {
  383.                this.field_13 = this.field_11 - this.field_4;
  384.             }
  385.          }
  386.  
  387.          if (this.infostr == null) {
  388.             this.durum = 4;
  389.             ((Component)this).repaint();
  390.          } else {
  391.             if (this.infostr.equals("Applet by Gokhan Dagli,japplets.tripod.com")) {
  392.                this.field_20 = new int[this.num + 1][this.field_3 * this.field_4];
  393.                this.isle = new int[this.field_3 * this.field_4];
  394.                this.acd = new double[this.field_3 * this.field_4];
  395.                this.MIS = new MemoryImageSource(this.field_3, this.field_4, this.isle, 0, this.field_3);
  396.  
  397.                for(this.field_1 = 1; this.field_1 <= this.num; ++this.field_1) {
  398.                   this.field_19 = new PixelGrabber(this.img[this.field_1].getSource(), 0, 0, this.field_3, this.field_4, this.field_20[this.field_1], 0, this.field_3);
  399.  
  400.                   try {
  401.                      this.field_19.grabPixels();
  402.                   } catch (Exception var9) {
  403.                   }
  404.                }
  405.  
  406.                this.field_15 = this.field_3 / 2;
  407.                this.field_16 = this.field_4 / 2;
  408.                if (this.modd == 0) {
  409.                   this.alfa = (Math.PI * 2D) / (double)this.field_14;
  410.                } else {
  411.                   this.alfa = Math.PI / (double)this.field_14;
  412.                }
  413.  
  414.                for(this.field_1 = 0; this.field_1 < this.field_3 * this.field_4; ++this.field_1) {
  415.                   this.isle[this.field_1] = this.field_20[1][this.field_1];
  416.                   double var1 = (double)this.field_16 - Math.floor((double)(this.field_1 / this.field_3));
  417.                   double var3 = (double)(this.field_1 % this.field_3 - this.field_15);
  418.                   double var5 = Math.atan(var1 / var3);
  419.                   if (var5 < (double)0.0F) {
  420.                      var5 *= (double)-1.0F;
  421.                   }
  422.  
  423.                   if (this.modd == 0 && var1 < (double)0.0F & var3 < (double)0.0F) {
  424.                      var5 += Math.PI;
  425.                   }
  426.  
  427.                   if ((this.modd == 0 || this.modd == 1) && var1 >= (double)0.0F & var3 < (double)0.0F) {
  428.                      var5 = Math.PI - var5;
  429.                   }
  430.  
  431.                   if (this.modd == 0 && var1 < (double)0.0F & var3 >= (double)0.0F) {
  432.                      var5 = (Math.PI * 2D) - var5;
  433.                   }
  434.  
  435.                   if (this.modd == 1 && var1 < (double)0.0F & var3 >= (double)0.0F) {
  436.                      var5 = Math.PI - var5;
  437.                   }
  438.  
  439.                   this.acd[this.field_1] = var5 - 0.0031415926535897933;
  440.                   if (var5 < (double)0.0F) {
  441.                      var5 = (double)0.0F;
  442.                   }
  443.                }
  444.  
  445.                this.field_17 = ((Component)this).createImage(this.MIS);
  446.                this.durum = 2;
  447.                ((Component)this).repaint();
  448.                this.field_5 = 1;
  449.                this.field_1 = 0;
  450.                this.field_6 = 0;
  451.                this.cit = -1;
  452.  
  453.                while(true) {
  454.                   if (this.cit != this.field_6) {
  455.                      this.cit = this.field_6;
  456.                      this.field_9 = this.field_8;
  457.                   } else {
  458.                      this.field_9 = this.dly;
  459.                   }
  460.  
  461.                   try {
  462.                      Thread.sleep((long)this.field_9);
  463.                   } catch (InterruptedException var8) {
  464.                      ((Throwable)var8).printStackTrace();
  465.                   }
  466.  
  467.                   this.field_7 = this.field_6 % this.num + 1;
  468.                   this.md2 = this.field_7 % this.num + 1;
  469.                   this.field_1 = 0;
  470.                   if (this.field_5 > this.field_14 / 2) {
  471.                      this.crr = this.md2;
  472.                      this.ssts();
  473.                      this.smc();
  474.                   } else {
  475.                      this.crr = this.field_7;
  476.                   }
  477.  
  478.                   this.alfasin = Math.sin((double)this.field_5 * this.alfa);
  479.                   if (this.field_5 == this.field_14) {
  480.                      if (this.modd == 0) {
  481.                         this.alfasin = (Math.PI * 2D);
  482.                      } else {
  483.                         this.alfasin = Math.PI;
  484.                      }
  485.                   }
  486.  
  487.                   for(this.field_1 = 0; this.field_1 < this.field_3 * this.field_4; ++this.field_1) {
  488.                      if (this.acd[this.field_1] <= (double)this.field_5 * this.alfa) {
  489.                         this.isle[this.field_1] = this.field_20[this.md2][this.field_1];
  490.                      } else {
  491.                         this.isle[this.field_1] = this.field_20[this.field_7][this.field_1];
  492.                      }
  493.                   }
  494.  
  495.                   this.isle[this.field_3 * this.field_16 + this.field_15] = this.field_20[this.md2][this.field_3 * this.field_16 + this.field_15];
  496.                   ++this.field_5;
  497.                   if (this.field_5 > this.field_14) {
  498.                      this.field_5 = 1;
  499.                      ++this.field_6;
  500.                   }
  501.  
  502.                   ((Component)this).repaint();
  503.                }
  504.             }
  505.  
  506.             this.durum = 4;
  507.             ((Component)this).repaint();
  508.          }
  509.       }
  510.    }
  511. }
  512.