home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1997 April / Win95_04974.iso / docs / 00016 / 01649.exe / data.2 / program / Templates / java / ImageHandler.tpl next >
Encoding:
Text File  |  1996-10-04  |  20.2 KB  |  666 lines

  1. <$$FILE
  2.     TYPE=JAVA
  3.     DESC="Java Image Handler Applet Generator"
  4. >
  5. <$$PARAMS
  6.     CLASSNAME=STRING CLASSNAME_D="Name of class"    
  7.     NOTE1=NOTICE NOTE1_D="(Should be the same as the filename, but you can do whatever you want...)"
  8.     PAGE
  9.  
  10.     CNONE=RADIO CNONE_D="No comments"
  11.     CBASE=RADIO CBASE_D="Basic comments"
  12.     CVERBOSE=RADIO CVERBOSE_M=ON CVERBOSE_D="Verbose comments"
  13.     PAGE
  14.     
  15.     DEBUG=CHECK DEBUG_D="Extra debugging support"
  16.     MOUSEHANDLER=CHECK MOUSEHANDLER_D="Generate mouse event handler code"
  17.     PAGE
  18.     
  19.     NOIMAGES=RADIO NOIMAGES_D="Do not handle images at all"
  20.     LOADIMAGES=RADIO LOADIMAGES_D="Generate code to load a series of images"
  21.     ANIMATEIMAGES=RADIO ANIMATEIMAGES_M=ON 
  22.     ANIMATEIMAGES_D="Load a series of images and use buffers and threads to animate them"
  23.     PAGE
  24.     
  25.     GENERATEHTML=CHECK GENERATEHTML_M="ON" 
  26.     GENERATEHTML_D="Generate a sample HTML page for the applet"
  27. ><$$NO>
  28. <$$IF S="CBASE=ON | CVERBOSE=ON"><$$NO>
  29.  
  30. // <$$INSERT PARAM=~CLASSNAME>, generated with the Mortar JavaImageHandler gnome
  31. //
  32. <$$IF S="CVERBOSE=ON"><$$NO>
  33. // This applet is customizable through APPLET tags; to gain this functionality
  34. // you should call it from an HTML document rather than directly as a .class
  35. // file with the interpreter.
  36. // 
  37. <$$ELSE><$$ENDIF><$$NO>
  38. // Parameters
  39. // NAME               DEFAULT/EX VAL. VALUE FORMAT, DESCRIPTION
  40. //------------------- --------------- ----------------------------------------
  41. <$$IF S="MOUSEHANDLER=ON"><$$NO>
  42. // stopOnClick        false           boolean (true/false), stop on mouse clicks
  43. //      Toggles running the animation thread each time a mouse button is pressed
  44. <$$ELSE><$$ENDIF><$$NO>
  45. <$$IF S="NOIMAGES=ON"><$$ELSE><$$NO>
  46. // imageX             image1          relative URL to the image (from 1)
  47. <$$ENDIF><$$NO>
  48. <$$IF S="ANIMATEIMAGES=ON"><$$NO>
  49. // delay              200             milliseconds between frames
  50. // clear              true            clear output before switching images?
  51. <$$ELSE><$$ENDIF><$$NO>
  52. // backgroundColor    000000          RRGGBB, in base 16 (hexadecimal); 00-FF
  53. <$$ELSE><$$ENDIF><$$NO>
  54.  
  55. <$$IF S="GENERATEHTML=ON"><$$NO>
  56. /*  Here is a sample HTML document which you can cut and paste
  57.     into any HTML file to use your applet, assuming it is placed
  58.     in the same directory.
  59.  
  60. <$$INSERT PARAM="<">HTML>
  61. <$$INSERT PARAM="<">HEAD>
  62. <$$INSERT PARAM="<">TITLE>The <$$INSERT PARAM=~CLASSNAME> Applet<$$INSERT PARAM="<">/TITLE>
  63. <$$INSERT PARAM="<">/HEAD>
  64.  
  65. <$$INSERT PARAM="<">BODY>
  66. <$$INSERT PARAM="<">H1>The <$$INSERT PARAM=~CLASSNAME> Applet<$$INSERT PARAM="<">/H1>
  67.  
  68. Have a look at an applet generated by the 
  69. Mortar Java Image Handler Applet Creation Gnome!
  70.  
  71. <$$INSERT PARAM="<">p>
  72.  
  73. <$$INSERT PARAM="<">APPLET CODE="<$$INSERT PARAM=~CLASSNAME>" WIDTH=400 HEIGHT=400>
  74. <$$IF S="MOUSEHANDLER=ON"><$$NO>
  75. <$$INSERT PARAM="<">PARAM NAME=stopOnClick VALUE=true>
  76. <$$ELSE><$$ENDIF><$$NO>
  77. <$$IF S="NOIMAGES=ON"><$$ELSE><$$NO>
  78. <$$INSERT PARAM="<">PARAM NAME=image0 VALUE="asdf.jpg">
  79. <$$ENDIF><$$NO>
  80. <$$IF S="ANIMATEIMAGES=ON"><$$NO>
  81. <$$INSERT PARAM="<">PARAM NAME=delay VALUE=200>
  82. <$$INSERT PARAM="<">PARAM NAME=clear VALUE=false>
  83. <$$ELSE><$$ENDIF><$$NO>
  84. <$$INSERT PARAM="<">PARAM NAME=backgroundColor VALUE=100030>
  85.  
  86. <$$INSERT PARAM="<">IMG SRC="does_not_exist.gif" WIDTH=400 HEIGHT=400 
  87.     ALT="You must have a Java-capable browser to see the wonder!"
  88. >
  89. You must have a Java-capable browser to see the wonder!
  90. <$$INSERT PARAM="<">/APPLET>
  91.  
  92. <$$INSERT PARAM="<">/BODY>
  93. <$$INSERT PARAM="<">/HTML>
  94.  
  95.  
  96. */
  97. <$$ELSE><$$ENDIF><$$NO>    
  98.  
  99. import java.applet.Applet;
  100. import java.awt.*;
  101. import java.net.*;
  102. import java.util.*;
  103.  
  104. public class <$$INSERT PARAM=~CLASSNAME> extends Applet <$$NO>
  105. <$$IF S="ANIMATEIMAGES=ON">implements Runnable <$$ELSE><$$ENDIF>
  106. {
  107. <$$IF S="DEBUG=ON"><$$NO>
  108. <$$IF S="CBASE=ON | CVERBOSE=ON"><$$NO>
  109.     // To turn on printing to System.out (for debugging), change
  110.     // SYSTEMOUTPUT to true.  If MOUSEINFO is true, detailed information
  111.     // about mouse events will be printed.
  112. <$$ELSE><$$ENDIF><$$NO>
  113.     public static final boolean SYSTEMOUTPUT = false;
  114.     public static final boolean MOUSEINFO = false;
  115.  
  116. <$$ELSE><$$ENDIF><$$NO>
  117.     public Color backgroundColor, foregroundColor;
  118.     
  119. <$$IF S="MOUSEHANDLER=ON"><$$NO>
  120.     public boolean threadSuspended=false;
  121.  
  122. <$$ELSE><$$ENDIF><$$NO>
  123. <$$IF S="ANIMATEIMAGES=ON"><$$NO>
  124. <$$IF S="CBASE=ON | CVERBOSE=ON"><$$NO>
  125.     // Parameter variables
  126. <$$ELSE><$$ENDIF><$$NO>
  127.     public int delay;
  128.     public boolean clear;
  129.  
  130. <$$IF S="CBASE=ON | CVERBOSE=ON"><$$NO>
  131.     // the off-screen image, for flicker-free updates,
  132.     // and a Thread variable for our animating thread.
  133. <$$ELSE><$$ENDIF><$$NO>
  134.     protected Image output;
  135.     protected int imagewidth, imageheight;
  136.     private Thread animatorThread = null;
  137.  
  138. <$$ELSE><$$ENDIF><$$NO>
  139. <$$IF S="ANIMATEIMAGES=ON | LOADIMAGES=ON"><$$NO>
  140. <$$IF S="CBASE=ON | CVERBOSE=ON"><$$NO>
  141.     // Image-related variables
  142. <$$ELSE><$$ENDIF><$$NO>
  143. <$$IF S="CVERBOSE=ON"><$$NO>
  144.     protected int numImages=0;          // the number of frames in the animation (1-based)
  145.     protected MediaTracker tracker;     // the Tracker is used to monitor the loading of images
  146.     protected ImageLinkedList images, currentImage; 
  147.                                         // the list of images, and a pointer to a "current" one
  148.  
  149. <$$ELSE><$$NO>
  150.     protected int numImages=0;
  151.     protected MediaTracker tracker;
  152.     protected ImageLinkedList images, currentImage; 
  153.  
  154. <$$ENDIF><$$NO>
  155. <$$ELSE><$$ENDIF><$$NO>
  156.     public void init()
  157.     {
  158. <$$IF S="CBASE=ON | CVERBOSE=ON"><$$NO>
  159.         // Create the foregroundColor as the complementary to the backgroundColor
  160. <$$ELSE><$$ENDIF><$$NO>
  161.         backgroundColor = IEExtend.strColor( getParameter( "backgroundColor" ), Color.black);
  162.         foregroundColor = new Color( 255-backgroundColor.getRed(),
  163.                                 255-backgroundColor.getGreen(),
  164.                                 255-backgroundColor.getBlue() );
  165. <$$IF S="ANIMATEIMAGES=ON"><$$NO>
  166.         
  167.         String junk;
  168.  
  169.         delay = IEExtend.strInt( getParameter( "delay" ), 200 );
  170.  
  171.         junk=getParameter( "clear" );
  172.         if( junk==null ) 
  173.             clear=false; 
  174.         else 
  175.             clear = (junk.equals("true") ? true : false);
  176.  
  177. <$$IF S="CVERBOSE=ON"><$$NO>
  178.         // Create the off-screen image of appropriate size
  179. <$$ELSE><$$ENDIF><$$NO>
  180.         updateOSI();
  181.  
  182.         Graphics g = output.getGraphics();
  183.         g.setColor( backgroundColor );
  184.         g.fillRect(0,0,size().width-1,size().height-1);
  185.         g.setColor( foregroundColor );
  186.  
  187. <$$ELSE><$$ENDIF><$$NO>
  188. <$$IF S="ANIMATEIMAGES=ON | LOADIMAGES=ON"><$$NO>
  189. <$$IF S="CVERBOSE=ON"><$$NO>
  190.         // Set up a MediaTracker to track the loading of images
  191.         // and initialize the image Linked List.
  192. <$$ELSE><$$ENDIF><$$NO>
  193.         tracker = new MediaTracker( this );
  194.         images = new ImageLinkedList();
  195.         currentImage = images;
  196.         
  197. <$$IF S="CVERBOSE=ON"><$$NO>
  198.         // The loop should stop when an image can't be loaded 
  199.         // because the parameter for that image doesn't exist.
  200. <$$ELSE><$$ENDIF><$$NO>
  201.         for( int i=1; numImages+1==i; i++ ) 
  202.         {
  203.             currentImage.name = this.getParameter( "image" + i );
  204.             if( currentImage.name==null ) 
  205.             {
  206. <$$IF S="CVERBOSE=ON"><$$NO>
  207.                 // The applet will animate whatever images loaded successfully.
  208.  
  209. <$$ELSE><$$ENDIF><$$NO>
  210.                 currentImage.name="";
  211. <$$IF S="DEBUG=ON"><$$NO>
  212.                 String message = "Bad PARAM tag for next image  <$$INSERT PARAM="<">PARAM NAME="
  213.                     + "image" + i + " VALUE=" + currentImage.name + "<$$INSERT PARAM=">">" + "\n"
  214.                     + "If you only specified this many, then that's good!";
  215.                 if( SYSTEMOUTPUT ) System.out.println( message );
  216. //              output.getGraphics().drawString( message, 10, 70 );
  217. <$$ELSE><$$ENDIF><$$NO>
  218.                 if( currentImage.previous != null ) 
  219.                 {
  220.                     (currentImage.previous).next=null;
  221.                     currentImage=null;
  222.                 }
  223.             }
  224.             else
  225.             {
  226. <$$IF S="CVERBOSE=ON"><$$NO>
  227.                 // Everything's good, so register with the tracker.
  228.  
  229. <$$ELSE><$$ENDIF><$$NO>
  230.                 currentImage.image = this.getImage( this.getDocumentBase(), currentImage.name);
  231.                 tracker.addImage(currentImage.image, i);
  232.                 currentImage.number = i;
  233.  
  234. <$$IF S="DEBUG=ON"><$$NO>
  235.                 if( SYSTEMOUTPUT )
  236.                 {
  237.                     System.out.println( "Registered image called " + currentImage.name );
  238.                     if( currentImage.previous != null ) 
  239.                         System.out.println( "Previous called " + currentImage.previous.name );
  240.                 }
  241.  
  242. <$$ELSE><$$ENDIF><$$NO>
  243.                 currentImage.next=new ImageLinkedList();
  244.                 (currentImage.next).previous=currentImage;
  245.                 currentImage=currentImage.next;
  246.                 numImages++;
  247.             }
  248.         }
  249.         repaint();
  250. <$$ELSE><$$ENDIF><$$NO>
  251.     }
  252.  
  253. <$$IF S="ANIMATEIMAGES=ON | LOADIMAGES=ON"><$$NO>
  254. <$$IF S="CVERBOSE=ON"><$$NO>
  255.     // The Applet's start method, called by the browser after init()
  256. <$$ELSE><$$ENDIF><$$NO>
  257.     public void start() 
  258.     {
  259. <$$IF S="ANIMATEIMAGES=ON"><$$NO>
  260. <$$IF S="CVERBOSE=ON"><$$NO>
  261.         // If the thread has not been previously initialized, start it.
  262. <$$ELSE><$$ENDIF><$$NO>
  263.         if( animatorThread == null ) 
  264.         {
  265. <$$IF S="CVERBOSE=ON"><$$NO>
  266.             // Start another thread on this object);
  267. <$$ELSE><$$ENDIF><$$NO>
  268.             animatorThread = new Thread(this);
  269. <$$IF S="CVERBOSE=ON"><$$NO>
  270.  
  271.             // Will ultimately cause a separate thread to call the run method
  272. <$$ELSE><$$ENDIF><$$NO>
  273.             animatorThread.start();
  274.         }
  275. <$$ELSE><$$NO>
  276.         loadResultMessage = loadImages();
  277. <$$ENDIF><$$NO>
  278.     }
  279.  
  280. <$$ELSE><$$ENDIF><$$NO>
  281. <$$IF S="ANIMATEIMAGES=ON"><$$NO>
  282. <$$IF S="CVERBOSE=ON"><$$NO>
  283.     // The Applet's stop method, called by a browser to cease action.
  284. <$$ELSE><$$ENDIF><$$NO>
  285.     public void stop() 
  286.     {
  287.         if(( animatorThread != null) && animatorThread.isAlive())
  288.             animatorThread.stop();
  289.         animatorThread = null;
  290.     }
  291.  
  292. <$$ELSE><$$ENDIF><$$NO>
  293. <$$IF S="MOUSEHANDLER=ON"><$$NO>
  294. <$$IF S="CBASE=ON | CVERBOSE=ON"><$$NO>
  295.     // Mouse button handling code
  296. <$$ELSE><$$ENDIF><$$NO>
  297.     public boolean mouseDown(Event event, int x, int y)
  298.     {
  299. <$$IF S="MOUSEHANDLER=ON"><$$NO>
  300.         if( threadSuspended==false ) 
  301.             threadSuspended=true;
  302.         else 
  303.             threadSuspended=false;
  304.  
  305. <$$ELSE><$$ENDIF><$$NO>
  306.         String message;
  307. <$$IF S="DEBUG=ON">
  308.         if( SYSTEMOUTPUT ) 
  309.         {
  310. <$$IF S="CVERBOSE=ON"><$$NO>
  311.             // Call to System.out for debugging
  312. <$$ELSE><$$ENDIF><$$NO>
  313.             System.out.println("in mousedown");
  314.             System.out.println("Mods " + event.modifiers);
  315.         }
  316.  
  317.         if( MOUSEINFO ) 
  318.         {
  319. <$$IF S="ANIMATEIMAGES=ON"><$$NO>
  320.             Graphics g = output.getGraphics();
  321. <$$ELSE><$$NO>
  322.             Graphics g = this.getGraphics();
  323. <$$ENDIF><$$NO>
  324.             g.setColor( backgroundColor );
  325.             g.fillRect(0, 0, size().width-1, size().height-1);
  326.             g.setColor(foregroundColor);
  327.  
  328. <$$IF S="CVERBOSE=ON"><$$NO>
  329.             // Right click sets META_MASK
  330. <$$ELSE><$$ENDIF><$$NO>
  331.             if ((event.modifiers & Event.META_MASK) != 0)
  332.                 message = new String("Right button");
  333.             else
  334.                 message = new String("Left button");
  335.  
  336. <$$IF S="CVERBOSE=ON"><$$NO>
  337.             // Check CTRL key
  338. <$$ELSE><$$ENDIF><$$NO>
  339.             if ((event.modifiers & Event.CTRL_MASK) != 0)
  340.                 message += " + CTRL";
  341.  
  342. <$$IF S="CVERBOSE=ON"><$$NO>
  343.             // Check SHIFT key
  344. <$$ELSE><$$ENDIF><$$NO>
  345.             if ((event.modifiers & Event.SHIFT_MASK) != 0)
  346.                 message += " + SHIFT";
  347.  
  348.             g.drawString(message, 30, 25);
  349. <$$IF S="ANIMATEIMAGES=ON"><$$NO>
  350.  
  351.             repaint();
  352. <$$ELSE><$$ENDIF><$$NO>
  353.         }
  354.         return true;
  355.     }
  356.  
  357. <$$ELSE><$$ENDIF><$$NO>
  358. <$$ELSE><$$ENDIF><$$NO>
  359. <$$IF S="CBASE=ON | CVERBOSE=ON"><$$NO>
  360.     // This method handles drawing.
  361. <$$ELSE><$$ENDIF><$$NO>
  362.     public void paint(Graphics g)
  363.     {
  364.         Dimension d = this.size();
  365.  
  366. <$$IF S="ANIMATEIMAGES=ON"><$$NO>
  367.         if( (imagewidth != d.width) || (imageheight != d.height )) 
  368.         {
  369.             updateOSI();
  370.         }
  371.  
  372.         if (output != null)
  373.         {
  374.             g.drawImage(output, 0, 0, this);
  375.         }
  376. <$$ELSE><$$NO>
  377.         g.setColor( backgroundColor );
  378.         g.fillRect(0,0,size().width-1,size().height-1);
  379. <$$IF S="LOADIMAGES=ON"><$$NO>        
  380.         if( loadResultMessage!="" ) 
  381.         {
  382.             g.setColor( foregroundColor );
  383.             g.drawString( loadResultMessage, 10, 20 );
  384.             this.showStatus( loadResultMessage );
  385.         }
  386. <$$ELSE><$$ENDIF><$$NO>
  387. <$$ENDIF><$$NO>
  388.     }
  389.  
  390. <$$IF S="ANIMATEIMAGES=ON"><$$NO>
  391. <$$IF S="CBASE=ON | CVERBOSE=ON"><$$NO>
  392.     // This is overridden because the paint() method induces an unneeded clear.
  393. <$$ELSE><$$ENDIF><$$NO>
  394.     public void repaint() 
  395.     {
  396.         Graphics g = this.getGraphics();
  397.         g.drawImage( output, 0, 0, this );
  398.     }
  399.  
  400.     public void updateOSI() 
  401.     {
  402. <$$IF S="CBASE=ON | CVERBOSE=ON"><$$NO>
  403.         // Handle resizing of the applet and OSI
  404. <$$ELSE><$$ENDIF><$$NO>
  405.         Graphics g;
  406.         Image newOSI = createImage(size().width-1, size().height-1);
  407.         g = newOSI.getGraphics();
  408.  
  409.         g.setColor( backgroundColor );
  410.         g.fillRect(0,0,size().width-1,size().height-1);
  411.         if( output!=null )
  412.             g.drawImage( output, 0, 0, this );
  413.  
  414.         imagewidth=size().width;
  415.         imageheight=size().height;
  416.     
  417.         output=newOSI;
  418.     }
  419.  
  420. <$$ELSE><$$ENDIF><$$NO>
  421. <$$IF S="ANIMATEIMAGES=ON"><$$NO>
  422. <$$IF S="CBASE=ON | CVERBOSE=ON"><$$NO>
  423.     // Implements Runnable Interface
  424. <$$ELSE><$$ENDIF><$$NO>
  425.     public void run()
  426.     {
  427. <$$ELSE><$$ENDIF><$$NO>
  428. <$$IF S="LOADIMAGES=ON"><$$NO>
  429.     protected String loadResultMessage = "";
  430.     
  431.     public String loadImages()
  432.     {
  433. <$$ELSE><$$ENDIF><$$NO>
  434. <$$IF S="ANIMATEIMAGES=ON | LOADIMAGES=ON"><$$NO>
  435. <$$IF S="CVERBOSE=ON"><$$NO>
  436.         // This method is called when the animatorThread is started,
  437.         // care of Runnable interface.
  438.     
  439. <$$IF S="CBASE=ON | CVERBOSE=ON"><$$NO>
  440.         // This code will wait for the loading of the images to
  441.         // complete before doing anything else, then sequence the images.
  442.  
  443. <$$ELSE><$$ENDIF><$$NO>
  444. <$$ELSE><$$ENDIF><$$NO>
  445.         this.showStatus( "Loading images..." );
  446.         try 
  447.         {
  448.             tracker.waitForAll();
  449.         }
  450.         catch (InterruptedException e) 
  451.             {}
  452.  
  453.         if( tracker.isErrorAny() );
  454.         {
  455.             currentImage=images;
  456.             for( int i=1; i<$$INSERT PARAM="<">=numImages; i++ ) 
  457.             {
  458.                 if (tracker.isErrorID(i)) 
  459.                 {
  460.                     String message = "Error loading \"image" + i + "\" (" 
  461.                         + currentImage.name + "); quitting.";
  462.                     this.showStatus( message );
  463. <$$IF S="DEBUG=ON"><$$NO>
  464.                     if( SYSTEMOUTPUT )
  465.                         System.out.println( message );
  466. <$$ELSE><$$ENDIF><$$NO>
  467. <$$IF S="LOADIMAGES=ON"><$$NO>
  468. <$$IF S="CVERBOSE=ON"><$$NO>
  469.  
  470.                     // The whole reason for this is because when the start()
  471.                     // method exits, any Status message it has set is replaced
  472.                     // with something like "Applet started.", so an alternate
  473.                     // way of delivering a message was established.
  474. <$$ELSE><$$ENDIF><$$NO>
  475.                     return message;
  476. <$$ELSE><$$NO>
  477.                     return;
  478. <$$ENDIF><$$NO>
  479.                 }
  480.                 currentImage=currentImage.next;
  481.             }
  482.         }
  483.  
  484. <$$IF S="DEBUG=ON"><$$NO>
  485. /*      This an inefficient way to do it, but it's here because it's 
  486.         slightly easier to debug.
  487.  
  488.         for( int i=0; i<$$INSERT PARAM="<">numImages;i++ ) 
  489.         {
  490.             this.showStatus( "Loading image " + i + "." );
  491.             try 
  492.             {
  493.                 tracker.waitForID(i);
  494.             }
  495.             catch (InterruptedException e) 
  496.                 {}
  497.  
  498.             if (tracker.isErrorID(i)) 
  499.             {
  500.                 this.showStatus( "Error loading image " + i + "; quitting." );
  501.             }
  502.         }
  503. */
  504.  
  505. <$$ELSE><$$ENDIF><$$NO>
  506.         this.showStatus( "Animating " + numImages + " images." );
  507. <$$ELSE><$$ENDIF><$$NO>
  508. <$$IF S="ANIMATEIMAGES=ON"><$$NO>
  509.  
  510.         currentImage=images;
  511.         threadSuspended=false;
  512.         while (true)
  513.         {
  514.             try 
  515.             {
  516. <$$IF S="MOUSEHANDLER=ON"><$$NO>            
  517.                 if( !threadSuspended )
  518.                 {
  519. <$$ELSE><$$NO>
  520. <$$IF S="CNONE"><$$NO>
  521.                 {
  522. <$$ELSE><$$NO>
  523.                 {   // braces are for functionality you didn't ask for
  524. <$$ENDIF><$$NO>                
  525. <$$ENDIF><$$NO>                
  526.                     Graphics g = output.getGraphics();
  527.                     if( clear ) 
  528.                     {
  529.                         g.setColor( backgroundColor );
  530.                         g.fillRect(0,0,size().width-1,size().height-1);
  531.                     }
  532.                     g.setColor( foregroundColor );
  533. <$$IF S="DEBUG=ON"><$$NO>
  534. //                  g.drawString( "yummy thread is running", 10, 50 );
  535. <$$ELSE><$$ENDIF><$$NO>
  536.                     g.drawImage( currentImage.image, 0, 0, this );
  537.                     repaint();
  538.                     Thread.sleep(delay);
  539.                     if( currentImage.next != null )
  540.                         currentImage = currentImage.next;
  541.                     else
  542.                         currentImage = images;
  543.                 }
  544.             }
  545.             catch (InterruptedException e)
  546.                 {}
  547.         }
  548.     }
  549.  
  550. <$$ELSE><$$NO>
  551. <$$IF S="LOADIMAGES=ON"><$$NO>
  552.         return (numImages + " images loaded successfully.");
  553.     }
  554.  
  555. <$$ELSE><$$ENDIF><$$NO>
  556. <$$ENDIF><$$NO>
  557. <$$IF S="CBASE=ON | CVERBOSE=ON"><$$NO>
  558.     // For running standalone
  559. <$$ELSE><$$ENDIF><$$NO>
  560.     public static void main(String[] argv)
  561.     {
  562. <$$IF S="CBASE=ON | CVERBOSE=ON"><$$NO>
  563.         // Create the frame and launch animator
  564.         
  565.         // Do note that getParameter doesn't really work without an
  566.         // Applet context from which to retrieve the parameters, so...
  567.         // you will have to make a way around it.  I, personally,
  568.         // recommend a global String[], which could easily replace all the
  569.         // getParameter stuff since it already has an index (usually i)
  570.         // which you can use!  Isn't that clever?  Thanks...
  571.  
  572. <$$ELSE><$$ENDIF><$$NO>
  573.         Frame f = new Frame("animatorFrame");
  574.         f.reshape(100, 100, 200, 100);
  575.         f.show();
  576.  
  577.         <$$INSERT PARAM=~CLASSNAME> x = new <$$INSERT PARAM=~CLASSNAME>();
  578.         f.add("Center", x);
  579.         x.init();
  580.         x.start();
  581.     }
  582. }
  583.  
  584. class IEExtend
  585. {
  586. <$$IF S="CBASE=ON | CVERBOSE=ON"><$$NO>
  587.     // The IE Extend class faciliates importing variables
  588.     // in different formats
  589.  
  590.     // Modified for consistency by JAR 
  591.  
  592. <$$ELSE><$$ENDIF><$$NO>
  593.    public final static int strInt(String c, int def)
  594.    {
  595.       if(c!=null && c.length() > 0)
  596.       {
  597.          try
  598.          {
  599.             return Integer.parseInt(c);
  600.          }
  601.          catch(NumberFormatException e)
  602.          {
  603.             return def;
  604.          }
  605.       }
  606.       return def;
  607.    }
  608.  
  609.    public final static double strDouble(String c, double def)
  610.    {
  611.       if(c!=null && c.length() > 0)
  612.       {
  613.          try
  614.          {
  615.             return Double.valueOf(c).doubleValue();
  616.          }
  617.          catch(NumberFormatException e)
  618.          {
  619.             return def;
  620.          }
  621.       }
  622.       return def;
  623.    }
  624.  
  625.    public final static Color strColor(String c, Color def)
  626.    {
  627.       if(c == null)
  628.          return def;
  629.       return colorFromStr(c,def);
  630.    }
  631.  
  632.    public final static Color colorFromStr(String c, Color def)
  633.    {
  634.       if(c.length() <$$INSERT PARAM="<"> 6)
  635.          return def;
  636.       String t;
  637.       t = new String();
  638.       t += c.charAt(0);
  639.       t += c.charAt(1);
  640.       int r = Integer.parseInt(t,16);
  641.       t = new String();
  642.       t += c.charAt(2);
  643.       t += c.charAt(3);
  644.       int g = Integer.parseInt(t,16);
  645.       t = new String();
  646.       t += c.charAt(4);
  647.       t += c.charAt(5);
  648.       int b = Integer.parseInt(t,16);
  649.  
  650.       return new Color(r,g,b);
  651.    }
  652. }
  653. <$$IF S="ANIMATEIMAGES=ON | LOADIMAGES=ON"><$$NO>
  654.  
  655. class ImageLinkedList
  656. {
  657.     ImageLinkedList next=null;
  658.     ImageLinkedList previous=null;
  659.     Image image=null;
  660.     String name="";
  661.     int number=0;
  662. }
  663. <$$ELSE><$$ENDIF><$$NO>
  664.  
  665.  
  666.