/* * @(#)NervousText.java 1.5 96/12/06 * * Copyright (c) 1994-1996 Sun Microsystems, Inc. All Rights Reserved. * * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, * modify and redistribute this software in source and binary code form, * provided that i) this copyright notice and license appear on all copies of * the software; and ii) Licensee does not utilize the software in a manner * which is disparaging to Sun. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * This software is not designed or intended for use in on-line control of * aircraft, air traffic, aircraft navigation or aircraft communications; or in * the design, construction, operation or maintenance of any nuclear * facility. Licensee represents and warrants that it will not use or * redistribute the Software for such purposes. */ import java.awt.Graphics; import java.awt.Image; import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; public class AnagramText2 extends java.applet.Applet implements Runnable { Image OSC = null; Graphics OSC_g = null; Font f = null; FontMetrics fm = null; char separated[]; char not_done[]; char dest[]; int src_pos, dest_pos; int curr_pos_x[], curr_pos_y[]; String s1 = null; String s2 = null; String s3 = null; String temp_str = null; Thread killme = null; int i; int strlen; int x_coord = 0, y_coord = 0; String num; int speed=35; int counter =0; boolean threadSuspended = false; //added by kwalrath public void init() { setBackground(Color.white); f = new Font("TimesRoman",Font.BOLD,15); fm = getFontMetrics(f); s1 = getParameter("text1"); if (s1 == null) { s1 = "hotjava"; } s2= getParameter("text2"); if (s2 == null) { s2 = "javahot"; } s3= getParameter("text3"); if (s3 == null) { s3 = "javahot"; } strlen = s1.length(); separated = new char [strlen]; dest = new char [strlen]; not_done = new char [strlen]; curr_pos_x = new int [strlen]; curr_pos_y = new int [strlen]; s1.getChars(0,strlen,separated,0); s1.getChars(0,strlen,not_done,0); s2.getChars(0,strlen,dest,0); resize((strlen+1)*15, 30); OSC = createImage(size().width, size().height); OSC_g = OSC.getGraphics(); OSC_g.setFont(f); /* load the initial letter positions */ for(i=0;i= strlen) { src_pos = 0; temp_str.getChars(0,strlen,dest,0); if (temp_str == s1) temp_str = s2; else if (temp_str == s2) temp_str = s3; else temp_str = s1; } } else { temp = separated[dest_pos]; separated[dest_pos] = separated[src_pos]; separated[src_pos] = temp; dest[dest_pos] = '.'; /* block out that letter, since it is done */ } dest_pos = find_dest(src_pos); } public void run() { while (killme != null) { try {Thread.sleep(100);} catch (InterruptedException e){} move_letter(); repaint(); } killme = null; } public void paint(Graphics g) { OSC_g.setColor(Color.white); // fill OSC with white OSC_g.fillRect(0,0,size().width,size().height); OSC_g.setColor(Color.black); // fill OSC with white for(i=0;i