vrml.eai
Class Node

java.lang.Object
  extended by vrml.eai.Node

public abstract class Node
extends java.lang.Object

Reference to a VRML node. The Node object represents nodes of the 3D scene in your code. You use it to get access to the fields of the node. You can either create new node objects by calling Browser.createVrmlFromString(java.lang.String), or you can get references to named nodes in the scene by calling Browser.getNode(java.lang.String), or you can get nodes from EventOutSFNode or EventOutMFNode slots. When you are finished with a node, you should call its dispose() method.

The following example demonstrates how to get a reference to a "Group" node called "root" (defined as "DEF root Group {}" in the scene), and how to get a reference to its "addChildren" MFNode event-in slot:

 vrml.eai.Browser browser = ...;
 vrml.eai.Node group = browser.getNode("root");
 vrml.eai.field.EventInMFNode addChildren = (vrml.eai.field.EventInMFNode)group.getEventIn("addChildren");
 ...
 group.dispose();
 


Constructor Summary
protected Node()
          Default constructor.
 
Method Summary
abstract  void dispose()
          Releases all resources held by this node object.
 void finalize()
          Destructor.
abstract  EventIn getEventIn(java.lang.String name)
          Gets an event-in slot of the node.
abstract  EventOut getEventOut(java.lang.String name)
          Gets an event-out slot of the node.
abstract  java.lang.String getType()
          Returns the type of the node.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Node

protected Node()
Default constructor. Node is an abstract class, for this reason there are no public constructors, i.e. you cannot create instances of this class. Use Browser.createVrmlFromString(java.lang.String) or Browser.getNode(java.lang.String) to get instances of the Node class, or get nodes from EventOutSFNode or EventOutMFNode slots.

Method Detail

getType

public abstract java.lang.String getType()
                                  throws InvalidNodeException
Returns the type of the node.

The following example prints the type of a node to the console:

 vrml.eai.Node node = browser.getNode(...);
 System.out.println("node.Type = \"" + node.getType() + '"');
 

Returns:
The type of the node.
Throws:
InvalidNodeException - when the node has already been disposed.

getEventIn

public abstract EventIn getEventIn(java.lang.String name)
                            throws InvalidEventInException,
                                   InvalidNodeException
Gets an event-in slot of the node. Whenever you need to write values into fields of a node, you have to call this method. It returns a reference to an EventIn object. You have to cast that object to the concrete type of the field.

The following example demonstrates how to get a reference to the "addChildren" field of a "Group" node:

 vrml.eai.Node group = browser.getNode(...);
 vrml.eai.field.EventInMFNode addChildren = (vrml.eai.field.EventInMFNode)group.getEventIn("addChildren");
 

Parameters:
name - The name of the event-in slot.
Returns:
The event-in slot.
Throws:
InvalidEventInException - when an event-in slot with the specified name does not exist in the node.
InvalidNodeException - when the node has already been disposed.

getEventOut

public abstract EventOut getEventOut(java.lang.String name)
                              throws InvalidEventOutException,
                                     InvalidNodeException
Gets an event-out slot of the node. Whenever you need to read values from fields of a node, you have to call this method. It returns a reference to an EventOut object. You have to cast that object to the concrete type of the field.

The following example demonstrates how to get a reference to the "isActive" field of a "TouchSensor" node:

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

Parameters:
name - The name of the event-out slot.
Returns:
The event-out slot.
Throws:
InvalidEventOutException - when an event-out slot with the specified name does not exist in the node.
InvalidNodeException - when the node has already been disposed.

dispose

public abstract void dispose()
                      throws InvalidNodeException
Releases all resources held by this node object. You should call this method when you do not need access to a node anymore. Calling it is optional - it gets automatically called by the finalizer of this class - but it is recommended to call this method manually because it allows the system the release resources held by this object as soon as possible. The node object is not valid anymore after calling this method - do not call any method of the node object, or you will get an InvalidNodeException. This method does not remove the node from the scene - it just removes the connection between the EAI node object and the node in the 3D scene.

Throws:
InvalidNodeException - when the node has already been disposed.

finalize

public void finalize()
Destructor. Calls the dispose() method.

Overrides:
finalize in class java.lang.Object