Source Code Cross Referenced for LineAttributesRetained.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: LineAttributesRetained.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:25 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import java.util.ArrayList;
035:
036:        /**
037:         * The LineAttributesRetained object defines all rendering state that can be set
038:         * as a component object of a Shape3D node.
039:         */
040:        class LineAttributesRetained extends NodeComponentRetained {
041:            // A list of pre-defined bits to indicate which component
042:            // in this LineAttributesRetained object changed.
043:            static final int LINE_WIDTH_CHANGED = 0x01;
044:            static final int LINE_PATTERN_CHANGED = 0x02;
045:            static final int LINE_AA_CHANGED = 0x04;
046:            static final int LINE_PATTERN_MASK_CHANGED = 0x08;
047:            static final int LINE_PATTERN_SCALEFACTOR_CHANGED = 0x10;
048:
049:            // Width, in pixels, of line primitives
050:            float lineWidth = 1.0f;
051:
052:            // The line pattern to be used
053:            int linePattern = LineAttributes.PATTERN_SOLID;
054:
055:            // Line antialiasing switch
056:            boolean lineAntialiasing = false;
057:
058:            // user-defined line pattern mask
059:            int linePatternMask = 0xffff;
060:
061:            // line mask pattern scale factor
062:            int linePatternScaleFactor = 1;
063:
064:            /**
065:             * Sets the line width for this lineAttributes component object.
066:             * @param lineWidth the width, in pixels, of line primitives
067:             */
068:            final void initLineWidth(float lineWidth) {
069:                this .lineWidth = lineWidth;
070:            }
071:
072:            /**
073:             * Sets the line width for this lineAttributes component object and sends a
074:             * message notifying the interested structures of the change.
075:             * @param lineWidth the width, in pixels, of line primitives
076:             */
077:            final void setLineWidth(float lineWidth) {
078:                initLineWidth(lineWidth);
079:                sendMessage(LINE_WIDTH_CHANGED, new Float(lineWidth));
080:            }
081:
082:            /**
083:             * Gets the line width for this lineAttributes component object.
084:             * @return the width, in pixels, of line primitives
085:             */
086:            final float getLineWidth() {
087:                return lineWidth;
088:            }
089:
090:            /**
091:             * Sets the line pattern for this lineAttributes component object
092:             * @param linePattern the line pattern to be used, one of:
093:             * PATTERN_SOLID, PATTERN_DASH, PATTERN_DOT, or PATTERN_DASH_DOT
094:             */
095:            final void initLinePattern(int linePattern) {
096:                this .linePattern = linePattern;
097:            }
098:
099:            /**
100:             * Sets the line pattern for this lineAttributes component object
101:             * and sends a message notifying the interested structures of the change.
102:             * @param linePattern the line pattern to be used, one of:
103:             * PATTERN_SOLID, PATTERN_DASH, PATTERN_DOT, or PATTERN_DASH_DOT
104:             */
105:            final void setLinePattern(int linePattern) {
106:                initLinePattern(linePattern);
107:                sendMessage(LINE_PATTERN_CHANGED, new Integer(linePattern));
108:            }
109:
110:            /**
111:             * Gets the line pattern for this lineAttributes component object.
112:             * @return the line pattern
113:             */
114:            final int getLinePattern() {
115:                return linePattern;
116:            }
117:
118:            /**
119:             * Enables or disables line antialiasing
120:             * for this lineAttributes component object and sends a 
121:             * message notifying the interested structures of the change.
122:             * @param state true or false to enable or disable line antialiasing
123:             */
124:            final void initLineAntialiasingEnable(boolean state) {
125:                lineAntialiasing = state;
126:            }
127:
128:            /**
129:             * Enables or disables line antialiasing
130:             * for this lineAttributes component object and sends a 
131:             * message notifying the interested structures of the change.
132:             * @param state true or false to enable or disable line antialiasing
133:             */
134:            final void setLineAntialiasingEnable(boolean state) {
135:                initLineAntialiasingEnable(state);
136:                sendMessage(LINE_AA_CHANGED, (state ? Boolean.TRUE
137:                        : Boolean.FALSE));
138:            }
139:
140:            /**
141:             * Retrieves the state of the line antialiasing flag.
142:             * @return true if line antialiasing is enabled,
143:             * false if line antialiasing is disabled
144:             */
145:            final boolean getLineAntialiasingEnable() {
146:                return lineAntialiasing;
147:            }
148:
149:            /**
150:             * Sets the pattern mask for this LineAttributes component object.
151:             * This is used when the linePattern attribute is set to 
152:             * PATTERN_USER_DEFINED.
153:             * @param mask the line pattern mask to be used.
154:             */
155:            final void initPatternMask(int mask) {
156:                this .linePatternMask = mask;
157:            }
158:
159:            /**
160:             * Sets the pattern mask for this LineAttributes component object
161:             * and sends a message notifying the interested structures of change.
162:             * This is used when the linePattern attribute is set to 
163:             * PATTERN_USER_DEFINED. 
164:             * @param mask the line pattern mask to be used.
165:             */
166:            final void setPatternMask(int mask) {
167:                initPatternMask(mask);
168:                sendMessage(LINE_PATTERN_MASK_CHANGED, new Integer(mask));
169:            }
170:
171:            /**
172:             * Retrieves the pattern mask for this LineAttributes component object.
173:             * @return the user-defined pattern mask
174:             */
175:            final int getPatternMask() {
176:                return linePatternMask;
177:            }
178:
179:            /**
180:             * Sets the pattern mask scale factor for this LineAttributes 
181:             * component object. This is used when the linePattern attribute
182:             * is set to PATTERN_USER_DEFINED.
183:             * @param scaleFactor the scale factor of mask, clamp to [1, 15]
184:             */
185:            final void initPatternScaleFactor(int scaleFactor) {
186:                if (scaleFactor < 1) {
187:                    scaleFactor = 1;
188:                } else if (scaleFactor > 15) {
189:                    scaleFactor = 15;
190:                }
191:                this .linePatternScaleFactor = scaleFactor;
192:            }
193:
194:            /**
195:             * Sets the pattern mask scale factor for this LineAttributes 
196:             * component object and sends a message notifying the interested 
197:             * structures of change. This is used when the linePattern
198:             * attribute is set to PATTERN_USER_DEFINED. 
199:             * @param scaleFactor  the scale factor of mask, clamp to [1, 15]
200:             */
201:            final void setPatternScaleFactor(int scaleFactor) {
202:                initPatternScaleFactor(scaleFactor);
203:                sendMessage(LINE_PATTERN_SCALEFACTOR_CHANGED, new Integer(
204:                        scaleFactor));
205:            }
206:
207:            /**
208:             * Retrieves the pattern scale factor for this LineAttributes 
209:             * component object.
210:             * @return the pattern mask scale factor
211:             */
212:            final int getPatternScaleFactor() {
213:                return linePatternScaleFactor;
214:            }
215:
216:            /**
217:             * Creates and initializes a mirror object, point the mirror object 
218:             * to the retained object if the object is not editable
219:             */
220:            synchronized void createMirrorObject() {
221:                if (mirror == null) {
222:                    // Check the capability bits and let the mirror object
223:                    // point to itself if is not editable
224:                    if (isStatic()) {
225:                        mirror = this ;
226:                    } else {
227:                        LineAttributesRetained mirrorLa = new LineAttributesRetained();
228:                        mirrorLa.source = source;
229:                        mirrorLa.set(this );
230:                        mirror = mirrorLa;
231:                    }
232:                } else {
233:                    ((LineAttributesRetained) mirror).set(this );
234:                }
235:            }
236:
237:            /**
238:             * This method updates the native context.
239:             */
240:            void updateNative(Context ctx) {
241:                Pipeline.getPipeline().updateLineAttributes(ctx, lineWidth,
242:                        linePattern, linePatternMask, linePatternScaleFactor,
243:                        lineAntialiasing);
244:            }
245:
246:            /**
247:             * Initializes a mirror object, point the mirror object to the retained
248:             * object if the object is not editable
249:             */
250:            synchronized void initMirrorObject() {
251:                ((LineAttributesRetained) mirror).set(this );
252:            }
253:
254:            /** Update the "component" field of the mirror object with the 
255:             *  given "value"
256:             */
257:            synchronized void updateMirrorObject(int component, Object value) {
258:
259:                LineAttributesRetained mirrorLa = (LineAttributesRetained) mirror;
260:
261:                if ((component & LINE_WIDTH_CHANGED) != 0) {
262:                    mirrorLa.lineWidth = ((Float) value).floatValue();
263:                } else if ((component & LINE_PATTERN_CHANGED) != 0) {
264:                    mirrorLa.linePattern = ((Integer) value).intValue();
265:                } else if ((component & LINE_AA_CHANGED) != 0) {
266:                    mirrorLa.lineAntialiasing = ((Boolean) value)
267:                            .booleanValue();
268:                } else if ((component & LINE_PATTERN_MASK_CHANGED) != 0) {
269:                    mirrorLa.linePatternMask = ((Integer) value).intValue();
270:                } else if ((component & LINE_PATTERN_SCALEFACTOR_CHANGED) != 0) {
271:                    mirrorLa.linePatternScaleFactor = ((Integer) value)
272:                            .intValue();
273:                }
274:            }
275:
276:            boolean equivalent(LineAttributesRetained lr) {
277:                return ((lr != null) && (lineWidth == lr.lineWidth)
278:                        && (linePattern == lr.linePattern)
279:                        && (lineAntialiasing == lr.lineAntialiasing)
280:                        && (linePatternMask == lr.linePatternMask) && (linePatternScaleFactor == lr.linePatternScaleFactor));
281:
282:            }
283:
284:            protected void set(LineAttributesRetained lr) {
285:                super .set(lr);
286:                lineWidth = lr.lineWidth;
287:                linePattern = lr.linePattern;
288:                linePatternScaleFactor = lr.linePatternScaleFactor;
289:                linePatternMask = lr.linePatternMask;
290:                lineAntialiasing = lr.lineAntialiasing;
291:            }
292:
293:            final void sendMessage(int attrMask, Object attr) {
294:                ArrayList univList = new ArrayList();
295:                ArrayList gaList = Shape3DRetained.getGeomAtomsList(
296:                        mirror.users, univList);
297:
298:                // Send to rendering attribute structure, regardless of
299:                // whether there are users or not (alternate appearance case ..)
300:                J3dMessage createMessage = new J3dMessage();
301:                createMessage.threads = J3dThread.UPDATE_RENDERING_ATTRIBUTES;
302:                createMessage.type = J3dMessage.LINEATTRIBUTES_CHANGED;
303:                createMessage.universe = null;
304:                createMessage.args[0] = this ;
305:                createMessage.args[1] = new Integer(attrMask);
306:                createMessage.args[2] = attr;
307:                createMessage.args[3] = new Integer(changedFrequent);
308:                VirtualUniverse.mc.processMessage(createMessage);
309:
310:                // System.err.println("univList.size is " + univList.size());
311:                for (int i = 0; i < univList.size(); i++) {
312:                    createMessage = new J3dMessage();
313:                    createMessage.threads = J3dThread.UPDATE_RENDER;
314:                    createMessage.type = J3dMessage.LINEATTRIBUTES_CHANGED;
315:
316:                    createMessage.universe = (VirtualUniverse) univList.get(i);
317:                    createMessage.args[0] = this ;
318:                    createMessage.args[1] = new Integer(attrMask);
319:                    createMessage.args[2] = attr;
320:
321:                    ArrayList gL = (ArrayList) gaList.get(i);
322:                    GeometryAtom[] gaArr = new GeometryAtom[gL.size()];
323:                    gL.toArray(gaArr);
324:                    createMessage.args[3] = gaArr;
325:
326:                    VirtualUniverse.mc.processMessage(createMessage);
327:                }
328:
329:            }
330:
331:            void handleFrequencyChange(int bit) {
332:                if (bit == LineAttributes.ALLOW_WIDTH_WRITE
333:                        || bit == LineAttributes.ALLOW_PATTERN_WRITE
334:                        || bit == LineAttributes.ALLOW_ANTIALIASING_WRITE) {
335:                    setFrequencyChangeMask(bit, 0x1);
336:                }
337:            }
338:
339:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.