home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1998 October / DPPCPRO1098.ISO / Hotdog / files / snagpack.exe / BROADWAY.CLASS (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-21  |  12.8 KB  |  837 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.Font;
  6. import java.awt.Graphics;
  7. import java.awt.Image;
  8. import java.util.Date;
  9. import java.util.NoSuchElementException;
  10. import java.util.StringTokenizer;
  11.  
  12. public class broadway extends Applet implements Runnable {
  13.    private Thread ledThread;
  14.    private Color ledRimColor;
  15.    private Color backGroundColor;
  16.    private Color borderColor;
  17.    private Color appletColor;
  18.    private int ledWidth = 10;
  19.    private int ledHeight = 10;
  20.    private int spaceWidth = 1;
  21.    private int ledDim;
  22.    private int startPosition;
  23.    int startPositionX;
  24.    int startPositionY;
  25.    private int letterSpace = 5;
  26.    private int blinkcount;
  27.    private boolean blinkOff = true;
  28.    private boolean blink;
  29.    private int displayWidth;
  30.    private int displayHeight;
  31.    private int ledPosition;
  32.    private boolean testPosInit = true;
  33.    private int borderTotalWidth;
  34.    private int borderOuter = 2;
  35.    private int borderSize = 2;
  36.    private int borderInner = 2;
  37.    private boolean borderRaised = true;
  38.    private Color ledOffColor;
  39.    private int maxLedHeightArray;
  40.    private int maxLedWidthArray;
  41.    private boolean brokenLed;
  42.    private boolean oval;
  43.    private String fontFile;
  44.    private String scriptFile;
  45.    private ldscript theScript;
  46.    private cmddata command;
  47.    private letters letterFont;
  48.    private textmess theMessage;
  49.    private int sleepTime;
  50.    private boolean nextFuncReady;
  51.    private boolean readyToPaint;
  52.    private boolean firstTime;
  53.    private boolean userPause;
  54.    private Image offImage;
  55.    private Graphics offGraphics;
  56.    private Date myDate;
  57.    private int date;
  58.    private int month;
  59.    private int year;
  60.    private boolean initialised;
  61.    private boolean unreg;
  62.    private boolean regError;
  63.    private boolean paramError;
  64.    private boolean fileError;
  65.    private boolean serialIdError;
  66.    static String paramErrorString = "HTML parameter error: ";
  67.    private String growingString;
  68.    private boolean dbg2;
  69.    private boolean dbg3;
  70.  
  71.    public void stop() {
  72.       if (this.ledThread != null && this.ledThread.isAlive()) {
  73.          this.ledThread.stop();
  74.       }
  75.  
  76.       this.ledThread = null;
  77.    }
  78.  
  79.    private void ScrollDown(Graphics var1, int var2) {
  80.       var1.copyArea(this.startPositionX, this.startPositionY, this.displayWidth, this.ledDim * (funcnum.MAXBITS - 1), 0, this.ledDim);
  81.       int var3 = this.startPositionX;
  82.       int var4 = this.startPositionY;
  83.  
  84.       for(int var5 = 0; var5 < this.theMessage.getStringLength() && var5 < this.maxLedWidthArray; ++var5) {
  85.          this.ledLight(var1, var3, var4, this.theMessage.getBool(var2, var5), this.theMessage.letterColor(var5));
  86.          var3 += this.ledDim;
  87.       }
  88.  
  89.       int var7 = 0;
  90.       if ((var7 = this.maxLedWidthArray - this.theMessage.getStringLength()) > 0) {
  91.          for(int var6 = 0; var6 < var7; ++var6) {
  92.             this.ledLight(var1, var3, var4, false, this.ledOffColor);
  93.             var3 += this.ledDim;
  94.          }
  95.       }
  96.  
  97.    }
  98.  
  99.    private String intoLetters(String var1) {
  100.       char[] var2 = new char[var1.length()];
  101.  
  102.       for(int var3 = 0; var3 < var1.length(); ++var3) {
  103.          var2[var3] = (char)(Character.digit(var1.charAt(var3), 10) + 65);
  104.       }
  105.  
  106.       return String.valueOf(var2);
  107.    }
  108.  
  109.    private void drawLed(Graphics var1, int var2, int var3, Color var4) {
  110.       var1.setColor(var4);
  111.       if (this.ledWidth > 2) {
  112.          for(int var5 = 0; var5 < this.ledWidth - 2; ++var5) {
  113.             var1.drawLine(var2 + 1 + var5, var3, var2 + 1 + var5, var3 + this.ledWidth - 1);
  114.             var1.drawLine(var2, var3 + 1 + var5, var2 + this.ledWidth - 1, var3 + 1 + var5);
  115.          }
  116.       } else if (this.ledWidth == 2) {
  117.          var1.drawLine(var2, var3, var2, var3 + 1);
  118.          var1.drawLine(var2 + 1, var3, var2 + 1, var3 + 1);
  119.       } else {
  120.          var1.drawLine(var2, var3, var2, var3);
  121.       }
  122.  
  123.    }
  124.  
  125.    private void drawBorder(Graphics var1, Color var2, int var3, int var4, int var5, boolean var6) {
  126.       var1.setColor(var2);
  127.       int var7 = 0;
  128.       int var8 = ((Component)this).size().width - 1;
  129.       int var9 = ((Component)this).size().height - 1;
  130.  
  131.       for(int var10 = 0; var10 < var3; ++var10) {
  132.          var1.draw3DRect(var7, var7, var8, var9, var6);
  133.          ++var7;
  134.          var8 -= 2;
  135.          var9 -= 2;
  136.       }
  137.  
  138.       for(int var11 = 0; var11 < var4; ++var11) {
  139.          var1.drawRect(var7, var7, var8, var9);
  140.          ++var7;
  141.          var8 -= 2;
  142.          var9 -= 2;
  143.       }
  144.  
  145.       for(int var12 = 0; var12 < var5; ++var12) {
  146.          var1.draw3DRect(var7, var7, var8, var9, !var6);
  147.          ++var7;
  148.          var8 -= 2;
  149.          var9 -= 2;
  150.       }
  151.  
  152.    }
  153.  
  154.    private synchronized void testPosition(int var1) {
  155.       ++this.ledPosition;
  156.       if (this.ledPosition >= var1) {
  157.          this.ledPosition = 0;
  158.          this.nextFuncReady = true;
  159.          this.testPosInit = true;
  160.       }
  161.  
  162.    }
  163.  
  164.    private synchronized void testPosition() {
  165.       this.ledPosition += -1;
  166.       if (this.ledPosition < 0) {
  167.          this.ledPosition = 0;
  168.          this.testPosInit = true;
  169.          this.nextFuncReady = true;
  170.       }
  171.  
  172.    }
  173.  
  174.    private void OverUpDown(Graphics var1, int var2) {
  175.       if (var2 < this.maxLedHeightArray) {
  176.          int var3 = this.startPositionX;
  177.          int var4 = this.startPositionY + this.ledDim * var2;
  178.  
  179.          for(int var5 = 0; var5 < this.maxLedWidthArray; ++var5) {
  180.             if (var5 < this.theMessage.getStringLength()) {
  181.                this.ledLight(var1, var3, var4, this.theMessage.getBool(var2, var5), this.theMessage.letterColor(var5));
  182.             } else {
  183.                this.ledLight(var1, var3, var4, false, this.ledOffColor);
  184.             }
  185.  
  186.             var3 += this.ledDim;
  187.          }
  188.       }
  189.  
  190.    }
  191.  
  192.    private void calcXY(String var1) {
  193.       String var2 = ((Applet)this).getParameter("serialid");
  194.       if (var2 == null) {
  195.          this.NotRegistered();
  196.       } else {
  197.          long var3 = this.whatXY(var1);
  198.          this.synchMaster(var1);
  199.          String var5 = this.intoLetters(Long.toString(var3));
  200.          this.synchMaster(var5);
  201.          boolean var6 = var2.regionMatches(true, 0, var5, 0, var5.length());
  202.          if (!var6) {
  203.             this.NotRegistered();
  204.          }
  205.       }
  206.  
  207.    }
  208.  
  209.    public void update(Graphics var1) {
  210.       if (this.readyToPaint) {
  211.          this.paint(var1);
  212.       }
  213.  
  214.    }
  215.  
  216.    private void getCommand() {
  217.       try {
  218.          this.command = this.theScript.nextFunction();
  219.          this.theMessage.setText(this.command);
  220.       } catch (ArrayIndexOutOfBoundsException var2) {
  221.          System.out.println(((Throwable)var2).getMessage());
  222.       }
  223.  
  224.    }
  225.  
  226.    public void start() {
  227.       System.out.println("START");
  228.       this.firstTime = true;
  229.       if (this.ledThread == null) {
  230.          this.ledThread = new Thread(this);
  231.       }
  232.  
  233.       this.ledThread.start();
  234.    }
  235.  
  236.    public String getAppletInfo() {
  237.       return "Broadway v1.1 - Copyright Sausage Software 1996";
  238.    }
  239.  
  240.    public broadway() {
  241.       this.maxLedHeightArray = funcnum.MAXBITS;
  242.       this.maxLedWidthArray = 10;
  243.       this.readyToPaint = true;
  244.       this.firstTime = true;
  245.       this.unreg = true;
  246.    }
  247.  
  248.    private String addString(String var1, String var2) {
  249.       return var1 == null ? new String(var2) : var1.concat(var2);
  250.    }
  251.  
  252.    private void getParams() {
  253.       String var1 = ((Applet)this).getParameter("from");
  254.       if (var1 != null) {
  255.          if (!var1.equals("Broadway - Sausage Software 1996")) {
  256.             this.unreg = true;
  257.          } else {
  258.             this.unreg = false;
  259.             this.growingString = this.addString(this.growingString, var1 + "6");
  260.          }
  261.       } else {
  262.          System.out.println("No 'from' parameter");
  263.          this.unreg = true;
  264.       }
  265.  
  266.       var1 = ((Applet)this).getParameter("date");
  267.       if (var1 == null) {
  268.          System.out.println("no 'date' parameter");
  269.          paramErrorString = new String(paramErrorString.concat("date "));
  270.          this.paramError = true;
  271.       } else {
  272.          this.growingString = this.addString(this.growingString, var1);
  273.       }
  274.  
  275.       this.growingString = this.addString(this.growingString, "font.fnt");
  276.       var1 = ((Applet)this).getParameter("scriptfile");
  277.       if (var1 != null) {
  278.          this.scriptFile = new String(var1);
  279.          this.growingString = this.addString(this.growingString, var1);
  280.       } else {
  281.          System.out.println("no scriptfile parameter");
  282.          paramErrorString = new String(paramErrorString.concat("scriptfile "));
  283.          this.paramError = true;
  284.       }
  285.  
  286.       var1 = ((Applet)this).getParameter("space");
  287.       if (var1 != null) {
  288.          this.letterSpace = Integer.parseInt(var1);
  289.          this.growingString = this.addString(this.growingString, var1);
  290.       }
  291.  
  292.       var1 = ((Applet)this).getParameter("spaceWidth");
  293.       if (var1 != null) {
  294.          this.spaceWidth = Integer.parseInt(var1);
  295.          this.growingString = this.addString(this.growingString, var1);
  296.       }
  297.  
  298.       var1 = ((Applet)this).getParameter("borderOuter");
  299.       if (var1 != null) {
  300.          this.borderOuter = Integer.parseInt(var1);
  301.          this.growingString = this.addString(this.growingString, var1);
  302.       }
  303.  
  304.       var1 = ((Applet)this).getParameter("borderInner");
  305.       if (var1 != null) {
  306.          this.borderInner = Integer.parseInt(var1);
  307.          this.growingString = this.addString(this.growingString, var1);
  308.       }
  309.  
  310.       var1 = ((Applet)this).getParameter("borderSize");
  311.       if (var1 != null) {
  312.          this.borderSize = Integer.parseInt(var1);
  313.          this.growingString = this.addString(this.growingString, var1);
  314.       }
  315.  
  316.       var1 = ((Applet)this).getParameter("borderColor");
  317.       if (var1 != null) {
  318.          StringTokenizer var2 = new StringTokenizer(var1, ",");
  319.          this.borderColor = this.getColor(var2);
  320.          this.growingString = this.addString(this.growingString, var1);
  321.       }
  322.  
  323.       var1 = ((Applet)this).getParameter("ledRimColor");
  324.       if (var1 != null) {
  325.          StringTokenizer var19 = new StringTokenizer(var1, ",");
  326.          this.ledRimColor = this.getColor(var19);
  327.       }
  328.  
  329.       var1 = ((Applet)this).getParameter("brokenLed");
  330.       if (var1 != null && var1.equalsIgnoreCase("true")) {
  331.          this.brokenLed = true;
  332.       }
  333.  
  334.       var1 = ((Applet)this).getParameter("appletColor");
  335.       if (var1 != null) {
  336.          StringTokenizer var20 = new StringTokenizer(var1, ",");
  337.          this.appletColor = this.getColor(var20);
  338.       } else {
  339.          this.appletColor = ((Component)this).getBackground();
  340.       }
  341.  
  342.       var1 = ((Applet)this).getParameter("backGroundColor");
  343.       if (var1 != null) {
  344.          this.backGroundColor = new Color(Integer.parseInt(var1));
  345.       } else {
  346.          this.backGroundColor = new Color(0, 0, 0);
  347.       }
  348.  
  349.       var1 = ((Applet)this).getParameter("ledOffColor");
  350.       if (var1 != null) {
  351.          StringTokenizer var21 = new StringTokenizer(var1, ",");
  352.          this.growingString = this.addString(this.growingString, var1);
  353.          this.ledOffColor = this.getColor(var21);
  354.       } else {
  355.          this.ledOffColor = new Color(0, 0, 0);
  356.       }
  357.  
  358.       var1 = ((Applet)this).getParameter("oval");
  359.       if (var1 != null) {
  360.          if ("true".equalsIgnoreCase(var1)) {
  361.             this.oval = true;
  362.          }
  363.  
  364.          this.growingString = this.addString(this.growingString, var1);
  365.       }
  366.  
  367.       var1 = ((Applet)this).getParameter("fontfile");
  368.       if (var1 != null) {
  369.          this.fontFile = new String(var1);
  370.       } else {
  371.          System.out.println("no fontfile parameter");
  372.          paramErrorString = new String(paramErrorString.concat("fontfile "));
  373.          this.paramError = true;
  374.       }
  375.  
  376.       var1 = ((Applet)this).getParameter("reguser");
  377.       if (var1 == null) {
  378.          this.paramError = true;
  379.       } else {
  380.          if (var1.toLowerCase().equals("unregistered")) {
  381.             this.unreg = true;
  382.          } else {
  383.             this.unreg = false;
  384.          }
  385.  
  386.          this.growingString = this.addString(this.growingString, var1);
  387.       }
  388.  
  389.       this.calcXY(this.growingString);
  390.    }
  391.  
  392.    private void OverLeftRight(Graphics var1, int var2) {
  393.       int var3 = this.startPositionY;
  394.       int var4 = this.startPositionX + this.ledDim * var2;
  395.       if (var2 < this.maxLedWidthArray) {
  396.          if (var2 < this.theMessage.getStringLength()) {
  397.             for(int var5 = 0; var5 < funcnum.MAXBITS; ++var5) {
  398.                this.ledLight(var1, var4, var3, this.theMessage.getBool(var5, var2), this.theMessage.letterColor(var2));
  399.                var3 += this.ledDim;
  400.             }
  401.          } else {
  402.             for(int var6 = 0; var6 < funcnum.MAXBITS; ++var6) {
  403.                this.ledLight(var1, var4, var3, false, this.ledOffColor);
  404.                var3 += this.ledDim;
  405.             }
  406.          }
  407.       }
  408.  
  409.    }
  410.  
  411.    private long whatXY(String var1) {
  412.       int var2 = 0;
  413.  
  414.       for(int var3 = 0; var3 < var1.length(); ++var3) {
  415.          if (Character.isLetterOrDigit(var1.charAt(var3))) {
  416.             var2 += var1.charAt(var3);
  417.          }
  418.       }
  419.  
  420.       return (long)var2;
  421.    }
  422.  
  423.    private void debug2(String var1) {
  424.       if (this.dbg2) {
  425.          if (var1 != null) {
  426.             System.out.println(var1);
  427.          } else {
  428.             System.out.println("NULL");
  429.          }
  430.       }
  431.  
  432.    }
  433.  
  434.    private void NotRegistered() {
  435.       System.out.println("Program not registered");
  436.       this.serialIdError = true;
  437.    }
  438.  
  439.    public void paint(Graphics var1) {
  440.       if (this.initialised && this.ledThread != null) {
  441.          if (this.serialIdError) {
  442.             this.showSerialIdError(this.offGraphics);
  443.          } else if (this.paramError) {
  444.             this.showParamError(this.offGraphics);
  445.          } else if (this.fileError) {
  446.             this.showFileError(this.offGraphics);
  447.          } else if (this.firstTime) {
  448.             System.out.println("PAINT");
  449.             ((Component)this).setBackground(this.appletColor);
  450.             var1.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
  451.             this.offGraphics.setColor(this.appletColor);
  452.             this.offGraphics.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
  453.             this.clearLeds(this.offGraphics);
  454.             this.drawBorder(this.offGraphics, this.borderColor, this.borderOuter, this.borderSize, this.borderInner, this.borderRaised);
  455.             this.firstTime = false;
  456.          }
  457.  
  458.          var1.drawImage(this.offImage, 0, 0, this);
  459.       }
  460.  
  461.    }
  462.  
  463.    private void posInit(int var1) {
  464.       if (this.testPosInit) {
  465.          this.testPosInit = false;
  466.          this.ledPosition = var1 - 1;
  467.       }
  468.  
  469.    }
  470.  
  471.    public Color getColor(StringTokenizer var1) {
  472.       try {
  473.          int var2 = Integer.parseInt(var1.nextToken());
  474.          int var3 = Integer.parseInt(var1.nextToken());
  475.          int var4 = Integer.parseInt(var1.nextToken());
  476.          return new Color(var2, var3, var4);
  477.       } catch (NoSuchElementException var5) {
  478.          System.out.println("Color problems getColor(St)");
  479.          return new Color(128, 128, 128);
  480.       }
  481.    }
  482.  
  483.    private void showParamError(Graphics var1) {
  484.       var1.setFont(new Font("Courier", 1, 11));
  485.       var1.setColor(Color.black);
  486.       var1.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
  487.       var1.setColor(Color.red);
  488.       var1.drawString("You are missing", 2, 11);
  489.       var1.drawString("vital parameters", 2, 22);
  490.       var1.drawString("in your .html file.", 2, 33);
  491.       var1.drawString(paramErrorString, 2, 44);
  492.       ((Applet)this).showStatus("PLEASE READ HELP FILE");
  493.    }
  494.  
  495.    private void showFileError(Graphics var1) {
  496.       var1.setFont(new Font("Courier", 1, 11));
  497.       var1.setColor(Color.black);
  498.       var1.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
  499.       var1.setColor(Color.red);
  500.       var1.drawString("I have problems reading from", 2, 11);
  501.       var1.drawString("script file and or", 2, 22);
  502.       var1.drawString("font file.", 2, 33);
  503.       ((Applet)this).showStatus("PLEASE READ HELP FILE");
  504.    }
  505.  
  506.    public void showSerialIdError(Graphics var1) {
  507.       var1.setFont(new Font("Courier", 1, 11));
  508.       var1.setColor(Color.black);
  509.       var1.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
  510.       var1.setColor(Color.red);
  511.       var1.drawString("SerialID ERROR", 2, 11);
  512.       ((Applet)this).showStatus("PLEASE READ HELP FILE");
  513.    }
  514.  
  515.    public void clearLeds(Graphics var1) {
  516.       int var3 = this.startPositionX;
  517.       int var4 = (this.startPositionY - this.startPosition) / this.ledDim;
  518.       int var5 = ((Component)this).size().height - this.borderTotalWidth;
  519.  
  520.       for(int var6 = 0; var6 < this.maxLedWidthArray; ++var6) {
  521.          int var2 = this.startPositionY - this.ledDim * var4;
  522.  
  523.          for(int var7 = 0; var7 < funcnum.MAXBITS; ++var7) {
  524.             this.ledLight(var1, var3, var2, false, this.ledOffColor);
  525.             var2 += this.ledDim;
  526.          }
  527.  
  528.          while(var2 + this.ledDim < var5) {
  529.             this.ledLight(var1, var3, var2, false, this.ledOffColor);
  530.             var2 += this.ledDim;
  531.          }
  532.  
  533.          var3 += this.ledDim;
  534.       }
  535.  
  536.    }
  537.  
  538.    private void synchMaster(String var1) {
  539.    }
  540.  
  541.    private void debug3(String var1) {
  542.       if (this.dbg3) {
  543.          System.out.println(var1);
  544.       }
  545.  
  546.    }
  547.  
  548.    private void calcDisplayArea() {
  549.       this.displayWidth = ((Component)this).size().width - this.borderTotalWidth * 2 - this.spaceWidth;
  550.       this.displayHeight = ((Component)this).size().height - this.borderTotalWidth * 2 - this.spaceWidth;
  551.       this.calcLeds();
  552.    }
  553.  
  554.    private void loader() {
  555.       this.debug3("LOAD font & script");
  556.       this.letterFont = new letters(((Applet)this).getDocumentBase(), this.fontFile, this.letterSpace);
  557.       if (!(this.fileError = this.letterFont.getFileError())) {
  558.          try {
  559.             this.letterFont.readFontFile();
  560.             this.debug3(this.fontFile + " loaded");
  561.          } catch (Exception var3) {
  562.             this.fileError = true;
  563.             System.out.println("Error reading from " + this.fontFile);
  564.             System.out.println(((Throwable)var3).getMessage());
  565.          }
  566.  
  567.          if (!this.fileError) {
  568.             this.theMessage = new textmess(this.letterFont);
  569.  
  570.             try {
  571.                this.theScript = new ldscript(((Applet)this).getDocumentBase(), this.scriptFile);
  572.                if (!(this.fileError = this.theScript.getFileError())) {
  573.                   this.getCommand();
  574.                   this.debug3(this.scriptFile + " loaded");
  575.                }
  576.             } catch (NullPointerException var2) {
  577.                this.fileError = true;
  578.                System.out.println("Could not find " + this.scriptFile);
  579.             }
  580.          }
  581.       }
  582.  
  583.    }
  584.  
  585.    private void ledLight(Graphics var1, int var2, int var3, boolean var4, Color var5) {
  586.       var1.setColor(this.ledRimColor);
  587.       Color var6;
  588.       if (!var4) {
  589.          var6 = this.ledOffColor;
  590.       } else {
  591.          var6 = var5;
  592.       }
  593.  
  594.       if (this.oval) {
  595.          this.drawLed(var1, var2, var3, var6);
  596.       } else {
  597.          var1.setColor(var6);
  598.          var1.fillRect(var2, var3, this.ledWidth, this.ledHeight);
  599.       }
  600.  
  601.    }
  602.  
  603.    private void calcLeds() {
  604.       this.ledWidth = this.ledHeight = this.displayHeight / funcnum.MAXBITS - this.spaceWidth;
  605.       int var1 = this.displayHeight % funcnum.MAXBITS;
  606.       this.maxLedWidthArray = this.displayWidth / (this.spaceWidth + this.ledHeight);
  607.       this.startPositionX = this.startPosition;
  608.       this.startPositionY = this.startPosition + var1 / 2;
  609.    }
  610.  
  611.    private void ScrollRight(Graphics var1, int var2) {
  612.       var1.copyArea(this.startPositionX, this.startPositionY, this.ledDim * (this.maxLedWidthArray - 1), this.displayHeight, this.ledDim, 0);
  613.       int var3 = this.startPositionY;
  614.       int var4 = this.startPositionX;
  615.  
  616.       for(int var5 = 0; var5 < funcnum.MAXBITS; ++var5) {
  617.          this.ledLight(var1, var4, var3, this.theMessage.getBool(var5, var2), this.theMessage.letterColor(var2));
  618.          var3 += this.ledDim;
  619.       }
  620.  
  621.    }
  622.  
  623.    public void run() {
  624.       System.out.println("RUN");
  625.       if (!this.paramError && !this.serialIdError) {
  626.          this.debug2("paramError=" + this.paramError);
  627.          this.loader();
  628.       }
  629.  
  630.       while(true) {
  631.          ((Component)this).repaint();
  632.  
  633.          try {
  634.             Thread.sleep((long)(this.sleepTime + 10));
  635.          } catch (Exception var1) {
  636.          }
  637.  
  638.          if (this.nextFuncReady) {
  639.             this.getCommand();
  640.          }
  641.  
  642.          this.nextFuncReady = false;
  643.          this.readyToPaint = false;
  644.          if (!this.fileError && !this.paramError && !this.serialIdError) {
  645.             this.preDraw();
  646.             if (this.unreg) {
  647.                ((Applet)this).getAppletContext().showStatus("Unregistered version. Copyright (c) Sausage Software 1996");
  648.             }
  649.          }
  650.  
  651.          this.readyToPaint = true;
  652.       }
  653.    }
  654.  
  655.    public void init() {
  656.       System.out.println(this.getAppletInfo());
  657.       System.out.println("INIT");
  658.       this.getParams();
  659.  
  660.       try {
  661.          this.offImage = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
  662.          this.offGraphics = this.offImage.getGraphics();
  663.       } catch (Exception var1) {
  664.          this.offGraphics = null;
  665.       }
  666.  
  667.       this.borderTotalWidth = this.borderOuter + this.borderSize + this.borderInner;
  668.       this.startPosition = this.borderTotalWidth + this.spaceWidth;
  669.       this.calcDisplayArea();
  670.       this.ledDim = this.ledWidth + this.spaceWidth;
  671.       this.initialised = true;
  672.    }
  673.  
  674.    public boolean handleEvent(Event var1) {
  675.       switch (var1.id) {
  676.          case 201:
  677.             this.stop();
  678.             System.exit(0);
  679.             break;
  680.          case 501:
  681.             if (this.userPause) {
  682.                this.ledThread.resume();
  683.             } else {
  684.                this.ledThread.suspend();
  685.             }
  686.  
  687.             this.userPause = !this.userPause;
  688.       }
  689.  
  690.       return true;
  691.    }
  692.  
  693.    private synchronized void preDraw() {
  694.       if (!this.firstTime) {
  695.          switch (this.command.getFuncNum()) {
  696.             case 1:
  697.                this.debug3("Scroll up");
  698.                this.ScrollUp(this.offGraphics, this.ledPosition);
  699.                this.testPosition(this.maxLedHeightArray);
  700.                break;
  701.             case 2:
  702.                this.debug3("Scrolldown");
  703.                this.posInit(this.maxLedHeightArray);
  704.                this.ScrollDown(this.offGraphics, this.ledPosition);
  705.                this.testPosition();
  706.                break;
  707.             case 3:
  708.                this.debug3("Scroll Right");
  709.                this.posInit(this.theMessage.getStringLength());
  710.                this.ScrollRight(this.offGraphics, this.ledPosition);
  711.                this.testPosition();
  712.                break;
  713.             case 4:
  714.                this.debug3("Scroll left");
  715.                this.ScrollLeft(this.offGraphics, this.ledPosition);
  716.                this.testPosition(this.theMessage.getStringLength());
  717.                break;
  718.             case 10:
  719.                this.debug3("Over Scroll Up");
  720.                this.posInit(this.maxLedHeightArray);
  721.                this.OverUpDown(this.offGraphics, this.ledPosition);
  722.                this.testPosition();
  723.                break;
  724.             case 11:
  725.                this.debug3("Over Scroll Down");
  726.                this.OverUpDown(this.offGraphics, this.ledPosition);
  727.                this.testPosition(this.maxLedHeightArray);
  728.                break;
  729.             case 12:
  730.                this.debug3("Over Scroll Right");
  731.                this.OverLeftRight(this.offGraphics, this.ledPosition);
  732.                this.testPosition(this.maxLedWidthArray);
  733.                break;
  734.             case 13:
  735.                this.debug3("Over Scroll Left");
  736.                this.posInit(this.maxLedWidthArray);
  737.                this.OverLeftRight(this.offGraphics, this.ledPosition);
  738.                this.testPosition();
  739.                break;
  740.             case 103:
  741.                this.debug3("Pause");
  742.                this.nextFuncReady = true;
  743.                break;
  744.             case 104:
  745.                this.debug3("Show");
  746.                this.Show(this.offGraphics);
  747.                this.nextFuncReady = true;
  748.                break;
  749.             case 105:
  750.                if (!this.blink) {
  751.                   this.blinkcount = this.command.getBlink();
  752.                   this.blink = true;
  753.                } else if (this.blinkOff) {
  754.                   this.clearLeds(this.offGraphics);
  755.                   this.blinkOff = false;
  756.                } else {
  757.                   this.Show(this.offGraphics);
  758.                   this.blinkOff = true;
  759.                   this.blinkcount += -1;
  760.                }
  761.  
  762.                if (this.blinkcount < 1) {
  763.                   this.nextFuncReady = true;
  764.                   this.blinkOff = true;
  765.                   this.blink = false;
  766.                }
  767.                break;
  768.             case 106:
  769.                this.debug3("CLEAR");
  770.                this.clearLeds(this.offGraphics);
  771.                this.ledPosition = 0;
  772.                this.nextFuncReady = true;
  773.                break;
  774.             default:
  775.                this.debug3("Default nothing");
  776.                this.ledPosition = 0;
  777.                this.nextFuncReady = true;
  778.                this.testPosInit = true;
  779.                System.out.println("Nothing to do.  A function is not known by me - led.java");
  780.          }
  781.  
  782.          this.sleepTime = this.command.getDelay();
  783.       }
  784.  
  785.    }
  786.  
  787.    private void ScrollUp(Graphics var1, int var2) {
  788.       var1.copyArea(this.startPositionX, this.startPositionY + this.ledDim, this.displayWidth, (funcnum.MAXBITS - 1) * this.ledDim, 0, -this.ledWidth - this.spaceWidth);
  789.       int var3 = this.startPositionX;
  790.       int var4 = this.startPositionY + this.ledDim * (funcnum.MAXBITS - 1);
  791.  
  792.       for(int var5 = 0; var5 < this.theMessage.getStringLength() && var5 < this.maxLedWidthArray; ++var5) {
  793.          this.ledLight(var1, var3, var4, this.theMessage.getBool(var2, var5), this.theMessage.letterColor(var5));
  794.          var3 += this.ledDim;
  795.       }
  796.  
  797.       int var7 = 0;
  798.       if ((var7 = this.maxLedWidthArray - this.theMessage.getStringLength()) > 0) {
  799.          for(int var6 = 0; var6 < var7; ++var6) {
  800.             this.ledLight(var1, var3, var4, false, this.ledOffColor);
  801.             var3 += this.ledDim;
  802.          }
  803.       }
  804.  
  805.    }
  806.  
  807.    private void Show(Graphics var1) {
  808.       int var2 = this.startPositionX;
  809.       int var3 = this.startPositionY;
  810.  
  811.       for(int var4 = 0; var4 < funcnum.MAXBITS; ++var4) {
  812.          var2 = this.startPosition;
  813.  
  814.          for(int var5 = 0; var5 < this.theMessage.getStringLength() && var5 < this.maxLedWidthArray; ++var5) {
  815.             this.ledLight(var1, var2, var3, this.theMessage.getBool(var4, var5), this.theMessage.letterColor(var5));
  816.             var2 += this.ledDim;
  817.          }
  818.  
  819.          var3 += this.ledDim;
  820.       }
  821.  
  822.    }
  823.  
  824.    private void ScrollLeft(Graphics var1, int var2) {
  825.       int var3 = (this.maxLedWidthArray - 1) * this.ledDim;
  826.       var1.copyArea(this.startPositionX + this.ledDim, this.startPosition, var3, this.displayHeight, -this.ledDim, 0);
  827.       int var4 = this.startPositionY;
  828.       int var5 = this.startPositionX + var3;
  829.  
  830.       for(int var6 = 0; var6 < funcnum.MAXBITS; ++var6) {
  831.          this.ledLight(var1, var5, var4, this.theMessage.getBool(var6, var2), this.theMessage.letterColor(var2));
  832.          var4 += this.ledDim;
  833.       }
  834.  
  835.    }
  836. }
  837.