//

Generic Improv Actors applet

import vrml.external.field.*;
import vrml.external.Node;
import vrml.external.Browser;
import vrml.external.exception.*;

import improv.actor.*;
import improv.actor.behavior.*;
import improv.event.*;
import improv.misc.*;
import improv.util.gui.*;
import improv.util.*;

import java.applet.Applet;

public class Actors extends Applet implements EventOutObserver,ImprovObserver
{
   private Actor actor;
   private Browser browser;
   private NYUSplashScreen splash;
   private Node timeNode;
   private LayerPanel panel;
   private ImprovEditor editor;
   
   public void init() {
      browser = Browser.getBrowser(this);
      splash = new NYUSplashScreen(this);
      try {
         timeNode = browser.getNode("Time");
         EventOut time = timeNode.getEventOut("time");
         time.advise(this,null);
      } catch(InvalidNodeException e) { System.out.println("Problem: "+e); }
      addActors();
   }

   public void addActors() { }
   public Actor addActor(String name) { return actor = new Actor(name, splash); }
   public void  setActor(Actor actor) { this.actor = actor; }
   public void  setBehavior(String state) { actor.setBehavior(state); }
   public void  setProperty(String property, float value) { actor.setProperty(property,value); }
   public void  showPanel() { (panel = new LayerPanel(actor)).show(); }
   public void  showEditor() { (editor = new ImprovEditor(actor)).show(); }

/**
   handleImprovEvent is implemented as part of the ImprovObserver interface:
   - called by any ImprovObservable object to which this VRMLManager is an observer,
   - usually not called directly, but is used by Improv to update the VRML scene.
*/

   public void handleImprovEvent(ImprovEvent evt) {
      switch(evt.id) {
         case ImprovTypes.SFObjectCHANNEL:
            ((EventInSFNode)evt.arg).setValue((Node)(((SFObjectChannel)evt.target).getValue()));
            break;
         case ImprovTypes.SFStringCHANNEL:
            ((EventInSFString)evt.arg).setValue(((SFStringChannel)evt.target).getValue());
            break;
         case ImprovTypes.SFBoolCHANNEL:
            ((EventInSFBool)evt.arg).setValue(((SFBoolChannel)evt.target).getValue());
            break;
         case ImprovTypes.SFFloatCHANNEL:
            ((EventInSFFloat)evt.arg).setValue(((SFFloatChannel)evt.target).getValue());
            break;
         case ImprovTypes.SFInt32CHANNEL:
            ((EventInSFInt32)evt.arg).setValue(((SFInt32Channel)evt.target).getValue());
            break;
         case ImprovTypes.SFVec2fCHANNEL:
            ((EventInSFVec2f)evt.arg).setValue(((SFVec2fChannel)evt.target).getValue());
            break;
         case ImprovTypes.SFVec3fCHANNEL:
            if(evt.arg instanceof EventInSFVec3f) 
               ((EventInSFVec3f)evt.arg).setValue(((SFVec3fChannel)evt.target).getValue());
            else 
               ((EventInSFColor)evt.arg).setValue(((SFVec3fChannel)evt.target).getValue());
            break;
         case ImprovTypes.SFRotationCHANNEL:
            SFRotationChannel chan = (SFRotationChannel)evt.target;
            ((EventInSFRotation)evt.arg).setValue(chan.getValue());
            if(chan.xyzArg!=null) ((EventInSFVec3f)chan.xyzArg).setValue(chan.getXYZ());
            break;
         case ImprovTypes.MFObjectCHANNEL:
            Object nodes[] = ((MFObjectChannel)evt.target).getValue();
            for(int i=0;i