vrml.eai.field
Class EventOut

java.lang.Object
  extended by vrml.eai.field.BaseField
      extended by vrml.eai.field.EventOut
Direct Known Subclasses:
EventOutMField, EventOutSFBool, EventOutSFColor, EventOutSFFloat, EventOutSFImage, EventOutSFInt32, EventOutSFNode, EventOutSFRotation, EventOutSFString, EventOutSFTime, EventOutSFVec2f, EventOutSFVec3f

public abstract class EventOut
extends BaseField

Abstract ancestor of all event-out slots. This class simply defines methods that allows to attach arbitrary application-specific data to event-in slots. This is an abstract class, i.e. you cannot create instances of this class. The only way to retrieve instances of this class is the Node.getEventOut(java.lang.String) method. Usually you do not use this class directly, but cast it to one of its descendants for the respective VRML data types.

The following example demonstrates how to get a reference to the "isActive" event-out slot of a "TouchSensor" node:

 vrml.eai.Node touchSensor = browser.getNode(...);
 vrml.eai.field.EventOutSFBool isActive = (vrml.eai.field.EventOutSFBool)touchSensor.getEventOut("isActive");
 


Field Summary
 
Fields inherited from class vrml.eai.field.BaseField
MFColor, MFFloat, MFInt32, MFNode, MFRotation, MFString, MFTime, MFVec2f, MFVec3f, SFBool, SFColor, SFFloat, SFImage, SFInt32, SFNode, SFRotation, SFString, SFTime, SFVec2f, SFVec3f
 
Method Summary
abstract  void addVrmlEventListener(VrmlEventListener l)
          Adds a VrmlEventListener to the event-out slot.
abstract  java.lang.Object getUserData()
          Returns the application-specific user data attached to this event-out slot.
abstract  void removeVrmlEventListener(VrmlEventListener l)
          Removes a VrmlEventListener from the event-out slot.
abstract  void setUserData(java.lang.Object data)
          Attaches application-specific user data to this event-out slot.
 
Methods inherited from class vrml.eai.field.BaseField
getType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addVrmlEventListener

public abstract void addVrmlEventListener(VrmlEventListener l)
Adds a VrmlEventListener to the event-out slot. The VrmlEventListener gets called whenever the value of the field changes.

The following example shows the skeleton of a VrmlEventListener, and it demonstrates how to add the listener to an EventOut object, and how to remove the listener when you're finished:

 class MyClass
 {
     private static vrml.eai.field.EventOutSFColor diffuseColor_changed;

     private static void onVrmlEvent(vrml.eai.event.VrmlEvent evt)
     {
         vrml.eai.field.BaseField field = evt.getSource();
         double time = evt.getTime();
         Object data = evt.getData();
         if (field == diffuseColor_changed)
         {
             // diffuseColor_changed event-out slot fired an event
             ...
         }
     }

     public static void main(String[] args)
     {
         ...
         diffuseColor_changed = ...;
         vrml.eai.event.VrmlEventListener listener = new vrml.eai.event.VrmlEventListener()
         {
             public void eventOutChanged(vrml.eai.event.VrmlEvent evt)
             {
                 EAIDocu.onVrmlEvent(evt);
             }
         };
         diffuseColor_changed.addVrmlEventListener(listener);
         ...
         diffuseColor_changed.removeVrmlEventListener(listener);
         ...
     }
 }
 

Parameters:
l - The listener.

removeVrmlEventListener

public abstract void removeVrmlEventListener(VrmlEventListener l)
Removes a VrmlEventListener from the event-out slot.

The following example shows the skeleton of a VrmlEventListener, and it demonstrates how to add the listener to an EventOut object, and how to remove the listener when you're finished:

 class MyClass
 {
     private static vrml.eai.field.EventOutSFColor diffuseColor_changed;

     private static void onVrmlEvent(vrml.eai.event.VrmlEvent evt)
     {
         vrml.eai.field.BaseField field = evt.getSource();
         double time = evt.getTime();
         Object data = evt.getData();
         if (field == diffuseColor_changed)
         {
             // diffuseColor_changed event-out slot fired an event
             ...
         }
     }

     public static void main(String[] args)
     {
         ...
         diffuseColor_changed = ...;
         vrml.eai.event.VrmlEventListener listener = new vrml.eai.event.VrmlEventListener()
         {
             public void eventOutChanged(vrml.eai.event.VrmlEvent evt)
             {
                 EAIDocu.onVrmlEvent(evt);
             }
         };
         diffuseColor_changed.addVrmlEventListener(listener);
         ...
         diffuseColor_changed.removeVrmlEventListener(listener);
         ...
     }
 }
 

Parameters:
l - The listener.

setUserData

public abstract void setUserData(java.lang.Object data)
Attaches application-specific user data to this event-out slot. This user data is not used by the EAI in any way - it is a simple way to attach application-specific data to event-out slots.

The following example demonstrates how to attach a data object ("myData") to an event-out slot:

 MyClass myData = ...;
 vrml.eai.field.EventOut eventOut = ...;
 eventOut.setUserData(myData);
 

Parameters:
data - The application-specific user data.

getUserData

public abstract java.lang.Object getUserData()
Returns the application-specific user data attached to this event-out slot. This user data is not used by the EAI in any way - it is a simple way to attach application-specific data to event-out slots.

The following example demonstrates how to retrieve a data object ("myData") attached to an event-out slot:

 vrml.eai.field.EventOut eventOut = ...;
 MyClass myData = (MyClass)eventOut.getUserData();
 

Returns:
The application-specific user data.