Source Code Cross Referenced for ViewingPlatformWarpPanel.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/ViewingPlatformWarpPanel.java,v 1.1 2005/04/20 21:04:48 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.table.DefaultTableModel;
021:        import java.util.LinkedList;
022:        import java.util.Iterator;
023:
024:        import javax.media.j3d.Transform3D;
025:
026:        import org.jdesktop.j3dfly.plugins.ViewingPlatformWarpPlugin.WarpLocation;
027:        import org.jdesktop.j3dfly.plugins.ViewingPlatformWarpPlugin;
028:        import org.jdesktop.j3dfly.plugins.ViewingPlatformWarpPlugin.ViewingPlatformWarpPluginPreference;
029:
030:        /**
031:         * An editor panel for the WarpPlugin
032:         *
033:         * @author  Paul Byrne
034:         * @version $Revision: 1.1 $
035:         */
036:        public class ViewingPlatformWarpPanel extends javax.swing.JPanel
037:                implements  javax.swing.event.ListSelectionListener,
038:                javax.swing.event.TableModelListener {
039:
040:            ViewingPlatformWarpPlugin plugin;
041:            private DefaultTableModel warpTableModel;
042:            private int currentDefaultRow;
043:            private boolean removingOldDefault = false;
044:
045:            private static final int NAME_COLUMN = 0;
046:            private static final int LOCATION_COLUMN = 1;
047:            private static final int DESCRIPTION_COLUMN = 2;
048:            private static final int DEFAULT_COLUMN = 3;
049:
050:            /** Creates new form ViewingPlatformWarpPanel */
051:            public ViewingPlatformWarpPanel(ViewingPlatformWarpPlugin plugin) {
052:                super ();
053:                this .plugin = plugin;
054:                initComponents();
055:
056:                warpTableModel = (DefaultTableModel) warpTable.getModel();
057:                warpTableModel.addTableModelListener(this );
058:                warpTable.getSelectionModel().addListSelectionListener(this );
059:                warpTable.getSelectionModel().setSelectionMode(
060:                        javax.swing.ListSelectionModel.SINGLE_SELECTION);
061:
062:                LinkedList warps = ((ViewingPlatformWarpPluginPreference) plugin
063:                        .getPluginPreference()).getWarps();
064:                WarpLocation defaultWarp = ((ViewingPlatformWarpPluginPreference) plugin
065:                        .getPluginPreference()).getDefaultWarp();
066:                if (warps != null) {
067:                    Iterator it = warps.iterator();
068:                    while (it.hasNext()) {
069:                        WarpLocation loc = (WarpLocation) it.next();
070:                        addRow(loc, loc == defaultWarp);
071:                    }
072:                } else {
073:                    WarpLocation warp = new WarpLocation("Origin", "",
074:                            new Transform3D());
075:                    addRow(warp, false);
076:                    ((ViewingPlatformWarpPluginPreference) plugin
077:                            .getPluginPreference()).addWarp(warp);
078:                }
079:
080:                warpTable.getDefaultEditor(String.class).addCellEditorListener(
081:                        new WarpCellEditorListener());
082:            }
083:
084:            private void addRow(WarpLocation warp, boolean defaultWarp) {
085:                warpTableModel.addRow(new Object[] { warp.getName(),
086:                        warp.getTransform3D(), warp.getDescription(),
087:                        new Boolean(defaultWarp) });
088:
089:                if (defaultWarp)
090:                    currentDefaultRow = warpTableModel.getRowCount() - 1;
091:            }
092:
093:            /** This method is called from within the constructor to
094:             * initialize the form.
095:             * WARNING: Do NOT modify this code. The content of this method is
096:             * always regenerated by the Form Editor.
097:             */
098:            private void initComponents() {//GEN-BEGIN:initComponents
099:                warpPopup = new javax.swing.JPopupMenu();
100:                addCurrentMI = new javax.swing.JMenuItem();
101:                addMI = new javax.swing.JMenuItem();
102:                jSeparator1 = new javax.swing.JSeparator();
103:                deleteMI = new javax.swing.JMenuItem();
104:                jPanel1 = new javax.swing.JPanel();
105:                jScrollPane1 = new javax.swing.JScrollPane();
106:                warpTable = new javax.swing.JTable();
107:
108:                addCurrentMI.setText("Add Current");
109:                addCurrentMI
110:                        .setToolTipText("Add the current view location to the set of warps");
111:                addCurrentMI
112:                        .addActionListener(new java.awt.event.ActionListener() {
113:                            public void actionPerformed(
114:                                    java.awt.event.ActionEvent evt) {
115:                                addCurrentMIActionPerformed(evt);
116:                            }
117:                        });
118:
119:                warpPopup.add(addCurrentMI);
120:                addMI.setText("Add");
121:                addMI.addActionListener(new java.awt.event.ActionListener() {
122:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
123:                        addMIActionPerformed(evt);
124:                    }
125:                });
126:
127:                warpPopup.add(addMI);
128:                warpPopup.add(jSeparator1);
129:                deleteMI.setText("Delete Warp");
130:                deleteMI.addActionListener(new java.awt.event.ActionListener() {
131:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
132:                        deleteMIActionPerformed(evt);
133:                    }
134:                });
135:
136:                warpPopup.add(deleteMI);
137:
138:                setLayout(new java.awt.BorderLayout());
139:
140:                jPanel1.setPreferredSize(new java.awt.Dimension(463, 200));
141:                jPanel1.addMouseListener(new java.awt.event.MouseAdapter() {
142:                    public void mousePressed(java.awt.event.MouseEvent evt) {
143:                        showPopup(evt);
144:                    }
145:
146:                    public void mouseReleased(java.awt.event.MouseEvent evt) {
147:                        showPopup(evt);
148:                    }
149:
150:                    public void mouseClicked(java.awt.event.MouseEvent evt) {
151:                        showPopup(evt);
152:                    }
153:                });
154:
155:                jScrollPane1
156:                        .addMouseListener(new java.awt.event.MouseAdapter() {
157:                            public void mousePressed(
158:                                    java.awt.event.MouseEvent evt) {
159:                                showPopup(evt);
160:                            }
161:
162:                            public void mouseReleased(
163:                                    java.awt.event.MouseEvent evt) {
164:                                showPopup(evt);
165:                            }
166:
167:                            public void mouseClicked(
168:                                    java.awt.event.MouseEvent evt) {
169:                                showPopup(evt);
170:                            }
171:                        });
172:
173:                warpTable.setModel(new javax.swing.table.DefaultTableModel(
174:                        new Object[][] {
175:
176:                        }, new String[] { "Name", "Location", "Description",
177:                                "DefaultWarp" }) {
178:                    Class[] types = new Class[] { java.lang.String.class,
179:                            java.lang.String.class, java.lang.String.class,
180:                            java.lang.Boolean.class };
181:                    boolean[] canEdit = new boolean[] { true, false, true, true };
182:
183:                    public Class getColumnClass(int columnIndex) {
184:                        return types[columnIndex];
185:                    }
186:
187:                    public boolean isCellEditable(int rowIndex, int columnIndex) {
188:                        return canEdit[columnIndex];
189:                    }
190:                });
191:                warpTable.addMouseListener(new java.awt.event.MouseAdapter() {
192:                    public void mousePressed(java.awt.event.MouseEvent evt) {
193:                        showPopup(evt);
194:                    }
195:
196:                    public void mouseReleased(java.awt.event.MouseEvent evt) {
197:                        showPopup(evt);
198:                    }
199:
200:                    public void mouseClicked(java.awt.event.MouseEvent evt) {
201:                        showPopup(evt);
202:                    }
203:                });
204:
205:                jScrollPane1.setViewportView(warpTable);
206:
207:                jPanel1.add(jScrollPane1);
208:
209:                add(jPanel1, java.awt.BorderLayout.CENTER);
210:
211:            }//GEN-END:initComponents
212:
213:            private void deleteMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteMIActionPerformed
214:                // Add your handling code here:
215:                if (warpTable.getSelectedRow() == -1)
216:                    return;
217:
218:                WarpLocation warp = (WarpLocation) ((ViewingPlatformWarpPluginPreference) plugin
219:                        .getPluginPreference()).getWarps().get(
220:                        warpTable.getSelectedRow());
221:                ((ViewingPlatformWarpPluginPreference) plugin
222:                        .getPluginPreference()).removeWarp(warp);
223:                warpTableModel.removeRow(warpTable.getSelectedRow());
224:            }//GEN-LAST:event_deleteMIActionPerformed
225:
226:            private void addMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addMIActionPerformed
227:                // Add your handling code here:
228:                WarpLocation warp = new WarpLocation("New Warp", "",
229:                        new Transform3D());
230:                addRow(warp, false);
231:                ((ViewingPlatformWarpPluginPreference) plugin
232:                        .getPluginPreference()).addWarp(warp);
233:            }//GEN-LAST:event_addMIActionPerformed
234:
235:            private void addCurrentMIActionPerformed(
236:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addCurrentMIActionPerformed
237:                // Add your handling code here:
238:                Transform3D t3d = new Transform3D();
239:                plugin.getPluginPreference().getContext().getUniverse()
240:                        .getViewingPlatform().getViewPlatformTransform()
241:                        .getTransform(t3d);
242:                WarpLocation warp = new WarpLocation("New Warp", "", t3d);
243:                addRow(warp, false);
244:                ((ViewingPlatformWarpPluginPreference) plugin
245:                        .getPluginPreference()).addWarp(warp);
246:            }//GEN-LAST:event_addCurrentMIActionPerformed
247:
248:            private void showPopup(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_showPopup
249:                // Add your handling code here:
250:                int row = warpTable.getSelectedRow();
251:
252:                if (row == -1)
253:                    deleteMI.setEnabled(false);
254:                else
255:                    deleteMI.setEnabled(true);
256:
257:                if (evt.isPopupTrigger())
258:                    warpPopup.show(this , evt.getX(), evt.getY());
259:            }//GEN-LAST:event_showPopup
260:
261:            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
262:                //if (evt.getValueIsAdjusting())
263:                //    return;
264:
265:                //System.out.println("Change "+warpTable.getSelectedColumn());
266:            }
267:
268:            public void tableChanged(javax.swing.event.TableModelEvent evt) {
269:                if (evt.getType() != javax.swing.event.TableModelEvent.UPDATE
270:                        || removingOldDefault)
271:                    return;
272:
273:                if (evt.getColumn() == 3) {
274:                    Boolean b = (Boolean) warpTableModel.getValueAt(evt
275:                            .getFirstRow(), 3);
276:                    if (b == Boolean.FALSE) {
277:                        ((ViewingPlatformWarpPluginPreference) plugin
278:                                .getPluginPreference()).setDefaultWarp(null);
279:                    } else {
280:                        WarpLocation warp = (WarpLocation) ((ViewingPlatformWarpPluginPreference) plugin
281:                                .getPluginPreference()).getWarps().get(
282:                                evt.getFirstRow());
283:                        ((ViewingPlatformWarpPluginPreference) plugin
284:                                .getPluginPreference()).setDefaultWarp(warp);
285:                        removingOldDefault = true;
286:                        warpTableModel.setValueAt(Boolean.FALSE,
287:                                currentDefaultRow, 3);
288:                        removingOldDefault = false;
289:                        currentDefaultRow = evt.getFirstRow();
290:                    }
291:                }
292:            }
293:
294:            class WarpCellEditorListener implements 
295:                    javax.swing.event.CellEditorListener {
296:                public void editingCanceled(javax.swing.event.ChangeEvent e) {
297:                    //System.out.println("WarpCellEditorListener - Canceled "+e);
298:                }
299:
300:                public void editingStopped(javax.swing.event.ChangeEvent e) {
301:                    int row = warpTable.getSelectedRow();
302:                    int column = warpTable.getSelectedColumn();
303:                    WarpLocation warp = (WarpLocation) ((ViewingPlatformWarpPluginPreference) plugin
304:                            .getPluginPreference()).getWarps().get(row);
305:                    switch (warpTable.getSelectedColumn()) {
306:                    case NAME_COLUMN:
307:                        warp.setName((String) warpTableModel.getValueAt(row,
308:                                column));
309:                        ((ViewingPlatformWarpPluginPreference) plugin
310:                                .getPluginPreference()).updateWarp(warp);
311:                        break;
312:                    case LOCATION_COLUMN:
313:                        System.out.println("Location Editing not supported");
314:                        break;
315:                    case DESCRIPTION_COLUMN:
316:                        warp.setDescription((String) warpTableModel.getValueAt(
317:                                row, column));
318:                        break;
319:                    case DEFAULT_COLUMN:
320:                        break;
321:                    }
322:                }
323:            }
324:
325:            // Variables declaration - do not modify//GEN-BEGIN:variables
326:            private javax.swing.JMenuItem addMI;
327:            private javax.swing.JPanel jPanel1;
328:            private javax.swing.JSeparator jSeparator1;
329:            private javax.swing.JMenuItem addCurrentMI;
330:            private javax.swing.JScrollPane jScrollPane1;
331:            private javax.swing.JTable warpTable;
332:            private javax.swing.JMenuItem deleteMI;
333:            private javax.swing.JPopupMenu warpPopup;
334:            // End of variables declaration//GEN-END:variables
335:
336:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.