home *** CD-ROM | disk | FTP | other *** search
/ Hacks & Cracks / Hacks_and_Cracks.iso / cracks / cracks2.zip / LEDSIGN.ZIP / LEDSign / LED / LED.java < prev    next >
Text File  |  1996-03-21  |  29KB  |  938 lines

  1. /////////////////////////////////////////////////////////////////////
  2. //  LED.java  -- LED Sign V2.7
  3. //
  4. //  The main for the LED Sign applet.  This applet mimics
  5. //  an LED sign that you typically see displaying messages
  6. //  at airport terminals and the such.
  7. //
  8. //  Revisions:
  9. //     V2.7: "Supped" up V2.5.  See the "Revisions" doc for more
  10. //           info.
  11. //
  12. //     V2.5: Fixed all known bugs in previous versions!  Added
  13. //           the new feature of ledsize, which allows the user
  14. //           to specify in pixels how big the LED's (1-4).
  15. //           Thanks to Robert B. Denny (rdenny@dc3.com) for
  16. //           code and input!
  17. //           Modified Dec 20-26, 1995
  18. //
  19. //     V2.0beta: Modified V1.0 to comply with Pre-Beta java.
  20. //               A problem with delay causes a jerky display.
  21. //               Modified Oct 20 - 29, 1995
  22. //
  23. //     V1.0: Written July 10 - August 6, 1995
  24. //
  25. //  By Darrick Brown
  26. //     dbrown@cs.hope.edu
  27. //     http://www.cs.hope.edu/~dbrown/
  28. //
  29. //  ⌐ Copyright 1995
  30. /////////////////////////////////////////////////////////////////////
  31.  
  32. import java.awt.*;
  33. import java.io.*;
  34. import java.net.*;
  35. import FuncInfo;
  36. import Script;
  37. import Letters;
  38. import LEDMessage;
  39.  
  40.  
  41. // Just a small struct
  42. // used in randomizing the pixels in the "Pixel" function
  43. class Pixelize
  44. {
  45.    int x;
  46.    int y;
  47. }
  48.  
  49. /////////////////////////////////////////////////////////////////////
  50. // The java.applet.Applet!!
  51. /////////////////////////////////////////////////////////////////////
  52. public class LED extends java.applet.Applet implements Runnable
  53. {
  54.    // my #defines
  55.    int WIDTH = 400;
  56.    int HEIGHT = 30;
  57.    Color highlight;
  58.    
  59.    Script com;                  // The class that takes care of the script
  60.    FuncInfo fi;                 // All the info for any funtion/transition
  61.    Letters let;                 // The class that contains all the letters
  62.    int ledsize;                 // The size of the LED's!
  63.  
  64.    Color colors[];              // The array of possible colors
  65.    LEDMessage msg;              // The class that takes care of the message to be displayed
  66.    Color bhilite;               // The highlight color of the border
  67.    Color bcolor;                // The color of the border
  68.    Color bshadow;               // The shadow of the border
  69.    
  70.    Thread led = null;
  71.    String scrpt,endspace,fnt;   // "command line" arguments
  72.    String text;                 // the current message
  73.    String currurl = "LED Sign V2.7";  // The current url that are set in the script
  74.    URL currURL = null;
  75.    String target = new String("");  // Target for frames
  76.    int place;                   // The place where we are in each transition.  How we know when we are done.
  77.    int border;                  // The border width
  78.    int offset;                  // The offset for the sign from the upper left
  79.    int w,h;                     // Width & Height in LEDs
  80.    int swidth;                  // The width of the space character.  Settable in the HTML command line.
  81.    boolean beginning = false;   // make sure we init certain stuff only once
  82.    boolean init = false;        // used to make sure "getinfo" is called only once.
  83.    boolean inapplet;            // Is the mouse cursor in the applet?  (used to display status messages)
  84.    boolean done = false;        // Is the transition done?
  85.    Image pixmapimg,offimg,tmpimg;    // The pixmaps!!  -- These are what make this program possible
  86.    Graphics pixmap,offmap,tmpmap;    // Graphics for the pixmaps
  87.    Pixelize pix[];              // Array of "pixels" used during the Pixel transition
  88.       
  89.  
  90.    //////////////////////////////////////////////////////////////////
  91.    // get the "command line" arguments from the HTML
  92.    private int getAttrs()
  93.    {
  94.       String s;
  95.       int r,g,b;
  96.       Graphics gr;
  97.       
  98.       if(getParameter("script") !=  null)
  99.       {
  100.          scrpt = new String(getParameter("script"));
  101.       }
  102.       else
  103.       {
  104.          System.out.println("LED Sign Error: No script specified in HTML.");
  105.          currurl = new String("LED Sign Error: No script specified in HTML.");
  106.          return -1;  // Script error;
  107.       }
  108.  
  109.       if(getParameter("font") !=  null)
  110.       {
  111.          fnt = new String(getParameter("font"));
  112.       }
  113.       else
  114.       {
  115.          System.out.println("LED Sign Error: No font specified in HTML.");
  116.          currurl = new String("LED Sign Error: No font specified in HTML.");
  117.          return -1; // font error
  118.       }
  119.       
  120.       if(getParameter("spacewidth") !=  null)
  121.       {
  122.          swidth = (new Integer(new String(getParameter("spacewidth")))).intValue();
  123.       }
  124.       else
  125.          swidth = 3;
  126.  
  127.       if(getParameter("ledsize") !=  null)
  128.       {
  129.          ledsize = new Integer(new String(getParameter("ledsize"))).intValue();
  130.          
  131.          // A little error trapping
  132.          if(ledsize < 1)
  133.             ledsize = 1;
  134.          else if(ledsize > 4)
  135.             ledsize = 4;
  136.  
  137.          ledsize++;    // The user enters 1-4, the applet needs 2-5
  138.       }
  139.       else
  140.          ledsize = 4;
  141.       
  142.       if(getParameter("ht") != null)
  143.       {
  144.          HEIGHT = ledsize*(new Integer(new String(getParameter("ht")))).intValue();
  145.          h = HEIGHT/ledsize;
  146.       }
  147.       else
  148.       {
  149.          System.out.println("LED Sign Warning: parameter \"ht\" (height in LED's) not specified");
  150.          HEIGHT = ledsize*9;
  151.          h = 9;
  152.       }
  153.       
  154.       if(getParameter("wth") !=  null)
  155.       {
  156.          WIDTH = ledsize*(new Integer(new String(getParameter("wth")))).intValue();
  157.          if(WIDTH/ledsize%2 == 1)
  158.             WIDTH += ledsize;  // It must be even!!!
  159.  
  160.          w = WIDTH/ledsize;
  161.       }
  162.       else
  163.       {
  164.          System.out.println("LED Sign Warning: parameter \"wth\" (width in LED's) not specified");
  165.          WIDTH = 60*ledsize;
  166.          w = 60;
  167.       }
  168.          
  169.       if(getParameter("border") !=  null)
  170.       {
  171.          border = new Integer(new String(getParameter("border"))).intValue();
  172.       }
  173.       else
  174.          border = 0;
  175.  
  176.       if(getParameter("bordercolor") != null)
  177.       {
  178.          // User specified border color!!
  179.          s = new String(getParameter("bordercolor"));
  180.          s = s.trim();
  181.          r = new Integer(s.substring(0,s.indexOf(","))).intValue();
  182.          s = s.substring(s.indexOf(",")+1);
  183.          g = new Integer(s.substring(0,s.indexOf(","))).intValue();
  184.          s = s.substring(s.indexOf(",")+1);
  185.          b = new Integer(s).intValue();
  186.          
  187.          // Forgive the "if" syntax, I didn't want to bother typing the
  188.          // "normal" ifs for this small part. :)
  189.          bhilite = new Color(r+40<256?r+40:255, g+40<256?g+40:255, b+40<256?b+40:255);
  190.          bcolor = new Color(r,g,b);
  191.          bshadow = new Color(r-40>=0?r-40:0, g-40>=0?g-40:0, b-40>=0?b-40:0);
  192.       }
  193.       else
  194.       {
  195.          // The default gray
  196.          bhilite = Color.white;
  197.          bcolor = Color.lightGray;
  198.          bshadow = Color.darkGray;
  199.       }
  200.  
  201.       return 1;  // Everthing so far is ok.
  202.       
  203.    } // end getAttrs()
  204.  
  205.    //////////////////////////////////////////////////////////////////
  206.    // Initialize the Applet
  207.    public void init()
  208.    {
  209.       // Set up the different colors for the sign
  210.       highlight = new Color(100,100,100);
  211.       colors = new Color[9];
  212.       colors[0] = new Color(80,80,80);  // off color
  213.       colors[1] = new Color(255,0,0);   // Default red
  214.       colors[2] = new Color(130,255,0); // green
  215.       colors[3] = new Color(0,130,255); // blue
  216.       colors[4] = new Color(255,255,0); // yellow
  217.       colors[5] = new Color(255,160,0); // orange
  218.       colors[6] = new Color(255,0,255); // purple
  219.       colors[7] = new Color(255,255,255); // white
  220.       colors[8] = new Color(0,255,255); // cyan
  221.  
  222.       // If the script and/or font are not specified, then stop!
  223.       if(getAttrs() == -1)
  224.          stop();
  225.       else
  226.       {
  227.          offset = 3*border;
  228.          beginning = true;
  229.          init = true;
  230.       }
  231.    }  // End Init
  232.  
  233.    
  234.    //////////////////////////////////////////////////////////////////
  235.    //  This is called from the run procedure.  This is to allow the
  236.    //  init procedure to finish as fast as possible, thus allowing
  237.    //  it to draw the blank sign to the screen sooner.
  238.    public void getinfo()
  239.    {
  240.       pix = new Pixelize[1];  // load this class now!
  241.  
  242.       let = new Letters(getDocumentBase(),fnt,swidth);
  243.       if(let.w == -1)
  244.       {
  245.          // Do some error output for a bad font
  246.          System.out.println("LED Sign Error - Bad font path in HTML:");
  247.          System.out.println("   File not found:  "+ "\"" + fnt + "\"");
  248.          currurl = new String("LED Sign Error - Bad font path in HTML.");
  249.          stop();
  250.       }
  251.       else
  252.       {
  253.          if(HEIGHT != let.height()*ledsize)
  254.          {
  255.             System.out.println("LED Sign Warning: parameter \"ht\" should be set to " + let.height()*ledsize + ".");
  256.          }
  257.  
  258.          // now that we have the dimensions of the applet, draw it now!
  259.          // This will make the applet *seem* to load faster.
  260.          // paint(getGraphics());
  261.    
  262.          msg = new LEDMessage(h,w,let);
  263.          
  264.          // Set up the script
  265.          com = new Script(getDocumentBase(),scrpt);
  266.          if(com.ok == -1)  // Check for bad script path...
  267.          {
  268.             System.out.println("LED Sign Error - Bad script path in HTML:");
  269.             System.out.println("   File not found:  "+ "\""+scrpt+"\"");
  270.             currurl = new String("LED Sign Error: Bad script path in HTML.");
  271.             stop();
  272.          }
  273.          else
  274.          {
  275.             fi = new FuncInfo();
  276.  
  277.             nextFunc();
  278.             
  279.             resize(WIDTH+2*(offset),HEIGHT+2*(offset));  // Set the applet size
  280.          }
  281.       }
  282.  
  283.       init = false;
  284.  
  285.    }  // End getinfo()
  286.  
  287.    //////////////////////////////////////////////////////////////////
  288.    // Start the applet running and thread the process
  289.    public void start()
  290.    {
  291.       if(led == null) 
  292.       {
  293.          led = new Thread(this);  // Start the applet running
  294.          led.start();
  295.       }
  296.    }
  297.  
  298.    //////////////////////////////////////////////////////////////////
  299.    // Stop the thread
  300.    public void stop()
  301.    {
  302.       if(led != null)
  303.       {
  304.          led.stop();
  305.          led = null;
  306.       }
  307.    }
  308.  
  309.    //////////////////////////////////////////////////////////////////
  310.    // The run loop
  311.    public void run()
  312.    {
  313.       if(init)
  314.          getinfo();
  315.  
  316.       while(led != null)
  317.       {
  318.          repaint();
  319.  
  320.          try 
  321.          {
  322.             led.sleep(fi.delay);
  323.          }
  324.          catch (InterruptedException e)
  325.          {
  326.          }
  327.  
  328.          // If we are done with the current transition, then get the
  329.          // next transition (function).
  330.          if(done)
  331.          {
  332.             nextFunc();
  333.  
  334.             // if fi is null then a reload caused a nonexistant
  335.             // script to be loaded.
  336.             if(fi == null)
  337.             {
  338.                System.out.println("LED Sign Error - Bad script path in HTML:");
  339.                System.out.println("   File not found: "+ scrpt);
  340.                currurl = new String("LED Sign Error: Bad script path in HTML.");
  341.                stop();
  342.             }
  343.             done = false;
  344.          }
  345.       }
  346.    }
  347.  
  348.    //////////////////////////////////////////////////////////////////
  349.    // The HTML tag parameter information
  350.    public String[][] getParameterInfo() {
  351.       String[][] info = {
  352.          {"script     ","URL        ", "LED script to use (Required)"},
  353.          {"font       ","URL        ", "Font to use (Required)"},
  354.          {"spacewidth ","int        ", "Width of space in columns, default = 3 )"},
  355.          {"wth        ","int        ", "Width of live display (cols, default=60)"},
  356.          {"ht         ","int        ", "Height of live display (rows, default=9)"},
  357.          {"border     ","int        ", "Width of display border (pix, default=0)"},
  358.          {"bordercolor","int,int,int", "Color of border (n,n,n default=lightGray)"},
  359.          {"ledsize    ","int        ", "Diameter of LEDs pixels (1-4), default=3)"}
  360.       };
  361.       return info;
  362.    }
  363.  
  364.    //////////////////////////////////////////////////////////////////
  365.    // The "about" stuff.
  366.    public String getAppletInfo() {
  367.       return "LED Sign V2.7 by Darrick Brown. 3-22-96";
  368.    }
  369.  
  370.  
  371.    //////////////////////////////////////////////////////////////////
  372.    // Trap for a mouse click on the applet to check to see if they
  373.    // want to go to another page.
  374.    public boolean mouseDown(java.awt.Event evt, int x, int y)
  375.    {
  376.       if (currURL != null)
  377.       {
  378.          if(target.length() > 0)  // They have specified a target
  379.          {
  380.             getAppletContext().showDocument(currURL,target);
  381.          }
  382.          else
  383.          {
  384.             getAppletContext().showDocument(currURL);
  385.          }
  386.       }
  387.  
  388.       return true;
  389.    }
  390.  
  391.    //////////////////////////////////////////////////////////////////
  392.    // If the mouse cursor enters the applet, then display something
  393.    // in the status bar of the browser.
  394.    public boolean mouseEnter(java.awt.Event evt, int x, int y)
  395.    {
  396.       inapplet = true;
  397.  
  398.       showStatus(currurl);
  399.  
  400.       return true;
  401.    }
  402.  
  403.    //////////////////////////////////////////////////////////////////
  404.    // If the mouse cursor exits the applet, then clear the status
  405.    // bar.
  406.    public boolean mouseExit(java.awt.Event evt, int x, int y)
  407.    {
  408.       inapplet = false;
  409.       
  410.       showStatus(" ");
  411.  
  412.       return true;
  413.    }
  414.  
  415.    //////////////////////////////////////////////////////////////////
  416.    // set the next function
  417.    // This function is only called when the previous
  418.    // function/transition has finished.
  419.    void nextFunc()
  420.    {
  421.       int i,j;
  422.       Pixelize temp;
  423.       int rand;
  424.  
  425.       // get the next function
  426.       fi = com.nextFunc();
  427.  
  428.       // Parse the text line to expand any time/date tags
  429.       fi = com.parseLine(fi);
  430.  
  431.       // Create the message in LED format (boolean)
  432.       msg.setmsg(fi);
  433.  
  434.       // Set up some initial stuff for each of the transitions
  435.       switch(fi.func)
  436.       {
  437.          case 0:
  438.             place = 0;
  439.             break;
  440.          case 1:
  441.             place = 0;
  442.             break;
  443.          case 2:
  444.             place = 0;
  445.             break;
  446.          case 3:
  447.             place = msg.length()-1;
  448.             break;
  449.          case 4:
  450.             place = 0;
  451.             break;
  452.          case 5:
  453.             place = h-1;
  454.             break;
  455.          case 6:
  456.             place = 0;
  457.  
  458.             // This randomizes the "LEDs" for the
  459.             // Pixel function.
  460.  
  461.             pix = new Pixelize[w*h];
  462.  
  463.             for(i=0;i<w;i++)
  464.             {
  465.                for(j=0;j<h;j++)
  466.                {
  467.                   pix[h*i+j] = new Pixelize();
  468.                   pix[h*i+j].x = i;
  469.                   pix[h*i+j].y = j;
  470.                }
  471.             }
  472.             
  473.             // Randomly sort all the LED's so all we have to do
  474.             // is draw them in "order" and they come out all pixelly
  475.             for(i=0;i<WIDTH/ledsize*h;i++)
  476.             {
  477.                   rand = (int)(Math.random()*(double)(WIDTH/ledsize)*(double)h);
  478.                   temp = pix[i];
  479.                   pix[i] = pix[rand];
  480.                   pix[rand] = temp;
  481.             }
  482.             break;
  483.          case 7:
  484.             place = fi.times*2;  // on AND off
  485.             break;
  486.          case 8:
  487.             place = 0;
  488.             break;
  489.          case 9:
  490.             place = 0;
  491.             break;
  492.          case 10:
  493.             place = 0;
  494.             break;
  495.          case 11:
  496.             place = w;
  497.             break;
  498.          case 12:
  499.             place = h-1;
  500.             break;
  501.          case 13:
  502.             place = 0;
  503.             break;
  504.       }
  505.  
  506.       if(fi.url != null)
  507.       {
  508.          currurl = fi.url.toString();
  509.          currURL = fi.url;
  510.          target = fi.target;
  511.       }
  512.       else
  513.       {
  514.          currurl = new String("LED Sign V2.7");
  515.          currURL = null;
  516.          target = new String("");
  517.       }
  518.  
  519.       if(inapplet)
  520.       {
  521.          showStatus(currurl);
  522.       }
  523.    }
  524.  
  525.    //////////////////////////////////////////////////////////////////
  526.    // Draw a pretty little LED
  527.    private void drawLED(int x, int y, boolean on, int col, Graphics gr)
  528.    {
  529.       if(on)
  530.       {
  531.          gr.setColor(colors[col]);
  532.       }
  533.       else  // its off
  534.       {
  535.          gr.setColor(colors[0]);
  536.       }
  537.  
  538.       switch(ledsize)
  539.       {
  540.          case 2:    // Just a pixel
  541.             gr.drawLine(x,y,x,y);
  542.             break;
  543.  
  544.          case 3:    // A 2x2 rectangle
  545.             gr.fillRect(x,y,2,2);
  546.             break;
  547.  
  548.          case 4:   // A 3x3 '+'
  549.             gr.drawLine(x,y+1,x+2,y+1);
  550.             gr.drawLine(x+1,y,x+1,y+2);
  551.             break;
  552.  
  553.          case 5:   // The original size seen in previous versions
  554.             gr.fillRect(x+1,y,2,4);
  555.             gr.fillRect(x,y+1,4,2);
  556.             break;
  557.       }
  558.  
  559.       if(ledsize == 5 && !on)
  560.       {
  561.          gr.setColor(highlight);
  562.          gr.drawLine(x+1,y+1,x+1,y+1);  // the cool little highlight
  563.       }
  564.    }
  565.          
  566.    //////////////////////////////////////////////////////////////////
  567.    // My version of paint3DRect (variable width) 
  568.    void draw3DRect(Graphics gr, int x, int y, int lx, int ly, int width, boolean raised)
  569.    {
  570.       int i;
  571.  
  572.       for(i=0; i<width; i++)
  573.       {
  574.          if(raised)
  575.             gr.setColor(bhilite);
  576.          else
  577.             gr.setColor(bshadow);
  578.             
  579.          gr.drawLine(x+i,y+i,lx-i,y+i);
  580.          gr.drawLine(x+i,y+i,x+i,ly-i);
  581.          
  582.          if(raised)
  583.             gr.setColor(bshadow);
  584.          else
  585.             gr.setColor(bhilite);
  586.             
  587.          gr.drawLine(lx-i,y+i,lx-i,ly-i);
  588.          gr.drawLine(x+i,ly-i,lx-i,ly-i);
  589.       }
  590.    }
  591.  
  592.    //////////////////////////////////////////////////////////////////
  593.    public void paint(Graphics gr)
  594.    {
  595.       int i,j;
  596.       int p,p2;
  597.       
  598.       // don't do any of this if the thread is null
  599.       if(led != null)
  600.       {   
  601.          if(border > 0)
  602.          {
  603.             draw3DRect(gr,0,0,WIDTH+2*offset-1,HEIGHT+2*offset-1,border,true);
  604.             gr.setColor(bcolor);
  605.             gr.fillRect(border,border,WIDTH+4*border,HEIGHT+4*border);
  606.             draw3DRect(gr,2*border,2*border,WIDTH+4*border-1,HEIGHT+4*border-1,border,false);
  607.          }
  608.  
  609.          // If the applet has just start, set up the pixmaps
  610.          // and draw all the LEDs off
  611.          if(beginning)
  612.          {
  613.             // OK, lets quickly set up the "offimage" (has all LED's turned
  614.             // off) so that we can draw it to the screen quicker when the
  615.             // applet first starts.
  616.             offimg = createImage(WIDTH, HEIGHT);
  617.             offmap = offimg.getGraphics();
  618.             offmap.setColor(Color.black);
  619.             offmap.fillRect(0,0,WIDTH,HEIGHT);
  620.  
  621.             for(i=0;i<HEIGHT;i+=ledsize)
  622.                for(j=0;j<WIDTH;j+=ledsize)
  623.                {
  624.                   drawLED(j,i,false,1,offmap);
  625.                }
  626.                   
  627.             gr.drawImage(offimg,offset,offset, this);
  628.  
  629.             // Now that we at least have the initial image up, create the other
  630.             // pixmaps we need.
  631.             pixmapimg = createImage(WIDTH, HEIGHT);
  632.             tmpimg = createImage(WIDTH, HEIGHT);
  633.             
  634.             pixmap = pixmapimg.getGraphics();
  635.             tmpmap = tmpimg.getGraphics();
  636.             
  637.             pixmap.setColor(Color.black);
  638.             pixmap.fillRect(0,0,WIDTH,HEIGHT);
  639.  
  640.             for(i=0;i<HEIGHT;i+=ledsize)
  641.                for(j=0;j<WIDTH;j+=ledsize)
  642.                {
  643.                   drawLED(j,i,false,1,pixmap);
  644.                }
  645.             
  646.             beginning = false;
  647.          }
  648.          else
  649.          {
  650.             gr.drawImage(pixmapimg,offset,offset, this);
  651.          }
  652.       }
  653.    }
  654.  
  655.  
  656.    //////////////////////////////////////////////////////////////////
  657.    // This procedure contains all the different transitions
  658.    // Each transition does one iteration and returns to the
  659.    // "run" procedure to use its delay.  This also allows
  660.    // the applet to be redrawn (if needed) more quickly.
  661.    public void update(Graphics gr)
  662.    {
  663.       int i,j;
  664.       int count;
  665.  
  666.       if(done)
  667.          return;
  668.  
  669.       // if we have not initialized our applet, don't do anything here.
  670.       if( (led != null) && (pixmap != null) && (offmap != null) && (tmpmap != null))
  671.       {
  672.          switch(fi.func)
  673.          {
  674.             case 0:  // Appear
  675.                if(fi.text == null)
  676.                {
  677.                   gr.drawImage(offimg,offset,offset, this);  // Turn all the LEDs off
  678.                }
  679.                else
  680.                {
  681.                   for(i=0;i<w;i++)
  682.                      for(j=0;j<h;j++)
  683.                         drawLED(i*ledsize,j*ledsize,msg.getLED(i,j),msg.getColor(i),pixmap);
  684.  
  685.                   gr.drawImage(pixmapimg,offset,offset, this);
  686.                }
  687.  
  688.                done = true;
  689.                
  690.                break;
  691.  
  692.             case 1:  // Sleep
  693.                done = true;  // We don't do anything here
  694.  
  695.                break;
  696.  
  697.             case 2:  // ScrollLeft
  698.                pixmap.copyArea(ledsize,0,WIDTH-ledsize,HEIGHT,-ledsize,0);
  699.  
  700.                for(i=0;i<HEIGHT;i+=ledsize)
  701.                   drawLED(WIDTH-ledsize,i,msg.getLED(place,i/ledsize),msg.getColor(place),pixmap);
  702.  
  703.                gr.drawImage(pixmapimg,offset,offset, this);
  704.  
  705.                place++;
  706.  
  707.                if(!msg.inRange(place))
  708.                   done = true;
  709.  
  710.                break;
  711.  
  712.             case 3:  // ScrollRight
  713.                pixmap.copyArea(0,0,WIDTH-ledsize,HEIGHT,ledsize,0);
  714.  
  715.                for(i=0;i<HEIGHT;i+=ledsize)
  716.                   drawLED(0,i,msg.getLED(place,i/ledsize),msg.getColor(place),pixmap);
  717.  
  718.                gr.drawImage(pixmapimg,offset,offset, this);
  719.  
  720.                place--;
  721.  
  722.                if(place < 0)
  723.                   done = true;
  724.                   
  725.                break;
  726.  
  727.             case 4:  // ScrollUp
  728.                pixmap.copyArea(0,ledsize,WIDTH,HEIGHT-ledsize,0,-ledsize);
  729.                
  730.                for(i=0;i<WIDTH;i+=ledsize)
  731.                   if(msg.inRange(i/ledsize))
  732.                      drawLED(i,HEIGHT-ledsize,msg.getLED(i/ledsize,place),msg.getColor(i/ledsize),pixmap);
  733.                   else
  734.                      drawLED(i,HEIGHT-ledsize,false,1,pixmap);
  735.  
  736.                gr.drawImage(pixmapimg,offset,offset, this);
  737.                
  738.                place++;
  739.  
  740.                if(place >= h)
  741.                   done = true;
  742.                   
  743.                break;
  744.  
  745.             case 5:  // ScrollDown
  746.                pixmap.copyArea(0,0,WIDTH,HEIGHT-ledsize,0,ledsize);
  747.                
  748.                for(i=0;i<WIDTH;i+=ledsize)
  749.                   if(msg.inRange(i/ledsize))
  750.                   {
  751.                      drawLED(i,0,msg.getLED(i/ledsize,place),msg.getColor(i/ledsize),pixmap);
  752.                   }
  753.                   else
  754.                   {
  755.                      drawLED(i,0,false,1,pixmap);
  756.                   }
  757.  
  758.                gr.drawImage(pixmapimg,offset,offset, this);
  759.                
  760.                place--;
  761.  
  762.                if(place < 0)
  763.                   done = true;
  764.  
  765.                break;
  766.  
  767.             case 6: // Pixel
  768.                i = place + fi.times;
  769.                while(place < WIDTH/ledsize*h && place < i)
  770.                {
  771.                   if(msg.inRange(pix[place].x))
  772.                   {
  773.                      drawLED(pix[place].x*ledsize,pix[place].y*ledsize,msg.getLED(pix[place].x,pix[place].y),msg.getColor(pix[place].x),pixmap);
  774.                   }
  775.                   else
  776.                   {
  777.                      drawLED(pix[place].x*ledsize,pix[place].y*ledsize,false,1,pixmap);
  778.                   }
  779.  
  780.                   place++;
  781.                }
  782.                gr.drawImage(pixmapimg,offset,offset, this);
  783.                
  784.                if(place >= w*h)
  785.                   done = true;
  786.                
  787.                break;
  788.                
  789.             case 7:  // Blink
  790.                if(place%2 == 0)
  791.                   gr.drawImage(offimg,offset,offset, this);
  792.                else
  793.                   gr.drawImage(pixmapimg,offset,offset, this);
  794.  
  795.                place--;
  796.  
  797.                if(place == 0)
  798.                   done = true;
  799.  
  800.                break;
  801.  
  802.             case 8:  // OverRight
  803.                if(msg.inRange(place))
  804.                   for(i=0;i<h;i++)
  805.                      drawLED(place*ledsize,i*ledsize,msg.getLED(place,i),msg.getColor(place),pixmap);
  806.                else
  807.                   for(i=0;i<h;i++)
  808.                      drawLED(place*ledsize,i*ledsize,false,1,pixmap);
  809.  
  810.                gr.drawImage(pixmapimg,offset,offset, this);
  811.  
  812.                place++;
  813.  
  814.                if(place >= w)
  815.                   done = true;
  816.  
  817.                break;
  818.                      
  819.             case 9:  // ScrollCenter
  820.                // The right side
  821.                if(w >= place*2)
  822.                {
  823.                   pixmap.copyArea(WIDTH/2,0,WIDTH/2-ledsize,HEIGHT,ledsize,0);
  824.                   for(i=0;i<h;i++)
  825.                      if(msg.inRange(w-place))
  826.                         drawLED(WIDTH/2,i*ledsize,msg.getLED(w-place,i),msg.getColor(w-place),pixmap);
  827.                      else
  828.                         drawLED(WIDTH/2,i*ledsize,false,1,pixmap);
  829.                }
  830.  
  831.                if(place < w/2)
  832.                {
  833.                   pixmap.copyArea(ledsize,0,WIDTH/2-ledsize,HEIGHT,-ledsize,0);
  834.                   for(i=0;i<h;i++)
  835.                      if(msg.inRange(place))
  836.                         drawLED(WIDTH/2-ledsize,i*ledsize,msg.getLED(place,i),msg.getColor(place),pixmap);
  837.                      else
  838.                         drawLED(WIDTH/2-ledsize,i*ledsize,false,1,pixmap);
  839.                }
  840.  
  841.                gr.drawImage(pixmapimg,offset,offset, this);
  842.                
  843.                place++;
  844.  
  845.                if(place >= w/2 && place*2 > w)
  846.                   done = true;
  847.  
  848.                break;
  849.  
  850.             case 10:  // OverCenter
  851.                // The right side
  852.                if(w >= place+w/2)
  853.                {
  854.                   for(i=0;i<h;i++)
  855.                      if(msg.inRange(w/2+place+1))
  856.                         drawLED(WIDTH/2+place*ledsize+ledsize,i*ledsize,msg.getLED(w/2+place+1,i),msg.getColor(w/2+place+1),pixmap);
  857.                      else
  858.                         drawLED(WIDTH/2+place*ledsize+ledsize,i*ledsize,false,1,pixmap);
  859.                }
  860.  
  861.                if(place < w/2)
  862.                {
  863.                   for(i=0;i<h;i++)
  864.                      if(msg.inRange(w/2-place))
  865.                         drawLED(WIDTH/2-place*ledsize,i*ledsize,msg.getLED(w/2-place,i),msg.getColor(w/2-place),pixmap);
  866.                      else
  867.                         drawLED(WIDTH/2-place*ledsize,i*ledsize,false,1,pixmap);
  868.                }
  869.  
  870.                gr.drawImage(pixmapimg,offset,offset, this);
  871.                
  872.                place++;
  873.  
  874.                if(w < w/2+place && place >= w/2)
  875.                   done = true;
  876.  
  877.                break;
  878.  
  879.             case 11:  // OverLeft
  880.                if(msg.inRange(place))
  881.                   for(i=0;i<h;i++)
  882.                      drawLED(place*ledsize,i*ledsize,msg.getLED(place,i),msg.getColor(place),pixmap);
  883.                else
  884.                   for(i=0;i<h;i++)
  885.                      drawLED(place*ledsize,i*ledsize,false,1,pixmap);
  886.  
  887.                gr.drawImage(pixmapimg,offset,offset, this);
  888.  
  889.                place--;
  890.  
  891.                if(place == 0)
  892.                   done = true;
  893.  
  894.                break;
  895.                
  896.             case 12:  // OverUp
  897.                for(i=0;i<w;i++)
  898.                {
  899.                   if(msg.inRange(i))
  900.                      drawLED(i*ledsize,place*ledsize,msg.getLED(i,place),msg.getColor(i),pixmap);
  901.                   else
  902.                      drawLED(i*ledsize,place*ledsize,false,1,pixmap);
  903.                }
  904.  
  905.                gr.drawImage(pixmapimg,offset,offset, this);
  906.  
  907.                place--;
  908.  
  909.                if(place < 0)
  910.                   done = true;
  911.  
  912.                break;
  913.  
  914.             case 13:  // OverDown
  915.                for(i=0;i<w;i++)
  916.                {
  917.                   if(msg.inRange(i))
  918.                      drawLED(i*ledsize,place*ledsize,msg.getLED(i,place),msg.getColor(i),pixmap);
  919.                   else
  920.                      drawLED(i*ledsize,place*ledsize,false,1,pixmap);
  921.                }
  922.  
  923.                gr.drawImage(pixmapimg,offset,offset, this);
  924.  
  925.                place++;
  926.  
  927.                if(place >= h)
  928.                   done = true;
  929.  
  930.                break;
  931.          }  // End switch() statement
  932.       }  // End if(led != null)
  933.  
  934.       return;
  935.  
  936.    }  // End update()
  937. }  // End LED class
  938.