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