home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Extras / Content / Images / StockObjects / objects / java / coalesce / Coalesce.java < prev    next >
Encoding:
Java Source  |  1998-10-22  |  27.2 KB  |  780 lines

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