FreeWRL / FreeX3D 4.3.0
FWSFVec2d.java
1package sai;
2import org.web3d.x3d.sai.*;
3import java.util.*;
4
5public class FWSFVec2d extends FreeWRLField implements SFVec2d {
6 FreeWRLBrowser browser;
7 static final int ROWS = 2;
8
10 super(def, b);
11 browser = b;
12 }
13
14 public void getValue(double[] value) throws ArrayIndexOutOfBoundsException {
15 int count;
16 String rep;
17 StringTokenizer tokens;
18
19 if (value.length < ROWS) {
20 throw new ArrayIndexOutOfBoundsException("SFVec2d 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] = Double.valueOf(tokens.nextToken()).doubleValue();
32 }
33 }
34 public void setValue(double[] value) throws ArrayIndexOutOfBoundsException {
35 if (value.length < ROWS) {
36 throw new ArrayIndexOutOfBoundsException("SFVec2d setValue passed degenerate value");
37 }
38 browser.newSendEvent(this, "" + value[0] + " " + value[1]);
39 }
40}