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


001:/*
002: *  $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/utils/internalplugins/BenchmarkPlugin.java,v 1.2 2007/01/26 19:31:29 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.utils.internalplugins;
019:
020:import org.jdesktop.j3dfly.plugins.PluginPreference;
021:import org.jdesktop.j3dfly.plugins.J3dFlyPlugin;
022:import org.jdesktop.j3dfly.J3dFly;
023:import org.jdesktop.j3dfly.J3dFlyContext;
024:import org.jdesktop.j3dfly.event.FlyEventListener;
025:import org.jdesktop.j3dfly.event.EventProcessor;
026:import org.jdesktop.j3dfly.event.FileLoadEvent;
027:import org.jdesktop.j3dfly.event.DefaultLightingRequiredEvent;
028:import org.jdesktop.j3dfly.utils.behaviors.PerfBehaviorListener;
029://import org.jdesktop.j3dfly.utils.behaviors.PerfBehavior;
030:import java.io.File;
031:
032:import javax.media.j3d.BranchGroup;
033:import javax.media.j3d.TransformGroup;
034:
035:/**
036: *
037: * @author  paulby
038: * @version 
039: */
040:public class BenchmarkPlugin extends org.jdesktop.j3dfly.plugins.J3dFlyPlugin
041:                             implements  FlyEventListener, PerfBehaviorListener {
042:
043:    private static String geometryFilename = "geometry/Buildings/CGSD_City.j3f";
044:    private static String splineFilename = "benchmark/city_house.kbsp";
045:    private static boolean finiteLoop = true;
046:    private static int loopCount=10;
047:    private static int memCount=0;
048:                                 
049:    /** Creates new BenchMarkPlugin */
050:    public BenchmarkPlugin() {
051:    }
052:
053:    /**
054:     * Install the plugin into j3dfly with the supplied preferences
055:     */
056:    public void installPlugin( PluginPreference pluginPref, J3dFlyContext j3dflyContext ) {
057:        super .installPlugin( pluginPref, j3dflyContext );
058:        
059:        j3dflyContext.getEventProcessor().addListener( this , FileLoadEvent.class );
060:        //j3dfly.getController().loadScene( new File(geometryFilename));
061:        
062:    }
063:
064:    /**
065:     * Get the title of the plugin
066:     */
067:    public String getPluginTitle() {
068:        return "Benchmark Plugin";
069:    }
070:    
071:    /**
072:     * Returns the control panel for this plugin, or null if there
073:     * is no control panel
074:     */
075:    public javax.swing.JPanel getControlPanel() {
076:        return null;
077:    }
078:    
079:    /**
080:     * Returns the class of the plugin preference.
081:     *
082:     * Plugins that require more preference information should provide a
083:     * subclass of PluginPrefernece that contains all the extra preference
084:     * data. This class must be Serializable.
085:     */
086:    public Class getPluginPreferenceClass() {
087:        return BenchmarkPluginPreference.class;
088:    }
089:    
090:    /**
091:     * Called by EventProcessor when an event occurs for which this
092:     * listener has registered interest
093:     */
094:    public void processFlyEvent(org.jdesktop.j3dfly.event.FlyEvent evt) {
095:        System.out.println("File Loaded");
096:        
097:        BranchGroup bg = new BranchGroup();
098:        BenchmarkBehavior behavior = new BenchmarkBehavior( j3dflyContext.getJ3dFly().getUniverse().getViewingPlatform().getViewPlatformTransform(), splineFilename );
099:        PerfBehavior perf = new PerfBehavior( new javax.media.j3d.BoundingSphere(new javax.vecmath.Point3d(), Double.POSITIVE_INFINITY), false, memCount );
100:        perf.setFiniteLoop( finiteLoop );
101:        perf.setLoopCount( loopCount );
102:        bg.addChild(perf);
103:        
104:        bg.addChild( behavior );
105:        
106:        j3dflyContext.getJ3dFly().getUniverse().getLocale().addBranchGraph( bg );
107:        
108:        behavior.setEnabled( true );
109:    }
110:    
111:    /**
112:     * Called by PerfBehavior when new performance figures are available
113:     */
114:    public void updatePerformanceFigures(float framesPerSecond) {
115:        System.out.println( framesPerSecond );
116:    }
117:    
118:    public static class BenchmarkPluginPreference extends PluginPreference {
119:        
120:        public BenchmarkPluginPreference() {
121:            super ();
122:        }
123:        
124:        public BenchmarkPluginPreference( boolean enabled, boolean installed ) {
125:            super ( enabled, installed );
126:        }
127:        
128:        public J3dFlyPlugin instantiatePlugin() {
129:            return new BenchmarkPlugin();
130:        }
131:        
132:        public void setFiniteLoop( boolean finite ) {
133:            finiteLoop = finite;
134:        }
135:        
136:        public boolean isFiniteLoop() {
137:            return finiteLoop;
138:        }
139:        
140:        public void setLoopCount( int count ) {
141:            loopCount = count;
142:        }
143:        
144:        public int getLoopCount() {
145:            return loopCount;
146:        }
147:        
148:        public void setMemCount( int count ) {
149:            memCount = count;
150:        }
151:        
152:        public int getMemCount() {
153:            return memCount;
154:        }
155:            
156:        public void setGeometryFilename( String geometryFile ) {
157:            geometryFilename = geometryFile;
158:        }
159:        
160:        public String getGeometryFilename() {
161:            return geometryFilename;
162:        }
163:        
164:        public void setSplineFilename( String splineFile ) {
165:            splineFilename = splineFile;
166:        }
167:        
168:        public String getSplineFilename() {
169:            return splineFilename;
170:        }
171:                
172:        /**
173:         * Return a description of this plugin
174:         */
175:        public String getDescription() {
176:            return "Java 3D benchmark plugin";
177:        }
178:        
179:        /**
180:         * Return the name of the Plugin for this prefernece.
181:         * This is the name that will appear in the list of plugins
182:         */
183:        public String getName() {
184:            return "Java 3D Benchmark";
185:        }
186:        
187:    }
188:    
189:    public class BenchmarkBehavior extends org.jdesktop.j3dfly.utils.behaviors.DemoKBSplineBehavior {
190:        public BenchmarkBehavior( TransformGroup target, String filename ) {
191:            super ( target, filename );
192:            //alpha.setLoopCount( 10 );
193:            //this.addChild( new TerminateBehavior( alpha ));
194:        }
195:        
196:        class TerminateBehavior extends javax.media.j3d.Behavior {
197:            
198:            private javax.media.j3d.Alpha alpha;
199:            private javax.media.j3d.WakeupOnElapsedFrames wakeup = new javax.media.j3d.WakeupOnElapsedFrames(0);
200:            
201:            public TerminateBehavior( javax.media.j3d.Alpha alpha ) {
202:                this .alpha = alpha;
203:                this .setSchedulingBounds( new javax.media.j3d.BoundingSphere( new javax.vecmath.Point3d(), Double.POSITIVE_INFINITY ));
204:            }
205:            
206:            public void initialize() {
207:                wakeupOn( wakeup );
208:            }
209:            
210:            public void processStimulus( java.util.Enumeration enum ) {
211:                if (alpha.finished())
212:                    System.exit(1);
213:                wakeupOn( wakeup );
214:            }
215:        }
216:    }
217:    
218:}
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.