vrml.eai.field
Class EventInMFNode
java.lang.Object
vrml.eai.field.BaseField
vrml.eai.field.EventIn
vrml.eai.field.EventInMFNode
public abstract class EventInMFNode
- extends EventIn
Reference to a MFNode event-in slot. Use this class to write
values into MFNode event-in slots.
The following example demonstrates how to add two geometric
objects (a box and a sphere) to a Group node:
vrml.eai.Node group = ...;
vrml.eai.field.EventInMFNode addChildren = (vrml.eai.field.EventInMFNode)group.getEventIn("addChildren");
String vrmlCode =
"Transform {\n" +
" translation -2 0 0\n" +
" children [\n" +
" Shape {\n" +
" appearance Appearance {\n" +
" material Material {}\n" +
" }\n" +
" geometry Box {}\n" +
" }\n" +
" ]\n" +
"}\n" +
"Transform {\n" +
" translation 2 0 0\n" +
" children [\n" +
" Shape {\n" +
" appearance Appearance {\n" +
" material Material {}\n" +
" }\n" +
" geometry Sphere {}\n" +
" }\n" +
" ]\n" +
"}\n";
vrml.eai.Node[] nodes = browser.createVrmlFromString(vrmlCode);
addChildren.setValue(nodes);
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 |
Constructor Summary |
protected |
EventInMFNode()
Default constructor. |
Method Summary |
abstract void |
set1Value(int index,
Node value)
Sets one element of the MFNode event-in slot. |
abstract void |
setValue(Node[] value)
Sets the elements of the MFNode event-in slot. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EventInMFNode
protected EventInMFNode()
- Default constructor. This method is protected, i.e. you cannot create
new instances of this class. The only way to get instances is via the
Node.getEventIn(java.lang.String)
method.
setValue
public abstract void setValue(Node[] value)
throws InvalidNodeException
- Sets the elements of the MFNode event-in slot.
The following example demonstrates how to add two geometric
objects (a box and a sphere) to a Group node:
vrml.eai.Node group = ...;
vrml.eai.field.EventInMFNode addChildren = (vrml.eai.field.EventInMFNode)group.getEventIn("addChildren");
String vrmlCode =
"Transform {\n" +
" translation -2 0 0\n" +
" children [\n" +
" Shape {\n" +
" appearance Appearance {\n" +
" material Material {}\n" +
" }\n" +
" geometry Box {}\n" +
" }\n" +
" ]\n" +
"}\n" +
"Transform {\n" +
" translation 2 0 0\n" +
" children [\n" +
" Shape {\n" +
" appearance Appearance {\n" +
" material Material {}\n" +
" }\n" +
" geometry Sphere {}\n" +
" }\n" +
" ]\n" +
"}\n";
vrml.eai.Node[] nodes = browser.createVrmlFromString(vrmlCode);
addChildren.setValue(nodes);
- Parameters:
value
- The new nodes.
- Throws:
InvalidNodeException
- when one of the nodes in the
value array is invalid.
set1Value
public abstract void set1Value(int index,
Node value)
throws InvalidNodeException,
java.lang.ArrayIndexOutOfBoundsException
- Sets one element of the MFNode event-in slot.
The following example demonstrates how to replace the first child of
a Group node by a Shape node:
vrml.eai.Node group = ...;
vrml.eai.field.EventInMFNode set_children = (vrml.eai.field.EventInMFNode)group.getEventIn("set_children");
String vrmlCode =
"Shape {\n" +
" appearance Appearance {\n" +
" material Material {}\n" +
" }\n" +
" geometry Box {}\n" +
"}\n";
vrml.eai.Node[] nodes = browser.createVrmlFromString(vrmlCode);
set_children.set1Value(0, nodes[0]);
- Parameters:
index
- The index of the element, starting at 0.value
- The new node.
- Throws:
InvalidNodeException
- when the node in the value parameter is
invalid.
java.lang.ArrayIndexOutOfBoundsException
- when the index is
invalid.