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