001: /*
002: * $RCSfile: SFColor.java,v $
003: *
004: * @(#)SFColor.java 1.15 98/11/05 20:35:00
005: *
006: * Copyright (c) 1996-1998 Sun Microsystems, Inc. All Rights Reserved.
007: *
008: * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
009: * modify and redistribute this software in source and binary code form,
010: * provided that i) this copyright notice and license appear on all copies of
011: * the software; and ii) Licensee does not utilize the software in a manner
012: * which is disparaging to Sun.
013: *
014: * This software is provided "AS IS," without a warranty of any kind. ALL
015: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
016: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
017: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
018: * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
019: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
020: * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
021: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
022: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
023: * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
024: * POSSIBILITY OF SUCH DAMAGES.
025: *
026: * This software is not designed or intended for use in on-line control of
027: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
028: * the design, construction, operation or maintenance of any nuclear
029: * facility. Licensee represents and warrants that it will not use or
030: * redistribute the Software for such purposes.
031: *
032: * $Revision: 1.2 $
033: * $Date: 2005/02/03 23:07:00 $
034: * $State: Exp $
035: */
036: /*
037: * @Author: Rick Goldberg
038: * @Author: Doug Gehringer
039: *
040: */
041: package org.jdesktop.j3d.loaders.vrml97.impl;
042:
043: import java.util.Observable;
044: import java.util.Observer;
045:
046: /** Description of the Class */
047: public class SFColor extends Field {
048:
049: float[] color;
050:
051: /**
052: *Constructor for the SFColor object
053: *
054: *@param red Description of the Parameter
055: *@param green Description of the Parameter
056: *@param blue Description of the Parameter
057: */
058: public SFColor(float red, float green, float blue) {
059: color = new float[3];
060: color[0] = red;
061: color[1] = green;
062: color[2] = blue;
063: }
064:
065: /**
066: *Constructor for the SFColor object
067: *
068: *@param initColor Description of the Parameter
069: */
070: public SFColor(float[] initColor) {
071: color = new float[3];
072: setValue(initColor);
073: }
074:
075: /**
076: * Gets the value attribute of the SFColor object
077: *
078: *@param colr Description of the Parameter
079: */
080: public void getValue(float colr[]) {
081: System.arraycopy(color, 0, colr, 0, 3);
082:
083: }
084:
085: /**
086: * Gets the value attribute of the SFColor object
087: *
088: *@return The value value
089: */
090: public float[] getValue() {
091: return color;
092: }
093:
094: /**
095: * Sets the red attribute of the SFColor object
096: *
097: *@param red The new red value
098: */
099: public void setRed(float red) {
100: color[0] = red;
101: route();
102: }
103:
104: /**
105: * Sets the green attribute of the SFColor object
106: *
107: *@param green The new green value
108: */
109: public void setGreen(float green) {
110: color[1] = green;
111: route();
112: }
113:
114: /**
115: * Sets the blue attribute of the SFColor object
116: *
117: *@param blue The new blue value
118: */
119: public void setBlue(float blue) {
120: color[2] = blue;
121: route();
122: }
123:
124: /**
125: * Gets the red attribute of the SFColor object
126: *
127: *@return The red value
128: */
129: public float getRed() {
130: return color[0];
131: }
132:
133: /**
134: * Gets the green attribute of the SFColor object
135: *
136: *@return The green value
137: */
138: public float getGreen() {
139: return color[1];
140: }
141:
142: /**
143: * Gets the blue attribute of the SFColor object
144: *
145: *@return The blue value
146: */
147: public float getBlue() {
148: return color[2];
149: }
150:
151: /**
152: * Sets the value attribute of the SFColor object
153: *
154: *@param colrs The new value value
155: */
156: public void setValue(float[] colrs) {
157: System.arraycopy(colrs, 0, color, 0, 3);
158: route();
159: }
160:
161: /**
162: * Sets the value attribute of the SFColor object
163: *
164: *@param red The new value value
165: *@param green The new value value
166: *@param blue The new value value
167: */
168: public void setValue(float red, float green, float blue) {
169: color[0] = red;
170: color[1] = green;
171: color[2] = blue;
172:
173: route();
174: }
175:
176: /**
177: * Sets the value attribute of the SFColor object
178: *
179: *@param constsfcolr The new value value
180: */
181: public void setValue(ConstSFColor constsfcolr) {
182: setValue((SFColor) constsfcolr.ownerField);
183:
184: }
185:
186: /**
187: * Sets the value attribute of the SFColor object
188: *
189: *@param sfcolr The new value value
190: */
191: public void setValue(SFColor sfcolr) {
192: setValue(sfcolr.color);
193:
194: }
195:
196: /**
197: * Description of the Method
198: *
199: *@return Description of the Return Value
200: */
201: public synchronized Object clone() {
202: return new SFColor(color);
203: }
204:
205: /**
206: * Description of the Method
207: *
208: *@param field Description of the Parameter
209: */
210: public void update(Field field) {
211: setValue((SFColor) field);
212: }
213:
214: /**
215: * Description of the Method
216: *
217: *@return Description of the Return Value
218: */
219: public synchronized ConstField constify() {
220: if (constField == null) {
221: constField = new ConstSFColor(this );
222: }
223: return constField;
224: }
225:
226: /**
227: * Description of the Method
228: *
229: *@return Description of the Return Value
230: */
231: public vrml.Field wrap() {
232: return new vrml.field.SFColor(this );
233: }
234:
235: /**
236: * Description of the Method
237: *
238: *@return Description of the Return Value
239: */
240: public String toString() {
241: return color[0] + " " + color[1] + " " + color[2] + "\n";
242: }
243:
244: }
|