|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvrml.eai.field.BaseField
vrml.eai.field.EventOut
public abstract class EventOut
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 |
---|
public abstract void addVrmlEventListener(VrmlEventListener l)
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); ... } }
l
- The listener.public abstract void removeVrmlEventListener(VrmlEventListener l)
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); ... } }
l
- The listener.public abstract void setUserData(java.lang.Object data)
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);
data
- The application-specific user data.public abstract java.lang.Object getUserData()
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();
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |