Source Code Cross Referenced for TransparencyAttributesPanel.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/TransparencyAttributesPanel.java,v 1.1 2005/04/20 22:21:12 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.TransparencyAttributes;
021:        import javax.media.j3d.NodeComponent;
022:        import javax.media.j3d.SceneGraphObject;
023:        import javax.media.j3d.Appearance;
024:
025:        import org.jdesktop.j3dfly.utils.gui.FloatDocument;
026:        import org.jdesktop.j3dedit.scenegraph.SGNodeComponent;
027:        import org.jdesktop.j3dedit.scenegraph.SGAppearance;
028:        import org.jdesktop.j3dedit.scenegraph.SGObject;
029:        import org.jdesktop.j3dedit.scenegraph.SGTransparencyAttributes;
030:        import org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.NodeComponentEditorPanel;
031:        import org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.NodeEditorPanel;
032:
033:        /**
034:         * @author Paul Byrne
035:         * @version $Id: TransparencyAttributesPanel.java,v 1.1 2005/04/20 22:21:12 paulby Exp $
036:         */
037:        public class TransparencyAttributesPanel extends
038:                NodeComponentEditorPanel {
039:
040:            private float origTransparency;
041:            private int origMode;
042:            private boolean wasNull;
043:            private java.awt.CardLayout cardLayout;
044:            private boolean doingSetControls = false;
045:
046:            /** Creates new form TransparencyAttributesPanel */
047:            public TransparencyAttributesPanel() {
048:                super ();
049:                initComponents();
050:                cardLayout = (java.awt.CardLayout) getLayout();
051:            }
052:
053:            public void startEdit(SGNodeComponent node, SGObject nodeParent,
054:                    NodeEditorPanel parentWindow) {
055:                super .startEdit(node, nodeParent, parentWindow);
056:                if (node == null)
057:                    wasNull = true;
058:            }
059:
060:            public void setReadOnly(boolean readOnly) {
061:                this .readOnly = readOnly;
062:
063:                createAttributeB.setEnabled(!readOnly);
064:                transparencyModeC.setEnabled(!readOnly);
065:                slider.setEnabled(!readOnly);
066:                transparencyTF.setEnabled(!readOnly);
067:            }
068:
069:            /** This method is called from within the constructor to
070:             * initialize the form.
071:             * WARNING: Do NOT modify this code. The content of this method is
072:             * always regenerated by the FormEditor.
073:             */
074:            private void initComponents() {//GEN-BEGIN:initComponents
075:                java.awt.GridBagConstraints gridBagConstraints;
076:
077:                normalPanel = new javax.swing.JPanel();
078:                jPanel1 = new javax.swing.JPanel();
079:                jLabel1 = new javax.swing.JLabel();
080:                transparencyModeC = new javax.swing.JComboBox(new String[] {
081:                        "BLENDED", "FASTEST", "NICEST", "SCREEN_DOOR", "NONE" });
082:                jLabel2 = new javax.swing.JLabel();
083:                transparencyTF = new javax.swing.JTextField();
084:                slider = new javax.swing.JSlider();
085:                ncCommonP = new org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.panels.CommonNodeComponentPanel();
086:                nullPanel = new javax.swing.JPanel();
087:                jPanel21 = new javax.swing.JPanel();
088:                jLabel31 = new javax.swing.JLabel();
089:                createAttributeB = new javax.swing.JButton();
090:
091:                setLayout(new java.awt.CardLayout());
092:
093:                jPanel1.setLayout(new java.awt.GridBagLayout());
094:
095:                jLabel1.setText("Transparenct Mode");
096:                gridBagConstraints = new java.awt.GridBagConstraints();
097:                gridBagConstraints.gridx = 0;
098:                gridBagConstraints.gridy = 1;
099:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 4);
100:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
101:                jPanel1.add(jLabel1, gridBagConstraints);
102:
103:                transparencyModeC
104:                        .addActionListener(new java.awt.event.ActionListener() {
105:                            public void actionPerformed(
106:                                    java.awt.event.ActionEvent evt) {
107:                                transparencyModeCActionPerformed(evt);
108:                            }
109:                        });
110:
111:                gridBagConstraints = new java.awt.GridBagConstraints();
112:                gridBagConstraints.gridx = 1;
113:                gridBagConstraints.gridy = 1;
114:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
115:                jPanel1.add(transparencyModeC, gridBagConstraints);
116:
117:                jLabel2.setText("Transparency");
118:                gridBagConstraints = new java.awt.GridBagConstraints();
119:                gridBagConstraints.gridx = 0;
120:                gridBagConstraints.gridy = 2;
121:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 4);
122:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
123:                jPanel1.add(jLabel2, gridBagConstraints);
124:
125:                transparencyTF.setDocument(new FloatDocument());
126:                transparencyTF.setText("0.0");
127:                transparencyTF
128:                        .addActionListener(new java.awt.event.ActionListener() {
129:                            public void actionPerformed(
130:                                    java.awt.event.ActionEvent evt) {
131:                                transparencyTFActionPerformed(evt);
132:                            }
133:                        });
134:
135:                gridBagConstraints = new java.awt.GridBagConstraints();
136:                gridBagConstraints.gridx = 1;
137:                gridBagConstraints.gridy = 2;
138:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
139:                gridBagConstraints.ipadx = 17;
140:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
141:                jPanel1.add(transparencyTF, gridBagConstraints);
142:
143:                slider.setValue(0);
144:                slider
145:                        .addChangeListener(new javax.swing.event.ChangeListener() {
146:                            public void stateChanged(
147:                                    javax.swing.event.ChangeEvent evt) {
148:                                sliderStateChanged(evt);
149:                            }
150:                        });
151:
152:                gridBagConstraints = new java.awt.GridBagConstraints();
153:                gridBagConstraints.gridx = 1;
154:                gridBagConstraints.gridy = 3;
155:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
156:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
157:                jPanel1.add(slider, gridBagConstraints);
158:
159:                gridBagConstraints = new java.awt.GridBagConstraints();
160:                gridBagConstraints.gridwidth = 2;
161:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
162:                jPanel1.add(ncCommonP, gridBagConstraints);
163:
164:                normalPanel.add(jPanel1);
165:
166:                add(normalPanel, "card4");
167:
168:                jLabel31.setFont(new java.awt.Font("Dialog", 1, 14));
169:                jLabel31.setText("Attribute is Null");
170:                jPanel21.add(jLabel31);
171:
172:                createAttributeB.setText("Create Transparency Attribute");
173:                jPanel21.add(createAttributeB);
174:
175:                nullPanel.add(jPanel21);
176:
177:                add(nullPanel, "card5");
178:
179:            }//GEN-END:initComponents
180:
181:            private void sliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderStateChanged
182:            // Add your handling code here:
183:                if (doingSetControls)
184:                    return;
185:
186:                setUpdateRequired(true);
187:
188:                float value = ((float) slider.getValue()) / 100.0f;
189:                ((TransparencyAttributes) node.getJ3dNode())
190:                        .setTransparency(value);
191:                transparencyTF.setText(Float.toString(value));
192:            }//GEN-LAST:event_sliderStateChanged
193:
194:            private void createAttributeBActionPerformed(
195:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createAttributeBActionPerformed
196:            // Add your handling code here:
197:                node = new SGTransparencyAttributes(
198:                        new TransparencyAttributes(), nodeParent.getContext());
199:                setControls();
200:                if (readOnly)
201:                    setReadCapabilityBits(node.getJ3dNode());
202:                else
203:                    setReadWriteCapabilityBits(node.getJ3dNode());
204:                ((Appearance) getParentJ3dNodeComponent())
205:                        .setTransparencyAttributes((TransparencyAttributes) node
206:                                .getJ3dNode());
207:                ((SGAppearance) nodeParent)
208:                        .setSGTransparencyAttributes((SGTransparencyAttributes) node);
209:            }//GEN-LAST:event_createAttributeBActionPerformed
210:
211:            private void transparencyTFActionPerformed(
212:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transparencyTFActionPerformed
213:            // Add your handling code here:
214:                if (doingSetControls)
215:                    return;
216:
217:                float value = Float.parseFloat(transparencyTF.getText());
218:                if (value < 0.0 || value > 1.0) {
219:                    org.jdesktop.j3dedit.scenegrapheditor.WindowManager
220:                            .getManager().showMessage("Error",
221:                                    "Transparency must be between 0.0 and 1.0");
222:                    setSlider(origTransparency);
223:                } else {
224:                    slider.setValue((int) value * 100);
225:                    ((TransparencyAttributes) node.getJ3dNode())
226:                            .setTransparency((float) (slider.getValue() / 100));
227:                    setUpdateRequired(true);
228:                }
229:            }//GEN-LAST:event_transparencyTFActionPerformed
230:
231:            private void transparencyModeCActionPerformed(
232:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transparencyModeCActionPerformed
233:            // Add your handling code here:
234:                if (doingSetControls)
235:                    return;
236:
237:                TransparencyAttributes transAttr = (TransparencyAttributes) node
238:                        .getJ3dNode();
239:                switch (transparencyModeC.getSelectedIndex()) {
240:                case 0:
241:                    transAttr
242:                            .setTransparencyMode(TransparencyAttributes.BLENDED);
243:                    break;
244:                case 1:
245:                    transAttr
246:                            .setTransparencyMode(TransparencyAttributes.FASTEST);
247:                    break;
248:                case 2:
249:                    transAttr
250:                            .setTransparencyMode(TransparencyAttributes.NICEST);
251:                    break;
252:                case 3:
253:                    transAttr
254:                            .setTransparencyMode(TransparencyAttributes.SCREEN_DOOR);
255:                    break;
256:                case 4:
257:                    transAttr.setTransparencyMode(TransparencyAttributes.NONE);
258:                    break;
259:                }
260:                setUpdateRequired(true);
261:            }//GEN-LAST:event_transparencyModeCActionPerformed
262:
263:            /**
264:             * Set the slide to the required value
265:             * transparency must be in the range 0.0 - 1.0
266:             */
267:            private void setSlider(float transparency) {
268:                slider.setValue(((int) transparency) * 100);
269:            }
270:
271:            public void setControls() {
272:                if (node == null || node.getJ3dNode() == null) {
273:                    cardLayout.last(this );
274:                } else {
275:                    cardLayout.first(this );
276:                    doingSetControls = true;
277:
278:                    TransparencyAttributes transAttr = (TransparencyAttributes) node
279:                            .getJ3dNode();
280:
281:                    origTransparency = transAttr.getTransparency();
282:                    setSlider(origTransparency);
283:                    transparencyTF.setText(Float.toString(origTransparency));
284:
285:                    origMode = transAttr.getTransparencyMode();
286:                    switch (origMode) {
287:                    case TransparencyAttributes.BLENDED:
288:                        transparencyModeC.setSelectedIndex(0);
289:                        break;
290:                    case TransparencyAttributes.FASTEST:
291:                        transparencyModeC.setSelectedIndex(1);
292:                        break;
293:                    case TransparencyAttributes.NICEST:
294:                        transparencyModeC.setSelectedIndex(2);
295:                        break;
296:                    case TransparencyAttributes.SCREEN_DOOR:
297:                        transparencyModeC.setSelectedIndex(3);
298:                        break;
299:                    case TransparencyAttributes.NONE:
300:                        transparencyModeC.setSelectedIndex(4);
301:                        break;
302:                    default:
303:                        throw new RuntimeException("Unknown Transparency Mode");
304:                    }
305:                    doingSetControls = false;
306:                }
307:            }
308:
309:            /**
310:             * Set capability bits for read-only operations on this
311:             * Nodes properties
312:             */
313:            protected void setReadCapabilityBits(NodeComponent node) {
314:                if (node == null || node.isLive())
315:                    return;
316:
317:                node.setCapability(TransparencyAttributes.ALLOW_MODE_READ);
318:                node.setCapability(TransparencyAttributes.ALLOW_VALUE_READ);
319:            }
320:
321:            /**
322:             * Set capability bits for read/write operations on this
323:             * Nodes properties.
324:             */
325:            protected void setReadWriteCapabilityBits(NodeComponent node) {
326:                if (node == null || node.isLive())
327:                    return;
328:
329:                node.setCapability(TransparencyAttributes.ALLOW_MODE_READ);
330:                node.setCapability(TransparencyAttributes.ALLOW_VALUE_READ);
331:                node.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
332:                node.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
333:            }
334:
335:            public void applyChanges() {
336:                if (node != null) {
337:                    wasNull = false;
338:                    setControls();
339:                    setUpdateRequired(false);
340:                }
341:            }
342:
343:            public void resetChanges() {
344:                if (node != null) {
345:                    if (wasNull) {
346:                        node = null;
347:                        ((Appearance) getParentJ3dNodeComponent())
348:                                .setTransparencyAttributes(null);
349:                    } else {
350:                        TransparencyAttributes transAttr = (TransparencyAttributes) node
351:                                .getJ3dNode();
352:                        transAttr.setTransparency(origTransparency);
353:                        transAttr.setTransparencyMode(origMode);
354:                    }
355:                    setControls();
356:                    setUpdateRequired(false);
357:                }
358:            }
359:
360:            /**
361:             * Get the CommonNodeComponentPanel
362:             */
363:            protected org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.panels.CommonNodeComponentPanel getCommonNCPanel() {
364:                return ncCommonP;
365:            }
366:
367:            // Variables declaration - do not modify//GEN-BEGIN:variables
368:            private javax.swing.JPanel nullPanel;
369:            private javax.swing.JPanel jPanel21;
370:            private javax.swing.JPanel jPanel1;
371:            private javax.swing.JSlider slider;
372:            private javax.swing.JPanel normalPanel;
373:            private org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.panels.CommonNodeComponentPanel ncCommonP;
374:            private javax.swing.JTextField transparencyTF;
375:            private javax.swing.JLabel jLabel31;
376:            private javax.swing.JLabel jLabel2;
377:            private javax.swing.JComboBox transparencyModeC;
378:            private javax.swing.JLabel jLabel1;
379:            private javax.swing.JButton createAttributeB;
380:            // End of variables declaration//GEN-END:variables
381:
382:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.