FreeWRL/FreeX3D  3.0.0
FWSFVec3d.java
1 package sai;
2 import org.web3d.x3d.sai.*;
3 import java.util.*;
4 
5 public class FWSFVec3d extends FreeWRLField implements SFVec3d {
6  FreeWRLBrowser browser;
7  private static final int ROWS = 3;
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("SFVec3d 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 
35  public void setValue(double[] value) throws ArrayIndexOutOfBoundsException {
36  if (value.length < ROWS) {
37  throw new ArrayIndexOutOfBoundsException("SFVec3d setValue passed degenerate value");
38  }
39  browser.newSendEvent(this, "" + value[0] + " " + value[1] + " " + value[2]);
40  }
41 }