/***************************************************
 * @file	HelloIcon1.java
 * @author	Chee Yap (yap@cs.nyu.edu)
 * @date	Jan 24, 2003
 * @purpose	Java Applet Example
 *			-- an elaboration of HelloIcon.java
 *		1. Gif size is a parameter
 *		2. Shows the documentbase
 *		3. Diagnostic messages printed on java console
 * @notes	For Visualization Class, Spring 2003
 * $Id: HelloIcon1.java,v 1.3 2003/03/09 21:38:02 yap Exp yap $
 ***************************************************/

import java.applet.Applet;
import java.awt.*;

public class HelloIcon1
		extends Applet {
  // Declare variables
  private Image myImage;
  int gifSize = 100;  // display image in natural size if gifSize=0;
  		    // else use gifSize (try gifSize = 0, 20, 50, 100)

  // Init method
    public void init() {
	setBackground(Color.yellow);
	setFont(new Font("Sanserif", Font.BOLD, 18));
	myImage = getImage(getDocumentBase(),
		"gifIcon.gif");	// documentbase is URL of where the
				// html file found
	add(new Label("Hello Resizable Icon!         "));

  // Diagnostics: the following appears in the Java console of browser:
	System.out.println("Document base:");
	System.out.println(getDocumentBase().toExternalForm());	
    }

  // Paint method
    public void paint(Graphics g) {
        if (gifSize == 0) {
	  g.drawImage(myImage, 10, 60, this);
	  g.drawString("natural image size", 60, 120);
	} else {
	  g.drawImage(myImage, 10, 50, gifSize, gifSize, this);
	  g.drawString("image size = " + gifSize, 20+gifSize, 50+gifSize);
	  g.drawString("Document base =", 10, 80+gifSize);
	  g.drawString(getDocumentBase().toExternalForm(), 30, 100+gifSize);
	}
    }

}// HelloIcon1 class

