import vrml.*; import vrml.field.*; import vrml.node.*; public class TimeTestScript extends Script implements TimeTestFrameCallback{ TimeTestFrame frame; boolean started=true; SFTime starttime, stoptime; public void initialize(){ frame=new TimeTestFrame(this); frame.resize(600, 275); frame.show(); starttime=(SFTime)getEventOut("startTime"); stoptime=(SFTime)getEventOut("stopTime"); } public void processEvent(vrml.Event e){ if (e.getName().equals("time")){ frame.call(((ConstSFTime)e.getValue()).getValue(), e.getTimeStamp()); return; } if (e.getName().equals("touchTime")){ double currenttime=(double) ((System.currentTimeMillis()/1000)); if (started==true){ stoptime.setValue(currenttime); frame.stopTime(); started=false; } else{ starttime.setValue(currenttime); frame.startTime(); started=true; } if (!frame.isShowing()){ frame.show(); } } } public void callback(TimeTestFrame frame){ double currenttime=(double) ((System.currentTimeMillis()/1000) +1.000); if (frame.started==true){ stoptime.setValue(currenttime); frame.stopTime(); started=false; } else{ starttime.setValue(currenttime); frame.startTime(); started=true; } } public void shutdown(){ if (frame.isShowing()){ frame.hide(); } frame.dispose(); } }