/* part of Stereographic Projection applet, copyright 1996 John M Sullivan */ /* extensions by Stuart Levy, 2002, to display triangle angles */ import java.applet.Applet; import java.awt.*; import java.lang.*; public class DragSphere extends Applet { DragPanel mainpanel; Panel buttonpanel = new Panel(); Choice polym, motion; Button reset, save; Image sphere; public void init() { sphere = getImage(getCodeBase(),"sph.gif"); mainpanel = new DragPanel(sphere); setLayout(new BorderLayout()); add("Center",mainpanel); mainpanel.init(); add("South",buttonpanel); buttonpanel.setLayout(new GridLayout(1,3)); reset = new Button("Reset View"); buttonpanel.add(reset); save = new Button("Save Arrow"); buttonpanel.add(save); motion = new Choice(); motion.addItem("Drag Arrow"); motion.addItem("Rotate Sphere"); motion.addItem("Draw Triangle"); motion.select("Drag Arrow"); String initmenu = getParameter( "initmenu" ); if(initmenu != null) motion.select( initmenu ); setmotionmode( motion.getSelectedItem() ); buttonpanel.add(motion); } public String[][] getParameterInfo() { String[][] info = { {"initmenu", "string", "initial interaction menu choice: 'Drag Arrow' or 'Rotate Sphere' or 'Draw Triangle'"} }; return info; } public String getAppletInfo() { return "Spherical Geometry demo by John Sullivan.\n" + "Needs sph.gif in same directory."; } // public boolean handleEvent(Event e) // { // return super.handleEvent(e); // } public void setmotionmode( String modename ) { mainpanel.setmode(modename.equals("Drag Arrow")? 0 : modename.equals("Rotate Sphere")? 1 : modename.equals("Draw Triangle")? 2 : -1 ); } public boolean action(Event e, Object o) { if (e.target.equals(motion)) setmotionmode( o.toString() ); else if (e.target.equals(reset)) mainpanel.reset(); else if (e.target.equals(save)) mainpanel.save_arrow(); else return false; mainpanel.repaint(); return true; } }