FreeWRL / FreeX3D 4.3.0
MFColor.java
1//AUTOMATICALLY GENERATED BY genfields.pl.
2//DO NOT EDIT!!!!
3
4package vrml.field;
5import vrml.*;
6import java.io.BufferedReader;
7import java.io.PrintWriter;
8import java.io.IOException;
9
10public class MFColor extends MField {
11 public MFColor() {
12 }
13
14 public MFColor(float[] colors) {
15 this(colors.length, colors);
16 }
17
18 public MFColor(int size, float[] colors) {
19 for (int i = 0; i < size; i += 3)
20 __vect.addElement(new ConstSFColor(colors[i], colors[i+1], colors[i+2]));
21 }
22
23 public MFColor(float[][] colors) {
24 for (int i = 0; i < colors.length; i++)
25 __vect.addElement(new ConstSFColor(colors[i][0], colors[i][1], colors[i][2]));
26 }
27
28 public void getValue(float[] colors) {
29 __updateRead();
30 int size = __vect.size();
31 for (int i = 0; i < size; i++) {
32 ConstSFColor sfColor = (ConstSFColor) __vect.elementAt(i);
33 colors[3*i+0] = sfColor.red;
34 colors[3*i+1] = sfColor.green;
35 colors[3*i+2] = sfColor.blue;
36 }
37 }
38
39 public void getValue(float[][] colors) {
40 __updateRead();
41 int size = __vect.size();
42 for (int i = 0; i < size; i++)
43 ((ConstSFColor) __vect.elementAt(i)).getValue(colors[i]);
44 }
45
46 public void get1Value(int index, float[] colors) {
47 __update1Read(index);
48 ((ConstSFColor) __vect.elementAt(index)).getValue(colors);
49 }
50
51 public void get1Value(int index, SFColor sfColor) {
52 __update1Read(index);
53 sfColor.setValue((ConstSFColor) __vect.elementAt(index));
54 }
55
56 public void setValue(float[] colors) {
57 setValue(colors.length, colors);
58 }
59
60 public void setValue(int size, float[] colors) {
61 __vect.clear();
62 for (int i = 0; i < size; i += 3)
63 __vect.addElement(new ConstSFColor(colors[i], colors[i+1], colors[i+2]));
64 __updateWrite();
65 }
66
67 public void set1Value(int index, float red, float green, float blue) {
68 __set1Value(index, new ConstSFColor(red, green, blue));
69 }
70
71 public void set1Value(int index, SFColor sfColor) {
72 sfColor.__updateRead();
73 __set1Value(index, new ConstSFColor(sfColor.red, sfColor.green, sfColor.blue));
74 }
75
76 public void set1Value(int index, ConstSFColor sfColor) {
77 __set1Value(index, sfColor);
78 }
79
80 public void addValue(float red, float green, float blue) {
81 __addValue(new ConstSFColor(red, green, blue));
82 }
83
84 public void addValue(SFColor sfColor) {
85 sfColor.__updateRead();
86 __addValue(new ConstSFColor(sfColor.red, sfColor.green, sfColor.blue));
87 }
88
89 public void addValue(ConstSFColor sfColor) {
90 __addValue(sfColor);
91 }
92
93 public void insertValue(int index, float red, float green, float blue) {
94 __insertValue(index, new ConstSFColor(red, green, blue));
95 }
96
97 public void insertValue(int index, SFColor sfColor) {
98 sfColor.__updateRead();
99 __insertValue(index, new ConstSFColor(sfColor.red, sfColor.green, sfColor.blue));
100 }
101
102 public void insertValue(int index, ConstSFColor sfColor) {
103 __insertValue(index, sfColor);
104 }
105
106 public String toString() {
107 __updateRead();
108 StringBuffer sb = new StringBuffer("[");
109 int size = __vect.size();
110 for (int i = 0; i < size; i++) {
111 if (i > 0) sb.append(", ");
112 sb.append(__vect.elementAt(i));
113 }
114 return sb.append("]").toString();
115 }
116
117 public void __fromPerl(BufferedReader in) throws IOException {
118 __vect.clear();
119 String lenline = in.readLine();
120 //System.out.println ("__fromPerl, read in length as " + lenline);
121 //int len = Integer.parseInt(in.readLine());
122 int len = Integer.parseInt(lenline);
123 for (int i = 0; i < len; i++) {
124 ConstSFColor sf = new ConstSFColor();
125 sf.__fromPerl(in);
126 __vect.addElement(sf);
127 }
128 }
129
130 public void __toPerl(PrintWriter out) throws IOException {
131 StringBuffer sb = new StringBuffer("");
132 int size = __vect.size();
133 //out.print(size);
134 for (int i = 0; i < size; i++) {
135 ((ConstSFColor) __vect.elementAt(i)).__toPerl(out);
136 if (i != (size-1)) out.print (", ");
137 }
138 //out.println();
139 }
140 //public void setOffset(String offs) { this.offset = offs; } //JAS2
141 //public String getOffset() { return this.offset; } //JAS2
142}