Source Code Cross Referenced for AppearanceAttributesPlugin.java in  » 6.0-JDK-Modules » java-3d » org » jdesktop » j3dfly » plugins » 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.j3dfly.plugins 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/plugins/AppearanceAttributesPlugin.java,v 1.1 2005/04/20 21:04:38 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 Java 3D(tm) Fly Through.
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.j3dfly.plugins;
019:
020:        import javax.swing.JMenu;
021:        import javax.swing.JMenuItem;
022:        import javax.swing.JRadioButtonMenuItem;
023:        import javax.swing.JCheckBoxMenuItem;
024:        import javax.swing.ButtonGroup;
025:        import javax.media.j3d.BranchGroup;
026:
027:        import org.jdesktop.j3dfly.utils.environment.J3dSkyControlPanel;
028:        import org.jdesktop.j3dfly.utils.environment.J3dSky;
029:        import org.jdesktop.j3dfly.J3dFlyContext;
030:
031:        import org.jdesktop.j3d.utils.scenegraph.traverser.ChangePolygonAttributes;
032:        import org.jdesktop.j3d.utils.scenegraph.traverser.BehaviorSetEnable;
033:        import org.jdesktop.j3d.utils.scenegraph.traverser.ChangeMaterial;
034:        import org.jdesktop.j3d.utils.scenegraph.traverser.ChangeTextureAttributes;
035:
036:        /**
037:         *
038:         * @author  Paul Byrne
039:         * @version $Id: AppearanceAttributesPlugin.java,v 1.1 2005/04/20 21:04:38 paulby Exp $
040:         */
041:        public class AppearanceAttributesPlugin extends J3dFlyPlugin {
042:
043:            private AppearanceAttributesPanel controlPanel = null;
044:
045:            /** Creates new EnvironmentPlugin */
046:            public AppearanceAttributesPlugin() {
047:                super ();
048:            }
049:
050:            /**
051:             * Returns the class of the plugin preference.
052:             *
053:             * Plugins that require more preference information should provide a
054:             * subclass of PluginPrefernece that contains all the extra preference
055:             * data. This class must be Serializable.
056:             */
057:            public Class getPluginPreferenceClass() {
058:                return AppearanceAttributesPluginPreference.class;
059:            }
060:
061:            public void installPlugin(PluginPreference pluginPref,
062:                    J3dFlyContext j3dflyContext) {
063:                super .installPlugin(pluginPref, j3dflyContext);
064:                if (pluginPref.isInstallInMenu())
065:                    getMenu("Plugins").add(getMenuItem());
066:            }
067:
068:            public void uninstallPlugin() {
069:                super .uninstallPlugin();
070:                if (pluginPref.isInstallInMenu())
071:                    getMenu("Plugins").remove(getMenuItem());
072:            }
073:
074:            /**
075:             * Returns the control panel for this plugin
076:             */
077:            public javax.swing.JPanel getControlPanel() {
078:                if (controlPanel == null)
079:                    controlPanel = new AppearanceAttributesPanel(this );
080:
081:                return controlPanel;
082:            }
083:
084:            /**
085:             * Returns the menu for this plugin
086:             */
087:            public JMenuItem getMenuItem() {
088:                if (menu == null)
089:                    buildMenu();
090:
091:                return menu;
092:            }
093:
094:            /**
095:             * Construct the menu
096:             */
097:            private void buildMenu() {
098:                menu = new JMenu("Appearance");
099:
100:                menu.setEnabled(isEnabled());
101:
102:                JMenu polyMenu = new JMenu("Polygon Mode");
103:                final JRadioButtonMenuItem fill = new JRadioButtonMenuItem(
104:                        "POLYGON_FILL");
105:                final JRadioButtonMenuItem line = new JRadioButtonMenuItem(
106:                        "POLYGON_LINE");
107:                final JRadioButtonMenuItem point = new JRadioButtonMenuItem(
108:                        "POLYGON_POINT");
109:                fill.setSelected(true);
110:                polyMenu.add(fill);
111:                polyMenu.add(line);
112:                polyMenu.add(point);
113:                ButtonGroup polyGroup = new ButtonGroup();
114:                polyGroup.add(fill);
115:                polyGroup.add(line);
116:                polyGroup.add(point);
117:
118:                class PolyModeListener implements  java.awt.event.ActionListener {
119:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
120:                        if (evt.getSource() == fill)
121:                            setPolygonMode(javax.media.j3d.PolygonAttributes.POLYGON_FILL);
122:                        else if (evt.getSource() == line)
123:                            setPolygonMode(javax.media.j3d.PolygonAttributes.POLYGON_LINE);
124:                        else if (evt.getSource() == point)
125:                            setPolygonMode(javax.media.j3d.PolygonAttributes.POLYGON_POINT);
126:                    }
127:                }
128:
129:                PolyModeListener polyModeListener = new PolyModeListener();
130:                fill.addActionListener(polyModeListener);
131:                line.addActionListener(polyModeListener);
132:                point.addActionListener(polyModeListener);
133:
134:                JMenu cullMenu = new JMenu("Polygon Cull");
135:                final JRadioButtonMenuItem cullNone = new JRadioButtonMenuItem(
136:                        "CULL_NONE");
137:                final JRadioButtonMenuItem cullBack = new JRadioButtonMenuItem(
138:                        "CULL_BACK");
139:                final JRadioButtonMenuItem cullFront = new JRadioButtonMenuItem(
140:                        "CULL_FRONT");
141:                cullNone.setSelected(true);
142:                cullMenu.add(cullNone);
143:                cullMenu.add(cullBack);
144:                cullMenu.add(cullFront);
145:                ButtonGroup cullGroup = new ButtonGroup();
146:                cullGroup.add(cullNone);
147:                cullGroup.add(cullBack);
148:                cullGroup.add(cullFront);
149:
150:                class CullModeListener implements  java.awt.event.ActionListener {
151:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
152:                        if (evt.getSource() == cullNone)
153:                            setCullFace(javax.media.j3d.PolygonAttributes.CULL_NONE);
154:                        else if (evt.getSource() == cullBack)
155:                            setCullFace(javax.media.j3d.PolygonAttributes.CULL_BACK);
156:                        else if (evt.getSource() == cullFront)
157:                            setCullFace(javax.media.j3d.PolygonAttributes.CULL_FRONT);
158:                    }
159:                }
160:
161:                CullModeListener cullModeListener = new CullModeListener();
162:                cullNone.addActionListener(cullModeListener);
163:                cullBack.addActionListener(cullModeListener);
164:                cullFront.addActionListener(cullModeListener);
165:
166:                final JCheckBoxMenuItem textureMI = new JCheckBoxMenuItem(
167:                        "Textures Disabled");
168:                textureMI
169:                        .addActionListener(new java.awt.event.ActionListener() {
170:                            public void actionPerformed(
171:                                    java.awt.event.ActionEvent evt) {
172:                                setTexturesEnabled(!textureMI.getState());
173:                            }
174:                        });
175:
176:                /*
177:                 * Behavior enable/disable does not belong in this plugin
178:                 *
179:                final JCheckBoxMenuItem behaviorMI = new JCheckBoxMenuItem("Behaviors Disabled");
180:                textureMI.addActionListener( new java.awt.event.ActionListener() {
181:                    public void actionPerformed( java.awt.event.ActionEvent evt ) {
182:                        setBehaviorsEnabled( !behaviorMI.getState() );
183:                    }
184:                });
185:                 */
186:
187:                menu.add(cullMenu);
188:                menu.add(polyMenu);
189:                menu.add(textureMI);
190:                //menu.add( behaviorMI );
191:            }
192:
193:            /**
194:             * Get the title of the plugin
195:             */
196:            public String getPluginTitle() {
197:                return "Appearance Attributes Control";
198:            }
199:
200:            /**
201:             * Set the polygon mode of all Appearances in the universe
202:             */
203:            void setPolygonMode(int mode) {
204:                j3dflyContext.getLocale().setLive(false);
205:                BranchGroup[] bg = j3dflyContext.getLocale().getBranchGraphs();
206:                for (int i = 0; i < bg.length; i++) {
207:                    ChangePolygonAttributes.setPolygonMode(bg[i], mode, true);
208:                }
209:                j3dflyContext.getLocale().setLive(true);
210:            }
211:
212:            /**
213:             * Set the polygon cull of all Appearances in the universe
214:             */
215:            void setCullFace(int mode) {
216:                j3dflyContext.getLocale().setLive(false);
217:                BranchGroup[] bg = j3dflyContext.getLocale().getBranchGraphs();
218:                for (int i = 0; i < bg.length; i++) {
219:                    ChangePolygonAttributes.setCullFace(bg[i], mode, true);
220:                }
221:                j3dflyContext.getLocale().setLive(true);
222:            }
223:
224:            void setBehaviorsEnabled(boolean enabled) {
225:                j3dflyContext.getLocale().setLive(false);
226:                BranchGroup[] bg = j3dflyContext.getLocale().getBranchGraphs();
227:                for (int i = 0; i < bg.length; i++) {
228:                    BehaviorSetEnable.setBehaviorEnable(bg[i], enabled);
229:                }
230:                j3dflyContext.getLocale().setLive(true);
231:            }
232:
233:            void setLightsEnabled(boolean enabled) {
234:                boolean wasLive = j3dflyContext.getLocale().getLive();
235:                j3dflyContext.getLocale().setLive(false);
236:                BranchGroup[] bg = j3dflyContext.getLocale().getBranchGraphs();
237:                for (int i = 0; i < bg.length; i++) {
238:                    ChangeMaterial.setLightingEnable(bg[i], enabled);
239:                }
240:                j3dflyContext.getLocale().setLive(wasLive);
241:            }
242:
243:            void setTexturesEnabled(boolean enabled) {
244:                j3dflyContext.getLocale().setLive(false);
245:                BranchGroup[] bg = j3dflyContext.getLocale().getBranchGraphs();
246:                for (int i = 0; i < bg.length; i++) {
247:                    ChangeTextureAttributes.setTextureEnable(bg[i], enabled);
248:                }
249:                j3dflyContext.getLocale().setLive(true);
250:            }
251:
252:            public static class AppearanceAttributesPluginPreference extends
253:                    PluginPreference {
254:                public AppearanceAttributesPluginPreference() {
255:                    super ();
256:                }
257:
258:                public AppearanceAttributesPluginPreference(boolean enabled,
259:                        boolean installed) {
260:                    super (enabled, installed);
261:                }
262:
263:                public J3dFlyPlugin instantiatePlugin() {
264:                    return new AppearanceAttributesPlugin();
265:                }
266:
267:                public String getDescription() {
268:                    return "Provides tools to make global scene graph appearance changes";
269:                }
270:
271:                /**
272:                 * Return the name of the Plugin for this prefernece.
273:                 * This is the name that will appear in the list of plugins
274:                 */
275:                public String getName() {
276:                    return "Appearance Controls";
277:                }
278:
279:            }
280:
281:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.