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 | * GUIChooser.java |
---|
19 | * Copyright (C) 1999 University of Waikato, Hamilton, New Zealand |
---|
20 | * |
---|
21 | */ |
---|
22 | |
---|
23 | package weka.gui; |
---|
24 | |
---|
25 | import weka.classifiers.bayes.net.GUI; |
---|
26 | import weka.classifiers.evaluation.ThresholdCurve; |
---|
27 | import weka.core.Copyright; |
---|
28 | import weka.core.Instances; |
---|
29 | import weka.core.Memory; |
---|
30 | import weka.core.SystemInfo; |
---|
31 | import weka.core.Utils; |
---|
32 | import weka.core.Version; |
---|
33 | import weka.core.scripting.Groovy; |
---|
34 | import weka.core.scripting.Jython; |
---|
35 | import weka.gui.arffviewer.ArffViewer; |
---|
36 | import weka.gui.beans.KnowledgeFlow; |
---|
37 | import weka.gui.beans.KnowledgeFlowApp; |
---|
38 | import weka.gui.boundaryvisualizer.BoundaryVisualizer; |
---|
39 | import weka.gui.experiment.Experimenter; |
---|
40 | import weka.gui.explorer.Explorer; |
---|
41 | import weka.gui.graphvisualizer.GraphVisualizer; |
---|
42 | import weka.gui.scripting.GroovyPanel; |
---|
43 | import weka.gui.scripting.JythonPanel; |
---|
44 | import weka.gui.sql.SqlViewer; |
---|
45 | import weka.gui.treevisualizer.Node; |
---|
46 | import weka.gui.treevisualizer.NodePlace; |
---|
47 | import weka.gui.treevisualizer.PlaceNode2; |
---|
48 | import weka.gui.treevisualizer.TreeBuild; |
---|
49 | import weka.gui.treevisualizer.TreeVisualizer; |
---|
50 | import weka.gui.visualize.PlotData2D; |
---|
51 | import weka.gui.visualize.ThresholdVisualizePanel; |
---|
52 | import weka.gui.visualize.VisualizePanel; |
---|
53 | |
---|
54 | import java.awt.BorderLayout; |
---|
55 | import java.awt.Color; |
---|
56 | import java.awt.Component; |
---|
57 | import java.awt.Container; |
---|
58 | import java.awt.Dimension; |
---|
59 | import java.awt.GridLayout; |
---|
60 | import java.awt.Image; |
---|
61 | import java.awt.LayoutManager; |
---|
62 | import java.awt.Point; |
---|
63 | import java.awt.Toolkit; |
---|
64 | import java.awt.event.ActionEvent; |
---|
65 | import java.awt.event.ActionListener; |
---|
66 | import java.awt.event.KeyEvent; |
---|
67 | import java.awt.event.WindowAdapter; |
---|
68 | import java.awt.event.WindowEvent; |
---|
69 | import java.io.BufferedReader; |
---|
70 | import java.io.File; |
---|
71 | import java.io.FileInputStream; |
---|
72 | import java.io.FileReader; |
---|
73 | import java.io.Reader; |
---|
74 | import java.util.Collections; |
---|
75 | import java.util.Enumeration; |
---|
76 | import java.util.HashSet; |
---|
77 | import java.util.Hashtable; |
---|
78 | import java.util.Vector; |
---|
79 | |
---|
80 | import javax.swing.BorderFactory; |
---|
81 | import javax.swing.ImageIcon; |
---|
82 | import javax.swing.JButton; |
---|
83 | import javax.swing.JFileChooser; |
---|
84 | import javax.swing.JFrame; |
---|
85 | import javax.swing.JLabel; |
---|
86 | import javax.swing.JMenu; |
---|
87 | import javax.swing.JMenuBar; |
---|
88 | import javax.swing.JMenuItem; |
---|
89 | import javax.swing.JOptionPane; |
---|
90 | import javax.swing.JPanel; |
---|
91 | import javax.swing.JScrollPane; |
---|
92 | import javax.swing.JSeparator; |
---|
93 | import javax.swing.JTable; |
---|
94 | import javax.swing.KeyStroke; |
---|
95 | |
---|
96 | /** |
---|
97 | * The main class for the Weka GUIChooser. Lets the user choose |
---|
98 | * which GUI they want to run. |
---|
99 | * |
---|
100 | * @author Len Trigg (trigg@cs.waikato.ac.nz) |
---|
101 | * @author Mark Hall (mhall@cs.waikato.ac.nz) |
---|
102 | * @author FracPete (fracpete at waikato dot ac dot nz) |
---|
103 | * @version $Revision: 5837 $ |
---|
104 | */ |
---|
105 | public class GUIChooser |
---|
106 | extends JFrame { |
---|
107 | |
---|
108 | /** for serialization */ |
---|
109 | private static final long serialVersionUID = 9001529425230247914L; |
---|
110 | |
---|
111 | /** the GUIChooser itself */ |
---|
112 | protected GUIChooser m_Self; |
---|
113 | |
---|
114 | // Menu stuff |
---|
115 | private JMenuBar m_jMenuBar; |
---|
116 | private JMenu m_jMenuProgram; |
---|
117 | private JMenu m_jMenuVisualization; |
---|
118 | private JMenu m_jMenuTools; |
---|
119 | private JMenu m_jMenuHelp; |
---|
120 | |
---|
121 | // Applications |
---|
122 | |
---|
123 | /** the panel for the application buttons */ |
---|
124 | protected JPanel m_PanelApplications = new JPanel(); |
---|
125 | |
---|
126 | /** Click to open the Explorer */ |
---|
127 | protected JButton m_ExplorerBut = new JButton("Explorer"); |
---|
128 | |
---|
129 | /** The frame containing the explorer interface */ |
---|
130 | protected JFrame m_ExplorerFrame; |
---|
131 | |
---|
132 | /** Click to open the Explorer */ |
---|
133 | protected JButton m_ExperimenterBut = new JButton("Experimenter"); |
---|
134 | |
---|
135 | /** The frame containing the experiment interface */ |
---|
136 | protected JFrame m_ExperimenterFrame; |
---|
137 | |
---|
138 | /** Click to open the KnowledgeFlow */ |
---|
139 | protected JButton m_KnowledgeFlowBut = new JButton("KnowledgeFlow"); |
---|
140 | |
---|
141 | /** The frame containing the knowledge flow interface */ |
---|
142 | protected JFrame m_KnowledgeFlowFrame; |
---|
143 | |
---|
144 | /** Click to open the simplecli */ |
---|
145 | protected JButton m_SimpleBut = new JButton("Simple CLI"); |
---|
146 | |
---|
147 | /** The SimpleCLI */ |
---|
148 | protected SimpleCLI m_SimpleCLI; |
---|
149 | |
---|
150 | /** The frame containing the Groovy console. */ |
---|
151 | protected JFrame m_GroovyConsoleFrame; |
---|
152 | |
---|
153 | /** The frame containing the Jython console. */ |
---|
154 | protected JFrame m_JythonConsoleFrame; |
---|
155 | |
---|
156 | /** keeps track of the opened ArffViewer instancs */ |
---|
157 | protected Vector m_ArffViewers = new Vector(); |
---|
158 | |
---|
159 | /** The frame containing the SqlViewer */ |
---|
160 | protected JFrame m_SqlViewerFrame; |
---|
161 | |
---|
162 | /** The frame containing the Bayes net GUI */ |
---|
163 | protected JFrame m_BayesNetGUIFrame; |
---|
164 | |
---|
165 | /** The frame containing the ensemble library interface */ |
---|
166 | protected JFrame m_EnsembleLibraryFrame; |
---|
167 | |
---|
168 | // Visualization |
---|
169 | |
---|
170 | /** keeps track of the opened plots */ |
---|
171 | protected Vector m_Plots = new Vector(); |
---|
172 | |
---|
173 | /** keeps track of the opened ROCs */ |
---|
174 | protected Vector m_ROCs = new Vector(); |
---|
175 | |
---|
176 | /** keeps track of the opened tree visualizer instancs */ |
---|
177 | protected Vector m_TreeVisualizers = new Vector(); |
---|
178 | |
---|
179 | /** keeps track of the opened graph visualizer instancs */ |
---|
180 | protected Vector m_GraphVisualizers = new Vector(); |
---|
181 | |
---|
182 | /** The frame containing the boundary visualizer */ |
---|
183 | protected JFrame m_BoundaryVisualizerFrame; |
---|
184 | |
---|
185 | // Help |
---|
186 | |
---|
187 | /** The frame containing the system info */ |
---|
188 | protected JFrame m_SystemInfoFrame; |
---|
189 | |
---|
190 | // Other |
---|
191 | |
---|
192 | /** The frame containing the memory usage */ |
---|
193 | protected JFrame m_MemoryUsageFrame; |
---|
194 | |
---|
195 | /** The frame of the LogWindow */ |
---|
196 | protected static LogWindow m_LogWindow = new LogWindow(); |
---|
197 | |
---|
198 | /** The weka image */ |
---|
199 | Image m_weka = Toolkit.getDefaultToolkit(). |
---|
200 | getImage(ClassLoader.getSystemResource("weka/gui/images/weka_background.gif")); |
---|
201 | |
---|
202 | /** filechooser for the TreeVisualizer */ |
---|
203 | protected JFileChooser m_FileChooserTreeVisualizer = new JFileChooser(new File(System.getProperty("user.dir"))); |
---|
204 | |
---|
205 | /** filechooser for the GraphVisualizer */ |
---|
206 | protected JFileChooser m_FileChooserGraphVisualizer = new JFileChooser(new File(System.getProperty("user.dir"))); |
---|
207 | |
---|
208 | /** filechooser for Plots */ |
---|
209 | protected JFileChooser m_FileChooserPlot = new JFileChooser(new File(System.getProperty("user.dir"))); |
---|
210 | |
---|
211 | /** filechooser for ROC curves */ |
---|
212 | protected JFileChooser m_FileChooserROC = new JFileChooser(new File(System.getProperty("user.dir"))); |
---|
213 | |
---|
214 | /** the icon for the frames */ |
---|
215 | protected Image m_Icon; |
---|
216 | |
---|
217 | /** contains the child frames (title <-> object). */ |
---|
218 | protected HashSet<Container> m_ChildFrames = new HashSet<Container>(); |
---|
219 | |
---|
220 | /** |
---|
221 | * Creates the experiment environment gui with no initial experiment |
---|
222 | */ |
---|
223 | public GUIChooser() { |
---|
224 | |
---|
225 | super("Weka GUI Chooser"); |
---|
226 | |
---|
227 | m_Self = this; |
---|
228 | |
---|
229 | // filechoosers |
---|
230 | m_FileChooserGraphVisualizer.addChoosableFileFilter( |
---|
231 | new ExtensionFileFilter(".bif", "BIF Files (*.bif)")); |
---|
232 | m_FileChooserGraphVisualizer.addChoosableFileFilter( |
---|
233 | new ExtensionFileFilter(".xml", "XML Files (*.xml)")); |
---|
234 | |
---|
235 | m_FileChooserPlot.addChoosableFileFilter( |
---|
236 | new ExtensionFileFilter( |
---|
237 | Instances.FILE_EXTENSION, |
---|
238 | "ARFF Files (*" + Instances.FILE_EXTENSION + ")")); |
---|
239 | m_FileChooserPlot.setMultiSelectionEnabled(true); |
---|
240 | |
---|
241 | m_FileChooserROC.addChoosableFileFilter( |
---|
242 | new ExtensionFileFilter( |
---|
243 | Instances.FILE_EXTENSION, |
---|
244 | "ARFF Files (*" + Instances.FILE_EXTENSION + ")")); |
---|
245 | |
---|
246 | // general layout |
---|
247 | m_Icon = Toolkit.getDefaultToolkit().getImage( |
---|
248 | ClassLoader.getSystemResource("weka/gui/weka_icon.gif")); |
---|
249 | setIconImage(m_Icon); |
---|
250 | this.getContentPane().setLayout(new BorderLayout()); |
---|
251 | |
---|
252 | this.getContentPane().add(m_PanelApplications, BorderLayout.EAST); |
---|
253 | |
---|
254 | // applications |
---|
255 | m_PanelApplications.setBorder(BorderFactory.createTitledBorder("Applications")); |
---|
256 | m_PanelApplications.setLayout(new GridLayout(4, 1)); |
---|
257 | m_PanelApplications.add(m_ExplorerBut); |
---|
258 | m_PanelApplications.add(m_ExperimenterBut); |
---|
259 | m_PanelApplications.add(m_KnowledgeFlowBut); |
---|
260 | m_PanelApplications.add(m_SimpleBut); |
---|
261 | |
---|
262 | // Weka image plus copyright info |
---|
263 | JPanel wekaPan = new JPanel(); |
---|
264 | wekaPan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
---|
265 | wekaPan.setLayout(new BorderLayout()); |
---|
266 | wekaPan.setToolTipText("Weka, a native bird of New Zealand"); |
---|
267 | ImageIcon wii = new ImageIcon(m_weka); |
---|
268 | JLabel wekaLab = new JLabel(wii); |
---|
269 | wekaPan.add(wekaLab, BorderLayout.CENTER); |
---|
270 | String infoString = "<html>" |
---|
271 | + "<font size=-2>" |
---|
272 | + "Waikato Environment for Knowledge Analysis<br>" |
---|
273 | + "Version " + Version.VERSION + "<br>" |
---|
274 | + "(c) " + Copyright.getFromYear() + " - " + Copyright.getToYear() + "<br>" |
---|
275 | + Copyright.getOwner() + "<br>" |
---|
276 | + Copyright.getAddress() |
---|
277 | + "</font>" |
---|
278 | + "</html>"; |
---|
279 | JLabel infoLab = new JLabel(infoString); |
---|
280 | infoLab.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
---|
281 | wekaPan.add(infoLab, BorderLayout.SOUTH); |
---|
282 | |
---|
283 | this.getContentPane().add(wekaPan, BorderLayout.CENTER); |
---|
284 | |
---|
285 | // Menu bar |
---|
286 | m_jMenuBar = new JMenuBar(); |
---|
287 | |
---|
288 | // Program |
---|
289 | m_jMenuProgram = new JMenu(); |
---|
290 | m_jMenuBar.add(m_jMenuProgram); |
---|
291 | m_jMenuProgram.setText("Program"); |
---|
292 | m_jMenuProgram.setMnemonic('P'); |
---|
293 | |
---|
294 | // Program/LogWindow |
---|
295 | JMenuItem jMenuItemProgramLogWindow = new JMenuItem(); |
---|
296 | m_jMenuProgram.add(jMenuItemProgramLogWindow); |
---|
297 | jMenuItemProgramLogWindow.setText("LogWindow"); |
---|
298 | //jMenuItemProgramLogWindow.setMnemonic('L'); |
---|
299 | jMenuItemProgramLogWindow.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, KeyEvent.CTRL_MASK)); |
---|
300 | m_LogWindow.setIconImage(m_Icon); |
---|
301 | jMenuItemProgramLogWindow.addActionListener(new ActionListener() { |
---|
302 | public void actionPerformed(ActionEvent e) { |
---|
303 | m_LogWindow.setVisible(true); |
---|
304 | } |
---|
305 | }); |
---|
306 | |
---|
307 | final JMenuItem jMenuItemProgramMemUsage = new JMenuItem(); |
---|
308 | m_jMenuProgram.add(jMenuItemProgramMemUsage); |
---|
309 | jMenuItemProgramMemUsage.setText("Memory usage"); |
---|
310 | //jMenuItemProgramMemUsage.setMnemonic('M'); |
---|
311 | jMenuItemProgramMemUsage.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_MASK)); |
---|
312 | |
---|
313 | jMenuItemProgramMemUsage.addActionListener(new ActionListener() { |
---|
314 | public void actionPerformed(ActionEvent e) { |
---|
315 | if (m_MemoryUsageFrame == null) { |
---|
316 | final MemoryUsagePanel panel = new MemoryUsagePanel(); |
---|
317 | jMenuItemProgramMemUsage.setEnabled(false); |
---|
318 | m_MemoryUsageFrame = new JFrame("Memory usage"); |
---|
319 | m_MemoryUsageFrame.setIconImage(m_Icon); |
---|
320 | m_MemoryUsageFrame.getContentPane().setLayout(new BorderLayout()); |
---|
321 | m_MemoryUsageFrame.getContentPane().add(panel, BorderLayout.CENTER); |
---|
322 | m_MemoryUsageFrame.addWindowListener(new WindowAdapter() { |
---|
323 | public void windowClosing(WindowEvent w) { |
---|
324 | panel.stopMonitoring(); |
---|
325 | m_MemoryUsageFrame.dispose(); |
---|
326 | m_MemoryUsageFrame = null; |
---|
327 | jMenuItemProgramMemUsage.setEnabled(true); |
---|
328 | checkExit(); |
---|
329 | } |
---|
330 | }); |
---|
331 | m_MemoryUsageFrame.pack(); |
---|
332 | m_MemoryUsageFrame.setSize(400, 50); |
---|
333 | Point l = panel.getFrameLocation(); |
---|
334 | if ((l.x != -1) && (l.y != -1)) |
---|
335 | m_MemoryUsageFrame.setLocation(l); |
---|
336 | m_MemoryUsageFrame.setVisible(true); |
---|
337 | Dimension size = m_MemoryUsageFrame.getPreferredSize(); |
---|
338 | m_MemoryUsageFrame.setSize(new Dimension((int) size.getWidth(), (int) size.getHeight())); |
---|
339 | } |
---|
340 | } |
---|
341 | }); |
---|
342 | |
---|
343 | m_jMenuProgram.add(new JSeparator()); |
---|
344 | |
---|
345 | // Program/Exit |
---|
346 | JMenuItem jMenuItemProgramExit = new JMenuItem(); |
---|
347 | m_jMenuProgram.add(jMenuItemProgramExit); |
---|
348 | jMenuItemProgramExit.setText("Exit"); |
---|
349 | // jMenuItemProgramExit.setMnemonic('E'); |
---|
350 | jMenuItemProgramExit. |
---|
351 | setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_MASK)); |
---|
352 | jMenuItemProgramExit.addActionListener(new ActionListener() { |
---|
353 | public void actionPerformed(ActionEvent e) { |
---|
354 | dispose(); |
---|
355 | checkExit(); |
---|
356 | } |
---|
357 | }); |
---|
358 | |
---|
359 | // Visualization |
---|
360 | m_jMenuVisualization = new JMenu(); |
---|
361 | m_jMenuBar.add(m_jMenuVisualization); |
---|
362 | m_jMenuVisualization.setText("Visualization"); |
---|
363 | m_jMenuVisualization.setMnemonic('V'); |
---|
364 | |
---|
365 | // Visualization/Plot |
---|
366 | JMenuItem jMenuItemVisualizationPlot = new JMenuItem(); |
---|
367 | m_jMenuVisualization.add(jMenuItemVisualizationPlot); |
---|
368 | jMenuItemVisualizationPlot.setText("Plot"); |
---|
369 | //jMenuItemVisualizationPlot.setMnemonic('P'); |
---|
370 | jMenuItemVisualizationPlot. |
---|
371 | setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK)); |
---|
372 | |
---|
373 | jMenuItemVisualizationPlot.addActionListener(new ActionListener() { |
---|
374 | public void actionPerformed(ActionEvent e) { |
---|
375 | // choose file |
---|
376 | int retVal = m_FileChooserPlot.showOpenDialog(m_Self); |
---|
377 | if (retVal != JFileChooser.APPROVE_OPTION) |
---|
378 | return; |
---|
379 | |
---|
380 | // build plot |
---|
381 | VisualizePanel panel = new VisualizePanel(); |
---|
382 | String filenames = ""; |
---|
383 | File[] files = m_FileChooserPlot.getSelectedFiles(); |
---|
384 | for (int j = 0; j < files.length; j++) { |
---|
385 | String filename = files[j].getAbsolutePath(); |
---|
386 | if (j > 0) |
---|
387 | filenames += ", "; |
---|
388 | filenames += filename; |
---|
389 | System.err.println("Loading instances from " + filename); |
---|
390 | try { |
---|
391 | Reader r = new java.io.BufferedReader(new FileReader(filename)); |
---|
392 | Instances i = new Instances(r); |
---|
393 | i.setClassIndex(i.numAttributes()-1); |
---|
394 | PlotData2D pd1 = new PlotData2D(i); |
---|
395 | |
---|
396 | if (j == 0) { |
---|
397 | pd1.setPlotName("Master plot"); |
---|
398 | panel.setMasterPlot(pd1); |
---|
399 | } else { |
---|
400 | pd1.setPlotName("Plot "+(j+1)); |
---|
401 | pd1.m_useCustomColour = true; |
---|
402 | pd1.m_customColour = (j % 2 == 0) ? Color.red : Color.blue; |
---|
403 | panel.addPlot(pd1); |
---|
404 | } |
---|
405 | } |
---|
406 | catch (Exception ex) { |
---|
407 | ex.printStackTrace(); |
---|
408 | JOptionPane.showMessageDialog( |
---|
409 | m_Self, "Error loading file '" + files[j] + "':\n" + ex.getMessage()); |
---|
410 | return; |
---|
411 | } |
---|
412 | } |
---|
413 | |
---|
414 | // create frame |
---|
415 | final JFrame frame = new JFrame("Plot - " + filenames); |
---|
416 | frame.setIconImage(m_Icon); |
---|
417 | frame.getContentPane().setLayout(new BorderLayout()); |
---|
418 | frame.getContentPane().add(panel, BorderLayout.CENTER); |
---|
419 | frame.addWindowListener(new WindowAdapter() { |
---|
420 | public void windowClosing(WindowEvent e) { |
---|
421 | m_Plots.remove(frame); |
---|
422 | frame.dispose(); |
---|
423 | checkExit(); |
---|
424 | } |
---|
425 | }); |
---|
426 | frame.pack(); |
---|
427 | frame.setSize(800, 600); |
---|
428 | frame.setVisible(true); |
---|
429 | m_Plots.add(frame); |
---|
430 | } |
---|
431 | }); |
---|
432 | |
---|
433 | // Visualization/ROC |
---|
434 | JMenuItem jMenuItemVisualizationROC = new JMenuItem(); |
---|
435 | m_jMenuVisualization.add(jMenuItemVisualizationROC); |
---|
436 | jMenuItemVisualizationROC.setText("ROC"); |
---|
437 | // jMenuItemVisualizationROC.setMnemonic('R'); |
---|
438 | jMenuItemVisualizationROC. |
---|
439 | setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.CTRL_MASK)); |
---|
440 | |
---|
441 | jMenuItemVisualizationROC.addActionListener(new ActionListener() { |
---|
442 | public void actionPerformed(ActionEvent e) { |
---|
443 | // choose file |
---|
444 | int retVal = m_FileChooserROC.showOpenDialog(m_Self); |
---|
445 | if (retVal != JFileChooser.APPROVE_OPTION) |
---|
446 | return; |
---|
447 | |
---|
448 | // create plot |
---|
449 | String filename = m_FileChooserROC.getSelectedFile().getAbsolutePath(); |
---|
450 | Instances result = null; |
---|
451 | try { |
---|
452 | result = new Instances(new BufferedReader(new FileReader(filename))); |
---|
453 | } |
---|
454 | catch (Exception ex) { |
---|
455 | ex.printStackTrace(); |
---|
456 | JOptionPane.showMessageDialog( |
---|
457 | m_Self, "Error loading file '" + filename + "':\n" + ex.getMessage()); |
---|
458 | return; |
---|
459 | } |
---|
460 | result.setClassIndex(result.numAttributes() - 1); |
---|
461 | ThresholdVisualizePanel vmc = new ThresholdVisualizePanel(); |
---|
462 | vmc.setROCString("(Area under ROC = " + |
---|
463 | Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + ")"); |
---|
464 | vmc.setName(result.relationName()); |
---|
465 | PlotData2D tempd = new PlotData2D(result); |
---|
466 | tempd.setPlotName(result.relationName()); |
---|
467 | tempd.addInstanceNumberAttribute(); |
---|
468 | try { |
---|
469 | vmc.addPlot(tempd); |
---|
470 | } |
---|
471 | catch (Exception ex) { |
---|
472 | ex.printStackTrace(); |
---|
473 | JOptionPane.showMessageDialog( |
---|
474 | m_Self, "Error adding plot:\n" + ex.getMessage()); |
---|
475 | return; |
---|
476 | } |
---|
477 | |
---|
478 | final JFrame frame = new JFrame("ROC - " + filename); |
---|
479 | frame.setIconImage(m_Icon); |
---|
480 | frame.getContentPane().setLayout(new BorderLayout()); |
---|
481 | frame.getContentPane().add(vmc, BorderLayout.CENTER); |
---|
482 | frame.addWindowListener(new WindowAdapter() { |
---|
483 | public void windowClosing(WindowEvent e) { |
---|
484 | m_ROCs.remove(frame); |
---|
485 | frame.dispose(); |
---|
486 | checkExit(); |
---|
487 | } |
---|
488 | }); |
---|
489 | frame.pack(); |
---|
490 | frame.setSize(800, 600); |
---|
491 | frame.setVisible(true); |
---|
492 | m_ROCs.add(frame); |
---|
493 | } |
---|
494 | }); |
---|
495 | |
---|
496 | // Visualization/TreeVisualizer |
---|
497 | JMenuItem jMenuItemVisualizationTree = new JMenuItem(); |
---|
498 | m_jMenuVisualization.add(jMenuItemVisualizationTree); |
---|
499 | jMenuItemVisualizationTree.setText("TreeVisualizer"); |
---|
500 | // jMenuItemVisualizationTree.setMnemonic('T'); |
---|
501 | jMenuItemVisualizationTree. |
---|
502 | setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_MASK)); |
---|
503 | |
---|
504 | jMenuItemVisualizationTree.addActionListener(new ActionListener() { |
---|
505 | public void actionPerformed(ActionEvent e) { |
---|
506 | // choose file |
---|
507 | int retVal = m_FileChooserTreeVisualizer.showOpenDialog(m_Self); |
---|
508 | if (retVal != JFileChooser.APPROVE_OPTION) |
---|
509 | return; |
---|
510 | |
---|
511 | // build tree |
---|
512 | String filename = m_FileChooserTreeVisualizer.getSelectedFile().getAbsolutePath(); |
---|
513 | TreeBuild builder = new TreeBuild(); |
---|
514 | Node top = null; |
---|
515 | NodePlace arrange = new PlaceNode2(); |
---|
516 | try { |
---|
517 | top = builder.create(new FileReader(filename)); |
---|
518 | } |
---|
519 | catch (Exception ex) { |
---|
520 | ex.printStackTrace(); |
---|
521 | JOptionPane.showMessageDialog( |
---|
522 | m_Self, "Error loading file '" + filename + "':\n" + ex.getMessage()); |
---|
523 | return; |
---|
524 | } |
---|
525 | |
---|
526 | // create frame |
---|
527 | final JFrame frame = new JFrame("TreeVisualizer - " + filename); |
---|
528 | frame.setIconImage(m_Icon); |
---|
529 | frame.getContentPane().setLayout(new BorderLayout()); |
---|
530 | frame.getContentPane().add(new TreeVisualizer(null, top, arrange), BorderLayout.CENTER); |
---|
531 | frame.addWindowListener(new WindowAdapter() { |
---|
532 | public void windowClosing(WindowEvent e) { |
---|
533 | m_TreeVisualizers.remove(frame); |
---|
534 | frame.dispose(); |
---|
535 | checkExit(); |
---|
536 | } |
---|
537 | }); |
---|
538 | frame.pack(); |
---|
539 | frame.setSize(800, 600); |
---|
540 | frame.setVisible(true); |
---|
541 | m_TreeVisualizers.add(frame); |
---|
542 | } |
---|
543 | }); |
---|
544 | |
---|
545 | // Visualization/GraphVisualizer |
---|
546 | JMenuItem jMenuItemVisualizationGraph = new JMenuItem(); |
---|
547 | m_jMenuVisualization.add(jMenuItemVisualizationGraph); |
---|
548 | jMenuItemVisualizationGraph.setText("GraphVisualizer"); |
---|
549 | // jMenuItemVisualizationGraph.setMnemonic('G'); |
---|
550 | jMenuItemVisualizationGraph. |
---|
551 | setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, KeyEvent.CTRL_MASK)); |
---|
552 | |
---|
553 | jMenuItemVisualizationGraph.addActionListener(new ActionListener() { |
---|
554 | public void actionPerformed(ActionEvent e) { |
---|
555 | // choose file |
---|
556 | int retVal = m_FileChooserGraphVisualizer.showOpenDialog(m_Self); |
---|
557 | if (retVal != JFileChooser.APPROVE_OPTION) |
---|
558 | return; |
---|
559 | |
---|
560 | // build graph |
---|
561 | String filename = m_FileChooserGraphVisualizer.getSelectedFile().getAbsolutePath(); |
---|
562 | GraphVisualizer panel = new GraphVisualizer(); |
---|
563 | try{ |
---|
564 | if ( filename.toLowerCase().endsWith(".xml") |
---|
565 | || filename.toLowerCase().endsWith(".bif") ) { |
---|
566 | panel.readBIF(new FileInputStream(filename)); |
---|
567 | } |
---|
568 | else { |
---|
569 | panel.readDOT(new FileReader(filename)); |
---|
570 | } |
---|
571 | } |
---|
572 | catch (Exception ex) { |
---|
573 | ex.printStackTrace(); |
---|
574 | JOptionPane.showMessageDialog( |
---|
575 | m_Self, "Error loading file '" + filename + "':\n" + ex.getMessage()); |
---|
576 | return; |
---|
577 | } |
---|
578 | |
---|
579 | // create frame |
---|
580 | final JFrame frame = new JFrame("GraphVisualizer - " + filename); |
---|
581 | frame.setIconImage(m_Icon); |
---|
582 | frame.getContentPane().setLayout(new BorderLayout()); |
---|
583 | frame.getContentPane().add(panel, BorderLayout.CENTER); |
---|
584 | frame.addWindowListener(new WindowAdapter() { |
---|
585 | public void windowClosing(WindowEvent e) { |
---|
586 | m_GraphVisualizers.remove(frame); |
---|
587 | frame.dispose(); |
---|
588 | checkExit(); |
---|
589 | } |
---|
590 | }); |
---|
591 | frame.pack(); |
---|
592 | frame.setSize(800, 600); |
---|
593 | frame.setVisible(true); |
---|
594 | m_GraphVisualizers.add(frame); |
---|
595 | } |
---|
596 | }); |
---|
597 | |
---|
598 | // Visualization/BoundaryVisualizer |
---|
599 | final JMenuItem jMenuItemVisualizationBoundary = new JMenuItem(); |
---|
600 | m_jMenuVisualization.add(jMenuItemVisualizationBoundary); |
---|
601 | jMenuItemVisualizationBoundary.setText("BoundaryVisualizer"); |
---|
602 | // jMenuItemVisualizationBoundary.setMnemonic('B'); |
---|
603 | jMenuItemVisualizationBoundary. |
---|
604 | setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK)); |
---|
605 | |
---|
606 | jMenuItemVisualizationBoundary.addActionListener(new ActionListener() { |
---|
607 | public void actionPerformed(ActionEvent e) { |
---|
608 | if (m_BoundaryVisualizerFrame == null) { |
---|
609 | jMenuItemVisualizationBoundary.setEnabled(false); |
---|
610 | m_BoundaryVisualizerFrame = new JFrame("BoundaryVisualizer"); |
---|
611 | m_BoundaryVisualizerFrame.setIconImage(m_Icon); |
---|
612 | m_BoundaryVisualizerFrame.getContentPane().setLayout(new BorderLayout()); |
---|
613 | final BoundaryVisualizer bv = new BoundaryVisualizer(); |
---|
614 | m_BoundaryVisualizerFrame.getContentPane().add(bv, BorderLayout.CENTER); |
---|
615 | m_BoundaryVisualizerFrame.setSize(bv.getMinimumSize()); |
---|
616 | m_BoundaryVisualizerFrame.addWindowListener(new WindowAdapter() { |
---|
617 | public void windowClosing(WindowEvent w) { |
---|
618 | bv.stopPlotting(); |
---|
619 | m_BoundaryVisualizerFrame.dispose(); |
---|
620 | m_BoundaryVisualizerFrame = null; |
---|
621 | jMenuItemVisualizationBoundary.setEnabled(true); |
---|
622 | checkExit(); |
---|
623 | } |
---|
624 | }); |
---|
625 | m_BoundaryVisualizerFrame.pack(); |
---|
626 | //m_BoundaryVisualizerFrame.setSize(800, 600); |
---|
627 | m_BoundaryVisualizerFrame.setResizable(false); |
---|
628 | m_BoundaryVisualizerFrame.setVisible(true); |
---|
629 | // dont' do a System.exit after last window got closed! |
---|
630 | BoundaryVisualizer.setExitIfNoWindowsOpen(false); |
---|
631 | } |
---|
632 | } |
---|
633 | }); |
---|
634 | |
---|
635 | // Extensions |
---|
636 | JMenu jMenuExtensions = new JMenu("Extensions"); |
---|
637 | jMenuExtensions.setMnemonic(java.awt.event.KeyEvent.VK_E); |
---|
638 | m_jMenuBar.add(jMenuExtensions); |
---|
639 | jMenuExtensions.setVisible(false); |
---|
640 | |
---|
641 | String extensions = GenericObjectEditor.EDITOR_PROPERTIES.getProperty( |
---|
642 | MainMenuExtension.class.getName(), ""); |
---|
643 | |
---|
644 | if (extensions.length() > 0) { |
---|
645 | jMenuExtensions.setVisible(true); |
---|
646 | String[] classnames = GenericObjectEditor.EDITOR_PROPERTIES.getProperty( |
---|
647 | MainMenuExtension.class.getName(), "").split(","); |
---|
648 | Hashtable<String,JMenu> submenus = new Hashtable<String,JMenu>(); |
---|
649 | |
---|
650 | // add all extensions |
---|
651 | for (int i = 0; i < classnames.length; i++) { |
---|
652 | String classname = classnames[i]; |
---|
653 | try { |
---|
654 | MainMenuExtension ext = (MainMenuExtension) Class.forName(classname).newInstance(); |
---|
655 | |
---|
656 | // menuitem in a submenu? |
---|
657 | JMenu submenu = null; |
---|
658 | if (ext.getSubmenuTitle() != null) { |
---|
659 | submenu = submenus.get(ext.getSubmenuTitle()); |
---|
660 | if (submenu == null) { |
---|
661 | submenu = new JMenu(ext.getSubmenuTitle()); |
---|
662 | submenus.put(ext.getSubmenuTitle(), submenu); |
---|
663 | insertMenuItem(jMenuExtensions, submenu); |
---|
664 | } |
---|
665 | } |
---|
666 | |
---|
667 | // create menu item |
---|
668 | JMenuItem menuitem = new JMenuItem(); |
---|
669 | menuitem.setText(ext.getMenuTitle()); |
---|
670 | // does the extension need a frame or does it have its own ActionListener? |
---|
671 | ActionListener listener = ext.getActionListener(m_Self); |
---|
672 | if (listener != null) { |
---|
673 | menuitem.addActionListener(listener); |
---|
674 | } |
---|
675 | else { |
---|
676 | final JMenuItem finalMenuitem = menuitem; |
---|
677 | final MainMenuExtension finalExt = ext; |
---|
678 | menuitem.addActionListener(new ActionListener() { |
---|
679 | public void actionPerformed(ActionEvent e) { |
---|
680 | Component frame = createFrame( |
---|
681 | m_Self, finalMenuitem.getText(), |
---|
682 | null, null, null, -1, -1, null, false, false); |
---|
683 | finalExt.fillFrame(frame); |
---|
684 | frame.setVisible(true); |
---|
685 | } |
---|
686 | }); |
---|
687 | } |
---|
688 | |
---|
689 | // sorted insert of menu item |
---|
690 | if (submenu != null) |
---|
691 | insertMenuItem(submenu, menuitem); |
---|
692 | else |
---|
693 | insertMenuItem(jMenuExtensions, menuitem); |
---|
694 | } |
---|
695 | catch (Exception e) { |
---|
696 | e.printStackTrace(); |
---|
697 | } |
---|
698 | } |
---|
699 | } |
---|
700 | |
---|
701 | // Tools |
---|
702 | m_jMenuTools = new JMenu(); |
---|
703 | m_jMenuBar.add(m_jMenuTools); |
---|
704 | m_jMenuTools.setText("Tools"); |
---|
705 | m_jMenuTools.setMnemonic('T'); |
---|
706 | |
---|
707 | // Tools/ArffViewer |
---|
708 | JMenuItem jMenuItemToolsArffViewer = new JMenuItem(); |
---|
709 | m_jMenuTools.add(jMenuItemToolsArffViewer); |
---|
710 | jMenuItemToolsArffViewer.setText("ArffViewer"); |
---|
711 | // jMenuItemToolsArffViewer.setMnemonic('A'); |
---|
712 | jMenuItemToolsArffViewer. |
---|
713 | setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK)); |
---|
714 | |
---|
715 | jMenuItemToolsArffViewer.addActionListener(new ActionListener() { |
---|
716 | public void actionPerformed(ActionEvent e) { |
---|
717 | final ArffViewer av = new ArffViewer(); |
---|
718 | av.addWindowListener(new WindowAdapter() { |
---|
719 | public void windowClosing(WindowEvent w) { |
---|
720 | m_ArffViewers.remove(av); |
---|
721 | checkExit(); |
---|
722 | } |
---|
723 | }); |
---|
724 | av.setVisible(true); |
---|
725 | m_ArffViewers.add(av); |
---|
726 | } |
---|
727 | }); |
---|
728 | |
---|
729 | // Tools/SqlViewer |
---|
730 | final JMenuItem jMenuItemToolsSql = new JMenuItem(); |
---|
731 | m_jMenuTools.add(jMenuItemToolsSql); |
---|
732 | jMenuItemToolsSql.setText("SqlViewer"); |
---|
733 | // jMenuItemToolsSql.setMnemonic('S'); |
---|
734 | jMenuItemToolsSql. |
---|
735 | setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK)); |
---|
736 | |
---|
737 | jMenuItemToolsSql.addActionListener(new ActionListener() { |
---|
738 | public void actionPerformed(ActionEvent e) { |
---|
739 | if (m_SqlViewerFrame == null) { |
---|
740 | jMenuItemToolsSql.setEnabled(false); |
---|
741 | final SqlViewer sql = new SqlViewer(null); |
---|
742 | m_SqlViewerFrame = new JFrame("SqlViewer"); |
---|
743 | m_SqlViewerFrame.setIconImage(m_Icon); |
---|
744 | m_SqlViewerFrame.getContentPane().setLayout(new BorderLayout()); |
---|
745 | m_SqlViewerFrame.getContentPane().add(sql, BorderLayout.CENTER); |
---|
746 | m_SqlViewerFrame.addWindowListener(new WindowAdapter() { |
---|
747 | public void windowClosing(WindowEvent w) { |
---|
748 | sql.saveSize(); |
---|
749 | m_SqlViewerFrame.dispose(); |
---|
750 | m_SqlViewerFrame = null; |
---|
751 | jMenuItemToolsSql.setEnabled(true); |
---|
752 | checkExit(); |
---|
753 | } |
---|
754 | }); |
---|
755 | m_SqlViewerFrame.pack(); |
---|
756 | m_SqlViewerFrame.setVisible(true); |
---|
757 | } |
---|
758 | } |
---|
759 | }); |
---|
760 | |
---|
761 | // Tools/Bayes net editor |
---|
762 | final JMenuItem jMenuItemBayesNet = new JMenuItem(); |
---|
763 | m_jMenuTools.add(jMenuItemBayesNet); |
---|
764 | jMenuItemBayesNet.setText("Bayes net editor"); |
---|
765 | jMenuItemBayesNet. |
---|
766 | setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK)); |
---|
767 | jMenuItemBayesNet.addActionListener(new ActionListener() { |
---|
768 | public void actionPerformed(ActionEvent e) { |
---|
769 | if (m_BayesNetGUIFrame == null) { |
---|
770 | jMenuItemBayesNet.setEnabled(false); |
---|
771 | final GUI bayesNetGUI = new GUI(); |
---|
772 | JMenuBar bayesBar = bayesNetGUI.getMenuBar(); |
---|
773 | m_BayesNetGUIFrame = new JFrame("Bayes Network Editor"); |
---|
774 | m_BayesNetGUIFrame.setIconImage(m_Icon); |
---|
775 | m_BayesNetGUIFrame.setJMenuBar(bayesBar); |
---|
776 | m_BayesNetGUIFrame.getContentPane().add(bayesNetGUI, BorderLayout.CENTER); |
---|
777 | m_BayesNetGUIFrame.addWindowListener(new WindowAdapter() { |
---|
778 | public void windowClosing(WindowEvent w) { |
---|
779 | m_BayesNetGUIFrame.dispose(); |
---|
780 | m_BayesNetGUIFrame = null; |
---|
781 | jMenuItemBayesNet.setEnabled(true); |
---|
782 | checkExit(); |
---|
783 | } |
---|
784 | }); |
---|
785 | m_BayesNetGUIFrame.setSize(800, 600); |
---|
786 | m_BayesNetGUIFrame.setVisible(true); |
---|
787 | } |
---|
788 | } |
---|
789 | }); |
---|
790 | |
---|
791 | // Tools/Groovy console |
---|
792 | if (Groovy.isPresent()) { |
---|
793 | final JMenuItem jMenuItemGroovyConsole = new JMenuItem(); |
---|
794 | m_jMenuTools.add(jMenuItemGroovyConsole); |
---|
795 | jMenuItemGroovyConsole.setText("Groovy console"); |
---|
796 | jMenuItemGroovyConsole.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, KeyEvent.CTRL_MASK)); |
---|
797 | jMenuItemGroovyConsole.addActionListener(new ActionListener() { |
---|
798 | public void actionPerformed(ActionEvent e) { |
---|
799 | if (m_BayesNetGUIFrame == null) { |
---|
800 | jMenuItemGroovyConsole.setEnabled(false); |
---|
801 | final GroovyPanel groovyPanel = new GroovyPanel(); |
---|
802 | m_GroovyConsoleFrame = new JFrame(groovyPanel.getPlainTitle()); |
---|
803 | m_GroovyConsoleFrame.setIconImage(m_Icon); |
---|
804 | m_GroovyConsoleFrame.setDefaultCloseOperation(DISPOSE_ON_CLOSE); |
---|
805 | m_GroovyConsoleFrame.setJMenuBar(groovyPanel.getMenuBar()); |
---|
806 | m_GroovyConsoleFrame.getContentPane().add(groovyPanel, BorderLayout.CENTER); |
---|
807 | m_GroovyConsoleFrame.addWindowListener(new WindowAdapter() { |
---|
808 | public void windowClosed(WindowEvent w) { |
---|
809 | m_GroovyConsoleFrame = null; |
---|
810 | jMenuItemGroovyConsole.setEnabled(true); |
---|
811 | checkExit(); |
---|
812 | } |
---|
813 | }); |
---|
814 | m_GroovyConsoleFrame.setSize(800, 600); |
---|
815 | m_GroovyConsoleFrame.setVisible(true); |
---|
816 | } |
---|
817 | } |
---|
818 | }); |
---|
819 | } |
---|
820 | |
---|
821 | // Tools/Jython console |
---|
822 | if (Jython.isPresent()) { |
---|
823 | final JMenuItem jMenuItemJythonConsole = new JMenuItem(); |
---|
824 | m_jMenuTools.add(jMenuItemJythonConsole); |
---|
825 | jMenuItemJythonConsole.setText("Jython console"); |
---|
826 | jMenuItemJythonConsole.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, KeyEvent.CTRL_MASK)); |
---|
827 | jMenuItemJythonConsole.addActionListener(new ActionListener() { |
---|
828 | public void actionPerformed(ActionEvent e) { |
---|
829 | if (m_BayesNetGUIFrame == null) { |
---|
830 | jMenuItemJythonConsole.setEnabled(false); |
---|
831 | final JythonPanel jythonPanel = new JythonPanel(); |
---|
832 | m_JythonConsoleFrame = new JFrame(jythonPanel.getPlainTitle()); |
---|
833 | m_JythonConsoleFrame.setIconImage(m_Icon); |
---|
834 | m_JythonConsoleFrame.setDefaultCloseOperation(DISPOSE_ON_CLOSE); |
---|
835 | m_JythonConsoleFrame.setJMenuBar(jythonPanel.getMenuBar()); |
---|
836 | m_JythonConsoleFrame.getContentPane().add(jythonPanel, BorderLayout.CENTER); |
---|
837 | m_JythonConsoleFrame.addWindowListener(new WindowAdapter() { |
---|
838 | public void windowClosed(WindowEvent w) { |
---|
839 | m_JythonConsoleFrame = null; |
---|
840 | jMenuItemJythonConsole.setEnabled(true); |
---|
841 | checkExit(); |
---|
842 | } |
---|
843 | }); |
---|
844 | m_JythonConsoleFrame.setSize(800, 600); |
---|
845 | m_JythonConsoleFrame.setVisible(true); |
---|
846 | } |
---|
847 | } |
---|
848 | }); |
---|
849 | } |
---|
850 | |
---|
851 | // Help |
---|
852 | m_jMenuHelp = new JMenu(); |
---|
853 | m_jMenuBar.add(m_jMenuHelp); |
---|
854 | m_jMenuHelp.setText("Help"); |
---|
855 | m_jMenuHelp.setMnemonic('H'); |
---|
856 | |
---|
857 | // Help/Homepage |
---|
858 | JMenuItem jMenuItemHelpHomepage = new JMenuItem(); |
---|
859 | m_jMenuHelp.add(jMenuItemHelpHomepage); |
---|
860 | jMenuItemHelpHomepage.setText("Weka homepage"); |
---|
861 | // jMenuItemHelpHomepage.setMnemonic('H'); |
---|
862 | jMenuItemHelpHomepage. |
---|
863 | setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.CTRL_MASK)); |
---|
864 | jMenuItemHelpHomepage.addActionListener(new ActionListener() { |
---|
865 | public void actionPerformed(ActionEvent e) { |
---|
866 | BrowserHelper.openURL("http://www.cs.waikato.ac.nz/~ml/weka/"); |
---|
867 | } |
---|
868 | }); |
---|
869 | |
---|
870 | m_jMenuHelp.add(new JSeparator()); |
---|
871 | |
---|
872 | // Help/WekaWiki |
---|
873 | JMenuItem jMenuItemHelpWekaWiki = new JMenuItem(); |
---|
874 | m_jMenuHelp.add(jMenuItemHelpWekaWiki); |
---|
875 | jMenuItemHelpWekaWiki.setText("HOWTOs, code snippets, etc."); |
---|
876 | // jMenuItemHelpWekaWiki.setMnemonic('W'); |
---|
877 | jMenuItemHelpWekaWiki. |
---|
878 | setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.CTRL_MASK)); |
---|
879 | |
---|
880 | jMenuItemHelpWekaWiki.addActionListener(new ActionListener() { |
---|
881 | public void actionPerformed(ActionEvent e) { |
---|
882 | BrowserHelper.openURL("http://weka.wikispaces.com/"); |
---|
883 | } |
---|
884 | }); |
---|
885 | |
---|
886 | // Help/Sourceforge |
---|
887 | JMenuItem jMenuItemHelpSourceforge = new JMenuItem(); |
---|
888 | m_jMenuHelp.add(jMenuItemHelpSourceforge); |
---|
889 | jMenuItemHelpSourceforge.setText("Weka on Sourceforge"); |
---|
890 | // jMenuItemHelpSourceforge.setMnemonic('F'); |
---|
891 | jMenuItemHelpSourceforge. |
---|
892 | setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, KeyEvent.CTRL_MASK)); |
---|
893 | |
---|
894 | jMenuItemHelpSourceforge.addActionListener(new ActionListener() { |
---|
895 | public void actionPerformed(ActionEvent e) { |
---|
896 | BrowserHelper.openURL("http://sourceforge.net/projects/weka/"); |
---|
897 | } |
---|
898 | }); |
---|
899 | |
---|
900 | // Help/SystemInfo |
---|
901 | final JMenuItem jMenuItemHelpSysInfo = new JMenuItem(); |
---|
902 | m_jMenuHelp.add(jMenuItemHelpSysInfo); |
---|
903 | jMenuItemHelpSysInfo.setText("SystemInfo"); |
---|
904 | // jMenuItemHelpSysInfo.setMnemonic('S'); |
---|
905 | jMenuItemHelpSysInfo. |
---|
906 | setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.CTRL_MASK)); |
---|
907 | |
---|
908 | jMenuItemHelpSysInfo.addActionListener(new ActionListener() { |
---|
909 | public void actionPerformed(ActionEvent e) { |
---|
910 | if (m_SystemInfoFrame == null) { |
---|
911 | jMenuItemHelpSysInfo.setEnabled(false); |
---|
912 | m_SystemInfoFrame = new JFrame("SystemInfo"); |
---|
913 | m_SystemInfoFrame.setIconImage(m_Icon); |
---|
914 | m_SystemInfoFrame.getContentPane().setLayout(new BorderLayout()); |
---|
915 | |
---|
916 | // get info |
---|
917 | Hashtable info = new SystemInfo().getSystemInfo(); |
---|
918 | |
---|
919 | // sort names |
---|
920 | Vector names = new Vector(); |
---|
921 | Enumeration enm = info.keys(); |
---|
922 | while (enm.hasMoreElements()) |
---|
923 | names.add(enm.nextElement()); |
---|
924 | Collections.sort(names); |
---|
925 | |
---|
926 | // generate table |
---|
927 | String[][] data = new String[info.size()][2]; |
---|
928 | for (int i = 0; i < names.size(); i++) { |
---|
929 | data[i][0] = names.get(i).toString(); |
---|
930 | data[i][1] = info.get(data[i][0]).toString(); |
---|
931 | } |
---|
932 | String[] titles = new String[]{"Key", "Value"}; |
---|
933 | JTable table = new JTable(data, titles); |
---|
934 | |
---|
935 | m_SystemInfoFrame.getContentPane().add(new JScrollPane(table), BorderLayout.CENTER); |
---|
936 | m_SystemInfoFrame.addWindowListener(new WindowAdapter() { |
---|
937 | public void windowClosing(WindowEvent w) { |
---|
938 | m_SystemInfoFrame.dispose(); |
---|
939 | m_SystemInfoFrame = null; |
---|
940 | jMenuItemHelpSysInfo.setEnabled(true); |
---|
941 | checkExit(); |
---|
942 | } |
---|
943 | }); |
---|
944 | m_SystemInfoFrame.pack(); |
---|
945 | m_SystemInfoFrame.setSize(800, 600); |
---|
946 | m_SystemInfoFrame.setVisible(true); |
---|
947 | } |
---|
948 | } |
---|
949 | }); |
---|
950 | |
---|
951 | |
---|
952 | // applications |
---|
953 | |
---|
954 | m_ExplorerBut.addActionListener(new ActionListener() { |
---|
955 | public void actionPerformed(ActionEvent e) { |
---|
956 | if (m_ExplorerFrame == null) { |
---|
957 | m_ExplorerBut.setEnabled(false); |
---|
958 | m_ExplorerFrame = new JFrame("Weka Explorer"); |
---|
959 | m_ExplorerFrame.setIconImage(m_Icon); |
---|
960 | m_ExplorerFrame.getContentPane().setLayout(new BorderLayout()); |
---|
961 | m_ExplorerFrame.getContentPane().add(new Explorer(), BorderLayout.CENTER); |
---|
962 | m_ExplorerFrame.addWindowListener(new WindowAdapter() { |
---|
963 | public void windowClosing(WindowEvent w) { |
---|
964 | m_ExplorerFrame.dispose(); |
---|
965 | m_ExplorerFrame = null; |
---|
966 | m_ExplorerBut.setEnabled(true); |
---|
967 | checkExit(); |
---|
968 | } |
---|
969 | }); |
---|
970 | m_ExplorerFrame.pack(); |
---|
971 | m_ExplorerFrame.setSize(800, 600); |
---|
972 | m_ExplorerFrame.setVisible(true); |
---|
973 | } |
---|
974 | } |
---|
975 | }); |
---|
976 | |
---|
977 | m_ExperimenterBut.addActionListener(new ActionListener() { |
---|
978 | public void actionPerformed(ActionEvent e) { |
---|
979 | if (m_ExperimenterFrame == null) { |
---|
980 | m_ExperimenterBut.setEnabled(false); |
---|
981 | m_ExperimenterFrame = new JFrame("Weka Experiment Environment"); |
---|
982 | m_ExperimenterFrame.setIconImage(m_Icon); |
---|
983 | m_ExperimenterFrame.getContentPane().setLayout(new BorderLayout()); |
---|
984 | m_ExperimenterFrame.getContentPane() |
---|
985 | .add(new Experimenter(false), BorderLayout.CENTER); |
---|
986 | m_ExperimenterFrame.addWindowListener(new WindowAdapter() { |
---|
987 | public void windowClosing(WindowEvent w) { |
---|
988 | m_ExperimenterFrame.dispose(); |
---|
989 | m_ExperimenterFrame = null; |
---|
990 | m_ExperimenterBut.setEnabled(true); |
---|
991 | checkExit(); |
---|
992 | } |
---|
993 | }); |
---|
994 | m_ExperimenterFrame.pack(); |
---|
995 | m_ExperimenterFrame.setSize(800, 600); |
---|
996 | m_ExperimenterFrame.setVisible(true); |
---|
997 | } |
---|
998 | } |
---|
999 | }); |
---|
1000 | |
---|
1001 | KnowledgeFlowApp.addStartupListener(new weka.gui.beans.StartUpListener() { |
---|
1002 | public void startUpComplete() { |
---|
1003 | if (m_KnowledgeFlowFrame == null) { |
---|
1004 | final KnowledgeFlowApp kna = KnowledgeFlowApp.getSingleton(); |
---|
1005 | m_KnowledgeFlowBut.setEnabled(false); |
---|
1006 | m_KnowledgeFlowFrame = new JFrame("Weka KnowledgeFlow Environment"); |
---|
1007 | m_KnowledgeFlowFrame.setIconImage(m_Icon); |
---|
1008 | m_KnowledgeFlowFrame.getContentPane().setLayout(new BorderLayout()); |
---|
1009 | m_KnowledgeFlowFrame.getContentPane() |
---|
1010 | .add(kna, BorderLayout.CENTER); |
---|
1011 | m_KnowledgeFlowFrame.addWindowListener(new WindowAdapter() { |
---|
1012 | public void windowClosing(WindowEvent w) { |
---|
1013 | kna.clearLayout(); |
---|
1014 | m_KnowledgeFlowFrame.dispose(); |
---|
1015 | m_KnowledgeFlowFrame = null; |
---|
1016 | m_KnowledgeFlowBut.setEnabled(true); |
---|
1017 | checkExit(); |
---|
1018 | } |
---|
1019 | }); |
---|
1020 | m_KnowledgeFlowFrame.pack(); |
---|
1021 | m_KnowledgeFlowFrame.setSize(1000, 750); |
---|
1022 | m_KnowledgeFlowFrame.setVisible(true); |
---|
1023 | } |
---|
1024 | } |
---|
1025 | }); |
---|
1026 | |
---|
1027 | m_KnowledgeFlowBut.addActionListener(new ActionListener() { |
---|
1028 | public void actionPerformed(ActionEvent e) { |
---|
1029 | KnowledgeFlow.startApp(); |
---|
1030 | } |
---|
1031 | }); |
---|
1032 | |
---|
1033 | m_SimpleBut.addActionListener(new ActionListener() { |
---|
1034 | public void actionPerformed(ActionEvent e) { |
---|
1035 | if (m_SimpleCLI == null) { |
---|
1036 | m_SimpleBut.setEnabled(false); |
---|
1037 | try { |
---|
1038 | m_SimpleCLI = new SimpleCLI(); |
---|
1039 | m_SimpleCLI.setIconImage(m_Icon); |
---|
1040 | } catch (Exception ex) { |
---|
1041 | throw new Error("Couldn't start SimpleCLI!"); |
---|
1042 | } |
---|
1043 | m_SimpleCLI.addWindowListener(new WindowAdapter() { |
---|
1044 | public void windowClosing(WindowEvent w) { |
---|
1045 | m_SimpleCLI.dispose(); |
---|
1046 | m_SimpleCLI = null; |
---|
1047 | m_SimpleBut.setEnabled(true); |
---|
1048 | checkExit(); |
---|
1049 | } |
---|
1050 | }); |
---|
1051 | m_SimpleCLI.setVisible(true); |
---|
1052 | } |
---|
1053 | } |
---|
1054 | }); |
---|
1055 | |
---|
1056 | /*m_EnsembleLibraryBut.addActionListener(new ActionListener() { |
---|
1057 | public void actionPerformed(ActionEvent e) { |
---|
1058 | if (m_EnsembleLibraryFrame == null) { |
---|
1059 | m_EnsembleLibraryBut.setEnabled(false); |
---|
1060 | m_EnsembleLibraryFrame = new JFrame("EnsembleLibrary"); |
---|
1061 | m_EnsembleLibraryFrame.setIconImage(m_Icon); |
---|
1062 | m_EnsembleLibraryFrame.getContentPane().setLayout(new BorderLayout()); |
---|
1063 | EnsembleLibrary value = new EnsembleLibrary(); |
---|
1064 | EnsembleLibraryEditor libraryEditor = new EnsembleLibraryEditor(); |
---|
1065 | libraryEditor.setValue(value); |
---|
1066 | m_EnsembleLibraryFrame.getContentPane().add(libraryEditor.getCustomEditor(), BorderLayout.CENTER); |
---|
1067 | m_EnsembleLibraryFrame.addWindowListener(new WindowAdapter() { |
---|
1068 | public void windowClosing(WindowEvent w) { |
---|
1069 | m_EnsembleLibraryFrame.dispose(); |
---|
1070 | m_EnsembleLibraryFrame = null; |
---|
1071 | m_EnsembleLibraryBut.setEnabled(true); |
---|
1072 | checkExit(); |
---|
1073 | } |
---|
1074 | }); |
---|
1075 | m_EnsembleLibraryFrame.pack(); |
---|
1076 | m_EnsembleLibraryFrame.setSize(800, 600); |
---|
1077 | m_EnsembleLibraryFrame.setVisible(true); |
---|
1078 | } |
---|
1079 | } |
---|
1080 | }); */ |
---|
1081 | |
---|
1082 | setJMenuBar(m_jMenuBar); |
---|
1083 | |
---|
1084 | addWindowListener(new WindowAdapter() { |
---|
1085 | public void windowClosing(WindowEvent w) { |
---|
1086 | dispose(); |
---|
1087 | checkExit(); |
---|
1088 | } |
---|
1089 | }); |
---|
1090 | pack(); |
---|
1091 | } |
---|
1092 | |
---|
1093 | /** |
---|
1094 | * insert the menu item in a sorted fashion. |
---|
1095 | * |
---|
1096 | * @param menu the menu to add the item to |
---|
1097 | * @param menuitem the menu item to add |
---|
1098 | */ |
---|
1099 | protected void insertMenuItem(JMenu menu, JMenuItem menuitem) { |
---|
1100 | insertMenuItem(menu, menuitem, 0); |
---|
1101 | } |
---|
1102 | |
---|
1103 | /** |
---|
1104 | * insert the menu item in a sorted fashion. |
---|
1105 | * |
---|
1106 | * @param menu the menu to add the item to |
---|
1107 | * @param menuitem the menu item to add |
---|
1108 | * @param startIndex the index in the menu to start with (0-based) |
---|
1109 | */ |
---|
1110 | protected void insertMenuItem(JMenu menu, JMenuItem menuitem, int startIndex) { |
---|
1111 | boolean inserted; |
---|
1112 | int i; |
---|
1113 | JMenuItem current; |
---|
1114 | String currentStr; |
---|
1115 | String newStr; |
---|
1116 | |
---|
1117 | inserted = false; |
---|
1118 | newStr = menuitem.getText().toLowerCase(); |
---|
1119 | |
---|
1120 | // try to find a spot inbetween |
---|
1121 | for (i = startIndex; i < menu.getMenuComponentCount(); i++) { |
---|
1122 | if (!(menu.getMenuComponent(i) instanceof JMenuItem)) |
---|
1123 | continue; |
---|
1124 | |
---|
1125 | current = (JMenuItem) menu.getMenuComponent(i); |
---|
1126 | currentStr = current.getText().toLowerCase(); |
---|
1127 | if (currentStr.compareTo(newStr) > 0) { |
---|
1128 | inserted = true; |
---|
1129 | menu.insert(menuitem, i); |
---|
1130 | break; |
---|
1131 | } |
---|
1132 | } |
---|
1133 | |
---|
1134 | // add it at the end if not yet inserted |
---|
1135 | if (!inserted) |
---|
1136 | menu.add(menuitem); |
---|
1137 | } |
---|
1138 | |
---|
1139 | /** |
---|
1140 | * creates a frame and returns it. |
---|
1141 | * |
---|
1142 | * @param parent the parent of the generated frame |
---|
1143 | * @param title the title of the frame |
---|
1144 | * @param c the component to place, can be null |
---|
1145 | * @param layout the layout to use, e.g., BorderLayout |
---|
1146 | * @param layoutConstraints the layout constraints, e.g., BorderLayout.CENTER |
---|
1147 | * @param width the width of the frame, ignored if -1 |
---|
1148 | * @param height the height of the frame, ignored if -1 |
---|
1149 | * @param menu an optional menu |
---|
1150 | * @param listener if true a default listener is added |
---|
1151 | * @param visible if true then the frame is made visible immediately |
---|
1152 | * @return the generated frame |
---|
1153 | */ |
---|
1154 | protected Container createFrame( |
---|
1155 | GUIChooser parent, String title, Component c, LayoutManager layout, |
---|
1156 | Object layoutConstraints, int width, int height, JMenuBar menu, |
---|
1157 | boolean listener, boolean visible) { |
---|
1158 | |
---|
1159 | Container result = null; |
---|
1160 | |
---|
1161 | |
---|
1162 | final ChildFrameSDI frame = new ChildFrameSDI(parent, title); |
---|
1163 | |
---|
1164 | // layout |
---|
1165 | frame.setLayout(layout); |
---|
1166 | if (c != null) |
---|
1167 | frame.getContentPane().add(c, layoutConstraints); |
---|
1168 | |
---|
1169 | // menu |
---|
1170 | frame.setJMenuBar(menu); |
---|
1171 | |
---|
1172 | // size |
---|
1173 | frame.pack(); |
---|
1174 | if ((width > -1) && (height > -1)) |
---|
1175 | frame.setSize(width, height); |
---|
1176 | frame.validate(); |
---|
1177 | |
---|
1178 | // location |
---|
1179 | int screenHeight = getGraphicsConfiguration().getBounds().height; |
---|
1180 | int screenWidth = getGraphicsConfiguration().getBounds().width; |
---|
1181 | frame.setLocation( |
---|
1182 | (screenWidth - frame.getBounds().width) / 2, |
---|
1183 | (screenHeight - frame.getBounds().height) / 2); |
---|
1184 | |
---|
1185 | // listener? |
---|
1186 | if (listener) { |
---|
1187 | frame.addWindowListener(new WindowAdapter() { |
---|
1188 | public void windowClosing(WindowEvent e) { |
---|
1189 | frame.dispose(); |
---|
1190 | } |
---|
1191 | }); |
---|
1192 | } |
---|
1193 | |
---|
1194 | // display frame |
---|
1195 | if (visible) |
---|
1196 | frame.setVisible(true); |
---|
1197 | |
---|
1198 | result = frame; |
---|
1199 | |
---|
1200 | |
---|
1201 | return result; |
---|
1202 | } |
---|
1203 | |
---|
1204 | /** |
---|
1205 | * Specialized JFrame class. |
---|
1206 | * |
---|
1207 | * @author fracpete (fracpete at waikato dot ac dot nz) |
---|
1208 | * @version $Revision: 5837 $ |
---|
1209 | */ |
---|
1210 | public static class ChildFrameSDI |
---|
1211 | extends JFrame { |
---|
1212 | |
---|
1213 | /** for serialization. */ |
---|
1214 | private static final long serialVersionUID = 8588293938686425618L; |
---|
1215 | |
---|
1216 | /** the parent frame. */ |
---|
1217 | protected GUIChooser m_Parent; |
---|
1218 | |
---|
1219 | /** |
---|
1220 | * constructs a new internal frame that knows about its parent. |
---|
1221 | * |
---|
1222 | * @param parent the parent frame |
---|
1223 | * @param title the title of the frame |
---|
1224 | */ |
---|
1225 | public ChildFrameSDI(GUIChooser parent, String title) { |
---|
1226 | super(title); |
---|
1227 | |
---|
1228 | m_Parent = parent; |
---|
1229 | |
---|
1230 | addWindowListener(new WindowAdapter() { |
---|
1231 | public void windowActivated(WindowEvent e) { |
---|
1232 | // update title of parent |
---|
1233 | if (getParentFrame() != null) |
---|
1234 | getParentFrame().createTitle(getTitle()); |
---|
1235 | } |
---|
1236 | }); |
---|
1237 | |
---|
1238 | // add to parent |
---|
1239 | if (getParentFrame() != null) { |
---|
1240 | getParentFrame().addChildFrame(this); |
---|
1241 | setIconImage(getParentFrame().getIconImage()); |
---|
1242 | } |
---|
1243 | } |
---|
1244 | |
---|
1245 | /** |
---|
1246 | * returns the parent frame, can be null. |
---|
1247 | * |
---|
1248 | * @return the parent frame |
---|
1249 | */ |
---|
1250 | public GUIChooser getParentFrame() { |
---|
1251 | return m_Parent; |
---|
1252 | } |
---|
1253 | |
---|
1254 | /** |
---|
1255 | * de-registers the child frame with the parent first. |
---|
1256 | */ |
---|
1257 | public void dispose() { |
---|
1258 | if (getParentFrame() != null) { |
---|
1259 | getParentFrame().removeChildFrame(this); |
---|
1260 | getParentFrame().createTitle(""); |
---|
1261 | } |
---|
1262 | |
---|
1263 | super.dispose(); |
---|
1264 | } |
---|
1265 | } |
---|
1266 | |
---|
1267 | /** |
---|
1268 | * creates and displays the title. |
---|
1269 | * |
---|
1270 | * @param title the additional part of the title |
---|
1271 | */ |
---|
1272 | protected void createTitle(String title) { |
---|
1273 | String newTitle; |
---|
1274 | |
---|
1275 | newTitle = "Weka " + new Version(); |
---|
1276 | if (title.length() != 0) |
---|
1277 | newTitle += " - " + title; |
---|
1278 | |
---|
1279 | setTitle(newTitle); |
---|
1280 | } |
---|
1281 | |
---|
1282 | /** |
---|
1283 | * adds the given child frame to the list of frames. |
---|
1284 | * |
---|
1285 | * @param c the child frame to add |
---|
1286 | */ |
---|
1287 | public void addChildFrame(Container c) { |
---|
1288 | m_ChildFrames.add(c); |
---|
1289 | } |
---|
1290 | |
---|
1291 | /** |
---|
1292 | * tries to remove the child frame, it returns true if it could do such. |
---|
1293 | * |
---|
1294 | * @param c the child frame to remove |
---|
1295 | * @return true if the child frame could be removed |
---|
1296 | */ |
---|
1297 | public boolean removeChildFrame(Container c) { |
---|
1298 | boolean result = m_ChildFrames.remove(c); |
---|
1299 | return result; |
---|
1300 | } |
---|
1301 | |
---|
1302 | /** |
---|
1303 | * Kills the JVM if all windows have been closed. |
---|
1304 | */ |
---|
1305 | private void checkExit() { |
---|
1306 | |
---|
1307 | if (!isVisible() |
---|
1308 | // applications |
---|
1309 | && (m_ExplorerFrame == null) |
---|
1310 | && (m_ExperimenterFrame == null) |
---|
1311 | && (m_KnowledgeFlowFrame == null) |
---|
1312 | && (m_SimpleCLI == null) |
---|
1313 | // tools |
---|
1314 | && (m_ArffViewers.size() == 0) |
---|
1315 | && (m_SqlViewerFrame == null) |
---|
1316 | && (m_GroovyConsoleFrame == null) |
---|
1317 | && (m_JythonConsoleFrame == null) |
---|
1318 | && (m_EnsembleLibraryFrame == null) |
---|
1319 | // visualization |
---|
1320 | && (m_Plots.size() == 0) |
---|
1321 | && (m_ROCs.size() == 0) |
---|
1322 | && (m_TreeVisualizers.size() == 0) |
---|
1323 | && (m_GraphVisualizers.size() == 0) |
---|
1324 | && (m_BoundaryVisualizerFrame == null) |
---|
1325 | // help |
---|
1326 | && (m_SystemInfoFrame == null) ) { |
---|
1327 | System.exit(0); |
---|
1328 | } |
---|
1329 | } |
---|
1330 | |
---|
1331 | /** variable for the GUIChooser class which would be set to null by the memory |
---|
1332 | monitoring thread to free up some memory if we running out of memory |
---|
1333 | */ |
---|
1334 | private static GUIChooser m_chooser; |
---|
1335 | |
---|
1336 | /** for monitoring the Memory consumption */ |
---|
1337 | private static Memory m_Memory = new Memory(true); |
---|
1338 | |
---|
1339 | /** |
---|
1340 | * Tests out the GUIChooser environment. |
---|
1341 | * |
---|
1342 | * @param args ignored. |
---|
1343 | */ |
---|
1344 | public static void main(String [] args) { |
---|
1345 | |
---|
1346 | weka.core.logging.Logger.log(weka.core.logging.Logger.Level.INFO, "Logging started"); |
---|
1347 | LookAndFeel.setLookAndFeel(); |
---|
1348 | |
---|
1349 | try { |
---|
1350 | |
---|
1351 | // uncomment to disable the memory management: |
---|
1352 | //m_Memory.setEnabled(false); |
---|
1353 | |
---|
1354 | m_chooser = new GUIChooser(); |
---|
1355 | m_chooser.setVisible(true); |
---|
1356 | |
---|
1357 | Thread memMonitor = new Thread() { |
---|
1358 | public void run() { |
---|
1359 | while(true) { |
---|
1360 | try { |
---|
1361 | //System.out.println("before sleeping"); |
---|
1362 | this.sleep(4000); |
---|
1363 | |
---|
1364 | System.gc(); |
---|
1365 | |
---|
1366 | if (m_Memory.isOutOfMemory()) { |
---|
1367 | // clean up |
---|
1368 | m_chooser.dispose(); |
---|
1369 | if(m_chooser.m_ExperimenterFrame!=null) { |
---|
1370 | m_chooser.m_ExperimenterFrame.dispose(); |
---|
1371 | m_chooser.m_ExperimenterFrame =null; |
---|
1372 | } |
---|
1373 | if(m_chooser.m_ExplorerFrame!=null) { |
---|
1374 | m_chooser.m_ExplorerFrame.dispose(); |
---|
1375 | m_chooser.m_ExplorerFrame = null; |
---|
1376 | } |
---|
1377 | if(m_chooser.m_KnowledgeFlowFrame!=null) { |
---|
1378 | m_chooser.m_KnowledgeFlowFrame.dispose(); |
---|
1379 | m_chooser.m_KnowledgeFlowFrame = null; |
---|
1380 | } |
---|
1381 | if(m_chooser.m_SimpleCLI!=null) { |
---|
1382 | m_chooser.m_SimpleCLI.dispose(); |
---|
1383 | m_chooser.m_SimpleCLI = null; |
---|
1384 | } |
---|
1385 | if (m_chooser.m_ArffViewers.size() > 0) { |
---|
1386 | for (int i = 0; i < m_chooser.m_ArffViewers.size(); i++) { |
---|
1387 | ArffViewer av = (ArffViewer) |
---|
1388 | m_chooser.m_ArffViewers.get(i); |
---|
1389 | av.dispose(); |
---|
1390 | } |
---|
1391 | m_chooser.m_ArffViewers.clear(); |
---|
1392 | } |
---|
1393 | m_chooser = null; |
---|
1394 | System.gc(); |
---|
1395 | |
---|
1396 | // stop threads |
---|
1397 | m_Memory.stopThreads(); |
---|
1398 | |
---|
1399 | // display error |
---|
1400 | m_chooser.m_LogWindow.setVisible(true); |
---|
1401 | m_chooser.m_LogWindow.toFront(); |
---|
1402 | System.err.println("\ndisplayed message:"); |
---|
1403 | m_Memory.showOutOfMemory(); |
---|
1404 | System.err.println("\nexiting..."); |
---|
1405 | System.exit(-1); |
---|
1406 | } |
---|
1407 | } |
---|
1408 | catch(InterruptedException ex) { |
---|
1409 | ex.printStackTrace(); |
---|
1410 | } |
---|
1411 | } |
---|
1412 | } |
---|
1413 | }; |
---|
1414 | |
---|
1415 | memMonitor.setPriority(Thread.NORM_PRIORITY); |
---|
1416 | memMonitor.start(); |
---|
1417 | } catch (Exception ex) { |
---|
1418 | ex.printStackTrace(); |
---|
1419 | System.err.println(ex.getMessage()); |
---|
1420 | } |
---|
1421 | } |
---|
1422 | } |
---|