Source Code Cross Referenced for JForcePanel.java in  » Database-Client » prefuse » prefuse » util » ui » 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 » Database Client » prefuse » prefuse.util.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package prefuse.util.ui;
002:
003:        import java.awt.Color;
004:        import java.awt.Dimension;
005:
006:        import javax.swing.BorderFactory;
007:        import javax.swing.Box;
008:        import javax.swing.BoxLayout;
009:        import javax.swing.JFrame;
010:        import javax.swing.JPanel;
011:        import javax.swing.event.ChangeEvent;
012:        import javax.swing.event.ChangeListener;
013:
014:        import prefuse.util.force.Force;
015:        import prefuse.util.force.ForceSimulator;
016:
017:        /**
018:         * Swing component for configuring the parameters of the
019:         * Force functions in a given ForceSimulator. Useful for exploring
020:         * different parameterizations when crafting a visualization.
021:         *
022:         * @author <a href="http://jheer.org">jeffrey heer</a>
023:         */
024:        public class JForcePanel extends JPanel {
025:
026:            private ForcePanelChangeListener lstnr = new ForcePanelChangeListener();
027:            private ForceSimulator fsim;
028:
029:            /**
030:             * Create a new JForcePanel
031:             * @param fsim the ForceSimulator to configure
032:             */
033:            public JForcePanel(ForceSimulator fsim) {
034:                this .fsim = fsim;
035:                this .setBackground(Color.WHITE);
036:                initUI();
037:            }
038:
039:            /**
040:             * Initialize the UI.
041:             */
042:            private void initUI() {
043:                this .setLayout(new BoxLayout(this , BoxLayout.Y_AXIS));
044:                Force[] forces = fsim.getForces();
045:                for (int i = 0; i < forces.length; i++) {
046:                    Force f = forces[i];
047:                    Box v = new Box(BoxLayout.Y_AXIS);
048:                    for (int j = 0; j < f.getParameterCount(); j++) {
049:                        JValueSlider field = createField(f, j);
050:                        field.addChangeListener(lstnr);
051:                        v.add(field);
052:                    }
053:                    String name = f.getClass().getName();
054:                    name = name.substring(name.lastIndexOf(".") + 1);
055:                    v.setBorder(BorderFactory.createTitledBorder(name));
056:                    this .add(v);
057:                }
058:            }
059:
060:            /**
061:             * Create an entry for configuring a single parameter.
062:             */
063:            private static JValueSlider createField(Force f, int param) {
064:                double value = f.getParameter(param);
065:                double min = f.getMinValue(param);
066:                double max = f.getMaxValue(param);
067:                String name = f.getParameterName(param);
068:
069:                JValueSlider s = new JValueSlider(name, min, max, value);
070:                s.setBackground(Color.WHITE);
071:                s.putClientProperty("force", f);
072:                s.putClientProperty("param", new Integer(param));
073:                s.setPreferredSize(new Dimension(300, 30));
074:                s.setMaximumSize(new Dimension(300, 30));
075:                return s;
076:            }
077:
078:            /**
079:             * Change listener that updates paramters in response to interaction.
080:             */
081:            private static class ForcePanelChangeListener implements 
082:                    ChangeListener {
083:                public void stateChanged(ChangeEvent e) {
084:                    JValueSlider s = (JValueSlider) e.getSource();
085:                    float val = s.getValue().floatValue();
086:                    Force f = (Force) s.getClientProperty("force");
087:                    Integer p = (Integer) s.getClientProperty("param");
088:                    f.setParameter(p.intValue(), val);
089:                }
090:            } // end of inner class ForcePanelChangeListener
091:
092:            /**
093:             * Create and displays a new window showing a configuration panel
094:             * for the given ForceSimulator.
095:             * @param fsim the force simulator
096:             * @return a JFrame instance containing a configuration interface
097:             * for the force simulator
098:             */
099:            public static JFrame showForcePanel(ForceSimulator fsim) {
100:                JFrame frame = new JFrame("prefuse Force Simulator");
101:                frame.setContentPane(new JForcePanel(fsim));
102:                frame.pack();
103:                frame.setVisible(true);
104:                return frame;
105:            }
106:
107:        } // end of class JForcePanel
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.