The Pad project explores zooming interfaces. Recently I've been exploring a Java-only version of Pad. Below is a small example of zooming in a Java Applet, which requires no plug-in. We haven't yet released the underlying Java implementation for this, but this demo should give you a small flavor of how you might build componentware for a zooming client. - Ken Perlin, Sept 1997



Copyright 1997, New York University.
Demonstration, for non-commercial purposes only.
import pad.*;
import pad.component.*;
import java.awt.*;
import java.util.*;

//Declare a zooming applet with one child.
public class TestButton extends PadApplet
{
   public void initPad() {
      addPicture(new ButtonTester(""));
   } 
}
//Customize the frame pad-component class.
class ButtonTester extends FramePC
{
   ButtonPC add, del;
   ButtonTester c[] = new ButtonTester[100];
   String name;
   int n = 0, rows;

   ButtonTester(String name) {
      //ADD and DELETE buttons have x,y and scale,
      addPicture(add=new ButtonPC("ADD"), 0.,0.,.5);
      addPicture(del=new ButtonPC("DELETE"), 50.,0.,.5);
      //Call update method when buttons are clicked.
      add.text.addObserver(this);
      del.text.addObserver(this);
      //Text label.
      addPicture(new LabelPC(this.name = name), 3.,80.,1.5);
   }
   public void update(Observable o, Object arg) {
      //Recursively add a child component
      if (o == add.text)
         addPicture(c[n++] = new ButtonTester(name+(char)(96+n)), 0.,0.,1.);
      //or delete the last child component.
      else if (n > 0)
         removePicture(c[--n]);
      //After any update, layout children again.
      for (rows = 1 ; rows*rows < n ; rows++)
	 ;
      for (int i = 0 ; i < n ; i++) {
         setOffset(c[i], 10. + 80.*(i/rows)/rows, 10. + 70.*(i%rows)/rows);
         setScale(c[i], .7/rows);
      }
   }
}