FreeWRL / FreeX3D 4.3.0
FWMFVec2f.java
1package sai;
2import org.web3d.x3d.sai.*;
3import java.util.*;
4
5public class FWMFVec2f extends FreeWRLMField implements MFVec2f {
6 FreeWRLBrowser browser;
7 private 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 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("MFVec2f getValue passed array of insufficient size");
33 }
34
35 for (count1=0; count1<lines; count1++) {
36 if ((value[count1]).length < ROWS) {
37 throw new ArrayIndexOutOfBoundsException("MFVec2f getValue passed array containing degenerate subarray value");
38 }
39 for (count2=0; count2<ROWS; count2++) {
40 value[count1][count2] = Float.valueOf(tokens.nextToken()).floatValue();
41 }
42 }
43 }
44 public void getValue(float[] value) throws ArrayIndexOutOfBoundsException {
45 int lines;
46 int count1;
47 int count2;
48 StringTokenizer tokens;
49 String rep;
50
51 if (RLreturn == null) {
52 rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
53 } else {
54 rep = RLreturn;
55 }
56
57 tokens = new StringTokenizer(rep);
58
59 lines = Integer.valueOf(tokens.nextToken()).intValue();
60
61 if (value.length < (lines*ROWS)) {
62 throw new ArrayIndexOutOfBoundsException("MFVec2f getValue passed array of insufficient size");
63 }
64
65 for (count1=0; count1<(lines*ROWS); count1++) {
66 value[count1] = Float.valueOf(tokens.nextToken()).floatValue();
67 }
68 }
69 public void get1Value(int index, float[] value) throws ArrayIndexOutOfBoundsException {
70 float[][] tval;
71 int lines;
72 int count1;
73 int count2;
74 StringTokenizer tokens;
75 String rep;
76
77 if (RLreturn == null) {
78 rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
79 } else {
80 rep = RLreturn;
81 }
82
83 tokens = new StringTokenizer(rep);
84
85 lines = Integer.valueOf(tokens.nextToken()).intValue();
86
87 if (value.length < ROWS) {
88 throw new ArrayIndexOutOfBoundsException("MFVec2f get1Value passed array of insufficient size");
89 }
90
91 if (index > lines) {
92 throw new ArrayIndexOutOfBoundsException("MFVec2f get1Value passed index out of bounds");
93 }
94
95 tval = new float[lines][ROWS];
96
97 for (count1=0; count1<lines; count1++) {
98 for (count2=0; count2<ROWS; count2++) {
99 tval[count1][count2] = Float.valueOf(tokens.nextToken()).floatValue();
100 }
101 }
102
103 for (count1=0; count1<ROWS; count1++) {
104 value[count1] = tval[index][count1];
105 }
106 }
107 public void setValue(int size, float[] value) throws ArrayIndexOutOfBoundsException {
108 int count;
109 String val;
110
111 if (value.length < (size*ROWS)) {
112 throw new ArrayIndexOutOfBoundsException("MFVec2f setValue passed array containing an insufficient number of values");
113 }
114
115 val = " " + size;
116
117 for (count = 0; count < (size*ROWS); count++) {
118 val = val + " " + value[count];
119 }
120 browser.newSendEvent(this, val);
121 }
122 public void setValue(int size, float[][] value) throws ArrayIndexOutOfBoundsException {
123 int count;
124 String val;
125
126 if (value.length < size) {
127 size = value.length;
128 }
129
130 val = " " + size;
131
132 for (count = 0; count < size; count++) {
133 if ((value[count]).length < ROWS) {
134 throw new ArrayIndexOutOfBoundsException("MFVec2f setValue degenerate vector value received");
135 }
136 val = val + " " + value[count][0] + " " + value[count][1];
137 }
138 browser.newSendEvent(this, val);
139 }
140 public void set1Value(int index, float[] value) throws ArrayIndexOutOfBoundsException {
141 if (value.length < ROWS) {
142 throw new ArrayIndexOutOfBoundsException("MFVec2f set1Value degenerate vector value received");
143 }
144 browser.newSendEvent(this, " ONEVAL " + index + " " + value[0] + " " + value[1]);
145 }
146 public void append(float[] value) {
147 int lines;
148 int count1;
149 int count2;
150 int count;
151 StringTokenizer tokens;
152 String rep;
153 String val;
154 int size;
155
156 if (RLreturn == null) {
157 rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
158 } else {
159 rep = RLreturn;
160 }
161
162 tokens = new StringTokenizer(rep);
163
164 lines = Integer.valueOf(tokens.nextToken()).intValue();
165 size = value.length/ROWS;
166
167 val = " " + (lines+size);
168
169 for (count = 0; count < lines; count++) {
170 val = val + " " + Float.valueOf(tokens.nextToken()).floatValue() + " " + Float.valueOf(tokens.nextToken()).floatValue();
171 }
172
173 for (count = 0; count < value.length; count++) {
174 if (value.length < ROWS) {
175 throw new ArrayIndexOutOfBoundsException("MFVec2f append degenerate vector value received");
176 }
177
178 val = val + " " + value[count] + " " + value[count+1];
179 count++;
180 }
181
182 browser.newSendEvent(this, val);
183 }
184 public void insertValue(int index, float[] value) {
185 int lines;
186 int count1;
187 int count2;
188 int count;
189 StringTokenizer tokens;
190 String rep;
191 String val;
192 int size;
193
194 if (RLreturn == null) {
195 rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
196 } else {
197 rep = RLreturn;
198 }
199
200 tokens = new StringTokenizer(rep);
201
202 lines = Integer.valueOf(tokens.nextToken()).intValue();
203 size = value.length/ROWS;
204
205 val = " " + (lines+size);
206
207 for (count = 0; count < index; count++) {
208 val = val + " " + Float.valueOf(tokens.nextToken()).floatValue() + " " + Float.valueOf(tokens.nextToken()).floatValue();
209 }
210
211 for (count = 0; count < value.length; count++) {
212 if (value.length < ROWS) {
213 throw new ArrayIndexOutOfBoundsException("MFVec2f insert degenerate vector value received");
214 }
215
216 val = val + " " + value[count] + " " + value[count+1];
217 count++;
218 }
219
220 for (count = (index+size); count < (lines+size); count++) {
221 val = val + " " + Float.valueOf(tokens.nextToken()).floatValue() + " " + Float.valueOf(tokens.nextToken()).floatValue();
222 }
223
224 browser.newSendEvent(this, val);
225 }
226}