FreeWRL / FreeX3D 4.3.0
FWSFVec2f.java
1package sai;
2import org.web3d.x3d.sai.*;
3import java.util.*;
4
5public class FWSFVec2f extends FreeWRLField implements SFVec2f {
6 FreeWRLBrowser browser;
7 static final int ROWS = 2;
8
10 super(def, b);
11 browser = b;
12 }
13
14 public void getValue(float[] value) throws ArrayIndexOutOfBoundsException {
15 int count;
16 String rep;
17 StringTokenizer tokens;
18
19 if (value.length < ROWS) {
20 throw new ArrayIndexOutOfBoundsException("SFVec2f getValue passed array of insufficient size");
21 }
22
23 if (command != null) {
24 rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
25 tokens = new StringTokenizer(rep);
26 } else {
27 tokens = new StringTokenizer(RLreturn);
28 }
29
30 for (count = 0; count < ROWS; count++) {
31 value[count] = Float.valueOf(tokens.nextToken()).floatValue();
32 }
33 }
34 public void setValue(float[] value) throws ArrayIndexOutOfBoundsException {
35 if (value.length < ROWS) {
36 throw new ArrayIndexOutOfBoundsException("SFVec2f setValue passed degenerate value");
37 }
38 browser.newSendEvent(this, "" + value[0] + " " + value[1]);
39 }
40}