Source Code Cross Referenced for MediaContainerRetained.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: MediaContainerRetained.java,v $
003:         *
004:         * Copyright 1997-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:26 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import java.net.URL;
035:        import java.io.InputStream;
036:
037:        /**
038:         * The MediaContainerRetained object defines all rendering state that can
039:         * be set as a component object of a retained Soundscape node.
040:         */
041:        class MediaContainerRetained extends NodeComponentRetained {
042:            /**
043:             *  Gain Scale Factor applied to source with this attribute
044:             */
045:            boolean cached = true;
046:
047:            /**
048:             *  URL string that references the sound data
049:             */
050:            URL url = null;
051:            String urlString = null;
052:            InputStream inputStream = null;
053:
054:            /**
055:             * Set Cached flag
056:             * @param state flag denoting sound data is cached by app within node
057:             */
058:            void setCacheEnable(boolean state) {
059:                this .cached = state;
060:                // changing this AFTER sound data attached to node is ignored
061:                // notifyUsers();
062:            }
063:
064:            /**
065:             * Retrieve Attrribute Gain (amplitude)
066:             * @return gain amplitude scale factor
067:             */
068:            boolean getCacheEnable() {
069:                return this .cached;
070:            }
071:
072:            /**
073:             * Set URL object that references the sound data
074:             * @param url URL object that references the sound data
075:             */
076:            void setURLObject(URL url) {
077:                setURLObject(url, true);
078:            }
079:
080:            /**
081:             * Set URL object that references the sound data
082:             * @param url URL object that references the sound data
083:             * @param forceLoad ensures that message about change is sent to scheduler
084:             */
085:            void setURLObject(URL url, boolean forceLoad) {
086:                // can NOT set URL object field unless the other related fields are null
087:                if (url != null) {
088:                    if (urlString != null || inputStream != null)
089:                        throw new IllegalArgumentException(J3dI18N
090:                                .getString("MediaContainer5"));
091:                    // Test if url object is valid by openning it
092:                    try {
093:                        InputStream stream;
094:                        stream = url.openStream();
095:                        stream.close();
096:                    } catch (Exception e) {
097:                        throw new SoundException(javax.media.j3d.J3dI18N
098:                                .getString("MediaContainer0"));
099:                    }
100:                }
101:                this .url = url;
102:                // notifyUsers();
103:                // avoid re-loading SAME MediaContainer when duplicateAttrib calls
104:                if (forceLoad)
105:                    dispatchMessage();
106:            }
107:
108:            /**
109:             * Set URL path that references the sound data
110:             * @param path string of URL that references the sound data
111:             */
112:            void setURLString(String path) {
113:                setURLString(path, true);
114:            }
115:
116:            /**
117:             * Set URL path that references the sound data
118:             * @param path string of URL that references the sound data
119:             * @param forceLoad ensures that message about change is sent to scheduler
120:             */
121:            void setURLString(String path, boolean forceLoad) {
122:                // can NOT set string field unless the other related fields are null
123:                if (path != null) {
124:                    if (this .url != null || inputStream != null)
125:                        throw new IllegalArgumentException(J3dI18N
126:                                .getString("MediaContainer5"));
127:                    // Test if path string is valid URL by trying to generate a URL
128:                    // and then openning it
129:                    try {
130:                        URL url = new URL(path);
131:                        InputStream stream;
132:                        stream = url.openStream();
133:                        stream.close();
134:                    } catch (Exception e) {
135:                        throw new SoundException(javax.media.j3d.J3dI18N
136:                                .getString("MediaContainer0"));
137:                    }
138:                }
139:                this .urlString = path;
140:                // notifyUsers();
141:                // avoid re-loading SAME MediaContainer when duplicateAttrib calls
142:                if (forceLoad)
143:                    dispatchMessage();
144:            }
145:
146:            /**
147:             * Set input stream reference to sound data
148:             * @param stream InputStream that references the sound data
149:             * @param forceLoad ensures that message about change is sent to scheduler
150:             */
151:            void setInputStream(InputStream stream) {
152:                setInputStream(stream, true);
153:            }
154:
155:            /**
156:             * Set input stream reference to sound data
157:             * @param stream InputStream that references the sound data
158:             */
159:            void setInputStream(InputStream stream, boolean forceLoad) {
160:                // XXXX: AudioDevice not intellegent enough to process InputStreams yet
161:                // can NOT set stream field unless the other related fields are null
162:                if (stream != null) {
163:                    if (url != null || urlString != null)
164:                        throw new IllegalArgumentException(J3dI18N
165:                                .getString("MediaContainer5"));
166:                }
167:                this .inputStream = stream;
168:                // notifyUsers();
169:                // avoid re-loading SAME MediaContainer when duplicateAttrib calls
170:                if (forceLoad)
171:                    dispatchMessage();
172:            }
173:
174:            /**
175:             * Retrieve URL String
176:             * @return URL string that references the sound data
177:             */
178:            String getURLString() {
179:                return this .urlString;
180:            }
181:
182:            /**
183:             * Retrieve URL objects
184:             * @return URL object that references the sound data
185:             */
186:            URL getURLObject() {
187:                return this .url;
188:            }
189:
190:            /**
191:             * Retrieve InputData
192:             * @return InputString that references the sound data
193:             */
194:            InputStream getInputStream() {
195:                return this .inputStream;
196:            }
197:
198:            /**  
199:             * Dispatch a message about a media container change
200:             */
201:            void dispatchMessage() {
202:                // Send message including a integer argumentD
203:                J3dMessage createMessage = new J3dMessage();
204:                createMessage.threads = J3dThread.SOUND_SCHEDULER;
205:                createMessage.type = J3dMessage.MEDIA_CONTAINER_CHANGED;
206:                createMessage.universe = null;
207:                createMessage.args[0] = this ;
208:                createMessage.args[1] = new Integer(
209:                        SoundRetained.SOUND_DATA_DIRTY_BIT);
210:                createMessage.args[2] = new Integer(users.size());
211:                createMessage.args[3] = users;
212:                VirtualUniverse.mc.processMessage(createMessage);
213:            }
214:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.