int retVal = m_FileChooserPlot.showOpenDialog(m_Self);
if (retVal != JFileChooser.APPROVE_OPTION)
return;
// build plot
VisualizePanel panel = new VisualizePanel();
String filenames = "";
File[] files = m_FileChooserPlot.getSelectedFiles();
for (int j = 0; j < files.length; j++) {
String filename = files[j].getAbsolutePath();
if (j > 0)
filenames += ", ";
filenames += filename;
System.err.println(Messages.getInstance().getString("GUIChooser_LoadingInstancesFrom_Error_Text") + filename);
try {
Reader r = new java.io.BufferedReader(new FileReader(filename));
Instances i = new Instances(r);
i.setClassIndex(i.numAttributes()-1);
PlotData2D pd1 = new PlotData2D(i);
if (j == 0) {
pd1.setPlotName(Messages.getInstance().getString("GUIChooser_MasterPlot_Text"));
panel.setMasterPlot(pd1);
} else {
pd1.setPlotName(Messages.getInstance().getString("GUIChooser_Plot_Text") + (j+1));
pd1.m_useCustomColour = true;
pd1.m_customColour = (j % 2 == 0) ? Color.red : Color.blue;
panel.addPlot(pd1);
}
}
catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(
m_Self, Messages.getInstance().getString("GUIChooser_Plot_LoadingFile_Error_Text_Front") + files[j] + Messages.getInstance().getString("GUIChooser_Plot_LoadingFile_Error_Text_End") + ex.getMessage());
return;
}
}
// create frame
final JFrame frame = new JFrame(Messages.getInstance().getString("GUIChooser_Plot_PlotName_Text") + filenames);
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_Plots.remove(frame);
frame.dispose();
checkExit();
}
});
frame.pack();
frame.setSize(800, 600);
frame.setVisible(true);
m_Plots.add(frame);
}
});
// Visualization/ROC
JMenuItem jMenuItemVisualizationROC = new JMenuItem();
m_jMenuVisualization.add(jMenuItemVisualizationROC);
jMenuItemVisualizationROC.setText(Messages.getInstance().getString("GUIChooser_ROC_Text"));
// jMenuItemVisualizationROC.setMnemonic('R');
jMenuItemVisualizationROC.
setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.CTRL_MASK));
jMenuItemVisualizationROC.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// choose file
int retVal = m_FileChooserROC.showOpenDialog(m_Self);
if (retVal != JFileChooser.APPROVE_OPTION)
return;
// create plot
String filename = m_FileChooserROC.getSelectedFile().getAbsolutePath();
Instances result = null;
try {
result = new Instances(new BufferedReader(new FileReader(filename)));
}
catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(
m_Self, Messages.getInstance().getString("GUIChooser_ROC_LoadingFile_Error_Text_Front") + filename + Messages.getInstance().getString("GUIChooser_ROC_LoadingFile_Error_Text_End") + ex.getMessage());
return;
}
result.setClassIndex(result.numAttributes() - 1);
ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
vmc.setROCString(Messages.getInstance().getString("GUIChooser_ROC_AreaUnderROC_Text_Front") +
Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + Messages.getInstance().getString("GUIChooser_ROC_AreaUnderROC_Text_End"));
vmc.setName(result.relationName());
PlotData2D tempd = new PlotData2D(result);
tempd.setPlotName(result.relationName());
tempd.addInstanceNumberAttribute();
try {
vmc.addPlot(tempd);
}
catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(
m_Self, Messages.getInstance().getString("GUIChooser_ROC_AddingPlot_Error_Text") + ex.getMessage());
return;
}
final JFrame frame = new JFrame(Messages.getInstance().getString("GUIChooser_ROC_File_Text") + filename);
frame.setIconImage(m_Icon);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(vmc, BorderLayout.CENTER);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
m_ROCs.remove(frame);
frame.dispose();
checkExit();
}
});
frame.pack();
frame.setSize(800, 600);
frame.setVisible(true);
m_ROCs.add(frame);
}
});
// Visualization/TreeVisualizer
JMenuItem jMenuItemVisualizationTree = new JMenuItem();
m_jMenuVisualization.add(jMenuItemVisualizationTree);
jMenuItemVisualizationTree.setText(Messages.getInstance().getString("GUIChooser_TreeVisualizer_Text"));
// jMenuItemVisualizationTree.setMnemonic('T');
jMenuItemVisualizationTree.
setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_MASK));
jMenuItemVisualizationTree.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// choose file
int retVal = m_FileChooserTreeVisualizer.showOpenDialog(m_Self);
if (retVal != JFileChooser.APPROVE_OPTION)
return;
// build tree
String filename = m_FileChooserTreeVisualizer.getSelectedFile().getAbsolutePath();
TreeBuild builder = new TreeBuild();
Node top = null;
NodePlace arrange = new PlaceNode2();
try {
top = builder.create(new FileReader(filename));
}
catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(
m_Self, Messages.getInstance().getString("GUIChooser_TreeVisualizer_LoadingFile_Error_Text_Front") + filename + Messages.getInstance().getString("GUIChooser_TreeVisualizer_LoadingFile_Error_Text_End") + ex.getMessage());
return;
}
// create frame
final JFrame frame = new JFrame(Messages.getInstance().getString("GUIChooser_TreeVisualizer_File_Text") + filename);
frame.setIconImage(m_Icon);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(new TreeVisualizer(null, top, arrange), BorderLayout.CENTER);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
m_TreeVisualizers.remove(frame);
frame.dispose();
checkExit();
}
});
frame.pack();
frame.setSize(800, 600);
frame.setVisible(true);
m_TreeVisualizers.add(frame);
}
});
// Visualization/GraphVisualizer
JMenuItem jMenuItemVisualizationGraph = new JMenuItem();
m_jMenuVisualization.add(jMenuItemVisualizationGraph);
jMenuItemVisualizationGraph.setText(Messages.getInstance().getString("GUIChooser_GraphVisualizer_Text"));
// jMenuItemVisualizationGraph.setMnemonic('G');
jMenuItemVisualizationGraph.
setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, KeyEvent.CTRL_MASK));
jMenuItemVisualizationGraph.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// choose file
int retVal = m_FileChooserGraphVisualizer.showOpenDialog(m_Self);
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(