/* 
	Simple.java

	java basics, 15-19.11.1999, juhuu@katastro.fi
*/

import java.applet.Applet;
import java.awt.*;
import java.net.*;
import java.util.Random;

public class fontti extends Applet implements Runnable {
  Image		imageDoubleBuffer;
  Graphics	gDoubleBuffer;
  Thread	engine = null;

  int		x, y, xstr, ystr;
  int		mousex, mousey;
  int dirx1, diry1, dirx2, diry2;
	
	
  int 		s_size;
  String	s = "jokko";
  boolean 	mouse_down;
  boolean b = true;
	
  Image 	imgPic;
  Image 	imgBackground;
  Random	rand;

  public void init() {
      // initialize double buffering
      imageDoubleBuffer = createImage(size().width, size().height);
      gDoubleBuffer = imageDoubleBuffer.getGraphics();
      gDoubleBuffer.setColor(Color.white);
      gDoubleBuffer.fillRect(0, 0, size().width, size().height);

      mousex 	= 0;
      mousey 	= 0;
      
      s_size = 20;

      rand 	= new Random();

      x 	= 100;
      y 	= 175;

	dirx1 = x;
	
	diry1 = y;

	  gDoubleBuffer.setFont(new Font("Impact",Font.BOLD,s_size));

      mouse_down = false;

      // let's load an image

      imgPic = null;

      String sBackground = "room.jpg";
      String sPic = "cursor.jpg";

      MediaTracker med = new MediaTracker(this);

      imgPic = getImage(getDocumentBase(), sPic);
      med.addImage(imgPic, 0);

      imgBackground = getImage(getDocumentBase(), sBackground);
      med.addImage(imgBackground, 1);

      try
      {
  	  med.waitForAll();
      }	catch (InterruptedException e) {
      }
  }

//----------------------------------------------------

  public void paint(Graphics g) {

	// clear the screen
//    	gDoubleBuffer.setColor(Color.white);
//    	gDoubleBuffer.fillRect(0, 0, size().width, size().height);




	if (imgBackground != null)
	{
		gDoubleBuffer.drawImage(imgBackground, 0, 0, null);
	

	}
	
	

	


	

	
	
	
	
	for(int s_size = 1;s_size < 150 ; s_size++)
		{
		
		
		/*if (s_size < 150) {*/
		    gDoubleBuffer.setColor(Color.black);	
			
			gDoubleBuffer.setFont(new Font("Impact",Font.BOLD,s_size));
			
			gDoubleBuffer.drawString(s, x, y);
			
			 gDoubleBuffer.setColor(Color.black);	
			
			gDoubleBuffer.setFont(new Font("Impact",Font.BOLD,s_size));
			
			gDoubleBuffer.drawString(s, x, y-1);
		
		
		
		
	   	    gDoubleBuffer.setColor(Color.white);	
			
			gDoubleBuffer.setFont(new Font("Impact",Font.BOLD,s_size));
			
			gDoubleBuffer.drawString(s, x+1, y+1);
		
		
	   	    gDoubleBuffer.setColor(Color.white);	
			
			gDoubleBuffer.setFont(new Font("Impact",Font.BOLD,s_size));
			
			gDoubleBuffer.drawString(s, x, y-1);
			
			
		}

			


	
	
			 gDoubleBuffer.setColor(Color.black);	
			
			gDoubleBuffer.setFont(new Font("Impact",Font.BOLD,s_size));
			
			gDoubleBuffer.drawString(s, x, y);
	
		
	   	    /*gDoubleBuffer.setColor(Color.white);	
			
			gDoubleBuffer.setFont(new Font("Impact",Font.BOLD,s_size+1));
			
			gDoubleBuffer.drawString(s, x+2, y+3);*/
			
			
			gDoubleBuffer.setColor(Color.red);	
			
			gDoubleBuffer.setFont(new Font("Impact",Font.BOLD,s_size));
			
			gDoubleBuffer.drawString(s, x+1, y+1);
		
		
	   	   /* gDoubleBuffer.setColor(Color.white);	
			
			gDoubleBuffer.setFont(new Font("Impact",Font.BOLD,s_size));
			
			gDoubleBuffer.drawString(s, x, y-1);*/
			
	
	
		
	
	
	
	
		
		
		
		
	

	// draw all the stuff from the double buffer to the screen
	g.drawImage(imageDoubleBuffer, 0, 0, null);	

			
  
}

//----------------------------------------------------


  // start the applet
  public void start() {
      if (engine == null) {
          engine = new Thread(this);
          engine.start();
      }
      showStatus(getAppletInfo());
  } 

  // stop the applet
  public void stop() {
     if (engine != null && engine.isAlive())
     {
         engine.stop();
     } 
     engine = null; 
  }

  public void run()
  {                  
     while (true)
     {
         try
         {
             repaint();
             Thread.sleep(10);
         } catch (InterruptedException e) {
             stop();
         }
     }                                  
  }

  public void update(Graphics g) {    
	paint(g);
  }

  // print to the console & browserstatus
  private void print(String s) {
    System.out.println(s); 		// console
    showStatus(s);         		// browser status  
  }

//---

  public boolean mouseDown(Event e, int x, int y) {
	mouse_down = true;
	return true;  
  }

  public boolean mouseUp(Event e, int x, int y) {
	mouse_down = false;
	return true;  
  }

  public boolean mouseMove(Event e, int x, int y)
  {
	mousex = x;
	mousey = y;
	return true;  
  }

  public boolean mouseDrag(Event e, int x, int y)
  {
	mousex = x;
	mousey = y;
	return true;  
  }


//---

}
