|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvrml.eai.event.VrmlEvent
public class VrmlEvent
Contains information about a VRML event. When you implement a
VrmlEventListener
, you'll get a VrmlEvent object as a
parameter that contains a reference to the
EventOut
object that fired the event
as well as a timestamp and the user-provided data object
attached to the EventOut
object.
The following example shows the skeleton of a vrml event listener, and how the VrmlEvent object is used inside the listener:
class MyVrmlEventListener implements vrml.eai.event.VrmlEventListener { private vrml.eai.field.EventOutSFColor diffuseColor_changed; ... public void eventOutChanged(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 ... } } ... }
Constructor Summary | |
---|---|
VrmlEvent(BaseField src,
double ts,
java.lang.Object data)
Initializes a VrmlEvent with a given EventOut object, timestamp and
user-provided data object. |
Method Summary | |
---|---|
java.lang.Object |
getData()
The user-provided data object attached to the event-out slot that fired the event. |
BaseField |
getSource()
Returns the event-out slot that fired the event. |
double |
getTime()
Returns the time when the event happened. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public VrmlEvent(BaseField src, double ts, java.lang.Object data)
EventOut
object, timestamp and
user-provided data object. Usually, you do not create your own
VRML events - they get generated by the
EventOut
object when it fires an event,
and you get them as a parameter to your VrmlEventListener
.
But nevertheless this constructor is public which allows you to
create your own events and send them to your listener.
src
- The event-out slot
whose value changed.ts
- The time when the event happened, measured in seconds
since January the 1st, 1970, 00:00:00 GMT.data
- A user-provided data object.Method Detail |
---|
public BaseField getSource()
VrmlEvent(vrml.eai.field.BaseField, double, java.lang.Object)
constructor when creating new VrmlEvent objects.
The following example shows how to get the
EventOut
object from the event:
vrml.eai.event.VrmlEvent evt = ...; vrml.eai.field.BaseField field = evt.getSource();
public double getTime()
VrmlEvent(vrml.eai.field.BaseField, double, java.lang.Object)
constructor
when creating new VrmlEvent objects.
The following example gets the timestamp from the event, converts it to a Date object, and prints it to the console:
vrml.eai.event.VrmlEvent evt = ...; Date date = new Date((long)(evt.getTime() * 1000.0)); System.out.println("Date = " + date);
public java.lang.Object getData()
EventOut.setUserData(java.lang.Object)
method. This object gets set via the VrmlEvent(vrml.eai.field.BaseField, double, java.lang.Object)
constructor
when creating new VrmlEvent objects.
The following example shows how to get the user-provided data object from the event:
vrml.eai.event.VrmlEvent evt = ...; Object data = evt.getData();
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |