home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / CoolMap / COMMON.CLA (.txt) < prev    next >
Encoding:
Java Class File  |  1996-09-17  |  9.2 KB  |  431 lines

  1. import java.applet.Applet;
  2. import java.applet.AudioClip;
  3. import java.awt.Color;
  4. import java.awt.Component;
  5. import java.awt.Container;
  6. import java.awt.Frame;
  7. import java.awt.Graphics;
  8. import java.awt.Image;
  9. import java.awt.MediaTracker;
  10. import java.net.URL;
  11. import java.util.Date;
  12. import java.util.Random;
  13.  
  14. class common {
  15.    static int soundOff;
  16.    static int whichStep;
  17.    static Color[] theColors = new Color[13];
  18.    static String teststring;
  19.    static boolean inAd;
  20.    int clientX;
  21.    int clientY;
  22.    int clientW;
  23.    int clientH;
  24.    int whichBase;
  25.    String background;
  26.    String bgcolor;
  27.    AudioClip[] hideSound;
  28.    int numHideSound;
  29.    String[] hideSoundName = new String[50];
  30.    int delayLoadAudio = 100;
  31.    Applet m_parent;
  32.    int bState;
  33.    String action = "URL";
  34.    int releaseLevel;
  35.    int TheShareware = 2;
  36.    int TheAdware = 1;
  37.    int TheDemo;
  38.    String Name;
  39.    int showAd = 1000;
  40.    int showAdCount;
  41.    // $FF: renamed from: wb int
  42.    int field_0;
  43.    // $FF: renamed from: hb int
  44.    int field_1;
  45.    // $FF: renamed from: w int
  46.    int field_2;
  47.    // $FF: renamed from: h int
  48.    int field_3;
  49.    String mmmm;
  50.    Graphics gBufBK;
  51.    Image bufBK;
  52.    boolean bBackgroundOK = false;
  53.    Color colForeground;
  54.    String colForegroundName = "STATIC";
  55.    Color colBackground;
  56.    String colBackgroundName;
  57.    Color fixCaptionColor;
  58.    String fixCaptionColorName = "STATIC";
  59.    Image imgBackground;
  60.    // $FF: renamed from: rr java.util.Random
  61.    Random field_4;
  62.    // $FF: renamed from: dd java.util.Date
  63.    static Date field_5 = new Date();
  64.    int disableLevel = 2;
  65.    static String myAd = "GO Coolshare!! You will explore COOL: Free Java applets, the best screen savers in the world, Cool resource to build your web pages, date through the Web, and more!! Go http://www.aimnet.com/~markqian to get them!!";
  66.    static String myAddress = "http://www.coolshare.com";
  67.    String whatWare = "evaluateShareware";
  68.    String homeURL;
  69.    URL uhomeURL;
  70.    String TheStatus;
  71.    String aboutMe = "Go http://www.coolshare.com  to get COOL shareware, applets, and more COOL stuff!!";
  72.    MediaTracker tracker;
  73.  
  74.    public common(Applet var1) {
  75.       this.m_parent = var1;
  76.       theColors[0] = Color.black;
  77.       theColors[1] = Color.blue;
  78.       theColors[2] = Color.cyan;
  79.       theColors[3] = Color.darkGray;
  80.       theColors[4] = Color.gray;
  81.       theColors[5] = Color.green;
  82.       theColors[6] = Color.lightGray;
  83.       theColors[7] = Color.magenta;
  84.       theColors[8] = Color.orange;
  85.       theColors[9] = Color.pink;
  86.       theColors[10] = Color.red;
  87.       theColors[11] = Color.white;
  88.       theColors[12] = Color.yellow;
  89.       this.field_4 = new Random();
  90.       this.field_4.setSeed((long)(field_5.getMinutes() * field_5.getSeconds()));
  91.    }
  92.  
  93.    public void turnSoundOff(int var1) {
  94.       soundOff = var1;
  95.    }
  96.  
  97.    public void doSound(int var1) {
  98.       System.out.println("Enter doSound");
  99.       if (soundOff != 1 && var1 <= this.numHideSound && var1 >= 1) {
  100.          if (this.hideSound[var1] != null) {
  101.             this.hideSound[var1].play();
  102.          } else {
  103.             System.out.println("hideSound[" + var1 + "]=null");
  104.          }
  105.       } else {
  106.          if (soundOff == 1) {
  107.             System.out.println("soundOff==1");
  108.          }
  109.  
  110.          if (var1 > this.numHideSound) {
  111.             System.out.println("which>numHideSound");
  112.          }
  113.  
  114.          if (var1 < 1) {
  115.             System.out.println("which<1");
  116.          }
  117.  
  118.          System.out.println("Before return");
  119.       }
  120.    }
  121.  
  122.    public void drawButtonBorder(int var1, Graphics var2, int var3, int var4, int var5, int var6) {
  123.       int[] var7 = new int[6];
  124.       int[] var8 = new int[6];
  125.       if (var1 == 0) {
  126.          var2.setColor(Color.white);
  127.       } else {
  128.          var2.setColor(Color.darkGray);
  129.       }
  130.  
  131.       var7[0] = 0;
  132.       var8[0] = 0;
  133.       var7[1] = 0;
  134.       var8[1] = var4;
  135.       var7[2] = var5;
  136.       var8[2] = var4 - var6;
  137.       var7[3] = var5;
  138.       var8[3] = var6;
  139.       var7[4] = var3 - var5;
  140.       var8[4] = var6;
  141.       var7[5] = var3;
  142.       var8[5] = 0;
  143.       var2.fillPolygon(var7, var8, 6);
  144.       if (var1 == 1) {
  145.          var2.setColor(Color.white);
  146.       } else {
  147.          var2.setColor(Color.darkGray);
  148.       }
  149.  
  150.       var2.drawPolygon(var7, var8, 6);
  151.       if (var1 == 0) {
  152.          var2.setColor(Color.darkGray);
  153.       } else {
  154.          var2.setColor(Color.white);
  155.       }
  156.  
  157.       var2.fillRect(var5, var6, var3, var4);
  158.       var2.setColor(Color.lightGray);
  159.       var2.fillRect(var5, var6, var3 - 2 * var5, var4 - 2 * var6);
  160.       var2.drawLine(0, 0, var5, var6);
  161.       if (var1 == 0) {
  162.          var2.setColor(Color.darkGray);
  163.       } else {
  164.          var2.setColor(Color.white);
  165.       }
  166.  
  167.       var7[0] = var3;
  168.       var8[0] = var4;
  169.       var7[1] = 0;
  170.       var8[1] = var4;
  171.       var7[2] = var5;
  172.       var8[2] = var4 - var6;
  173.       var7[3] = var3 - var5;
  174.       var8[3] = var4 - var6;
  175.       var7[4] = var3 - var5;
  176.       var8[4] = var6;
  177.       var7[5] = var3;
  178.       var8[5] = 0;
  179.       var2.fillPolygon(var7, var8, 6);
  180.       var2.drawLine(0, 0, var5, var6);
  181.       if (var1 == 1) {
  182.          var2.setColor(Color.darkGray);
  183.       } else {
  184.          var2.setColor(Color.white);
  185.       }
  186.  
  187.       var2.drawPolygon(var7, var8, 6);
  188.       if (var1 == 0) {
  189.          var2.setColor(Color.white);
  190.       } else {
  191.          var2.setColor(Color.darkGray);
  192.       }
  193.  
  194.       var2.drawLine(var3 - var5, var4 - var6, var3, var4);
  195.       var2.setColor(Color.lightGray);
  196.       var7[0] = var5;
  197.       var8[0] = var6;
  198.       var7[1] = var3 - var5;
  199.       var8[1] = var6;
  200.       var7[2] = var3 - var5;
  201.       var8[2] = var4 - var6;
  202.       var7[3] = var5;
  203.       var8[3] = var4 - var6;
  204.       var2.fillPolygon(var7, var8, 4);
  205.    }
  206.  
  207.    Color getColorFromParam(String var1, Color var2) {
  208.       byte var7 = 0;
  209.       String var3;
  210.       if ((var3 = this.m_parent.getParameter(var1)) == null) {
  211.          return var2;
  212.       } else {
  213.          if (var3.startsWith("#")) {
  214.             var7 = 1;
  215.          }
  216.  
  217.          int var4;
  218.          int var5;
  219.          int var6;
  220.          try {
  221.             var4 = Integer.parseInt(var3.substring(var7, 2 + var7), 16);
  222.             var6 = Integer.parseInt(var3.substring(2 + var7, 4 + var7), 16);
  223.             var5 = Integer.parseInt(var3.substring(4 + var7, 6 + var7), 16);
  224.          } catch (Exception var8) {
  225.             System.out.println("parseInt failed");
  226.             return var2;
  227.          }
  228.  
  229.          return new Color(var4, var6, var5);
  230.       }
  231.    }
  232.  
  233.    public void iniCommon() {
  234.       Date var3 = new Date();
  235.       this.field_4.setSeed((long)(var3.getMinutes() * var3.getSeconds()));
  236.       String var1 = this.m_parent.getParameter("whatWare");
  237.       this.whatWare = var1 != null ? var1 : "evaluateShareware";
  238.       if (!this.whatWare.equalsIgnoreCase("evaluateShareware") && !this.whatWare.equalsIgnoreCase("AdWare")) {
  239.          this.whatWare = "evaluateShareware";
  240.       }
  241.  
  242.       if (this.releaseLevel == this.TheShareware) {
  243.          this.disableLevel = 0;
  244.       } else if (this.whatWare.equalsIgnoreCase("AdWare")) {
  245.          this.disableLevel = 1;
  246.       } else if ((var3.getHours() < 7 || var3.getHours() > 18) && this.releaseLevel <= this.TheShareware && this.releaseLevel >= this.TheAdware) {
  247.          this.disableLevel = 0;
  248.       } else {
  249.          this.disableLevel = 2;
  250.       }
  251.  
  252.       this.tracker = new MediaTracker(this.m_parent);
  253.       var1 = this.m_parent.getParameter("action");
  254.       this.action = var1 != null ? var1 : "URL";
  255.       if (!this.action.equalsIgnoreCase("URL") && !this.action.equalsIgnoreCase("SoundSwitch")) {
  256.          this.action = "URL";
  257.       }
  258.  
  259.       var1 = this.m_parent.getParameter("nice");
  260.       if (var1 != null) {
  261.          this.showAd *= 2;
  262.       }
  263.  
  264.       var1 = this.m_parent.getParameter("status_text");
  265.       if (this.disableLevel > 0) {
  266.          this.TheStatus = this.aboutMe;
  267.       }
  268.  
  269.       var1 = this.m_parent.getParameter("on_click");
  270.       if (this.disableLevel == 2) {
  271.          this.homeURL = myAddress;
  272.       } else {
  273.          this.homeURL = var1 != null ? var1 : myAddress;
  274.       }
  275.  
  276.       var1 = this.m_parent.getParameter("delayLoadAudio");
  277.       this.delayLoadAudio = var1 == null ? 100 : Integer.valueOf(var1);
  278.       var1 = this.m_parent.getParameter("whichBase");
  279.       this.whichBase = var1 == null ? 0 : Integer.valueOf(var1);
  280.       int var2 = 0;
  281.  
  282.       do {
  283.          ++var2;
  284.          this.hideSoundName[var2] = this.m_parent.getParameter("hideSound" + var2);
  285.       } while(this.hideSoundName[var2] != null);
  286.  
  287.       this.numHideSound = var2 - 1;
  288.       if (this.numHideSound > 0) {
  289.          this.hideSound = new AudioClip[this.numHideSound + 1];
  290.  
  291.          for(int var12 = 1; var12 <= this.numHideSound; ++var12) {
  292.             this.hideSound[var12] = null;
  293.          }
  294.       }
  295.  
  296.       var1 = this.m_parent.getParameter("borderWidth");
  297.       this.field_0 = var1 == null ? 0 : Integer.valueOf(var1);
  298.       var1 = this.m_parent.getParameter("borderHeight");
  299.       this.field_1 = var1 == null ? 0 : Integer.valueOf(var1);
  300.       if (this.m_parent.size().width > 0 && this.m_parent.size().height > 0) {
  301.          this.clientW = this.m_parent.size().width - 2 * this.field_0;
  302.          this.clientH = this.m_parent.size().height - 2 * this.field_1;
  303.          this.clientX = this.field_0;
  304.          this.clientY = this.field_1;
  305.          this.bufBK = this.m_parent.createImage(this.m_parent.size().width, this.m_parent.size().height);
  306.          this.gBufBK = this.bufBK.getGraphics();
  307.       } else {
  308.          this.clientW = 0;
  309.       }
  310.  
  311.       this.setColors("bgcolor");
  312.       this.setColors("fgcolor");
  313.       this.background = this.m_parent.getParameter("background");
  314.       if (this.background != null && !this.background.equals("")) {
  315.          if (this.whichBase == 0) {
  316.             this.imgBackground = this.m_parent.getImage(this.m_parent.getDocumentBase(), this.background);
  317.          } else {
  318.             this.imgBackground = this.m_parent.getImage(this.m_parent.getCodeBase(), this.background);
  319.          }
  320.       }
  321.  
  322.       if (this.imgBackground != null) {
  323.          this.bBackgroundOK = true;
  324.          this.tracker.addImage(this.imgBackground, 0);
  325.       }
  326.  
  327.    }
  328.  
  329.    public void loadHideSound() {
  330.       System.out.println("Enter loadHideSound");
  331.       if (this.numHideSound > 0) {
  332.          for(int var1 = 1; var1 <= this.numHideSound; ++var1) {
  333.             if (this.whichBase == 0) {
  334.                this.hideSound[var1] = this.m_parent.getAudioClip(this.m_parent.getDocumentBase(), this.hideSoundName[var1]);
  335.             } else {
  336.                this.hideSound[var1] = this.m_parent.getAudioClip(this.m_parent.getCodeBase(), this.hideSoundName[var1]);
  337.             }
  338.  
  339.             System.out.println("hideSound[" + var1 + "]=" + this.hideSound[var1]);
  340.          }
  341.       }
  342.  
  343.    }
  344.  
  345.    public void maintainBK() {
  346.       int var1 = 0;
  347.       int var2 = 0;
  348.       if (this.bBackgroundOK && this.imgBackground != null) {
  349.          if ((var1 = this.imgBackground.getWidth(this.m_parent)) > 0 && (var2 = this.imgBackground.getHeight(this.m_parent)) > 0) {
  350.             for(int var8 = 0; var8 < this.bufBK.getWidth(this.m_parent); var8 += var1) {
  351.                for(int var9 = 0; var9 < this.bufBK.getHeight(this.m_parent); var9 += var2) {
  352.                   this.m_parent.showStatus("Applet is preparing background images...");
  353.                   this.gBufBK.drawImage(this.imgBackground, var8, var9, this.m_parent);
  354.                }
  355.             }
  356.  
  357.             return;
  358.          }
  359.       } else {
  360.          Color var3;
  361.          if (this.colBackgroundName.equalsIgnoreCase("vary")) {
  362.             Date var4 = new Date();
  363.             this.field_4.setSeed((long)(var4.getMinutes() * var4.getSeconds()));
  364.             float var5 = this.field_4.nextFloat();
  365.             var3 = theColors[(int)(var5 * 12.0F)];
  366.          } else {
  367.             var3 = this.colBackground;
  368.          }
  369.  
  370.          this.gBufBK.setColor(var3);
  371.          this.gBufBK.fillRect(0, 0, this.bufBK.getWidth(this.m_parent), this.bufBK.getHeight(this.m_parent));
  372.       }
  373.  
  374.    }
  375.  
  376.    public Color getTheColor(String var1, int var2) {
  377.       if (var1.equalsIgnoreCase("vary")) {
  378.          return theColors[(int)(this.field_4.nextFloat() * 12.0F)];
  379.       } else if (var2 == 0) {
  380.          return this.colForeground;
  381.       } else {
  382.          return var2 == 1 ? this.colBackground : this.fixCaptionColor;
  383.       }
  384.    }
  385.  
  386.    public void setColors(String var1) {
  387.       Object var2 = null;
  388.       String var3 = this.m_parent.getParameter(var1);
  389.       if (var1.equalsIgnoreCase("fgcolor")) {
  390.          if (var3 != null && var3.equalsIgnoreCase("null")) {
  391.             var3 = null;
  392.          }
  393.  
  394.          this.colForegroundName = var3 != null ? var3 : "STATIC";
  395.          if (!this.colForegroundName.equalsIgnoreCase("STATIC") && !this.colForegroundName.equalsIgnoreCase("vary")) {
  396.             this.colForeground = this.getColorFromParam("fgcolor", Color.black);
  397.             return;
  398.          }
  399.       } else if (var1.equalsIgnoreCase("bgcolor")) {
  400.          if (var3 != null && var3.equalsIgnoreCase("null")) {
  401.             var3 = null;
  402.          }
  403.  
  404.          this.bgcolor = var3;
  405.          this.colBackgroundName = var3 != null ? var3 : "STATIC";
  406.          if (!this.colBackgroundName.equalsIgnoreCase("STATIC") && !this.colBackgroundName.equalsIgnoreCase("vary")) {
  407.             this.colBackground = this.getColorFromParam(var1, Color.pink);
  408.             return;
  409.          }
  410.       } else if (var1.equalsIgnoreCase("fixCaptionColor")) {
  411.          if (var3 != null && var3.equalsIgnoreCase("null")) {
  412.             var3 = null;
  413.          }
  414.  
  415.          this.fixCaptionColorName = var3 != null ? var3 : "STATIC";
  416.          if (!this.fixCaptionColorName.equalsIgnoreCase("STATIC") && !this.fixCaptionColorName.equalsIgnoreCase("vary")) {
  417.             this.fixCaptionColor = this.getColorFromParam(var1, Color.black);
  418.          }
  419.       }
  420.  
  421.    }
  422.  
  423.    public void setTheCursor(int var1) {
  424.       Container var2;
  425.       for(var2 = this.m_parent.getParent(); !(var2 instanceof Frame); var2 = ((Component)var2).getParent()) {
  426.       }
  427.  
  428.       ((Frame)var2).setCursor(var1);
  429.    }
  430. }
  431.