home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 22 / AMUG_22-1.ISO / Files / Internet / Java / applet-iconbar-1.0.sit / applet-iconbar / afIconBar.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-09-10  |  9.9 KB  |  417 lines  |  [Clss/CWIE]

  1. import java.applet.Applet;
  2. import java.applet.AppletContext;
  3. import java.applet.AudioClip;
  4. import java.awt.Color;
  5. import java.awt.Component;
  6. import java.awt.Container;
  7. import java.awt.Dimension;
  8. import java.awt.Event;
  9. import java.awt.Graphics;
  10. import java.awt.Image;
  11. import java.awt.Label;
  12. import java.awt.LayoutManager;
  13. import java.awt.MediaTracker;
  14. import java.awt.image.ImageObserver;
  15. import java.io.IOException;
  16. import java.net.MalformedURLException;
  17. import java.net.URL;
  18.  
  19. public class afIconBar extends Applet {
  20.    private Image offScreenImage;
  21.    private Dimension offScreenSize;
  22.    private Graphics offScreenGraphics;
  23.    boolean fullb;
  24.    boolean Sinkin;
  25.    boolean Bolder;
  26.    String Face = "Helvetica";
  27.    AudioClip clip;
  28.    Label discription = new Label("");
  29.    private boolean m_boo;
  30.    String bbb = "OK";
  31.    private String m_Image = "task.gif";
  32.    private String m_Frame = "_self";
  33.    private int m_Numbers;
  34.    private Image m_BackImage;
  35.    private int m_PixWid = 40;
  36.    private String m_PixSpace = "10";
  37.    private String m_UserCode = "gdafggb";
  38.    private String m_Backsound = "gogo.au";
  39.    private String[] m_Url;
  40.    private String[] m_Description;
  41.    private String[] m_LinkName;
  42.    afIcon2[] theButt;
  43.    Image tempo;
  44.    private final String PARAM_Image = "Image";
  45.    private final String PARAM_Frame = "Frame";
  46.    private final String PARAM_NoLinks = "NoLinks";
  47.    private final String PARAM_BackImage = "BackImage";
  48.    private final String PARAM_PixWid = "PixWid";
  49.    private final String PARAM_PixSpace = "PixSpace";
  50.    private final String PARAM_UserCode = "UserCode";
  51.    private final String PARAM_Backsound = "Backsound";
  52.    boolean vCvCv;
  53.    Color nickCol2;
  54.    boolean itrocks;
  55.    Color nickCol;
  56.  
  57.    public afIconBar() {
  58.       this.nickCol2 = Color.black;
  59.    }
  60.  
  61.    public void stop() {
  62.    }
  63.  
  64.    public boolean overthetop(int val) {
  65.       if (this.vCvCv) {
  66.          ((Applet)this).showStatus(this.m_Description[val]);
  67.       } else {
  68.          ((Applet)this).showStatus("This copy of IconBar is unlicensed please remove it from your page! go to http://silk.webware.co.nz");
  69.       }
  70.  
  71.       return true;
  72.    }
  73.  
  74.    public boolean mouseEnter(Event evt, int x, int y) {
  75.       return true;
  76.    }
  77.  
  78.    boolean ftxx() {
  79.       int fxtx = 1975;
  80.       String hexstart = "f-";
  81.       String hexfin = "1I";
  82.       boolean xzxzvv = true;
  83.       URL OoooOo = ((Applet)this).getDocumentBase();
  84.       String Oxo = OoooOo.getProtocol();
  85.       int pp = Oxo.compareTo("http");
  86.       if (pp != 0) {
  87.          xzxzvv = false;
  88.          return true;
  89.       } else {
  90.          xzxzvv = true;
  91.          String xzxzv = "";
  92.          String param = ((Applet)this).getParameter("RegistrationID");
  93.          if (param == null) {
  94.             return false;
  95.          } else {
  96.             if (param != null) {
  97.                xzxzv = param;
  98.             }
  99.  
  100.             xzxzv = xzxzv.trim();
  101.             String hexa4 = "";
  102.             int lengthh = xzxzv.length();
  103.             String bitof = "";
  104.             int iii = lengthh;
  105.             if (lengthh <= 9) {
  106.                return false;
  107.             } else {
  108.                try {
  109.                   for(int ii = 0; ii <= lengthh; ++ii) {
  110.                      --iii;
  111.                      if (iii <= 0) {
  112.                         iii = 0;
  113.                      }
  114.  
  115.                      bitof = xzxzv.substring(iii, lengthh - ii);
  116.                      hexa4 = hexa4 + bitof;
  117.                   }
  118.                } catch (Exception var31) {
  119.                   return false;
  120.                }
  121.  
  122.                int hexa7 = hexa4.length();
  123.                String Licen = hexa4.substring(0, 2);
  124.                String ProdnVers = hexa4.substring(hexa7 - 2, hexa7);
  125.                String rawNum = hexa4.substring(2, hexa7 - 3);
  126.                int moveto = rawNum.indexOf("-");
  127.                if (moveto < 0) {
  128.                   return false;
  129.                } else {
  130.                   String bitup = rawNum.substring(0, moveto);
  131.                   String bitdn = rawNum.substring(moveto + 1, rawNum.length());
  132.                   String Num = bitup + bitdn;
  133.                   (new StringBuffer()).append("Code:").append(xzxzv).append(" The Reverse:").append(hexa4).append(" licence:").append(Licen).append("  Version").append(ProdnVers).append("\n").append(rawNum).append("  ").append(Num).toString();
  134.                   int original = 1;
  135.  
  136.                   try {
  137.                      original = Integer.parseInt(Num);
  138.                   } catch (Exception var30) {
  139.                      Num = "0";
  140.                      return false;
  141.                   }
  142.  
  143.                   int Result = 0;
  144.                   Result = original % fxtx;
  145.                   boolean rtclassconvert = false;
  146.                   rtclassconvert = hexfin.equals(ProdnVers);
  147.                   boolean KeepCool = true;
  148.                   KeepCool = hexstart.equals(Licen);
  149.                   String fallornerd = "not Registered";
  150.                   if (Result == 0 && rtclassconvert && KeepCool) {
  151.                      fallornerd = "Licenced";
  152.                      return true;
  153.                   } else {
  154.                      return false;
  155.                   }
  156.                }
  157.             }
  158.          }
  159.       }
  160.    }
  161.  
  162.    public boolean mouseExit(Event evt, int x, int y) {
  163.       return true;
  164.    }
  165.  
  166.    public void paint(Graphics g) {
  167.       g.setColor(this.nickCol);
  168.       g.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
  169.       if (this.itrocks) {
  170.          g.fill3DRect(0, 0, ((Component)this).size().width, ((Component)this).size().height, false);
  171.       }
  172.  
  173.    }
  174.  
  175.    public boolean mouseUp(Event evt, int x, int y) {
  176.       return true;
  177.    }
  178.  
  179.    public void distroy() {
  180.       this.offScreenGraphics.dispose();
  181.    }
  182.  
  183.    public final synchronized void update(Graphics g) {
  184.       Dimension d = ((Component)this).size();
  185.       if (this.offScreenImage == null || d.width != this.offScreenSize.width || d.height != this.offScreenSize.height) {
  186.          this.offScreenImage = ((Component)this).createImage(d.width, d.height);
  187.          this.offScreenSize = d;
  188.          this.offScreenGraphics = this.offScreenImage.getGraphics();
  189.       }
  190.  
  191.       this.paint(this.offScreenGraphics);
  192.       g.drawImage(this.offScreenImage, 0, 0, (ImageObserver)null);
  193.    }
  194.  
  195.    public void start() {
  196.       ((Component)this).repaint();
  197.    }
  198.  
  199.    public String getAppletInfo() {
  200.       return "Name: afIconBar\r\n" + "Author: Nick Harrow\r\n" + "Created with Microsoft Visual J++ Version 1.1";
  201.    }
  202.  
  203.    public boolean buttonclick(int val) {
  204.       if (this.clip != null) {
  205.          this.clip.play();
  206.       }
  207.  
  208.       AppletContext ac = ((Applet)this).getAppletContext();
  209.  
  210.       try {
  211.          URL yahoo = new URL(((Applet)this).getDocumentBase(), this.m_Url[val]);
  212.          ((Applet)this).showStatus("Opening page:" + this.m_Url[val]);
  213.          ac.showDocument(yahoo, this.m_Frame);
  214.          return true;
  215.       } catch (MalformedURLException var5) {
  216.          ((Applet)this).showStatus("This has not been referenced correctly");
  217.          return false;
  218.       } catch (IOException var6) {
  219.          return false;
  220.       }
  221.    }
  222.  
  223.    public boolean mouseDown(Event evt, int x, int y) {
  224.       return true;
  225.    }
  226.  
  227.    public void init() {
  228.       this.vCvCv = this.ftxx();
  229.       String Backgroundgraph = ((Applet)this).getParameter("IconImage");
  230.       if (Backgroundgraph != null) {
  231.          MediaTracker mt = new MediaTracker(this);
  232.          URL db = ((Applet)this).getDocumentBase();
  233.          this.tempo = ((Applet)this).getImage(db, Backgroundgraph);
  234.          mt.addImage(this.tempo, 0);
  235.  
  236.          try {
  237.             mt.waitForID(0);
  238.          } catch (InterruptedException var8) {
  239.             this.m_BackImage = null;
  240.          }
  241.  
  242.          this.m_BackImage = null;
  243.       }
  244.  
  245.       ((Container)this).setLayout((LayoutManager)null);
  246.       String param = ((Applet)this).getParameter("LinkNameFont");
  247.       if (param != null) {
  248.          this.Face = param;
  249.       }
  250.  
  251.       param = ((Applet)this).getParameter("LinkNameCenter");
  252.       if (param != null) {
  253.          this.m_boo = Boolean.valueOf(param);
  254.       }
  255.  
  256.       param = ((Applet)this).getParameter("BarFramed");
  257.       if (param != null) {
  258.          this.itrocks = Boolean.valueOf(param);
  259.       }
  260.  
  261.       param = ((Applet)this).getParameter("AllUp");
  262.       if (param != null) {
  263.          this.fullb = Boolean.valueOf(param);
  264.       }
  265.  
  266.       param = ((Applet)this).getParameter("LinkNameSink");
  267.       if (param != null) {
  268.          this.Sinkin = Boolean.valueOf(param);
  269.       }
  270.  
  271.       param = ((Applet)this).getParameter("LinkNameBold");
  272.       if (param != null) {
  273.          this.Bolder = Boolean.valueOf(param);
  274.       }
  275.  
  276.       param = ((Applet)this).getParameter("NoLinks");
  277.       if (param != null) {
  278.          this.m_Numbers = Integer.parseInt(param);
  279.       }
  280.  
  281.       if (this.m_Numbers > 7) {
  282.          this.m_Numbers = 7;
  283.       }
  284.  
  285.       if (this.m_Numbers < 1) {
  286.          this.m_Numbers = 1;
  287.       }
  288.  
  289.       this.m_Url = new String[this.m_Numbers + 1];
  290.  
  291.       for(int i = 0; i <= this.m_Numbers; ++i) {
  292.          param = ((Applet)this).getParameter("Url" + i);
  293.          if (param != null) {
  294.             this.m_Url[i] = param;
  295.          } else if (param == null) {
  296.             this.m_Url[i] = "http://nothing";
  297.          }
  298.       }
  299.  
  300.       this.m_Description = new String[this.m_Numbers + 1];
  301.  
  302.       for(int i = 0; i <= this.m_Numbers; ++i) {
  303.          param = ((Applet)this).getParameter("Description" + i);
  304.          if (param != null) {
  305.             this.m_Description[i] = param;
  306.          } else {
  307.             this.m_Description[i] = this.m_Url[i];
  308.          }
  309.       }
  310.  
  311.       this.m_LinkName = new String[this.m_Numbers + 1];
  312.  
  313.       for(int i = 0; i <= this.m_Numbers; ++i) {
  314.          String itter = "LinkName" + i;
  315.          param = ((Applet)this).getParameter(itter);
  316.          if (param != null) {
  317.             this.m_LinkName[i] = param;
  318.          } else {
  319.             this.m_LinkName[i] = "nothing";
  320.          }
  321.       }
  322.  
  323.       this.theButt = new afIcon2[this.m_Numbers + 1];
  324.       boolean vertal = false;
  325.       int heiver = ((Component)this).size().height;
  326.       if (heiver > 60) {
  327.          vertal = true;
  328.       }
  329.  
  330.       for(int i = 0; i <= this.m_Numbers - 1; ++i) {
  331.          this.theButt[i] = new afIcon2(i + 1, this, this.tempo, this.m_LinkName[i + 1], this.m_Description[i + 1], this.m_boo);
  332.          this.theButt[i].resize(75, 50);
  333.          if (!vertal) {
  334.             this.theButt[i].move(1 + i * 75, 1);
  335.          } else {
  336.             this.theButt[i].move(1, 1 + i * 50);
  337.          }
  338.  
  339.          ((Container)this).add(this.theButt[i]);
  340.       }
  341.  
  342.       param = ((Applet)this).getParameter("PixWid");
  343.       if (param != null) {
  344.          this.m_PixWid = Integer.parseInt(param);
  345.       }
  346.  
  347.       param = ((Applet)this).getParameter("PixSpace");
  348.       if (param != null) {
  349.          this.m_PixSpace = param;
  350.       }
  351.  
  352.       param = ((Applet)this).getParameter("Image");
  353.       if (param != null) {
  354.          this.m_Image = param;
  355.       }
  356.  
  357.       param = ((Applet)this).getParameter("ClickSound");
  358.       if (param != null) {
  359.          this.clip = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), param);
  360.       } else {
  361.          this.clip = null;
  362.       }
  363.  
  364.       param = ((Applet)this).getParameter("Frame");
  365.       if (param != null) {
  366.          this.m_Frame = param;
  367.       }
  368.  
  369.       String colin = "c5c5c5";
  370.       param = ((Applet)this).getParameter("BackColor");
  371.       if (param != null) {
  372.          colin = param;
  373.       }
  374.  
  375.       String marvin = "000000";
  376.       param = ((Applet)this).getParameter("LinkNameColor");
  377.       if (param != null) {
  378.          marvin = param;
  379.       }
  380.  
  381.       param = ((Applet)this).getParameter("UserCode");
  382.       if (param != null) {
  383.          this.m_UserCode = param;
  384.       }
  385.  
  386.       param = ((Applet)this).getParameter("Backsound");
  387.       if (param != null) {
  388.          this.m_Backsound = param;
  389.       }
  390.  
  391.       this.nickCol = this.MaketheColor(colin);
  392.       this.nickCol2 = this.MaketheColor(marvin);
  393.    }
  394.  
  395.    public boolean handleEvent(Event evt) {
  396.       ((Component)this).repaint();
  397.       return true;
  398.    }
  399.  
  400.    Color MaketheColor(String col) {
  401.       String parameterValue = col;
  402.       if (col.startsWith("#")) {
  403.          parameterValue = col.substring(1);
  404.       }
  405.  
  406.       Color result;
  407.       try {
  408.          int intValue = Integer.parseInt(parameterValue, 16);
  409.          result = new Color(intValue);
  410.       } catch (NumberFormatException var7) {
  411.          result = new Color(3);
  412.       }
  413.  
  414.       return result;
  415.    }
  416. }
  417.