Source Code Cross Referenced for DirectionalLightPanel.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/DirectionalLightPanel.java,v 1.1 2005/04/20 22:21:04 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 javax.media.j3d.DirectionalLight;
021:        import javax.vecmath.Color3f;
022:        import javax.vecmath.Vector3f;
023:        import java.awt.Color;
024:
025:        import org.jdesktop.j3dfly.utils.gui.FloatDocument;
026:        import org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.NodeEditorPanel;
027:
028:        /**
029:         * @author Paul Byrne
030:         * @version	1.6, 01/18/02
031:         */
032:        public class DirectionalLightPanel extends NodeEditorPanel {
033:
034:            private Vector3f origDirection = new Vector3f();
035:            private boolean origEnabled;
036:            private Color3f origColor = new Color3f();
037:
038:            private Vector3f tmpVector3f = new Vector3f(); // Temporary Storage
039:
040:            /** Creates new form DirectionalLightPanel */
041:            public DirectionalLightPanel() {
042:                super ();
043:                frameTitle = "Directional Light";
044:                initComponents();
045:            }
046:
047:            /** This method is called from within the constructor to
048:             * initialize the form.
049:             * WARNING: Do NOT modify this code. The content of this method is
050:             * always regenerated by the FormEditor.
051:             */
052:            private void initComponents() {//GEN-BEGIN:initComponents
053:                lightEnableCB = new javax.swing.JCheckBox();
054:                colorB = new javax.swing.JButton();
055:                jPanel1 = new javax.swing.JPanel();
056:                xLabel = new javax.swing.JLabel();
057:                yLabel = new javax.swing.JLabel();
058:                zLabel = new javax.swing.JLabel();
059:                xTF = new javax.swing.JTextField();
060:                zTF = new javax.swing.JTextField();
061:                yTF = new javax.swing.JTextField();
062:                colorPanel = new javax.swing.JPanel();
063:
064:                setLayout(new java.awt.GridBagLayout());
065:                java.awt.GridBagConstraints gridBagConstraints1;
066:
067:                lightEnableCB.setText("enabled");
068:                lightEnableCB
069:                        .addActionListener(new java.awt.event.ActionListener() {
070:                            public void actionPerformed(
071:                                    java.awt.event.ActionEvent evt) {
072:                                lightEnableCBActionPerformed(evt);
073:                            }
074:                        });
075:
076:                gridBagConstraints1 = new java.awt.GridBagConstraints();
077:                gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
078:                add(lightEnableCB, gridBagConstraints1);
079:
080:                colorB.setText("Color ...");
081:                colorB.addActionListener(new java.awt.event.ActionListener() {
082:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
083:                        selectColor(evt);
084:                    }
085:                });
086:
087:                gridBagConstraints1 = new java.awt.GridBagConstraints();
088:                gridBagConstraints1.gridx = 0;
089:                gridBagConstraints1.gridy = 1;
090:                gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
091:                add(colorB, gridBagConstraints1);
092:
093:                jPanel1.setLayout(new java.awt.GridBagLayout());
094:                java.awt.GridBagConstraints gridBagConstraints2;
095:
096:                jPanel1.setBorder(new javax.swing.border.TitledBorder(
097:                        new javax.swing.border.EtchedBorder(), "Direction"));
098:                xLabel.setText("X");
099:                gridBagConstraints2 = new java.awt.GridBagConstraints();
100:                gridBagConstraints2.insets = new java.awt.Insets(0, 0, 0, 2);
101:                jPanel1.add(xLabel, gridBagConstraints2);
102:
103:                yLabel.setText("Y");
104:                gridBagConstraints2 = new java.awt.GridBagConstraints();
105:                gridBagConstraints2.gridx = 0;
106:                gridBagConstraints2.gridy = 1;
107:                gridBagConstraints2.insets = new java.awt.Insets(0, 0, 0, 2);
108:                jPanel1.add(yLabel, gridBagConstraints2);
109:
110:                zLabel.setText("Z");
111:                gridBagConstraints2 = new java.awt.GridBagConstraints();
112:                gridBagConstraints2.gridx = 0;
113:                gridBagConstraints2.gridy = 2;
114:                gridBagConstraints2.insets = new java.awt.Insets(0, 0, 0, 2);
115:                jPanel1.add(zLabel, gridBagConstraints2);
116:
117:                xTF.setDocument(new FloatDocument());
118:                xTF.setText("jTextField1");
119:                xTF.addFocusListener(new java.awt.event.FocusAdapter() {
120:                    public void focusLost(java.awt.event.FocusEvent evt) {
121:                        xTFFocusLost(evt);
122:                    }
123:                });
124:
125:                xTF.addKeyListener(new java.awt.event.KeyAdapter() {
126:                    public void keyPressed(java.awt.event.KeyEvent evt) {
127:                        xTFKeyPressed(evt);
128:                    }
129:                });
130:
131:                gridBagConstraints2 = new java.awt.GridBagConstraints();
132:                gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
133:                jPanel1.add(xTF, gridBagConstraints2);
134:
135:                zTF.setDocument(new FloatDocument());
136:                zTF.setText("jTextField3");
137:                zTF.addFocusListener(new java.awt.event.FocusAdapter() {
138:                    public void focusLost(java.awt.event.FocusEvent evt) {
139:                        zTFFocusLost(evt);
140:                    }
141:                });
142:
143:                zTF.addKeyListener(new java.awt.event.KeyAdapter() {
144:                    public void keyPressed(java.awt.event.KeyEvent evt) {
145:                        zTFKeyPressed(evt);
146:                    }
147:                });
148:
149:                gridBagConstraints2 = new java.awt.GridBagConstraints();
150:                gridBagConstraints2.gridx = 1;
151:                gridBagConstraints2.gridy = 2;
152:                gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
153:                jPanel1.add(zTF, gridBagConstraints2);
154:
155:                yTF.setDocument(new FloatDocument());
156:                yTF.setText("jTextField2");
157:                yTF.addFocusListener(new java.awt.event.FocusAdapter() {
158:                    public void focusLost(java.awt.event.FocusEvent evt) {
159:                        yTFFocusLost(evt);
160:                    }
161:                });
162:
163:                yTF.addKeyListener(new java.awt.event.KeyAdapter() {
164:                    public void keyPressed(java.awt.event.KeyEvent evt) {
165:                        yTFKeyPressed(evt);
166:                    }
167:                });
168:
169:                gridBagConstraints2 = new java.awt.GridBagConstraints();
170:                gridBagConstraints2.gridx = 1;
171:                gridBagConstraints2.gridy = 1;
172:                gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
173:                jPanel1.add(yTF, gridBagConstraints2);
174:
175:                gridBagConstraints1 = new java.awt.GridBagConstraints();
176:                gridBagConstraints1.gridx = 0;
177:                gridBagConstraints1.gridy = 2;
178:                gridBagConstraints1.gridwidth = 2;
179:                gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
180:                add(jPanel1, gridBagConstraints1);
181:
182:                colorPanel.setBackground(java.awt.Color.red);
183:                colorPanel.setPreferredSize(new java.awt.Dimension(50, 10));
184:                colorPanel.setMinimumSize(new java.awt.Dimension(50, 10));
185:                gridBagConstraints1 = new java.awt.GridBagConstraints();
186:                gridBagConstraints1.gridx = 1;
187:                gridBagConstraints1.gridy = 1;
188:                gridBagConstraints1.gridwidth = 2;
189:                gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
190:                add(colorPanel, gridBagConstraints1);
191:
192:            }//GEN-END:initComponents
193:
194:            private void zTFKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_zTFKeyPressed
195:            // Add your handling code here:
196:                if (evt.getKeyCode() == 10)
197:                    zTFFocusLost(null);
198:            }//GEN-LAST:event_zTFKeyPressed
199:
200:            private void xTFKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_xTFKeyPressed
201:            // Add your handling code here:
202:                if (evt.getKeyCode() == 10)
203:                    xTFFocusLost(null);
204:            }//GEN-LAST:event_xTFKeyPressed
205:
206:            private void yTFKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_yTFKeyPressed
207:            // Add your handling code here:
208:                if (evt.getKeyCode() == 10)
209:                    yTFFocusLost(null);
210:            }//GEN-LAST:event_yTFKeyPressed
211:
212:            private void yTFFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_yTFFocusLost
213:            // Add your handling code here:
214:                setUpdateRequired(true);
215:                ((DirectionalLight) node.getJ3dNode())
216:                        .getDirection(tmpVector3f);
217:                tmpVector3f.y = Float.parseFloat(yTF.getText());
218:                ((DirectionalLight) node.getJ3dNode())
219:                        .setDirection(tmpVector3f);
220:            }//GEN-LAST:event_yTFFocusLost
221:
222:            private void xTFFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_xTFFocusLost
223:            // Add your handling code here:
224:                setUpdateRequired(true);
225:                ((DirectionalLight) node.getJ3dNode())
226:                        .getDirection(tmpVector3f);
227:                tmpVector3f.x = Float.parseFloat(xTF.getText());
228:                ((DirectionalLight) node.getJ3dNode())
229:                        .setDirection(tmpVector3f);
230:            }//GEN-LAST:event_xTFFocusLost
231:
232:            private void zTFFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_zTFFocusLost
233:            // Add your handling code here:
234:                setUpdateRequired(true);
235:                ((DirectionalLight) node.getJ3dNode())
236:                        .getDirection(tmpVector3f);
237:                tmpVector3f.z = Float.parseFloat(zTF.getText());
238:                ((DirectionalLight) node.getJ3dNode())
239:                        .setDirection(tmpVector3f);
240:            }//GEN-LAST:event_zTFFocusLost
241:
242:            private void lightEnableCBActionPerformed(
243:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lightEnableCBActionPerformed
244:            // Add your handling code here:
245:                setUpdateRequired(true);
246:                ((DirectionalLight) node.getJ3dNode()).setEnable(lightEnableCB
247:                        .isSelected());
248:            }//GEN-LAST:event_lightEnableCBActionPerformed
249:
250:            private void selectColor(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectColor
251:            // Add your handling code here:
252:                DirectionalLight light = (DirectionalLight) node.getJ3dNode();
253:
254:                setUpdateRequired(true);
255:                Color3f color = new Color3f();
256:                light.getColor(color);
257:                Color c = org.jdesktop.j3dedit.scenegrapheditor.WindowManager
258:                        .getManager().chooseColor(
259:                                new Color(color.x, color.y, color.z));
260:
261:                colorPanel.setBackground(c);
262:                if (c.getRed() != 0)
263:                    color.x = (float) c.getRed() / 255.0f;
264:                if (c.getGreen() != 0)
265:                    color.y = (float) c.getGreen() / 255.0f;
266:                if (c.getBlue() != 0)
267:                    color.z = (float) c.getBlue() / 255.0f;
268:                light.setColor(color);
269:
270:            }//GEN-LAST:event_selectColor
271:
272:            public void setControls() {
273:                DirectionalLight light = (DirectionalLight) node.getJ3dNode();
274:
275:                lightEnableCB.setSelected(light.getEnable());
276:
277:                light.getColor(origColor);
278:                colorPanel.setBackground(new Color(origColor.x, origColor.y,
279:                        origColor.z));
280:
281:                light.getDirection(origDirection);
282:                xTF.setText(Float.toString(origDirection.x));
283:                yTF.setText(Float.toString(origDirection.y));
284:                zTF.setText(Float.toString(origDirection.z));
285:
286:                origEnabled = light.getEnable();
287:            }
288:
289:            public void applyChanges() {
290:                setControls();
291:                setUpdateRequired(false);
292:            }
293:
294:            public void resetChanges() {
295:                DirectionalLight light = (DirectionalLight) node.getJ3dNode();
296:                light.setEnable(origEnabled);
297:                light.setDirection(origDirection);
298:                light.setColor(origColor);
299:                setUpdateRequired(false);
300:            }
301:
302:            /*    public void setCapabilityBits( javax.media.j3d.Node node ) {
303:             DirectionalLight light = (DirectionalLight)node;
304:            
305:             storeCapabilityBits( node );
306:            
307:             light.setCapability( DirectionalLight.ALLOW_COLOR_READ );
308:             light.setCapability( DirectionalLight.ALLOW_COLOR_WRITE );
309:             light.setCapability( DirectionalLight.ALLOW_STATE_READ );
310:             light.setCapability( DirectionalLight.ALLOW_STATE_WRITE );
311:             light.setCapability( DirectionalLight.ALLOW_DIRECTION_READ );
312:             light.setCapability( DirectionalLight.ALLOW_DIRECTION_WRITE );
313:             }
314:            
315:             public void resetCapabilityBits( javax.media.j3d.Node node ) {
316:             super.resetCapabilityBits( node );
317:             }
318:             */
319:            protected void setReadCapabilityBits(javax.media.j3d.Node node) {
320:                DirectionalLight light = (DirectionalLight) node;
321:                light.setCapability(DirectionalLight.ALLOW_COLOR_READ);
322:                light.setCapability(DirectionalLight.ALLOW_STATE_READ);
323:                light.setCapability(DirectionalLight.ALLOW_DIRECTION_READ);
324:            }
325:
326:            protected void setReadWriteCapabilityBits(javax.media.j3d.Node node) {
327:                DirectionalLight light = (DirectionalLight) node;
328:                light.setCapability(DirectionalLight.ALLOW_COLOR_READ);
329:                light.setCapability(DirectionalLight.ALLOW_STATE_READ);
330:                light.setCapability(DirectionalLight.ALLOW_DIRECTION_READ);
331:                light.setCapability(DirectionalLight.ALLOW_COLOR_WRITE);
332:                light.setCapability(DirectionalLight.ALLOW_STATE_WRITE);
333:                light.setCapability(DirectionalLight.ALLOW_DIRECTION_WRITE);
334:            }
335:
336:            // Variables declaration - do not modify//GEN-BEGIN:variables
337:            private javax.swing.JCheckBox lightEnableCB;
338:            private javax.swing.JButton colorB;
339:            private javax.swing.JPanel jPanel1;
340:            private javax.swing.JLabel xLabel;
341:            private javax.swing.JLabel yLabel;
342:            private javax.swing.JLabel zLabel;
343:            private javax.swing.JTextField xTF;
344:            private javax.swing.JTextField zTF;
345:            private javax.swing.JTextField yTF;
346:            private javax.swing.JPanel colorPanel;
347:            // End of variables declaration//GEN-END:variables
348:
349:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.