FreeWRL / FreeX3D 4.3.0
Node.java
1package vrml.node;
2//JAS import java.util.Hashtable;
3import vrml.Field;
4import vrml.ConstField;
5import vrml.BaseNode;
6import vrml.FWJavaScript;
7import vrml.*;
8
9//
10// This is the general Node class
11//
12public class Node extends BaseNode
13{
14 public Node(String id) {
15 super(id);
16 }
17
18
19 // Get an EventIn by name. Return value is write-only.
20 // Throws an InvalidEventInException if eventInName isn't a valid
21 // eventIn name for a node of this type.
22 public final Field getEventIn(String eventInName) {
23
24 String ftype = FWJavaScript
25 .getFieldType(this, eventInName, "eventIn");
26 if (ftype.equals("ILLEGAL"))
27 throw new InvalidEventInException(_get_nodeid()+"."+eventInName);
28
29
30 /* split field type from field offset */
31 System.out.println ("eventIn: " + ftype);
32 String sp[] = ftype.split (" ");
33 // type is in sp[0]
34 Field fval = FWCreateField.createField(sp[0]);
35 fval.setOffset(ftype);
36 fval.bind_to(new FWJavaScriptBinding(this, eventInName));
37 return fval;
38 }
39
40 // Get an EventOut by name. Return value is read-only.
41 // Throws an InvalidEventOutException if eventOutName isn't a valid
42 // eventOut name for a node of this type.
43 public final ConstField getEventOut(String eventOutName) {
44 String ftype = FWJavaScript
45 .getFieldType(this, eventOutName, "eventOut");
46
47 if (ftype.equals("ILLEGAL"))
48 throw new InvalidEventOutException(_get_nodeid()+"."+eventOutName);
49
50 /* split field type from field offset */
51 String sp[] = ftype.split (" ");
52
53 ConstField fval = FWCreateField.createConstField(sp[0]);
54 fval.setOffset(ftype);
55 fval.bind_to(new FWJavaScriptBinding(this, eventOutName));
56 return fval;
57 }
58
59 // Get an exposed field by name.
60 // Throws an InvalidExposedFieldException if exposedFieldName isn't a valid
61 // exposedField name for a node of this type.
62 public final Field getExposedField(String exposedFieldName) {
63 String ftype = FWJavaScript
64 .getFieldType(this, exposedFieldName, "exposedField");
65 if (ftype.equals("ILLEGAL"))
66 throw new InvalidExposedFieldException(_get_nodeid()+"."
67 +exposedFieldName);
68
69 /* split field type from field offset */
70 String sp[] = ftype.split (" ");
71
72 Field fval = FWCreateField.createField(sp[0]);
73 fval.setOffset(ftype);
74
75 fval.bind_to(new FWJavaScriptBinding(this, exposedFieldName));
76 return fval;
77 }
78}
79
80