Source Code Cross Referenced for InstancesSummaryPanel.java in  » Science » weka » weka » gui » 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 » Science » weka » weka.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    This program is free software; you can redistribute it and/or modify
003:         *    it under the terms of the GNU General Public License as published by
004:         *    the Free Software Foundation; either version 2 of the License, or
005:         *    (at your option) any later version.
006:         *
007:         *    This program is distributed in the hope that it will be useful,
008:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
009:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
010:         *    GNU General Public License for more details.
011:         *
012:         *    You should have received a copy of the GNU General Public License
013:         *    along with this program; if not, write to the Free Software
014:         *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
015:         */
016:
017:        /*
018:         *    InstancesSummaryPanel.java
019:         *    Copyright (C) 1999 University of Waikato, Hamilton, New Zealand
020:         *
021:         */
022:
023:        package weka.gui;
024:
025:        import weka.core.Instances;
026:
027:        import java.awt.BorderLayout;
028:        import java.awt.GridBagConstraints;
029:        import java.awt.GridBagLayout;
030:
031:        import javax.swing.BorderFactory;
032:        import javax.swing.JLabel;
033:        import javax.swing.JPanel;
034:        import javax.swing.SwingConstants;
035:
036:        /** 
037:         * This panel just displays relation name, number of instances, and number of
038:         * attributes.
039:         *
040:         * @author Len Trigg (trigg@cs.waikato.ac.nz)
041:         * @version $Revision: 1.6 $
042:         */
043:        public class InstancesSummaryPanel extends JPanel {
044:
045:            /** for serialization */
046:            private static final long serialVersionUID = -5243579535296681063L;
047:
048:            /** Message shown when no instances have been loaded */
049:            protected static final String NO_SOURCE = "None";
050:
051:            /** Displays the name of the relation */
052:            protected JLabel m_RelationNameLab = new JLabel(NO_SOURCE);
053:
054:            /** Displays the number of instances */
055:            protected JLabel m_NumInstancesLab = new JLabel(NO_SOURCE);
056:
057:            /** Displays the number of attributes */
058:            protected JLabel m_NumAttributesLab = new JLabel(NO_SOURCE);
059:
060:            /** The instances we're playing with */
061:            protected Instances m_Instances;
062:
063:            /**
064:             * Creates the instances panel with no initial instances.
065:             */
066:            public InstancesSummaryPanel() {
067:
068:                GridBagLayout gbLayout = new GridBagLayout();
069:                setLayout(gbLayout);
070:                JLabel lab = new JLabel("Relation:", SwingConstants.RIGHT);
071:                lab.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
072:                GridBagConstraints gbConstraints = new GridBagConstraints();
073:                gbConstraints.anchor = GridBagConstraints.EAST;
074:                gbConstraints.fill = GridBagConstraints.HORIZONTAL;
075:                gbConstraints.gridy = 0;
076:                gbConstraints.gridx = 0;
077:                gbLayout.setConstraints(lab, gbConstraints);
078:                add(lab);
079:                gbConstraints = new GridBagConstraints();
080:                gbConstraints.anchor = GridBagConstraints.WEST;
081:                gbConstraints.fill = GridBagConstraints.HORIZONTAL;
082:                gbConstraints.gridy = 0;
083:                gbConstraints.gridx = 1;
084:                gbConstraints.weightx = 100;
085:                gbConstraints.gridwidth = 3;
086:                gbLayout.setConstraints(m_RelationNameLab, gbConstraints);
087:                add(m_RelationNameLab);
088:                m_RelationNameLab.setBorder(BorderFactory.createEmptyBorder(0,
089:                        5, 0, 10));
090:
091:                lab = new JLabel("Instances:", SwingConstants.RIGHT);
092:                lab.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
093:                gbConstraints = new GridBagConstraints();
094:                gbConstraints.anchor = GridBagConstraints.EAST;
095:                gbConstraints.fill = GridBagConstraints.HORIZONTAL;
096:                gbConstraints.gridy = 1;
097:                gbConstraints.gridx = 0;
098:                gbLayout.setConstraints(lab, gbConstraints);
099:                add(lab);
100:                gbConstraints = new GridBagConstraints();
101:                gbConstraints.anchor = GridBagConstraints.WEST;
102:                gbConstraints.fill = GridBagConstraints.HORIZONTAL;
103:                gbConstraints.gridy = 1;
104:                gbConstraints.gridx = 1;
105:                gbConstraints.weightx = 100;
106:                gbLayout.setConstraints(m_NumInstancesLab, gbConstraints);
107:                add(m_NumInstancesLab);
108:                m_NumInstancesLab.setBorder(BorderFactory.createEmptyBorder(0,
109:                        5, 0, 10));
110:
111:                lab = new JLabel("Attributes:", SwingConstants.RIGHT);
112:                lab.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
113:                gbConstraints = new GridBagConstraints();
114:                gbConstraints.anchor = GridBagConstraints.EAST;
115:                gbConstraints.fill = GridBagConstraints.HORIZONTAL;
116:                gbConstraints.gridy = 1;
117:                gbConstraints.gridx = 2;
118:                gbLayout.setConstraints(lab, gbConstraints);
119:                add(lab);
120:                gbConstraints = new GridBagConstraints();
121:                gbConstraints.anchor = GridBagConstraints.WEST;
122:                gbConstraints.fill = GridBagConstraints.HORIZONTAL;
123:                gbConstraints.gridy = 1;
124:                gbConstraints.gridx = 3;
125:                gbConstraints.weightx = 100;
126:                gbLayout.setConstraints(m_NumAttributesLab, gbConstraints);
127:                add(m_NumAttributesLab);
128:                m_NumAttributesLab.setBorder(BorderFactory.createEmptyBorder(0,
129:                        5, 0, 10));
130:            }
131:
132:            /**
133:             * Tells the panel to use a new set of instances.
134:             *
135:             * @param inst a set of Instances
136:             */
137:            public void setInstances(Instances inst) {
138:
139:                m_Instances = inst;
140:                m_RelationNameLab.setText(m_Instances.relationName());
141:                m_NumInstancesLab.setText("" + m_Instances.numInstances());
142:                m_NumAttributesLab.setText("" + m_Instances.numAttributes());
143:            }
144:
145:            /**
146:             * Tests out the instance summary panel from the command line.
147:             *
148:             * @param args optional name of dataset to load
149:             */
150:            public static void main(String[] args) {
151:
152:                try {
153:                    final javax.swing.JFrame jf = new javax.swing.JFrame(
154:                            "Instances Panel");
155:                    jf.getContentPane().setLayout(new BorderLayout());
156:                    final InstancesSummaryPanel p = new InstancesSummaryPanel();
157:                    p.setBorder(BorderFactory.createTitledBorder("Relation"));
158:                    jf.getContentPane().add(p, BorderLayout.CENTER);
159:                    jf.addWindowListener(new java.awt.event.WindowAdapter() {
160:                        public void windowClosing(java.awt.event.WindowEvent e) {
161:                            jf.dispose();
162:                            System.exit(0);
163:                        }
164:                    });
165:                    jf.pack();
166:                    jf.setVisible(true);
167:                    if (args.length == 1) {
168:                        java.io.Reader r = new java.io.BufferedReader(
169:                                new java.io.FileReader(args[0]));
170:                        Instances i = new Instances(r);
171:                        p.setInstances(i);
172:                    }
173:                } catch (Exception ex) {
174:                    ex.printStackTrace();
175:                    System.err.println(ex.getMessage());
176:                }
177:            }
178:
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.