home *** CD-ROM | disk | FTP | other *** search
/ Internet 1996 World Exposition / park.org.s3.amazonaws.com.7z / park.org.s3.amazonaws.com / Java / LEDSign / LED / LED.java < prev    next >
Encoding:
Java Source  |  2017-09-21  |  24.1 KB  |  827 lines

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