FreeWRL/FreeX3D  3.0.0
FWMFDouble.java
1 package sai;
2 import org.web3d.x3d.sai.*;
3 import java.util.*;
4 
5 public class FWMFDouble extends FreeWRLMField implements MFDouble {
6  FreeWRLBrowser browser;
7  private static final int ROWS = 1;
8 
10  super(def, b);
11  browser = b;
12  }
13 
14  public void getValue(double[] value) throws ArrayIndexOutOfBoundsException {
15  int lines;
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 
27  tokens = new StringTokenizer(rep);
28 
29  lines = Integer.valueOf(tokens.nextToken()).intValue();
30 
31  if (value.length < lines) {
32  throw new ArrayIndexOutOfBoundsException("MFDouble getValue passed array of insufficient size");
33  }
34 
35  for (count1=0; count1<lines; count1++) {
36  value[count1] = Double.valueOf(tokens.nextToken()).doubleValue();
37  }
38  }
39 
40  public double get1Value(int index) throws ArrayIndexOutOfBoundsException {
41  int lines;
42  int count1;
43  int count2;
44  StringTokenizer tokens;
45  String rep;
46  double[] rval;
47 
48  if (RLreturn == null) {
49  rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
50  } else {
51  rep = RLreturn;
52  }
53 
54  tokens = new StringTokenizer(rep);
55 
56  lines = Integer.valueOf(tokens.nextToken()).intValue();
57 
58  rval = new double[lines];
59 
60  if (index > lines) {
61  throw new ArrayIndexOutOfBoundsException("MFDouble get1Value passed index out of bounds");
62  }
63 
64  for (count1=0; count1<lines; count1++) {
65  rval[count1] = Double.valueOf(tokens.nextToken()).doubleValue();
66  }
67 
68 
69  return rval[index];
70  }
71  public void setValue(int size, double[] value) {
72  String val;
73  int count;
74 
75  if (size > value.length) {
76  size = value.length;
77  }
78 
79  val = " " + size;
80 
81  for (count = 0; count < size; count++) {
82  val = val + " " + value[count];
83  }
84  browser.newSendEvent(this, val);
85  }
86  public void set1Value(int index, double value) throws ArrayIndexOutOfBoundsException {
87  browser.newSendEvent(this, " ONEVAL " + index + " " + value);
88  }
89  public void append(double[] value){
90  int lines;
91  int append_size;
92  int count1, count2;
93  StringTokenizer tokens;
94  String rep;
95  String val;
96 
97  if (RLreturn == null) {
98  rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
99  } else {
100  rep = RLreturn;
101  }
102 
103  tokens = new StringTokenizer(rep);
104  lines = Integer.valueOf(tokens.nextToken()).intValue();
105 
106  append_size = value.length;
107 
108  val = " " + (lines + append_size);
109 
110  for (count1 = 0; count1 < lines; count1++) {
111  val = val + tokens.nextToken();
112  }
113 
114  for (count1 = 0; count1 < append_size; count1++) {
115  val = val + " " + value[count1];
116  }
117 
118  browser.newSendEvent(this, val);
119  }
120  public void insertValue(int index, double[] value) throws ArrayIndexOutOfBoundsException {
121  int lines;
122  int insert_size;
123  int count1, count2;
124  StringTokenizer tokens;
125  String rep;
126  String val;
127 
128  if (RLreturn == null) {
129  rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
130  } else {
131  rep = RLreturn;
132  }
133 
134  tokens = new StringTokenizer(rep);
135  lines = Integer.valueOf(tokens.nextToken()).intValue();
136 
137  insert_size = value.length;
138 
139  if ((index > lines) || (index < 0)) {
140  throw new ArrayIndexOutOfBoundsException("MFDouble insertValue passed index out of bounds");
141  }
142 
143  val = " " + (lines + insert_size);
144 
145  for (count1 = 0; count1 < index; count1++) {
146  val = val + tokens.nextToken();
147  }
148 
149  for (count1 = 0; count1 < insert_size; count1++) {
150  val = val + " " + value[count1];
151  }
152 
153  for (count1 = index; count1 < lines; count1++) {
154  val = val + tokens.nextToken();
155  }
156 
157  browser.newSendEvent(this, val);
158  }
159 }