home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Extras / Content / Images / StockObjects / objects / java / ticker / Ticker.java < prev   
Encoding:
Java Source  |  1998-10-22  |  27.0 KB  |  774 lines

  1. import java.awt.*;
  2. import java.awt.image.*;
  3. import java.net.*;
  4. import java.util.*;
  5. import java.applet.*;
  6.  
  7. public class Ticker extends Applet implements Runnable {
  8.     protected char              separated[];
  9.     protected char              separateda[][];
  10.     protected Thread            StringThread = null;
  11.     protected int               xlocation[];
  12.     protected int               xlocationa[][];
  13.     protected int               xwidth[];
  14.     protected int               xwidtha[][];
  15.     protected boolean           threadSuspended = false;
  16.     protected int               chardelay;
  17.     protected int               rundelay;
  18.     protected boolean           endofstring = false;
  19.     protected int               total_width;
  20.     protected int               total_widtha[];
  21.     protected boolean           thread_running;
  22.  
  23.     // Parameters that apply to the entire applet
  24.     protected Color       app_bg_color;         // Applet background color
  25.     protected Image       offScreen;           
  26.     protected Graphics    offGC;           
  27.     protected int         applet_width;
  28.     protected int         applet_height;
  29.     protected int         app_height;
  30.     protected int         app_width;
  31.     protected String      bgimage_file;
  32.     protected Image       bgimage;
  33.     protected boolean     tile;
  34.     protected int         bgimage_height;
  35.     protected int         bgimage_width;
  36.     protected Image       tiled_bgimage;
  37.     protected Graphics    bg_g;
  38.  
  39.     // Parameters specific to Text
  40.     protected String      tx;                // Text
  41.     protected String      txa[];             // Text array
  42.     protected int         xoffset;           // Text X offset
  43.     protected int         yoffset;           // Text Y offset
  44.     protected Color       textcolor;         // Text color
  45.     protected boolean     horizcenter;       // Text horizontally centered
  46.     protected boolean     vertcenter;        // Text vertically centered
  47.     protected Font        font;              // Text font
  48.     protected FontMetrics fontmetrics;       // Text font metrics
  49.     protected boolean     underline;         // Text underline
  50.     protected int         width;             // Text width
  51.     protected int         widtha[];          // Text width array
  52.     protected int         height;            // Text height
  53.     protected int         ascent;            // Text ascent
  54.     protected int         descent;           // Text descent
  55.     protected int         txcount;           // number of texts
  56.  
  57.     protected int index = 0;
  58.     protected int cur_xoffset;
  59.     protected int move_dist;
  60.     protected boolean forward = true;
  61.     protected boolean reverse = false;
  62.  
  63.     public void init() {
  64.         int i, j;
  65.         // Applet parameters
  66.         app_bg_color    = GetParmToColor("AppBGColor", null);
  67.  
  68.         // Text parameters
  69.         txcount      = GetParmToInt("TextCount", 0);
  70.         tx           = GetParmToString("Text", "");
  71.         xoffset      = GetParmToInt("XOffset", 0);
  72.         yoffset      = GetParmToInt("YOffset", -1);
  73.         textcolor    = GetParmToColor("TextColor", null);
  74.         horizcenter  = GetParmToBoolean("HorizCenter", false);
  75.         vertcenter   = GetParmToBoolean("VertCenter",  false);
  76.         font         = GetParmToFont("Font",
  77.                                                "Style",
  78.                                                "PointSize");
  79.         if(txcount > 0)
  80.             txa = new String[txcount];
  81.         for(i=0;i < txcount;i++)
  82.             txa[i] = GetParmToString("Text"+(i+1), "");
  83.  
  84.         chardelay      = GetParmToInt("DelayBetweenChars", 20);
  85.         rundelay       = GetParmToInt("DelayBetweenRuns", 3000);
  86.  
  87.         // ======== BG Image ===========
  88.         tile           = GetParmToBoolean("AppTile",     false);
  89.         bgimage_file   = GetParmToString("AppBGImage",  null);
  90.  
  91.         if(bgimage_file != null) {
  92.             bgimage = process(getDocumentBase(), bgimage_file, false);
  93.             prepareImage(bgimage);
  94.             bgimage_width = getWidth(bgimage, this);
  95.             bgimage_height = getHeight(bgimage, this);
  96.         }
  97.  
  98.  
  99.         setFont(font);
  100.         fontmetrics = getFontMetrics(font);
  101.  
  102.         width  = fontmetrics.stringWidth(tx);
  103.         height = fontmetrics.getHeight();
  104.         ascent = fontmetrics.getMaxAscent();
  105.         descent = fontmetrics.getDescent();
  106.         if(txcount > 0)
  107.             widtha = new int[txcount];
  108.         for(i=0;i < txcount;i++)
  109.             widtha[i]  = fontmetrics.stringWidth(txa[i]);
  110.             
  111.  
  112.         // Set the background and foreground colors, if specified
  113.         if(app_bg_color != null)
  114.             setBackground(app_bg_color);
  115.         else
  116.             app_bg_color = getBackground();
  117.         if(textcolor != null)
  118.             setForeground(textcolor);
  119.         else
  120.             textcolor = getForeground();
  121.  
  122.         // Allocate space for array of chars, location, and width 
  123.         separated =  new char [tx.length()];
  124.         xlocation =  new int  [tx.length()];
  125.         xwidth    =  new int  [tx.length()];
  126.         if(txcount > 0) {
  127.             separateda = new char[txcount][];
  128.             xlocationa = new int [txcount][];
  129.             xwidtha    = new int [txcount][];
  130.         }
  131.         for(i=0;i < txcount;i++) {
  132.             separateda[i] =  new char [txa[i].length()];
  133.             xlocationa[i] =  new int  [txa[i].length()];
  134.             xwidtha[i]    =  new int  [txa[i].length()];
  135.             txa[i].getChars(0, txa[i].length(), separateda[i], 0);
  136.         }
  137.  
  138.         // Put each character from the string into the separated array
  139.         tx.getChars(0,tx.length(),separated,0);
  140.  
  141.  
  142.         // Calculate the x locations for each character based on width
  143.         if(txcount > 0)
  144.             total_widtha = new int[txcount];
  145.         for(i=0;i < txcount;i++)
  146.             total_widtha[i] = 0;
  147.  
  148.         for(i=0;i<txcount;i++) {
  149.             for(j=0;j<txa[i].length();j++) {
  150.                 xwidtha[i][j] = fontmetrics.charWidth(separateda[i][j]);
  151.                 total_widtha[i] += xwidtha[i][j];
  152.                 if(j+1<txa[i].length())
  153.                     xlocationa[i][j+1] = total_widtha[i];
  154.             }
  155.         }
  156.  
  157.  
  158.         total_width = 0;
  159.         for(i=0;i<tx.length();i++) {
  160.             xwidth[i] = fontmetrics.charWidth(separated[i]);
  161.             total_width += xwidth[i];
  162.             if(i+1<tx.length())
  163.                 xlocation[i+1] = total_width;
  164.         }
  165.         offScreen = createImage(size().width, size().height);
  166.         offGC = offScreen.getGraphics();
  167.         offGC.setFont(font);
  168.         move_dist = GetParmToInt("MoveDist", 5);
  169.         reverse   = GetParmToBoolean("Reverse",  false);
  170.         if(reverse == true)
  171.             forward = false;
  172.     }
  173.  
  174.     public void paint(Graphics g) {
  175.         int i, j;
  176.  
  177.         // If this is the first time we've been in paint
  178.         // or the applet has changed size then create
  179.         // an image the size of the applet into which
  180.         // we write the background image
  181.         if(applet_width != size().width ||
  182.            applet_height!= size().height) {
  183.             applet_width  = size().width;
  184.             applet_height = size().height;
  185.             offScreen = createImage(applet_width, applet_height);
  186.             offGC = offScreen.getGraphics();
  187.             offGC.setFont(font);
  188.         }
  189.         // We never know when the size might change so check it every time
  190.         if(horizcenter) {
  191.             xoffset = (size().width / 2) - (total_width / 2);
  192.         }
  193.         if(vertcenter) {
  194.             yoffset = (size().height / 2) + (ascent / 3);
  195.         } else if(yoffset == -1) {
  196.             yoffset = height - descent;
  197.         }
  198.  
  199.     offGC.setColor(getBackground());
  200.     offGC.fillRect(0, 0, applet_width, applet_height);
  201.     tilebackground(offGC);
  202.  
  203.         if(forward == true) {
  204.             if(widtha[index] + cur_xoffset > 0) {
  205.                 cur_xoffset -= move_dist;
  206.                 offGC.setColor(getForeground());
  207.                 offGC.drawString(txa[index], cur_xoffset, yoffset);
  208.             } else {
  209.                 endofstring = true;
  210.             }
  211.         } else {
  212.             if(cur_xoffset < size().width) {
  213.                 cur_xoffset += move_dist;
  214.                 offGC.setColor(getForeground());
  215.                 offGC.drawString(txa[index], cur_xoffset, yoffset);
  216.             } else {
  217.                 endofstring = true;
  218.             }
  219.         }
  220.  
  221.         g.drawImage(offScreen, 0, 0, this);
  222.     }
  223.  
  224.     public void run() {
  225.         StringThread.setPriority(1);
  226.         while (StringThread != null) {
  227.             try {Thread.sleep(chardelay);} catch (InterruptedException e){}
  228.             if(endofstring == true) {
  229.                 if(forward == true) {
  230.                     index++;
  231.                     if(index == txcount)
  232.                         index = 0;
  233.                 } else {
  234.                     index--;
  235.                     if(index < 0)
  236.                         index = txcount - 1;
  237.                 }
  238.                 try {Thread.sleep(rundelay);} catch (InterruptedException e){}
  239.                 if(forward == true)
  240.                     cur_xoffset = size().width;
  241.                 else
  242.                     cur_xoffset = -widtha[index];
  243.                 endofstring = false;
  244.             } else
  245.                 repaint();
  246.         }
  247.     }
  248.  
  249.     public boolean keyDown(Event evt, int key) {
  250.         int x = evt.x;
  251.         int y = evt.y;
  252.  
  253.         if(key == 'm') {
  254.             move_dist += 1;
  255.             getAppletContext().showStatus("New distance: " + move_dist);
  256.             return true;
  257.         } else if(key == 'l') {
  258.             move_dist -= 1;
  259.             if(move_dist <= 0)
  260.                 move_dist = 1;
  261.             getAppletContext().showStatus("New distance: " + move_dist);
  262.             return true;
  263.         } else if(key == 'f') {
  264.             chardelay *= .9;
  265.             if(chardelay < 10)
  266.                 chardelay = 10;
  267.             getAppletContext().showStatus("Setting image delay to: " +
  268.                         chardelay);
  269.         } else if(key == 's') {
  270.             if(chardelay < 10)
  271.                 chardelay++;
  272.             else
  273.                 chardelay *= 1.1;
  274.             getAppletContext().showStatus("Setting image delay to: " +
  275.                         chardelay);
  276.         } else if(key == 'F') {
  277.             rundelay *= .9;
  278.             if(rundelay < 10)
  279.                 rundelay = 10;
  280.             getAppletContext().showStatus("Setting run delay to: " +
  281.                         rundelay);
  282.         } else if(key == 'S') {
  283.             if(rundelay < 10)
  284.                 rundelay++;
  285.             else
  286.                 rundelay *= 1.1;
  287.             getAppletContext().showStatus("Setting run delay to: " +
  288.                         rundelay);
  289.         }
  290.         return true;
  291.     }
  292.  
  293.     public boolean mouseDown(Event evt, int x, int y) {
  294.  
  295.         if((evt.modifiers & Event.SHIFT_MASK) != 0) {
  296.             forward = !forward;
  297.         } else {
  298.         if(StringThread == null) {
  299.         StringThread = new Thread(this);
  300.         StringThread.start();
  301.         } else 
  302.         StringThread = null;
  303.         }
  304.         
  305.         return true;
  306.     }
  307. // Begin - Included from SAnimate.include
  308.  
  309.  
  310.     //
  311.     // Overwrite the default update method
  312.     // This may not be necessary for this case
  313.     // but it certainly doesn't hurt
  314.     //
  315.     public void update(Graphics g) {
  316.         paint(g);
  317.     }
  318.  
  319.  
  320.     public void start() {
  321.         if(StringThread == null) {
  322.         endofstring = false;
  323.         cur_xoffset = size().width;
  324.             StringThread = new Thread(this);
  325.             StringThread.start();
  326.         }
  327.     }
  328.  
  329.     public void stop() {
  330.         if(StringThread != null)
  331.             StringThread.stop();
  332.         StringThread = null;
  333.     }
  334.  
  335.     // 
  336.     // Tile the background with the specified image
  337.     //
  338.     protected void tilebackground(Graphics g) {
  339.         int i, j;
  340.  
  341.         if(bgimage == null)
  342.             return;
  343.         if(isImagePrepared(bgimage) == false)
  344.             loadImageAndWait(bgimage);
  345.         //
  346.         // If the applet has changed size or this is the first time
  347.         // tilebackground has been called then create the bg image
  348.         //
  349.         if(app_width != size().width || app_height != size().height) {
  350.             app_width  = size().width;
  351.             app_height = size().height;
  352.  
  353.             tiled_bgimage = createImage(size().width, size().height); 
  354.             bg_g = tiled_bgimage.getGraphics();
  355.             bg_g.setColor(app_bg_color);
  356.             bg_g.fillRect(0, 0, size().width, size().height);
  357.             if(tile) {
  358.                 for(i=-bgimage_height;i<app_height;i+=bgimage_height) {
  359.                     for(j=-bgimage_width;j<app_width;j+=bgimage_width) {
  360.                         bg_g.drawImage(bgimage, j+2, i+2, this);
  361.                     }
  362.                 }
  363.             } else {
  364.                 bg_g.drawImage(bgimage, 0, 0, this);
  365.             }
  366.         }
  367.  
  368.         if(tiled_bgimage != null) {
  369.             g.drawImage(tiled_bgimage, 0, 0, this);
  370.         }
  371.     }
  372. // End - Included from SAnimate.include
  373.  
  374. // Begin - Included from GetParm.include
  375.  
  376.     public int GetParmToInt(String par, int defaultval) {
  377.         String s = getParameter(par);
  378.         if(s == null)
  379.             return defaultval;
  380.         else
  381.             return(Integer.parseInt(s));
  382.     }
  383.  
  384.     public String GetParmToString(String par, String defaultval) {
  385.         String s = getParameter(par);
  386.         if(s == null)
  387.             return defaultval;
  388.         else
  389.             return(s);
  390.     }
  391.     
  392.     public boolean GetParmToBoolean(
  393.                             String par,
  394.                             boolean defaultval) {
  395.         String s = getParameter(par);
  396.         if(s == null)
  397.             return defaultval;
  398.         else
  399.             return(s.equalsIgnoreCase("true"));
  400.     }
  401.  
  402.     public Color GetParmToColor(
  403.                             String par,
  404.                             Color defaultval) {
  405.         Color color;
  406.  
  407.         String s = getParameter(par);
  408.         if(s == null)
  409.             return defaultval;
  410.         else {
  411.             try {
  412.                 if(s.charAt(0) == '#') {
  413.                     char chars[];
  414.                     // Get rid of leading #
  415.                     chars =  new char [s.length()];
  416.                     s.getChars(0, s.length(), chars, 0);
  417.                     color = new Color(Integer.parseInt(
  418.                             new String(chars, 1, s.length()-1),16));
  419.                     return(new Color(Integer.parseInt(
  420.                             new String(chars, 1, s.length()-1), 16)));
  421.                 } else {
  422.                     color = new Color(Integer.parseInt(s, 16));
  423.                     return(color);
  424.                 }
  425.             } catch (NumberFormatException e) {
  426.                 String retcolor;
  427.                 retcolor = getColor(s);
  428.                 if(retcolor != null)
  429.                     return(new Color(Integer.parseInt(retcolor, 16)));
  430.                 else
  431.                     System.out.println("Bad color specification: " + e.getMessage());
  432.                 
  433.                 return null;
  434.             }
  435.         }
  436.     }
  437.  
  438.     public URL GetParmToURL(
  439.                             String par) {
  440.         URL url = null;
  441.         String s = getParameter(par);
  442.         if(s == null)
  443.             return null;
  444.         else {
  445.             try {
  446.                 url = new URL(s);
  447.             } catch(MalformedURLException e) {
  448.                 url = null;
  449.             }
  450.             if(url == null) {
  451.                 // The URL may be specified as relative to
  452.                 // the HTML document base in which the URL resides
  453.                 // We should be able to handle that
  454.                 try {
  455.                     url = new URL(getDocumentBase(), s);
  456.                 } catch(MalformedURLException e) {
  457.                     url = null;
  458.                 }
  459.             }
  460.             if(url == null) {
  461.                 // The URL may be specified as relative to
  462.                 // the Code base (though that seems rather
  463.                 // unlikely) 
  464.                 //
  465.                 try {
  466.                     url = new URL(getCodeBase(), s);
  467.                 } catch(MalformedURLException e) {
  468.                     url = null;
  469.                 }
  470.             }
  471.             if(url == null)
  472.                 System.out.println("Unable to load URL: " + s);
  473.         }
  474.         return url;
  475.     }
  476.     
  477.     public Font GetParmToFont(
  478.                             String par1,
  479.                             String par2,
  480.                             String par3) {
  481.  
  482.         String fontname;
  483.         String fontstyle;
  484.         int style = -1;
  485.         int psize;
  486.         Font font;
  487.         Font currentfont;
  488.         String psize_str;
  489.  
  490.         currentfont = getFont();
  491.         fontname = getParameter(par1);
  492.         if(fontname == null)
  493.             fontname = currentfont.getName();
  494.         fontstyle = getParameter(par2);
  495.         if(fontstyle == null)
  496.             style = currentfont.getStyle();
  497.  
  498.         // Get the Font
  499.         if(fontname.equalsIgnoreCase("TimesRoman")  ||
  500.            fontname.equalsIgnoreCase("Helvetica")   ||
  501.            fontname.equalsIgnoreCase("Courier")     ||
  502.            fontname.equalsIgnoreCase("Dialog")      ||
  503.            fontname.equalsIgnoreCase("DialogInput") ||
  504.            fontname.equalsIgnoreCase("ZapfDingbats")) {
  505.                 // Do Nothing, we got a valid font
  506.         } else {
  507.             fontname = currentfont.getName();
  508.         }
  509.  
  510.         if(style == -1) {
  511.             // Get the Font Style
  512.             if(fontstyle.equalsIgnoreCase("bold"))
  513.                 style = Font.BOLD;
  514.             else if(fontstyle.equalsIgnoreCase("italic"))
  515.                 style = Font.ITALIC;
  516.             else if(fontstyle.equalsIgnoreCase("bolditalic"))
  517.                 style = Font.ITALIC|Font.BOLD;
  518.             else
  519.                 style = Font.PLAIN;
  520.         }
  521.         psize_str = getParameter(par3);
  522.         if(psize_str == null)
  523.             psize = currentfont.getSize();
  524.         else {
  525.             try {
  526.                 psize = Integer.parseInt(psize_str);
  527.             } catch (NumberFormatException e) {
  528.                 psize = currentfont.getSize();
  529.                 System.out.println("NumberformatException: " + psize_str);
  530.             }
  531.         }
  532.  
  533.  
  534.         // Set up the font stuff
  535.         font = new Font(fontname, style, psize);
  536.         return font;
  537.     }
  538.  
  539.     Hashtable colors;
  540.  
  541.     public String getColor(String name) {
  542.         if(colors == null)
  543.             createHashTable();
  544.         return (String)colors.get(name);
  545.     }
  546.  
  547.     public void createHashTable() {
  548.  
  549.         if(colors != null)
  550.             return;
  551.  
  552.         colors = new Hashtable(650);
  553.         colors.put("aliceblue",         "f0f8ff");
  554.         colors.put("antiquewhite",      "faebd7");
  555.         colors.put("aquamarine",        "7fffd4");
  556.         colors.put("azure",             "f0ffff");
  557.         colors.put("beige",             "f5f5dc");
  558.         colors.put("bisque",            "ffe4c4");
  559.         colors.put("black",             "000000");
  560.         colors.put("blanchedalmond",    "ffebcd");
  561.         colors.put("blue",              "0000ff");
  562.         colors.put("blueviolet",        "8a2be2");
  563.         colors.put("brown",             "a52a2a");
  564.         colors.put("burlywood",         "deb887");
  565.         colors.put("cadetblue",         "5f9ea0");
  566.         colors.put("chartreuse",        "7fff00");
  567.         colors.put("chocolate",         "d2691e");
  568.         colors.put("coral",             "ff7f50");
  569.         colors.put("cornflowerblue",    "6495ed");
  570.         colors.put("cornsilk",          "fff8dc");
  571.         colors.put("cyan",              "00ffff");
  572.         colors.put("darkgoldenrod",     "b8860b");
  573.         colors.put("darkgreen",         "006400");
  574.         colors.put("darkkhaki",         "bdb76b");
  575.         colors.put("darkolivegreen",    "556b2f");
  576.         colors.put("darkorange",        "ff8c00");
  577.         colors.put("darkorchid",        "9932cc");
  578.         colors.put("darksalmon",        "e9967a");
  579.         colors.put("darkseagreen",      "8fbc8f");
  580.         colors.put("darkslateblue",     "483d8b");
  581.         colors.put("darkslategray",     "2f4f4f");
  582.         colors.put("darkslategrey",     "2f4f4f");
  583.         colors.put("darkturquoise",     "00ced1");
  584.         colors.put("darkviolet",        "9400d3");
  585.         colors.put("deeppink",          "ff1493");
  586.         colors.put("deepskyblue",       "00bfff");
  587.         colors.put("dimgray",           "696969");
  588.         colors.put("dimgrey",           "696969");
  589.         colors.put("dodgerblue",        "1e90ff");
  590.         colors.put("firebrick",         "b22222");
  591.         colors.put("floralwhite",       "fffaf0");
  592.         colors.put("forestgreen",       "228b22");
  593.         colors.put("green",             "00ff00");
  594.         colors.put("gainsboro",         "dcdcdc");
  595.         colors.put("ghostwhite",        "f8f8ff");
  596.         colors.put("gold",              "ffd700");
  597.         colors.put("goldenrod",         "daa520");
  598.         colors.put("gray",              "bebebe");
  599.         colors.put("honeydew",          "f0fff0");
  600.         colors.put("hotpink",           "ff69b4");
  601.         colors.put("indianred",         "cd5c5c");
  602.         colors.put("ivory",             "fffff0");
  603.         colors.put("khaki",             "f0e68c");
  604.         colors.put("lavender",          "e6e6fa");
  605.         colors.put("lavenderblush",     "fff0f5");
  606.         colors.put("lawngreen",         "7cfc00");
  607.         colors.put("lemonchiffon",      "fffacd");
  608.         colors.put("lightblue",         "add8e6");
  609.         colors.put("lightcoral",        "f08080");
  610.         colors.put("lightcyan",         "e0ffff");
  611.         colors.put("lightgoldenrod",    "eedd82");
  612.         colors.put("lightgoldenrodyellow","fafad2");
  613.         colors.put("lightgray",         "d3d3d3");
  614.         colors.put("lightgrey",         "d3d3d3");
  615.         colors.put("lightpink",         "ffb6c1");
  616.         colors.put("lightsalmon",       "ffa07a");
  617.         colors.put("lightseagreen",     "20b2aa");
  618.         colors.put("lightskyblue",      "87cefa");
  619.         colors.put("lightslateblue",    "8470ff");
  620.         colors.put("lightslategray",    "778899");
  621.         colors.put("lightslategrey",    "778899");
  622.         colors.put("lightsteelblue",    "b0c4de");
  623.         colors.put("lightyellow",       "ffffe0");
  624.         colors.put("limegreen",         "32cd32");
  625.         colors.put("linen",             "faf0e6");
  626.         colors.put("magenta",           "ff00ff");
  627.         colors.put("maroon",            "b03060");
  628.         colors.put("mediumaquamarine",  "66cdaa");
  629.         colors.put("mediumblue",        "0000cd");
  630.         colors.put("mediumorchid",      "ba55d3");
  631.         colors.put("mediumpurple",      "9370db");
  632.         colors.put("mediumseagreen",    "3cb371");
  633.         colors.put("mediumslateblue",   "7b68ee");
  634.         colors.put("mediumspringgreen", "00fa9a");
  635.         colors.put("mediumturquoise",   "48d1cc");
  636.         colors.put("mediumvioletred",   "c71585");
  637.         colors.put("midnightblue",      "191970");
  638.         colors.put("mintcream",         "f5fffa");
  639.         colors.put("mistyrose",         "ffe4e1");
  640.         colors.put("moccasin",          "ffe4b5");
  641.         colors.put("navajowhite",       "ffdead");
  642.         colors.put("navy",              "000080");
  643.         colors.put("navyblue",          "000080");
  644.         colors.put("oldlace",           "fdf5e6");
  645.         colors.put("olivedrab",         "6b8e23");
  646.         colors.put("orange",            "ffa500");
  647.         colors.put("orangered",         "ff4500");
  648.         colors.put("orchid",            "da70d6");
  649.         colors.put("palegoldenrod",     "eee8aa");
  650.         colors.put("palegreen",         "98fb98");
  651.         colors.put("paleturquoise",     "afeeee");
  652.         colors.put("palevioletred",     "db7093");
  653.         colors.put("papayawhip",        "ffefd5");
  654.         colors.put("peachpuff",         "ffdab9");
  655.         colors.put("peru",              "cd853f");
  656.         colors.put("pink",              "ffc0cb");
  657.         colors.put("plum",              "dda0dd");
  658.         colors.put("powderblue",        "b0e0e6");
  659.         colors.put("purple",            "a020f0");
  660.         colors.put("red",               "ff0000");
  661.         colors.put("rosybrown",         "bc8f8f");
  662.         colors.put("royalblue",         "4169e1");
  663.         colors.put("saddlebrown",       "8b4513");
  664.         colors.put("salmon",            "fa8072");
  665.         colors.put("sandybrown",        "f4a460");
  666.         colors.put("seagreen",          "2e8b57");
  667.         colors.put("seashell",          "fff5ee");
  668.         colors.put("sienna",            "a0522d");
  669.         colors.put("skyblue",           "87ceeb");
  670.         colors.put("slateblue",         "6a5acd");
  671.         colors.put("slategray",         "708090");
  672.         colors.put("slategrey",         "708090");
  673.         colors.put("snow",              "fffafa");
  674.         colors.put("springgreen",       "00ff7f");
  675.         colors.put("steelblue",         "4682b4");
  676.         colors.put("tan",               "d2b48c");
  677.         colors.put("thistle",           "d8bfd8");
  678.         colors.put("tomato",            "ff6347");
  679.         colors.put("turquoise",         "40e0d0");
  680.         colors.put("violet",            "ee82ee");
  681.         colors.put("violetred",         "d02090");
  682.         colors.put("wheat",             "f5deb3");
  683.         colors.put("white",             "ffffff");
  684.         colors.put("whitesmoke",        "f5f5f5");
  685.         colors.put("yellow",            "ffff00");
  686.         colors.put("yellowgreen",       "9acd32");
  687.     }
  688.  
  689. // End - Included from ColrLook.include
  690.  
  691. // End - Included from GetParm.include
  692. // Begin - Included from ImgGetr.include
  693.  
  694.     public Image process(URL url, String file, boolean loadnow) {
  695.     Image image;
  696.  
  697.         // See if the user specified an Image parameter
  698.         // If not, return
  699.         if(file == null)
  700.             return null;
  701.  
  702.     image = getImage(url, file);
  703.     if(loadnow)
  704.         loadImageAndWait(image);
  705.         return image;
  706.     }
  707.  
  708.     /**
  709.      * Checks to see if the specified image is actually 
  710.      * prepared (loaded) and ready to display
  711.      * Return true if loaded, otherwise false
  712.      *
  713.      * @param image the image to check
  714.      */
  715.     public boolean isImagePrepared(Image image) {
  716.         boolean ImagePrepared;
  717.         ImagePrepared = prepareImage(image, this);
  718.         return ImagePrepared;
  719.     }
  720.  
  721.     /**
  722.      * Begins the preparation (loading) of the image
  723.      * This function returns immediately
  724.      * The image is loaded in a thread
  725.      *
  726.      * @param image the image to prepare
  727.      */
  728.     public void prepareImage(Image image) {
  729.         boolean ImagePrepared;
  730.         ImagePrepared = prepareImage(image, this);
  731.     }
  732.  
  733.     /**
  734.      * Prepares (loads) the image and does not return 
  735.      * until the loading is complete
  736.      *
  737.      * @param image the image to load
  738.      */
  739.     public synchronized void loadImageAndWait(Image image) {
  740.         int checkImageFlags;
  741.         boolean ImagePrepared;
  742.  
  743.         ImagePrepared = prepareImage(image, this);
  744.         if(ImagePrepared == false) {
  745.             while(((checkImageFlags = 
  746.                     checkImage(image, this)) &
  747.                             ImageObserver.ALLBITS) == 0) {
  748.                 try {
  749.                     wait(100);
  750.                 } catch (InterruptedException e){}
  751.             }
  752.         }
  753.     }
  754.  
  755.     public synchronized int getWidth(Image image, ImageObserver observer) {
  756.         int width;
  757.         while((width = image.getWidth(observer)) == -1) {
  758.             try {wait(100);} catch (InterruptedException e){}
  759.         }
  760.         return width;
  761.     }
  762.  
  763.     public synchronized int getHeight(Image image, ImageObserver observer) {
  764.         int height;
  765.         while((height = image.getHeight(observer)) == -1) {
  766.             try {wait(100);} catch (InterruptedException e){}
  767.         }
  768.         return height;
  769.     }
  770.  
  771. // End - Included from ImgGetr.include
  772. }
  773.