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


001:        /*
002:         *  $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/warp/WarpSet.java,v 1.1 2005/04/20 21:05:19 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.warp;
019:
020:        import java.io.Serializable;
021:        import java.util.HashMap;
022:        import java.util.Iterator;
023:        import javax.swing.JDialog;
024:        import javax.swing.JOptionPane;
025:        import javax.swing.JComboBox;
026:
027:        import javax.media.j3d.TransformGroup;
028:        import javax.media.j3d.Transform3D;
029:
030:        /**
031:         * Encapsulates a set of WarpPositions
032:         *
033:         * @author Paul Byrne
034:         * @version	1.6, 12/19/00
035:         */
036:        public class WarpSet extends Object implements  Serializable {
037:
038:            private static final long serialVersionUID = 4278610821202427778L;
039:
040:            private HashMap warps; // Map of warps indexed by name
041:            private String defaultWarp;
042:            private transient JComboBox comboBox;
043:
044:            /** Creates new WarpSet */
045:            public WarpSet(JComboBox comboBox) {
046:                warps = new HashMap();
047:                this .comboBox = comboBox;
048:            }
049:
050:            public WarpSet() {
051:                warps = new HashMap();
052:                comboBox = null;
053:            }
054:
055:            /**
056:             * Add a new Warp to the set.
057:             * @param name Name of the warp
058:             * @param description A description of the Warp (can be null)
059:             * @param position The position of the warp
060:             */
061:            public void addWarpPosition(String name, String description,
062:                    Transform3D position) {
063:                WarpPosition w = new WarpPosition(name, description, position);
064:                warps.put(name, w);
065:                if (comboBox != null)
066:                    comboBox.addItem(name);
067:            }
068:
069:            /**
070:             * Remove the named warp
071:             */
072:            public void deleteWarpPosition(String name) {
073:                warps.remove(name);
074:                if (comboBox != null)
075:                    comboBox.removeItem(name);
076:            }
077:
078:            /**
079:             * Change the position of the named warp, if the warp does not exist it
080:             * will be created.
081:             *
082:             * @param name Name of the warp
083:             * @param newPosition The new position for the warp
084:             */
085:            public void changeWarpPosition(String name, Transform3D newPosition) {
086:                WarpPosition w = (WarpPosition) warps.get(name);
087:                if (w == null)
088:                    addWarpPosition(name, null, newPosition);
089:                else
090:                    w.setPosition(newPosition);
091:            }
092:
093:            /**
094:             * Returns true if name exists in the set
095:             */
096:            public boolean nameExists(String name) {
097:                return warps.containsKey(name);
098:            }
099:
100:            /**
101:             * Clear the warp set and update the combobox
102:             */
103:            public void clear() {
104:                warps.clear();
105:                if (comboBox != null) {
106:                    comboBox.removeAllItems();
107:                    comboBox.addItem("");
108:                }
109:            }
110:
111:            /**
112:             * Set the viewTG to the position of the named warp.
113:             *
114:             * If the named warp does not exist the transformGroup will not
115:             * be modified.
116:             *
117:             * @param name Name of the warp
118:             * @param viewTG The View TransformGroup
119:             */
120:            public void warpTo(String name, TransformGroup viewTG) {
121:                WarpPosition w = (WarpPosition) warps.get(name);
122:                if (w != null) {
123:                    viewTG.setTransform(w.getPosition());
124:                }
125:            }
126:
127:            /**
128:             * Create a warp for the supplied position.
129:             * Present the user with a dialog to obtain the
130:             * name and description of the warp.
131:             *
132:             * @param position The position of the warp
133:             * @param parent The component which should be the parent of the dialog
134:             * @return Returns the name of the new warp, or null if user cancelled creation
135:             */
136:            public String createWarp(Transform3D position, JDialog parent) {
137:                CreateWarpDialog dialog = new CreateWarpDialog(parent, true,
138:                        this );
139:                dialog.setVisible(true);
140:
141:                if (dialog.isValid()) {
142:                    addWarpPosition(dialog.getName(), dialog.getDescription(),
143:                            position);
144:                    return dialog.getName();
145:                }
146:
147:                return null;
148:
149:            }
150:
151:            public void setDefaultWarp(String name) {
152:                defaultWarp = name;
153:            }
154:
155:            public String getDefaultWarp() {
156:                return defaultWarp;
157:            }
158:
159:            /**
160:             * Returns an array containing all the warp names
161:             */
162:            public String[] getNames() {
163:                return (String[]) warps.keySet().toArray(
164:                        new String[warps.size()]);
165:            }
166:
167:            /**
168:             * Return all the warps.
169:             *
170:             * This was added to support the transition to the new
171:             * WarpPlugin
172:             */
173:            public WarpPosition[] getWarps() {
174:                return (WarpPosition[]) warps.values().toArray(
175:                        new WarpPosition[warps.size()]);
176:            }
177:
178:            java.util.Collection getValues() {
179:                return warps.values();
180:            }
181:
182:            /** 
183:             * Merge set with this warp set
184:             * If this defaultWarp==null then set it to set.defaultWarp
185:             *
186:             * TODO - Handle duplicate names correctly
187:             */
188:            public void merge(WarpSet set) {
189:                java.util.Collection collection = set.getValues();
190:
191:                Iterator it = collection.iterator();
192:                while (it.hasNext()) {
193:                    WarpPosition w = (WarpPosition) it.next();
194:                    addWarpPosition(w.getName(), w.getDescription(), w
195:                            .getPosition());
196:                }
197:
198:                if (defaultWarp == null)
199:                    defaultWarp = set.getDefaultWarp();
200:            }
201:
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.