<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <TITLE>widget/Slider.java.html</TITLE> </HEAD> <BODY><PRE> package widget; import vrml.field.*; import vrml.node.*; import vrml.*; public class Slider extends Script { boolean loop; float fraction; SFFloat fchanged; SFVec3f off_changed; SFTime touchTime, stopit; float vecval[] = new float[3]; public void initialize() { off_changed = (SFVec3f)getEventOut("offset_changed"); fchanged = (SFFloat)getEventOut("fraction_changed"); touchTime = (SFTime)getEventOut("touchTime"); stopit = (SFTime)getEventOut("stopit"); fraction = ((SFFloat)getField("fraction")).getValue(); loop = !((SFBool)getField("noloop")).getValue(); vecval[0] = fraction; vecval[1] = 0; vecval[2] = 0; off_changed.setValue(vecval); if (loop) fchanged.setValue(fraction); } public void sendtime(boolean active, Event event) { if (active) touchTime.setValue(event.getTimeStamp()); } public void processEvent(Event event) { switch (event.getName().charAt(4)) { case 'm': //eventIn SFTime initme stopit.setValue(event.getTimeStamp()); break; case 'f': //eventIn SFFloat set_fraction fraction = ((ConstSFFloat)event.getValue()).getValue(); if (loop) fchanged.setValue(fraction); vecval[0] = fraction; vecval[1] = 0; vecval[2] = 0; off_changed.setValue(vecval); break; case 't': //eventIn SFVec3f set_translation ((ConstSFVec3f)event.getValue()).getValue(vecval); fraction = vecval[0]; fchanged.setValue(fraction); break; case 'c': //eventIn SFBool is_Active sendtime(((ConstSFBool)event.getValue()).getValue(), event); break; } } } </PRE></BODY> </HTML>