Source Code Cross Referenced for ColoringAttributesRetained.java in  » 6.0-JDK-Modules » java-3d » javax » media » j3d » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » java 3d » javax.media.j3d 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: ColoringAttributesRetained.java,v $
003:         *
004:         * Copyright 1998-2008 Sun Microsystems, Inc.  All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006:         *
007:         * This code is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU General Public License version 2 only, as
009:         * published by the Free Software Foundation.  Sun designates this
010:         * particular file as subject to the "Classpath" exception as provided
011:         * by Sun in the LICENSE file that accompanied this code.
012:         *
013:         * This code is distributed in the hope that it will be useful, but WITHOUT
014:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
016:         * version 2 for more details (a copy is included in the LICENSE file that
017:         * accompanied this code).
018:         *
019:         * You should have received a copy of the GNU General Public License version
020:         * 2 along with this work; if not, write to the Free Software Foundation,
021:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022:         *
023:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024:         * CA 95054 USA or visit www.sun.com if you need additional information or
025:         * have any questions.
026:         *
027:         * $Revision: 1.7 $
028:         * $Date: 2008/02/28 20:17:20 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import javax.vecmath.Color3f;
035:        import java.util.ArrayList;
036:
037:        /**
038:         * The ColoringAttributesRetained object defines attributes that apply to
039:         * to coloring mapping.
040:         */
041:        class ColoringAttributesRetained extends NodeComponentRetained {
042:            // A list of pre-defined bits to indicate which component
043:            // in this ColoringAttributes object changed.
044:            static final int COLOR_CHANGED = 0x01;
045:            static final int SHADE_MODEL_CHANGED = 0x02;
046:
047:            // Intrinsic color used when lighting is disabled or when
048:            // material is null
049:            Color3f color = new Color3f(1.0f, 1.0f, 1.0f);
050:
051:            // Shade model (flat, smooth)
052:            int shadeModel = ColoringAttributes.SHADE_GOURAUD;
053:
054:            /**
055:             * Sets the intrinsic color of this ColoringAttributes
056:             * component object.
057:             * @param color the color that is used when lighting is disabled
058:             * or when material is null
059:             */
060:            final void initColor(Color3f color) {
061:                this .color.set(color);
062:            }
063:
064:            /**
065:             * Sets the intrinsic color of this ColoringAttributes
066:             * component object and sends a message notifying
067:             * the interested structures of the change.
068:             * @param color the color that is used when lighting is disabled
069:             * or when material is null
070:             */
071:            final void setColor(Color3f color) {
072:                initColor(color);
073:                sendMessage(COLOR_CHANGED, new Color3f(color));
074:            }
075:
076:            /**
077:             * Sets the intrinsic color of this ColoringAttributes
078:             * component object.  This color is used when lighting is disabled
079:             * or when material is null.
080:             * @param r the red component of the color
081:             * @param g the green component of the color
082:             * @param b the blue component of the color
083:             */
084:            final void initColor(float r, float g, float b) {
085:                this .color.set(r, g, b);
086:            }
087:
088:            /**
089:             * Sets the intrinsic color of this ColoringAttributes
090:             * component object and sends a message notifying
091:             * the interested structures of the change.
092:             * This color is used when lighting is disabled
093:             * or when material is null.
094:             * @param r the red component of the color
095:             * @param g the green component of the color
096:             * @param b the blue component of the color
097:             */
098:            final void setColor(float r, float g, float b) {
099:                initColor(r, g, b);
100:                sendMessage(COLOR_CHANGED, new Color3f(r, g, b));
101:            }
102:
103:            /**
104:             * Gets the intrinsic color of this ColoringAttributes
105:             * component object.
106:             * @param color the vector that will receive color
107:             */
108:            final void getColor(Color3f color) {
109:                color.set(this .color);
110:            }
111:
112:            /**
113:             * Sets the shade mode for this ColoringAttributes component object.
114:             * @param shadeModel the shade mode to be used; one of FASTEST,
115:             * NICEST, SHADE_FLAT, or SHADE_GOURAUD
116:             */
117:            final void initShadeModel(int shadeModel) {
118:                this .shadeModel = shadeModel;
119:            }
120:
121:            /**
122:             * Sets the shade mode for this ColoringAttributes component object
123:             * and sends a message notifying
124:             * the interested structures of the change.
125:             * @param shadeModel the shade mode to be used; one of FASTEST,
126:             * NICEST, SHADE_FLAT, or SHADE_GOURAUD
127:             */
128:            final void setShadeModel(int shadeModel) {
129:                initShadeModel(shadeModel);
130:                sendMessage(SHADE_MODEL_CHANGED, new Integer(shadeModel));
131:            }
132:
133:            /**
134:             * Gets the shade mode for this ColoringAttributes component object.
135:             * @return shadeModel the shade mode
136:             */
137:            final int getShadeModel() {
138:                return shadeModel;
139:            }
140:
141:            /**
142:             * Creates and initializes a mirror object, point the mirror object 
143:             * to the retained object if the object is not editable
144:             */
145:            synchronized void createMirrorObject() {
146:                if (mirror == null) {
147:                    // Check the capability bits and let the mirror object
148:                    // point to itself if is not editable
149:                    if (isStatic()) {
150:                        mirror = this ;
151:                    } else {
152:                        ColoringAttributesRetained mirrorCa = new ColoringAttributesRetained();
153:                        mirrorCa.source = source;
154:                        mirrorCa.set(this );
155:                        mirror = mirrorCa;
156:                    }
157:                } else {
158:                    ((ColoringAttributesRetained) mirror).set(this );
159:                }
160:            }
161:
162:            void updateNative(Context ctx, float dRed, float dGreen,
163:                    float dBlue, float alpha, boolean lEnable) {
164:                Pipeline.getPipeline().updateColoringAttributes(ctx, dRed,
165:                        dBlue, dGreen, color.x, color.y, color.z, alpha,
166:                        lEnable, shadeModel);
167:            }
168:
169:            /**
170:             * Creates a mirror object, point the mirror object to the retained
171:             * object if the object is not editable
172:             */
173:            synchronized void initMirrorObject() {
174:                ((ColoringAttributesRetained) mirror).set(this );
175:            }
176:
177:            /** Update the "component" field of the mirror object with the 
178:             *  given "value"
179:             */
180:            synchronized void updateMirrorObject(int component, Object value) {
181:
182:                ColoringAttributesRetained mirrorCa = (ColoringAttributesRetained) mirror;
183:
184:                if ((component & COLOR_CHANGED) != 0) {
185:                    mirrorCa.color.set(((Color3f) value));
186:                } else if ((component & SHADE_MODEL_CHANGED) != 0) {
187:                    mirrorCa.shadeModel = ((Integer) value).intValue();
188:                }
189:            }
190:
191:            boolean equivalent(ColoringAttributesRetained cr) {
192:                return ((cr != null) && color.equals(cr.color) && (shadeModel == cr.shadeModel));
193:            }
194:
195:            // This functions clones the retained side only and is used
196:            // internally
197:            protected Object clone() {
198:                ColoringAttributesRetained cr = (ColoringAttributesRetained) super 
199:                        .clone();
200:                cr.color = new Color3f(color);
201:                // shadeModel is copied in super.clone()
202:                return cr;
203:            }
204:
205:            // This functions clones the retained side only and is used
206:            // internally
207:            protected void set(ColoringAttributesRetained cr) {
208:                super .set(cr);
209:                color.set(cr.color);
210:                shadeModel = cr.shadeModel;
211:            }
212:
213:            final void sendMessage(int attrMask, Object attr) {
214:                ArrayList univList = new ArrayList();
215:                ArrayList gaList = Shape3DRetained.getGeomAtomsList(
216:                        mirror.users, univList);
217:                // Send to rendering attribute structure, regardless of
218:                // whether there are users or not (alternate appearance case ..)
219:                J3dMessage createMessage = new J3dMessage();
220:                createMessage.threads = J3dThread.UPDATE_RENDERING_ATTRIBUTES;
221:                createMessage.type = J3dMessage.COLORINGATTRIBUTES_CHANGED;
222:                createMessage.universe = null;
223:                createMessage.args[0] = this ;
224:                createMessage.args[1] = new Integer(attrMask);
225:                createMessage.args[2] = attr;
226:                createMessage.args[3] = new Integer(changedFrequent);
227:                VirtualUniverse.mc.processMessage(createMessage);
228:
229:                // System.err.println("univList.size is " + univList.size());
230:                for (int i = 0; i < univList.size(); i++) {
231:                    createMessage = new J3dMessage();
232:                    createMessage.threads = J3dThread.UPDATE_RENDER;
233:                    createMessage.type = J3dMessage.COLORINGATTRIBUTES_CHANGED;
234:
235:                    createMessage.universe = (VirtualUniverse) univList.get(i);
236:                    createMessage.args[0] = this ;
237:                    createMessage.args[1] = new Integer(attrMask);
238:                    createMessage.args[2] = attr;
239:
240:                    ArrayList gL = (ArrayList) gaList.get(i);
241:                    GeometryAtom[] gaArr = new GeometryAtom[gL.size()];
242:                    gL.toArray(gaArr);
243:                    createMessage.args[3] = gaArr;
244:
245:                    VirtualUniverse.mc.processMessage(createMessage);
246:                }
247:            }
248:
249:            void handleFrequencyChange(int bit) {
250:                if (bit == ColoringAttributes.ALLOW_COLOR_WRITE
251:                        || bit == ColoringAttributes.ALLOW_SHADE_MODEL_WRITE) {
252:                    setFrequencyChangeMask(bit, 0x1);
253:                }
254:            }
255:
256:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.