Source Code Cross Referenced for MediaContainerPanel.java in  » 6.0-JDK-Modules » java-3d » org » jdesktop » j3dedit » scenegrapheditor » nodeeditors » panels » 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 » org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.panels 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/nodeeditors/panels/MediaContainerPanel.java,v 1.1 2005/04/20 22:21:05 paulby Exp $
003:         *
004:         *                         Sun Public License Notice
005:         *
006:         *  The contents of this file are subject to the Sun Public License Version
007:         *  1.0 (the "License"). You may not use this file except in compliance with
008:         *  the License. A copy of the License is available at http://www.sun.com/
009:         *  
010:         *  The Original Code is the Java 3D(tm) Scene Graph Editor.
011:         *  The Initial Developer of the Original Code is Paul Byrne.
012:         *  Portions created by Paul Byrne are Copyright (C) 2002.
013:         *  All Rights Reserved.
014:         *  
015:         *  Contributor(s): Paul Byrne.
016:         *  
017:         **/
018:        package org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.panels;
019:
020:        import java.awt.Frame;
021:        import java.net.URL;
022:        import java.io.File;
023:        import javax.media.j3d.MediaContainer;
024:        import javax.media.j3d.NodeComponent;
025:        import javax.media.j3d.Sound;
026:        import org.jdesktop.j3dedit.scenegraph.SGNodeComponent;
027:        import org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.NodeComponentEditorPanel;
028:        import org.jdesktop.j3dfly.utils.loadercontrol.ExampleFileFilter;
029:
030:        /**
031:         * @author Paul Byrne
032:         * @version	1.5, 01/18/02
033:         */
034:        public class MediaContainerPanel extends NodeComponentEditorPanel {
035:
036:            private ExampleFileFilter soundFileFilter = null;
037:            private boolean wasNull;
038:            private java.awt.CardLayout cardLayout;
039:            private String origURLString;
040:            private URL origURL;
041:            private boolean origCacheEnable;
042:
043:            public MediaContainerPanel() {
044:                super ();
045:                initComponents();
046:
047:                cardLayout = (java.awt.CardLayout) this .getLayout();
048:
049:            }
050:
051:            /** This method is called from within the constructor to
052:             * initialize the form.
053:             * WARNING: Do NOT modify this code. The content of this method is
054:             * always regenerated by the FormEditor.
055:             */
056:            private void initComponents() {//GEN-BEGIN:initComponents
057:                java.awt.GridBagConstraints gridBagConstraints;
058:
059:                normalPanel = new javax.swing.JPanel();
060:                jPanel3 = new javax.swing.JPanel();
061:                soundFileTF = new javax.swing.JTextField();
062:                loadFileB = new javax.swing.JButton();
063:                cacheEnableCB = new javax.swing.JCheckBox();
064:                jLabel2 = new javax.swing.JLabel();
065:                ncCommonP = new org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.panels.CommonNodeComponentPanel();
066:                nullPanel = new javax.swing.JPanel();
067:                jPanel4 = new javax.swing.JPanel();
068:                jLabel1 = new javax.swing.JLabel();
069:                newComponentB = new javax.swing.JButton();
070:
071:                setLayout(new java.awt.CardLayout());
072:
073:                jPanel3.setLayout(new java.awt.GridBagLayout());
074:
075:                soundFileTF.setEditable(false);
076:                soundFileTF
077:                        .setText("                                                  ");
078:                gridBagConstraints = new java.awt.GridBagConstraints();
079:                gridBagConstraints.gridx = 1;
080:                gridBagConstraints.gridy = 1;
081:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
082:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
083:                jPanel3.add(soundFileTF, gridBagConstraints);
084:
085:                loadFileB.setText("Choose New Sound ...");
086:                loadFileB.setToolTipText("Select the Sound file to be played");
087:                loadFileB
088:                        .addActionListener(new java.awt.event.ActionListener() {
089:                            public void actionPerformed(
090:                                    java.awt.event.ActionEvent evt) {
091:                                loadFileBActionPerformed(evt);
092:                            }
093:                        });
094:
095:                gridBagConstraints = new java.awt.GridBagConstraints();
096:                gridBagConstraints.gridx = 1;
097:                gridBagConstraints.gridy = 2;
098:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
099:                jPanel3.add(loadFileB, gridBagConstraints);
100:
101:                cacheEnableCB.setText("Enable Cache");
102:                cacheEnableCB
103:                        .addActionListener(new java.awt.event.ActionListener() {
104:                            public void actionPerformed(
105:                                    java.awt.event.ActionEvent evt) {
106:                                cacheEnableCBActionPerformed(evt);
107:                            }
108:                        });
109:
110:                gridBagConstraints = new java.awt.GridBagConstraints();
111:                gridBagConstraints.gridx = 1;
112:                gridBagConstraints.gridy = 3;
113:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
114:                jPanel3.add(cacheEnableCB, gridBagConstraints);
115:
116:                jLabel2.setText("URL :");
117:                gridBagConstraints = new java.awt.GridBagConstraints();
118:                gridBagConstraints.gridx = 0;
119:                gridBagConstraints.gridy = 1;
120:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
121:                jPanel3.add(jLabel2, gridBagConstraints);
122:
123:                gridBagConstraints = new java.awt.GridBagConstraints();
124:                gridBagConstraints.gridwidth = 2;
125:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
126:                jPanel3.add(ncCommonP, gridBagConstraints);
127:
128:                normalPanel.add(jPanel3);
129:
130:                add(normalPanel, "card4");
131:
132:                jPanel4.setLayout(new java.awt.GridBagLayout());
133:
134:                jLabel1.setText("Component is Null");
135:                jPanel4.add(jLabel1, new java.awt.GridBagConstraints());
136:
137:                newComponentB.setText("New MediaContainer");
138:                newComponentB
139:                        .addActionListener(new java.awt.event.ActionListener() {
140:                            public void actionPerformed(
141:                                    java.awt.event.ActionEvent evt) {
142:                                newComponentBActionPerformed(evt);
143:                            }
144:                        });
145:
146:                gridBagConstraints = new java.awt.GridBagConstraints();
147:                gridBagConstraints.gridx = 0;
148:                gridBagConstraints.gridy = 1;
149:                jPanel4.add(newComponentB, gridBagConstraints);
150:
151:                nullPanel.add(jPanel4);
152:
153:                add(nullPanel, "card5");
154:
155:            }//GEN-END:initComponents
156:
157:            private void cacheEnableCBActionPerformed(
158:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cacheEnableCBActionPerformed
159:            // Add your handling code here:
160:                ((MediaContainer) node.getJ3dNode())
161:                        .setCacheEnable(cacheEnableCB.isSelected());
162:                setUpdateRequired(true);
163:            }//GEN-LAST:event_cacheEnableCBActionPerformed
164:
165:            private void newComponentBActionPerformed(
166:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newComponentBActionPerformed
167:            // Add your handling code here:
168:                node = new SGNodeComponent(new MediaContainer(), nodeParent
169:                        .getContext());
170:                if (org.jdesktop.j3dedit.scenegrapheditor.PropertiesDialog.performanceLevel == org.jdesktop.j3dedit.scenegrapheditor.PropertiesDialog.READ_ALLOWED)
171:                    setReadCapabilityBits(node.getJ3dNode());
172:                else if (org.jdesktop.j3dedit.scenegrapheditor.PropertiesDialog.performanceLevel == org.jdesktop.j3dedit.scenegrapheditor.PropertiesDialog.READ_WRITE_ALLOWED)
173:                    setReadWriteCapabilityBits(node.getJ3dNode());
174:
175:                ((javax.media.j3d.Sound) getParentJ3dNode())
176:                        .setSoundData((MediaContainer) node.getJ3dNode());
177:                setControls();
178:                wasNull = true;
179:            }//GEN-LAST:event_newComponentBActionPerformed
180:
181:            private void loadFileBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadFileBActionPerformed
182:            // Add your handling code here:
183:                URL soundURL;
184:                if (soundFileFilter == null)
185:                    createSoundFileFilter();
186:                File soundFile = org.jdesktop.j3dedit.scenegrapheditor.WindowManager
187:                        .getManager().chooseOpenFile("Open Sound File",
188:                                soundFileFilter);
189:                if (soundFile == null)
190:                    return;
191:
192:                try {
193:                    soundURL = soundFile.toURL();
194:                } catch (java.net.MalformedURLException e) {
195:                    org.jdesktop.j3dedit.scenegrapheditor.WindowManager
196:                            .getManager().showErrorMessage(
197:                                    "Unable to Load Sound");
198:                    return;
199:                }
200:
201:                soundFileTF.setText(soundURL.toString());
202:                ((MediaContainer) node.getJ3dNode()).setURLObject(soundURL);
203:                setUpdateRequired(true);
204:            }//GEN-LAST:event_loadFileBActionPerformed
205:
206:            /**
207:             * Set the GUI controls to represent node
208:             * Store the state of the node so any subsequent changes
209:             * can be reset
210:             */
211:            public void setControls() {
212:                if (node == null) {
213:                    cardLayout.last(this );
214:                    wasNull = true;
215:                } else {
216:                    cardLayout.first(this );
217:                    wasNull = false;
218:                    origURL = ((MediaContainer) node.getJ3dNode())
219:                            .getURLObject();
220:                    origCacheEnable = ((MediaContainer) node.getJ3dNode())
221:                            .getCacheEnable();
222:                    cacheEnableCB.setSelected(origCacheEnable);
223:                    if (origURL != null) {
224:                        soundFileTF.setText(origURL.toString());
225:                    } else if (((MediaContainer) node.getJ3dNode())
226:                            .getInputStream() != null) {
227:                        org.jdesktop.j3dedit.scenegrapheditor.WindowManager
228:                                .getManager()
229:                                .showMessage("Sound Data",
230:                                        "Sound Data is from an InputStream, \n unable to locate file details");
231:                    }
232:                }
233:            }
234:
235:            /**
236:             * Permanently apply the changes to the node
237:             */
238:            public void applyChanges() {
239:                setControls();
240:            }
241:
242:            /**
243:             * Reset the changes to the state when setControls or applyChanges
244:             * was last called
245:             */
246:            public void resetChanges() {
247:                if (wasNull)
248:                    ((Sound) getParentJ3dNode()).setSoundData(null);
249:                else {
250:                    ((MediaContainer) node.getJ3dNode()).setURLObject(origURL);
251:                    ((MediaContainer) node.getJ3dNode())
252:                            .setURLString(origURLString);
253:                    ((MediaContainer) node.getJ3dNode())
254:                            .setCacheEnable(origCacheEnable);
255:                }
256:                setControls();
257:            }
258:
259:            /**
260:             * Set capability bits for read-only operations on this
261:             * Nodes properties
262:             */
263:            protected void setReadCapabilityBits(NodeComponent node) {
264:                if (node == null)
265:                    return;
266:
267:                ((MediaContainer) node)
268:                        .setCapability(MediaContainer.ALLOW_URL_READ);
269:                ((MediaContainer) node)
270:                        .setCapability(MediaContainer.ALLOW_CACHE_READ);
271:            }
272:
273:            /**
274:             * Set capability bits for full read/write access to this
275:             * nodes properties
276:             */
277:            protected void setReadWriteCapabilityBits(NodeComponent node) {
278:                if (node == null)
279:                    return;
280:
281:                ((MediaContainer) node)
282:                        .setCapability(MediaContainer.ALLOW_URL_READ);
283:                ((MediaContainer) node)
284:                        .setCapability(MediaContainer.ALLOW_URL_WRITE);
285:                ((MediaContainer) node)
286:                        .setCapability(MediaContainer.ALLOW_CACHE_READ);
287:                ((MediaContainer) node)
288:                        .setCapability(MediaContainer.ALLOW_CACHE_WRITE);
289:            }
290:
291:            private void createSoundFileFilter() {
292:                soundFileFilter = new ExampleFileFilter(new String[] { "au",
293:                        "wav", "aiff", "pcm" });
294:            }
295:
296:            /**
297:             * Get the CommonNodeComponentPanel
298:             */
299:            protected org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.panels.CommonNodeComponentPanel getCommonNCPanel() {
300:                return ncCommonP;
301:            }
302:
303:            // Variables declaration - do not modify//GEN-BEGIN:variables
304:            private javax.swing.JPanel nullPanel;
305:            private javax.swing.JPanel jPanel4;
306:            private javax.swing.JPanel jPanel3;
307:            private javax.swing.JButton newComponentB;
308:            private javax.swing.JPanel normalPanel;
309:            private javax.swing.JTextField soundFileTF;
310:            private org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.panels.CommonNodeComponentPanel ncCommonP;
311:            private javax.swing.JLabel jLabel2;
312:            private javax.swing.JLabel jLabel1;
313:            private javax.swing.JCheckBox cacheEnableCB;
314:            private javax.swing.JButton loadFileB;
315:            // End of variables declaration//GEN-END:variables
316:
317:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.