if (retVal != JFileChooser.APPROVE_OPTION)
return;
// build graph
String filename = m_FileChooserGraphVisualizer.getSelectedFile().getAbsolutePath();
GraphVisualizer panel = new GraphVisualizer();
try{
if ( filename.toLowerCase().endsWith(".xml")
|| filename.toLowerCase().endsWith(".bif") ) {
panel.readBIF(new FileInputStream(filename));
}
else {
panel.readDOT(new FileReader(filename));
}
}
catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(
m_Self, "Error loading file '" + filename + "':\n" + ex.getMessage());
return;
}
// create frame
final JFrame frame = new JFrame("GraphVisualizer - " + filename);
frame.setIconImage(m_Icon);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(panel, BorderLayout.CENTER);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
m_GraphVisualizers.remove(frame);
frame.dispose();
checkExit();
}
});
frame.pack();
frame.setSize(800, 600);
frame.setVisible(true);
m_GraphVisualizers.add(frame);
}
});
m_BoundaryVisualizerBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (m_BoundaryVisualizerFrame == null) {
m_BoundaryVisualizerBut.setEnabled(false);
m_BoundaryVisualizerFrame = new JFrame("BoundaryVisualizer");
m_BoundaryVisualizerFrame.setIconImage(m_Icon);
m_BoundaryVisualizerFrame.getContentPane().setLayout(new BorderLayout());
m_BoundaryVisualizerFrame.getContentPane().add(new BoundaryVisualizer(), BorderLayout.CENTER);
m_BoundaryVisualizerFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent w) {
m_BoundaryVisualizerFrame.dispose();
m_BoundaryVisualizerFrame = null;
m_BoundaryVisualizerBut.setEnabled(true);
checkExit();
}
});
m_BoundaryVisualizerFrame.pack();
m_BoundaryVisualizerFrame.setSize(800, 600);
m_BoundaryVisualizerFrame.setVisible(true);
// dont' do a System.exit after last window got closed!
BoundaryVisualizer.setExitIfNoWindowsOpen(false);
}
}
});
// help
m_HomepageBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
BrowserHelper.openURL("http://www.cs.waikato.ac.nz/~ml/weka/");
}
});
m_WekaDocBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
BrowserHelper.openURL("http://weka.sourceforge.net/wekadoc/");
}
});
m_WekaWikiBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
BrowserHelper.openURL("http://weka.sourceforge.net/wiki/");
}
});
m_SourceforgeBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
BrowserHelper.openURL("http://sourceforge.net/projects/weka/");
}
});
m_SystemInfoBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (m_SystemInfoFrame == null) {
m_SystemInfoBut.setEnabled(false);
m_SystemInfoFrame = new JFrame("SystemInfo");
m_SystemInfoFrame.setIconImage(m_Icon);
m_SystemInfoFrame.getContentPane().setLayout(new BorderLayout());
// get info
Hashtable info = new SystemInfo().getSystemInfo();
// sort names
Vector names = new Vector();
Enumeration enm = info.keys();
while (enm.hasMoreElements())
names.add(enm.nextElement());
Collections.sort(names);
// generate table
String[][] data = new String[info.size()][2];
for (int i = 0; i < names.size(); i++) {
data[i][0] = names.get(i).toString();
data[i][1] = info.get(data[i][0]).toString();
}
String[] titles = new String[]{"Key", "Value"};
JTable table = new JTable(data, titles);
m_SystemInfoFrame.getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);
m_SystemInfoFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent w) {
m_SystemInfoFrame.dispose();
m_SystemInfoFrame = null;
m_SystemInfoBut.setEnabled(true);
checkExit();
}
});
m_SystemInfoFrame.pack();
m_SystemInfoFrame.setSize(800, 600);
m_SystemInfoFrame.setVisible(true);
}
}
});
// other
m_LogWindow.setIconImage(m_Icon);
m_LogWindowBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
m_LogWindow.setVisible(true);
}
});
m_MemoryUsageBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (m_MemoryUsageFrame == null) {
final MemoryUsagePanel panel = new MemoryUsagePanel();
m_MemoryUsageBut.setEnabled(false);
m_MemoryUsageFrame = new JFrame("Memory usage");
m_MemoryUsageFrame.setIconImage(m_Icon);
m_MemoryUsageFrame.getContentPane().setLayout(new BorderLayout());
m_MemoryUsageFrame.getContentPane().add(panel, BorderLayout.CENTER);
m_MemoryUsageFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent w) {
panel.stopMonitoring();
m_MemoryUsageFrame.dispose();
m_MemoryUsageFrame = null;
m_MemoryUsageBut.setEnabled(true);
checkExit();
}
});
m_MemoryUsageFrame.pack();
m_MemoryUsageFrame.setSize(400, 50);
Point l = panel.getFrameLocation();
if ((l.x != -1) && (l.y != -1))
m_MemoryUsageFrame.setLocation(l);
m_MemoryUsageFrame.setVisible(true);
Dimension size = m_MemoryUsageFrame.getPreferredSize();
m_MemoryUsageFrame.setSize(new Dimension((int) size.getWidth(), (int) size.getHeight()));