FreeWRL / FreeX3D 4.3.0
EventOutMFFloat.java
1// read in a multi float value from the FreeWRL browser.
2
3package vrml.external.field;
4import vrml.external.Browser;
5import vrml.external.field.FieldTypes;
6import java.util.*;
7
8public class EventOutMFFloat extends EventOutMField {
9 public EventOutMFFloat() { EventType = FieldTypes.MFFLOAT; }
10
11 public float[] getValue() {
12 float [] rval;
13 int lines;
14 int rows;
15 int count1;
16 int count2;
17 StringTokenizer tokens;
18 String rep;
19
20 if (RLreturn == null) {
21 rep = Browser.SendEventOut (nodeptr, offset, datasize, datatype, command);
22 } else {
23 rep = RLreturn;
24 }
25 // get the number of lines of code to come back.
26
27 rows = 1;
28
29 tokens = new StringTokenizer (rep);
30
31 //System.out.println ("DEBUG: EventOutMFFloat getValue - rep = " + rep);
32 lines = Integer.valueOf(tokens.nextToken()).intValue();
33 //System.out.println ("DEBUG: read in as a token " + lines);
34
35 rval = new float [lines];
36
37 // now, read in the lines.
38 for (count1=0; count1<lines; count1++) {
39 rval[count1] = Float.valueOf(tokens.nextToken()).floatValue();
40 }
41
42 // for the getSize call
43 sizeof = lines;
44
45 return rval;
46 }
47
48
49 public float get1Value(int index) {
50 float all[] = getValue();
51
52 return all[index];
53 }
54}