1 | /* |
---|
2 | * This program is free software; you can redistribute it and/or modify |
---|
3 | * it under the terms of the GNU General Public License as published by |
---|
4 | * the Free Software Foundation; either version 2 of the License, or |
---|
5 | * (at your option) any later version. |
---|
6 | * |
---|
7 | * This program is distributed in the hope that it will be useful, |
---|
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
10 | * GNU General Public License for more details. |
---|
11 | * |
---|
12 | * You should have received a copy of the GNU General Public License |
---|
13 | * along with this program; if not, write to the Free Software |
---|
14 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
15 | */ |
---|
16 | |
---|
17 | /* |
---|
18 | * InstanceInfoFrame.java |
---|
19 | * Copyright (C) 2009 University of Waikato, Hamilton, New Zealand |
---|
20 | */ |
---|
21 | |
---|
22 | package weka.gui.visualize; |
---|
23 | |
---|
24 | import weka.core.Instances; |
---|
25 | |
---|
26 | import java.awt.BorderLayout; |
---|
27 | import java.awt.Font; |
---|
28 | import java.util.Vector; |
---|
29 | |
---|
30 | import javax.swing.JFrame; |
---|
31 | import javax.swing.JScrollPane; |
---|
32 | import javax.swing.JTextArea; |
---|
33 | |
---|
34 | /** |
---|
35 | * Frame for displaying information on the displayed data. |
---|
36 | * |
---|
37 | * @author fracpete (fracpete at waikato dot ac dot nz) |
---|
38 | * @version $Revision: 5014 $ |
---|
39 | */ |
---|
40 | public class InstanceInfoFrame |
---|
41 | extends JFrame |
---|
42 | implements InstanceInfo { |
---|
43 | |
---|
44 | /** for serialization. */ |
---|
45 | private static final long serialVersionUID = 4684184733677263009L; |
---|
46 | |
---|
47 | /** the underlying data. */ |
---|
48 | protected Vector<Instances> m_Data; |
---|
49 | |
---|
50 | /** the text area for displaying the info. */ |
---|
51 | protected JTextArea m_TextInfo; |
---|
52 | |
---|
53 | /** |
---|
54 | * Initializes the frame. |
---|
55 | */ |
---|
56 | public InstanceInfoFrame() { |
---|
57 | super("Weka: Instance info"); |
---|
58 | |
---|
59 | initialize(); |
---|
60 | initGUI(); |
---|
61 | initFinished(); |
---|
62 | } |
---|
63 | |
---|
64 | /** |
---|
65 | * Initializes member variables. |
---|
66 | */ |
---|
67 | protected void initialize() { |
---|
68 | m_Data = new Vector<Instances>(); |
---|
69 | } |
---|
70 | |
---|
71 | /** |
---|
72 | * Sets up the GUI components. |
---|
73 | */ |
---|
74 | protected void initGUI() { |
---|
75 | getContentPane().setLayout(new BorderLayout()); |
---|
76 | |
---|
77 | m_TextInfo = new JTextArea(); |
---|
78 | m_TextInfo.setEditable(false); |
---|
79 | m_TextInfo.setFont(new Font("Monospaced", Font.PLAIN,12)); |
---|
80 | getContentPane().add(new JScrollPane(m_TextInfo), BorderLayout.CENTER); |
---|
81 | |
---|
82 | pack(); |
---|
83 | setSize(320, 400); |
---|
84 | } |
---|
85 | |
---|
86 | /** |
---|
87 | * A hook method after initialize() and initGUI have been called. |
---|
88 | */ |
---|
89 | protected void initFinished() { |
---|
90 | } |
---|
91 | |
---|
92 | /** |
---|
93 | * Sets the text to display. |
---|
94 | * |
---|
95 | * @param text the text to display |
---|
96 | */ |
---|
97 | public void setInfoText(String text) { |
---|
98 | m_TextInfo.setText(text); |
---|
99 | } |
---|
100 | |
---|
101 | /** |
---|
102 | * Returns the currently displayed info text. |
---|
103 | * |
---|
104 | * @return the info text |
---|
105 | */ |
---|
106 | public String getInfoText() { |
---|
107 | return m_TextInfo.getText(); |
---|
108 | } |
---|
109 | |
---|
110 | /** |
---|
111 | * Sets the underlying data. |
---|
112 | * |
---|
113 | * @param data the data of the info text |
---|
114 | */ |
---|
115 | public void setInfoData(Vector<Instances> data) { |
---|
116 | m_Data = new Vector<Instances>(); |
---|
117 | if (data != null) |
---|
118 | m_Data.addAll(data); |
---|
119 | } |
---|
120 | |
---|
121 | /** |
---|
122 | * Returns the underlying data. |
---|
123 | * |
---|
124 | * @return the data of the info text, can be null |
---|
125 | */ |
---|
126 | public Vector<Instances> getInfoData() { |
---|
127 | return m_Data; |
---|
128 | } |
---|
129 | } |
---|