FreeWRL / FreeX3D 4.3.0
EventOutMFNode.java
1package vrml.external.field;
2import vrml.external.Node;
3import java.util.*;
4import vrml.external.field.FieldTypes;
5import vrml.external.Browser;
6
7
8public class EventOutMFNode extends EventOutMField {
9
10 // retnodes is an array of string values.
11 Node[] retnodes;
12 int mySize;
13
14
15 public EventOutMFNode() {EventType = FieldTypes.MFNODE;}
16
17 public Node[] getValue() {
18 String rep;
19 StringTokenizer tokens;
20 int counttokens;
21
22 if (RLreturn == null) {
23 rep = Browser.SendEventOut (nodeptr, offset, datasize, datatype, command);
24 } else {
25 rep = RLreturn;
26 }
27 tokens = new StringTokenizer (rep);
28
29 counttokens = tokens.countTokens();
30 retnodes = new Node[counttokens];
31 mySize = 0;
32
33 while (mySize < counttokens) {
34
35 retnodes[mySize] = new Node();
36 rep = tokens.nextToken();
37 retnodes[mySize].nodeptr = Integer.parseInt(rep);
38 mySize ++;
39 }
40
41 // for the getSize call
42 sizeof = mySize;
43
44 return retnodes;
45 }
46
47 public Node get1Value(int index) {
48
49 // MyNode is used to ensure that the getValue call is called before this.
50
51 Node[] MyNode = getValue();
52
53 if ((index > sizeof) || (index < 0)) {
54 System.out.println ("EventOutMFNode.get1Value - index " + index +
55 " out of range");
56 index = 0;
57 }
58 return MyNode[index];
59 }
60}