[4] | 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 | * ResultsPanel.java |
---|
| 19 | * Copyright (C) 1999 University of Waikato, Hamilton, New Zealand |
---|
| 20 | * |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | package weka.gui.experiment; |
---|
| 24 | |
---|
| 25 | import java.awt.BorderLayout; |
---|
| 26 | import java.awt.Dimension; |
---|
| 27 | import java.awt.Font; |
---|
| 28 | import java.awt.GridBagConstraints; |
---|
| 29 | import java.awt.GridBagLayout; |
---|
| 30 | import java.awt.GridLayout; |
---|
| 31 | import java.awt.Insets; |
---|
| 32 | import java.awt.event.ActionEvent; |
---|
| 33 | import java.awt.event.ActionListener; |
---|
| 34 | import java.awt.event.WindowAdapter; |
---|
| 35 | import java.awt.event.WindowEvent; |
---|
| 36 | import java.io.BufferedReader; |
---|
| 37 | import java.io.File; |
---|
| 38 | import java.io.FileReader; |
---|
| 39 | import java.io.Reader; |
---|
| 40 | import java.text.SimpleDateFormat; |
---|
| 41 | import java.util.Date; |
---|
| 42 | import java.util.StringTokenizer; |
---|
| 43 | import java.util.Vector; |
---|
| 44 | |
---|
| 45 | import javax.swing.BorderFactory; |
---|
| 46 | import javax.swing.DefaultComboBoxModel; |
---|
| 47 | import javax.swing.DefaultListModel; |
---|
| 48 | import javax.swing.JButton; |
---|
| 49 | import javax.swing.JCheckBox; |
---|
| 50 | import javax.swing.JComboBox; |
---|
| 51 | import javax.swing.JFileChooser; |
---|
| 52 | import javax.swing.JFrame; |
---|
| 53 | import javax.swing.JLabel; |
---|
| 54 | import javax.swing.JList; |
---|
| 55 | import javax.swing.JOptionPane; |
---|
| 56 | import javax.swing.JPanel; |
---|
| 57 | import javax.swing.JScrollPane; |
---|
| 58 | import javax.swing.JSplitPane; |
---|
| 59 | import javax.swing.JTextArea; |
---|
| 60 | import javax.swing.JTextField; |
---|
| 61 | import javax.swing.ListSelectionModel; |
---|
| 62 | import javax.swing.SwingConstants; |
---|
| 63 | import javax.swing.SwingUtilities; |
---|
| 64 | |
---|
| 65 | import weka.core.Attribute; |
---|
| 66 | import weka.core.ClassDiscovery; |
---|
| 67 | import weka.core.Instance; |
---|
| 68 | import weka.core.Instances; |
---|
| 69 | import weka.core.Range; |
---|
| 70 | import weka.core.converters.CSVLoader; |
---|
| 71 | import weka.experiment.CSVResultListener; |
---|
| 72 | import weka.experiment.DatabaseResultListener; |
---|
| 73 | import weka.experiment.Experiment; |
---|
| 74 | import weka.experiment.InstanceQuery; |
---|
| 75 | import weka.experiment.PairedCorrectedTTester; |
---|
| 76 | import weka.experiment.ResultMatrix; |
---|
| 77 | import weka.experiment.ResultMatrixPlainText; |
---|
| 78 | import weka.experiment.Tester; |
---|
| 79 | import weka.gui.DatabaseConnectionDialog; |
---|
| 80 | import weka.gui.ExtensionFileFilter; |
---|
| 81 | import weka.gui.GenericObjectEditor; |
---|
| 82 | import weka.gui.ListSelectorDialog; |
---|
| 83 | import weka.gui.PropertyDialog; |
---|
| 84 | import weka.gui.ResultHistoryPanel; |
---|
| 85 | import weka.gui.SaveBuffer; |
---|
| 86 | |
---|
| 87 | /** |
---|
| 88 | * This panel controls simple analysis of experimental results. |
---|
| 89 | * |
---|
| 90 | * @author Len Trigg (trigg@cs.waikato.ac.nz) |
---|
| 91 | * @version $Revision: 6087 $ |
---|
| 92 | */ |
---|
| 93 | public class ResultsPanel |
---|
| 94 | extends JPanel { |
---|
| 95 | |
---|
| 96 | /** for serialization. */ |
---|
| 97 | private static final long serialVersionUID = -4913007978534178569L; |
---|
| 98 | |
---|
| 99 | /** Message shown when no experimental results have been loaded. */ |
---|
| 100 | protected static final String NO_SOURCE = "No source"; |
---|
| 101 | |
---|
| 102 | /** Click to load results from a file. */ |
---|
| 103 | protected JButton m_FromFileBut = new JButton("File..."); |
---|
| 104 | |
---|
| 105 | /** Click to load results from a database. */ |
---|
| 106 | protected JButton m_FromDBaseBut = new JButton("Database..."); |
---|
| 107 | |
---|
| 108 | /** Click to get results from the destination given in the experiment. */ |
---|
| 109 | protected JButton m_FromExpBut = new JButton("Experiment"); |
---|
| 110 | |
---|
| 111 | /** Displays a message about the current result set. */ |
---|
| 112 | protected JLabel m_FromLab = new JLabel(NO_SOURCE); |
---|
| 113 | |
---|
| 114 | /** |
---|
| 115 | * This is needed to get around a bug in Swing <= 1.1 -- Once everyone |
---|
| 116 | * is using Swing 1.1.1 or higher just remove this variable and use the |
---|
| 117 | * no-arg constructor to DefaultComboBoxModel. |
---|
| 118 | */ |
---|
| 119 | private static String [] FOR_JFC_1_1_DCBM_BUG = {""}; |
---|
| 120 | |
---|
| 121 | /** The model embedded in m_DatasetCombo. */ |
---|
| 122 | protected DefaultComboBoxModel m_DatasetModel = |
---|
| 123 | new DefaultComboBoxModel(FOR_JFC_1_1_DCBM_BUG); |
---|
| 124 | |
---|
| 125 | /** The model embedded in m_CompareCombo. */ |
---|
| 126 | protected DefaultComboBoxModel m_CompareModel = |
---|
| 127 | new DefaultComboBoxModel(FOR_JFC_1_1_DCBM_BUG); |
---|
| 128 | |
---|
| 129 | /** The model embedded in m_SortCombo. */ |
---|
| 130 | protected DefaultComboBoxModel m_SortModel = |
---|
| 131 | new DefaultComboBoxModel(FOR_JFC_1_1_DCBM_BUG); |
---|
| 132 | |
---|
| 133 | /** The model embedded in m_TestsList. */ |
---|
| 134 | protected DefaultListModel m_TestsModel = new DefaultListModel(); |
---|
| 135 | |
---|
| 136 | /** The model embedded in m_DisplayedList. */ |
---|
| 137 | protected DefaultListModel m_DisplayedModel = new DefaultListModel(); |
---|
| 138 | |
---|
| 139 | /** Displays the currently selected Tester-Class. */ |
---|
| 140 | protected JLabel m_TesterClassesLabel = new JLabel("Testing with", |
---|
| 141 | SwingConstants.RIGHT); |
---|
| 142 | |
---|
| 143 | /** Contains all the available classes implementing the Tester-Interface |
---|
| 144 | * (the display names). |
---|
| 145 | * @see Tester */ |
---|
| 146 | protected static DefaultComboBoxModel m_TesterClassesModel = |
---|
| 147 | new DefaultComboBoxModel(FOR_JFC_1_1_DCBM_BUG); |
---|
| 148 | |
---|
| 149 | /** Contains all the available classes implementing the Tester-Interface |
---|
| 150 | * (the actual Classes). |
---|
| 151 | * @see Tester */ |
---|
| 152 | protected static Vector m_Testers = null; |
---|
| 153 | |
---|
| 154 | /** determine all classes implementing the Tester interface (in the same |
---|
| 155 | * package!). |
---|
| 156 | * @see Tester |
---|
| 157 | * @see ClassDiscovery */ |
---|
| 158 | static { |
---|
| 159 | Vector classes = GenericObjectEditor.getClassnames(Tester.class.getName()); |
---|
| 160 | |
---|
| 161 | // set names and classes |
---|
| 162 | m_Testers = new Vector(); |
---|
| 163 | m_TesterClassesModel = new DefaultComboBoxModel(); |
---|
| 164 | for (int i = 0; i < classes.size(); i++) { |
---|
| 165 | try { |
---|
| 166 | Class cls = Class.forName(classes.get(i).toString()); |
---|
| 167 | Tester tester = (Tester) cls.newInstance(); |
---|
| 168 | m_Testers.add(cls); |
---|
| 169 | m_TesterClassesModel.addElement(tester.getDisplayName()); |
---|
| 170 | } |
---|
| 171 | catch (Exception e) { |
---|
| 172 | e.printStackTrace(); |
---|
| 173 | } |
---|
| 174 | } |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | /** Lists all the available classes implementing the Tester-Interface. |
---|
| 178 | * @see Tester */ |
---|
| 179 | protected JComboBox m_TesterClasses = |
---|
| 180 | new JComboBox(m_TesterClassesModel); |
---|
| 181 | |
---|
| 182 | /** Label for the dataset and result key buttons. */ |
---|
| 183 | protected JLabel m_DatasetAndResultKeysLabel = new JLabel("Select rows and cols", |
---|
| 184 | SwingConstants.RIGHT); |
---|
| 185 | |
---|
| 186 | /** the panel encapsulating the Rows/Columns/Swap buttons. */ |
---|
| 187 | protected JPanel m_PanelDatasetResultKeys = new JPanel(new GridLayout(1, 3)); |
---|
| 188 | |
---|
| 189 | /** Click to edit the columns used to determine the scheme. */ |
---|
| 190 | protected JButton m_DatasetKeyBut = new JButton("Rows"); |
---|
| 191 | |
---|
| 192 | /** Stores the list of attributes for selecting the scheme columns. */ |
---|
| 193 | protected DefaultListModel m_DatasetKeyModel = new DefaultListModel(); |
---|
| 194 | |
---|
| 195 | /** Displays the list of selected columns determining the scheme. */ |
---|
| 196 | protected JList m_DatasetKeyList = new JList(m_DatasetKeyModel); |
---|
| 197 | |
---|
| 198 | /** Click to edit the columns used to determine the scheme. */ |
---|
| 199 | protected JButton m_ResultKeyBut = new JButton("Cols"); |
---|
| 200 | |
---|
| 201 | /** For swapping rows and columns. */ |
---|
| 202 | protected JButton m_SwapDatasetKeyAndResultKeyBut = new JButton("Swap"); |
---|
| 203 | |
---|
| 204 | /** Stores the list of attributes for selecting the scheme columns. */ |
---|
| 205 | protected DefaultListModel m_ResultKeyModel = new DefaultListModel(); |
---|
| 206 | |
---|
| 207 | /** Displays the list of selected columns determining the scheme. */ |
---|
| 208 | protected JList m_ResultKeyList = new JList(m_ResultKeyModel); |
---|
| 209 | |
---|
| 210 | /** Lets the user select which scheme to base comparisons against. */ |
---|
| 211 | protected JButton m_TestsButton = new JButton("Select"); |
---|
| 212 | |
---|
| 213 | /** Lets the user select which schemes are compared to base. */ |
---|
| 214 | protected JButton m_DisplayedButton = new JButton("Select"); |
---|
| 215 | |
---|
| 216 | /** Holds the list of schemes to base the test against. */ |
---|
| 217 | protected JList m_TestsList = new JList(m_TestsModel); |
---|
| 218 | |
---|
| 219 | /** Holds the list of schemes to display. */ |
---|
| 220 | protected JList m_DisplayedList = new JList(m_DisplayedModel); |
---|
| 221 | |
---|
| 222 | /** Lets the user select which performance measure to analyze. */ |
---|
| 223 | protected JComboBox m_CompareCombo = new JComboBox(m_CompareModel); |
---|
| 224 | |
---|
| 225 | /** Lets the user select which column to use for sorting. */ |
---|
| 226 | protected JComboBox m_SortCombo = new JComboBox(m_SortModel); |
---|
| 227 | |
---|
| 228 | /** Lets the user edit the test significance. */ |
---|
| 229 | protected JTextField m_SigTex = new JTextField( |
---|
| 230 | "" + ExperimenterDefaults.getSignificance()); |
---|
| 231 | |
---|
| 232 | /** Lets the user select whether standard deviations are to be output |
---|
| 233 | or not. */ |
---|
| 234 | protected JCheckBox m_ShowStdDevs = |
---|
| 235 | new JCheckBox(""); |
---|
| 236 | |
---|
| 237 | /** lets the user choose the format for the output. */ |
---|
| 238 | protected JButton m_OutputFormatButton = new JButton("Select"); |
---|
| 239 | |
---|
| 240 | /** Click to start the test. */ |
---|
| 241 | protected JButton m_PerformBut = new JButton("Perform test"); |
---|
| 242 | |
---|
| 243 | /** Click to save test output to a file. */ |
---|
| 244 | protected JButton m_SaveOutBut = new JButton("Save output"); |
---|
| 245 | |
---|
| 246 | /** The buffer saving object for saving output. */ |
---|
| 247 | SaveBuffer m_SaveOut = new SaveBuffer(null, this); |
---|
| 248 | |
---|
| 249 | /** Displays the output of tests. */ |
---|
| 250 | protected JTextArea m_OutText = new JTextArea(); |
---|
| 251 | |
---|
| 252 | /** A panel controlling results viewing. */ |
---|
| 253 | protected ResultHistoryPanel m_History = new ResultHistoryPanel(m_OutText); |
---|
| 254 | |
---|
| 255 | /** The file chooser for selecting result files. */ |
---|
| 256 | protected JFileChooser m_FileChooser = new JFileChooser(new File(System.getProperty("user.dir"))); |
---|
| 257 | |
---|
| 258 | // File filters for various file types. |
---|
| 259 | /** CSV file filter. */ |
---|
| 260 | protected ExtensionFileFilter m_csvFileFilter = |
---|
| 261 | new ExtensionFileFilter(CSVLoader.FILE_EXTENSION, "CSV data files"); |
---|
| 262 | |
---|
| 263 | /** ARFF file filter. */ |
---|
| 264 | protected ExtensionFileFilter m_arffFileFilter = |
---|
| 265 | new ExtensionFileFilter(Instances.FILE_EXTENSION, "Arff data files"); |
---|
| 266 | |
---|
| 267 | /** The PairedTTester object. */ |
---|
| 268 | protected Tester m_TTester = new PairedCorrectedTTester(); |
---|
| 269 | |
---|
| 270 | /** The instances we're extracting results from. */ |
---|
| 271 | protected Instances m_Instances; |
---|
| 272 | |
---|
| 273 | /** Does any database querying for us. */ |
---|
| 274 | protected InstanceQuery m_InstanceQuery; |
---|
| 275 | |
---|
| 276 | /** A thread to load results instances from a file or database. */ |
---|
| 277 | protected Thread m_LoadThread; |
---|
| 278 | |
---|
| 279 | /** An experiment (used for identifying a result source) -- optional. */ |
---|
| 280 | protected Experiment m_Exp; |
---|
| 281 | |
---|
| 282 | /** the size for a combobox. */ |
---|
| 283 | private Dimension COMBO_SIZE = new Dimension(210, m_ResultKeyBut.getPreferredSize().height); |
---|
| 284 | |
---|
| 285 | /** the initial result matrix. */ |
---|
| 286 | protected ResultMatrix m_ResultMatrix = new ResultMatrixPlainText(); |
---|
| 287 | |
---|
| 288 | /** |
---|
| 289 | * Creates the results panel with no initial experiment. |
---|
| 290 | */ |
---|
| 291 | public ResultsPanel() { |
---|
| 292 | |
---|
| 293 | // defaults |
---|
| 294 | m_TTester.setSignificanceLevel(ExperimenterDefaults.getSignificance()); |
---|
| 295 | m_TTester.setShowStdDevs(ExperimenterDefaults.getShowStdDevs()); |
---|
| 296 | m_ResultMatrix = ExperimenterDefaults.getOutputFormat(); |
---|
| 297 | m_ResultMatrix.setShowStdDev(ExperimenterDefaults.getShowStdDevs()); |
---|
| 298 | m_ResultMatrix.setMeanPrec(ExperimenterDefaults.getMeanPrecision()); |
---|
| 299 | m_ResultMatrix.setStdDevPrec(ExperimenterDefaults.getStdDevPrecision()); |
---|
| 300 | m_ResultMatrix.setRemoveFilterName(ExperimenterDefaults.getRemoveFilterClassnames()); |
---|
| 301 | m_ResultMatrix.setShowAverage(ExperimenterDefaults.getShowAverage()); |
---|
| 302 | |
---|
| 303 | // Create/Configure/Connect components |
---|
| 304 | |
---|
| 305 | m_FileChooser. |
---|
| 306 | addChoosableFileFilter(m_csvFileFilter); |
---|
| 307 | m_FileChooser. |
---|
| 308 | addChoosableFileFilter(m_arffFileFilter); |
---|
| 309 | |
---|
| 310 | m_FileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); |
---|
| 311 | m_FromExpBut.setEnabled(false); |
---|
| 312 | m_FromExpBut.setMnemonic('E'); |
---|
| 313 | m_FromExpBut.addActionListener(new ActionListener() { |
---|
| 314 | public void actionPerformed(ActionEvent e) { |
---|
| 315 | if (m_LoadThread == null) { |
---|
| 316 | m_LoadThread = new Thread() { |
---|
| 317 | public void run() { |
---|
| 318 | setInstancesFromExp(m_Exp); |
---|
| 319 | m_LoadThread = null; |
---|
| 320 | } |
---|
| 321 | }; |
---|
| 322 | m_LoadThread.start(); |
---|
| 323 | } |
---|
| 324 | } |
---|
| 325 | }); |
---|
| 326 | m_FromDBaseBut.setMnemonic('D'); |
---|
| 327 | m_FromDBaseBut.addActionListener(new ActionListener() { |
---|
| 328 | public void actionPerformed(ActionEvent e) { |
---|
| 329 | if (m_LoadThread == null) { |
---|
| 330 | m_LoadThread = new Thread() { |
---|
| 331 | public void run() { |
---|
| 332 | setInstancesFromDBaseQuery(); |
---|
| 333 | m_LoadThread = null; |
---|
| 334 | } |
---|
| 335 | }; |
---|
| 336 | m_LoadThread.start(); |
---|
| 337 | } |
---|
| 338 | } |
---|
| 339 | }); |
---|
| 340 | m_FromFileBut.setMnemonic('F'); |
---|
| 341 | m_FromFileBut.addActionListener(new ActionListener() { |
---|
| 342 | public void actionPerformed(ActionEvent e) { |
---|
| 343 | int returnVal = m_FileChooser.showOpenDialog(ResultsPanel.this); |
---|
| 344 | if (returnVal == JFileChooser.APPROVE_OPTION) { |
---|
| 345 | final File selected = m_FileChooser.getSelectedFile(); |
---|
| 346 | if (m_LoadThread == null) { |
---|
| 347 | m_LoadThread = new Thread() { |
---|
| 348 | public void run() { |
---|
| 349 | setInstancesFromFile(selected); |
---|
| 350 | m_LoadThread = null; |
---|
| 351 | } |
---|
| 352 | }; |
---|
| 353 | m_LoadThread.start(); |
---|
| 354 | } |
---|
| 355 | } |
---|
| 356 | } |
---|
| 357 | }); |
---|
| 358 | setComboSizes(); |
---|
| 359 | m_TesterClasses.setEnabled(false); |
---|
| 360 | m_DatasetKeyBut.setEnabled(false); |
---|
| 361 | m_DatasetKeyBut.setToolTipText("For selecting the keys that are shown as rows."); |
---|
| 362 | m_DatasetKeyBut.addActionListener(new ActionListener() { |
---|
| 363 | public void actionPerformed(ActionEvent e) { |
---|
| 364 | setDatasetKeyFromDialog(); |
---|
| 365 | } |
---|
| 366 | }); |
---|
| 367 | m_DatasetKeyList.setSelectionMode(ListSelectionModel |
---|
| 368 | .MULTIPLE_INTERVAL_SELECTION); |
---|
| 369 | m_ResultKeyBut.setEnabled(false); |
---|
| 370 | m_ResultKeyBut.setToolTipText("For selecting the keys that are shown as columns."); |
---|
| 371 | m_ResultKeyBut.addActionListener(new ActionListener() { |
---|
| 372 | public void actionPerformed(ActionEvent e) { |
---|
| 373 | setResultKeyFromDialog(); |
---|
| 374 | } |
---|
| 375 | }); |
---|
| 376 | m_ResultKeyList.setSelectionMode(ListSelectionModel |
---|
| 377 | .MULTIPLE_INTERVAL_SELECTION); |
---|
| 378 | m_SwapDatasetKeyAndResultKeyBut.setEnabled(false); |
---|
| 379 | m_SwapDatasetKeyAndResultKeyBut.setToolTipText("Swaps the keys for selecting rows and columns."); |
---|
| 380 | m_SwapDatasetKeyAndResultKeyBut.addActionListener(new ActionListener() { |
---|
| 381 | public void actionPerformed(ActionEvent e) { |
---|
| 382 | swapDatasetKeyAndResultKey(); |
---|
| 383 | } |
---|
| 384 | }); |
---|
| 385 | m_CompareCombo.setEnabled(false); |
---|
| 386 | m_SortCombo.setEnabled(false); |
---|
| 387 | |
---|
| 388 | m_SigTex.setEnabled(false); |
---|
| 389 | m_TestsButton.setEnabled(false); |
---|
| 390 | m_TestsButton.addActionListener(new ActionListener() { |
---|
| 391 | public void actionPerformed(ActionEvent e) { |
---|
| 392 | setTestBaseFromDialog(); |
---|
| 393 | } |
---|
| 394 | }); |
---|
| 395 | |
---|
| 396 | m_DisplayedButton.setEnabled(false); |
---|
| 397 | m_DisplayedButton.addActionListener(new ActionListener() { |
---|
| 398 | public void actionPerformed(ActionEvent e) { |
---|
| 399 | setDisplayedFromDialog(); |
---|
| 400 | } |
---|
| 401 | }); |
---|
| 402 | |
---|
| 403 | m_ShowStdDevs.setEnabled(false); |
---|
| 404 | m_ShowStdDevs.setSelected(ExperimenterDefaults.getShowStdDevs()); |
---|
| 405 | m_OutputFormatButton.setEnabled(false); |
---|
| 406 | m_OutputFormatButton.addActionListener(new ActionListener() { |
---|
| 407 | public void actionPerformed(ActionEvent e) { |
---|
| 408 | setOutputFormatFromDialog(); |
---|
| 409 | } |
---|
| 410 | }); |
---|
| 411 | |
---|
| 412 | m_PerformBut.setEnabled(false); |
---|
| 413 | m_PerformBut.addActionListener(new ActionListener() { |
---|
| 414 | public void actionPerformed(ActionEvent e) { |
---|
| 415 | performTest(); |
---|
| 416 | m_SaveOutBut.setEnabled(true); |
---|
| 417 | } |
---|
| 418 | }); |
---|
| 419 | |
---|
| 420 | m_PerformBut.setToolTipText(m_TTester.getToolTipText()); |
---|
| 421 | |
---|
| 422 | m_SaveOutBut.setEnabled(false); |
---|
| 423 | m_SaveOutBut.addActionListener(new ActionListener() { |
---|
| 424 | public void actionPerformed(ActionEvent e) { |
---|
| 425 | saveBuffer(); |
---|
| 426 | } |
---|
| 427 | }); |
---|
| 428 | m_OutText.setFont(new Font("Monospaced", Font.PLAIN, 12)); |
---|
| 429 | m_OutText.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
---|
| 430 | m_OutText.setEditable(false); |
---|
| 431 | m_History.setBorder(BorderFactory.createTitledBorder("Result list")); |
---|
| 432 | |
---|
| 433 | |
---|
| 434 | // Set up the GUI layout |
---|
| 435 | JPanel p1 = new JPanel(); |
---|
| 436 | p1.setBorder(BorderFactory.createTitledBorder("Source")); |
---|
| 437 | JPanel p2 = new JPanel(); |
---|
| 438 | GridBagLayout gb = new GridBagLayout(); |
---|
| 439 | GridBagConstraints constraints = new GridBagConstraints(); |
---|
| 440 | p2.setBorder(BorderFactory.createEmptyBorder(5, 5, 10, 5)); |
---|
| 441 | // p2.setLayout(new GridLayout(1, 3)); |
---|
| 442 | p2.setLayout(gb); |
---|
| 443 | constraints.gridx=0;constraints.gridy=0;constraints.weightx=5; |
---|
| 444 | constraints.fill = GridBagConstraints.HORIZONTAL; |
---|
| 445 | constraints.gridwidth=1;constraints.gridheight=1; |
---|
| 446 | constraints.insets = new Insets(0,2,0,2); |
---|
| 447 | p2.add(m_FromFileBut,constraints); |
---|
| 448 | constraints.gridx=1;constraints.gridy=0;constraints.weightx=5; |
---|
| 449 | constraints.gridwidth=1;constraints.gridheight=1; |
---|
| 450 | p2.add(m_FromDBaseBut,constraints); |
---|
| 451 | constraints.gridx=2;constraints.gridy=0;constraints.weightx=5; |
---|
| 452 | constraints.gridwidth=1;constraints.gridheight=1; |
---|
| 453 | p2.add(m_FromExpBut,constraints); |
---|
| 454 | p1.setLayout(new BorderLayout()); |
---|
| 455 | p1.add(m_FromLab, BorderLayout.CENTER); |
---|
| 456 | p1.add(p2, BorderLayout.EAST); |
---|
| 457 | |
---|
| 458 | JPanel p3 = new JPanel(); |
---|
| 459 | p3.setBorder(BorderFactory.createTitledBorder("Configure test")); |
---|
| 460 | GridBagLayout gbL = new GridBagLayout(); |
---|
| 461 | p3.setLayout(gbL); |
---|
| 462 | |
---|
| 463 | int y = 0; |
---|
| 464 | GridBagConstraints gbC = new GridBagConstraints(); |
---|
| 465 | gbC.anchor = GridBagConstraints.EAST; |
---|
| 466 | gbC.gridy = y; gbC.gridx = 0; |
---|
| 467 | gbC.insets = new Insets(2, 10, 2, 10); |
---|
| 468 | gbL.setConstraints(m_TesterClassesLabel,gbC); |
---|
| 469 | m_TesterClassesLabel.setDisplayedMnemonic('w'); |
---|
| 470 | m_TesterClassesLabel.setLabelFor(m_TesterClasses); |
---|
| 471 | p3.add(m_TesterClassesLabel); |
---|
| 472 | gbC = new GridBagConstraints(); |
---|
| 473 | gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; |
---|
| 474 | gbC.insets = new Insets(5,0,5,0); |
---|
| 475 | gbC.fill = GridBagConstraints.HORIZONTAL; |
---|
| 476 | gbL.setConstraints(m_TesterClasses, gbC); |
---|
| 477 | p3.add(m_TesterClasses); |
---|
| 478 | m_TesterClasses.addActionListener(new ActionListener() { |
---|
| 479 | public void actionPerformed(ActionEvent e) { |
---|
| 480 | setTester(); |
---|
| 481 | } |
---|
| 482 | }); |
---|
| 483 | setSelectedItem(m_TesterClasses, ExperimenterDefaults.getTester()); |
---|
| 484 | |
---|
| 485 | y++; |
---|
| 486 | gbC = new GridBagConstraints(); |
---|
| 487 | gbC.anchor = GridBagConstraints.EAST; |
---|
| 488 | gbC.gridy = y; gbC.gridx = 0; |
---|
| 489 | gbC.insets = new Insets(2, 10, 2, 10); |
---|
| 490 | gbL.setConstraints(m_DatasetAndResultKeysLabel,gbC); |
---|
| 491 | m_DatasetAndResultKeysLabel.setDisplayedMnemonic('R'); |
---|
| 492 | m_DatasetAndResultKeysLabel.setLabelFor(m_DatasetKeyBut); |
---|
| 493 | p3.add(m_DatasetAndResultKeysLabel); |
---|
| 494 | |
---|
| 495 | m_PanelDatasetResultKeys.add(m_DatasetKeyBut); |
---|
| 496 | m_PanelDatasetResultKeys.add(m_ResultKeyBut); |
---|
| 497 | m_PanelDatasetResultKeys.add(m_SwapDatasetKeyAndResultKeyBut); |
---|
| 498 | gbC = new GridBagConstraints(); |
---|
| 499 | gbC.fill = GridBagConstraints.HORIZONTAL; |
---|
| 500 | gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; |
---|
| 501 | gbC.insets = new Insets(5,0,5,0); |
---|
| 502 | gbL.setConstraints(m_PanelDatasetResultKeys, gbC); |
---|
| 503 | p3.add(m_PanelDatasetResultKeys); |
---|
| 504 | |
---|
| 505 | y++; |
---|
| 506 | JLabel lab = new JLabel("Comparison field", SwingConstants.RIGHT); |
---|
| 507 | lab.setDisplayedMnemonic('m'); |
---|
| 508 | lab.setLabelFor(m_CompareCombo); |
---|
| 509 | gbC = new GridBagConstraints(); |
---|
| 510 | gbC.anchor = GridBagConstraints.EAST; |
---|
| 511 | gbC.gridy = y; gbC.gridx = 0; |
---|
| 512 | gbC.insets = new Insets(2, 10, 2, 10); |
---|
| 513 | gbL.setConstraints(lab, gbC); |
---|
| 514 | p3.add(lab); |
---|
| 515 | gbC = new GridBagConstraints(); |
---|
| 516 | gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; |
---|
| 517 | gbC.insets = new Insets(5,0,5,0); |
---|
| 518 | gbC.fill = GridBagConstraints.HORIZONTAL; |
---|
| 519 | gbL.setConstraints(m_CompareCombo, gbC); |
---|
| 520 | p3.add(m_CompareCombo); |
---|
| 521 | |
---|
| 522 | y++; |
---|
| 523 | lab = new JLabel("Significance", SwingConstants.RIGHT); |
---|
| 524 | lab.setDisplayedMnemonic('g'); |
---|
| 525 | lab.setLabelFor(m_SigTex); |
---|
| 526 | gbC = new GridBagConstraints(); |
---|
| 527 | gbC.anchor = GridBagConstraints.EAST; |
---|
| 528 | gbC.gridy = y; gbC.gridx = 0; |
---|
| 529 | gbC.insets = new Insets(2, 10, 2, 10); |
---|
| 530 | gbL.setConstraints(lab, gbC); |
---|
| 531 | p3.add(lab); |
---|
| 532 | gbC = new GridBagConstraints(); |
---|
| 533 | gbC.fill = GridBagConstraints.HORIZONTAL; |
---|
| 534 | gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; |
---|
| 535 | gbL.setConstraints(m_SigTex, gbC); |
---|
| 536 | p3.add(m_SigTex); |
---|
| 537 | |
---|
| 538 | y++; |
---|
| 539 | lab = new JLabel("Sorting (asc.) by", SwingConstants.RIGHT); |
---|
| 540 | lab.setDisplayedMnemonic('S'); |
---|
| 541 | lab.setLabelFor(m_SortCombo); |
---|
| 542 | gbC = new GridBagConstraints(); |
---|
| 543 | gbC.anchor = GridBagConstraints.EAST; |
---|
| 544 | gbC.gridy = y; gbC.gridx = 0; |
---|
| 545 | gbC.insets = new Insets(2, 10, 2, 10); |
---|
| 546 | gbL.setConstraints(lab, gbC); |
---|
| 547 | p3.add(lab); |
---|
| 548 | gbC = new GridBagConstraints(); |
---|
| 549 | gbC.anchor = GridBagConstraints.WEST; |
---|
| 550 | gbC.fill = GridBagConstraints.HORIZONTAL; |
---|
| 551 | gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; |
---|
| 552 | gbC.insets = new Insets(5,0,5,0); |
---|
| 553 | gbL.setConstraints(m_SortCombo, gbC); |
---|
| 554 | p3.add(m_SortCombo); |
---|
| 555 | |
---|
| 556 | y++; |
---|
| 557 | lab = new JLabel("Test base", SwingConstants.RIGHT); |
---|
| 558 | lab.setDisplayedMnemonic('b'); |
---|
| 559 | lab.setLabelFor(m_TestsButton); |
---|
| 560 | gbC = new GridBagConstraints(); |
---|
| 561 | gbC.anchor = GridBagConstraints.EAST; |
---|
| 562 | gbC.gridy = y; gbC.gridx = 0; |
---|
| 563 | gbC.insets = new Insets(2, 10, 2, 10); |
---|
| 564 | gbL.setConstraints(lab, gbC); |
---|
| 565 | p3.add(lab); |
---|
| 566 | gbC = new GridBagConstraints(); |
---|
| 567 | gbC.fill = GridBagConstraints.HORIZONTAL; |
---|
| 568 | gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; |
---|
| 569 | gbC.insets = new Insets(5,0,5,0); |
---|
| 570 | gbL.setConstraints(m_TestsButton, gbC); |
---|
| 571 | p3.add(m_TestsButton); |
---|
| 572 | |
---|
| 573 | y++; |
---|
| 574 | lab = new JLabel("Displayed Columns", SwingConstants.RIGHT); |
---|
| 575 | lab.setDisplayedMnemonic('i'); |
---|
| 576 | lab.setLabelFor(m_DisplayedButton); |
---|
| 577 | gbC = new GridBagConstraints(); |
---|
| 578 | gbC.anchor = GridBagConstraints.EAST; |
---|
| 579 | gbC.gridy = y; gbC.gridx = 0; |
---|
| 580 | gbC.insets = new Insets(2, 10, 2, 10); |
---|
| 581 | gbL.setConstraints(lab, gbC); |
---|
| 582 | p3.add(lab); |
---|
| 583 | gbC = new GridBagConstraints(); |
---|
| 584 | gbC.fill = GridBagConstraints.HORIZONTAL; |
---|
| 585 | gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; |
---|
| 586 | gbC.insets = new Insets(5,0,5,0); |
---|
| 587 | gbL.setConstraints(m_DisplayedButton, gbC); |
---|
| 588 | p3.add(m_DisplayedButton); |
---|
| 589 | |
---|
| 590 | y++; |
---|
| 591 | lab = new JLabel("Show std. deviations", SwingConstants.RIGHT); |
---|
| 592 | lab.setDisplayedMnemonic('a'); |
---|
| 593 | lab.setLabelFor(m_ShowStdDevs); |
---|
| 594 | gbC = new GridBagConstraints(); |
---|
| 595 | gbC.anchor = GridBagConstraints.EAST; |
---|
| 596 | gbC.gridy = y; gbC.gridx = 0; |
---|
| 597 | gbC.insets = new Insets(2, 10, 2, 10); |
---|
| 598 | gbL.setConstraints(lab, gbC); |
---|
| 599 | p3.add(lab); |
---|
| 600 | gbC = new GridBagConstraints(); |
---|
| 601 | gbC.anchor = GridBagConstraints.WEST; |
---|
| 602 | gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; |
---|
| 603 | gbC.insets = new Insets(5,0,5,0); |
---|
| 604 | gbL.setConstraints(m_ShowStdDevs, gbC); |
---|
| 605 | p3.add(m_ShowStdDevs); |
---|
| 606 | |
---|
| 607 | y++; |
---|
| 608 | lab = new JLabel("Output Format", SwingConstants.RIGHT); |
---|
| 609 | lab.setDisplayedMnemonic('O'); |
---|
| 610 | lab.setLabelFor(m_OutputFormatButton); |
---|
| 611 | gbC = new GridBagConstraints(); |
---|
| 612 | gbC.anchor = GridBagConstraints.EAST; |
---|
| 613 | gbC.gridy = y; gbC.gridx = 0; |
---|
| 614 | gbC.insets = new Insets(2, 10, 2, 10); |
---|
| 615 | gbL.setConstraints(lab, gbC); |
---|
| 616 | p3.add(lab); |
---|
| 617 | gbC = new GridBagConstraints(); |
---|
| 618 | gbC.anchor = GridBagConstraints.WEST; |
---|
| 619 | gbC.fill = GridBagConstraints.HORIZONTAL; |
---|
| 620 | gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; |
---|
| 621 | gbC.insets = new Insets(5,0,5,0); |
---|
| 622 | gbL.setConstraints(m_OutputFormatButton, gbC); |
---|
| 623 | p3.add(m_OutputFormatButton); |
---|
| 624 | |
---|
| 625 | JPanel output = new JPanel(); |
---|
| 626 | output.setLayout(new BorderLayout()); |
---|
| 627 | output.setBorder(BorderFactory.createTitledBorder("Test output")); |
---|
| 628 | output.add(new JScrollPane(m_OutText), BorderLayout.CENTER); |
---|
| 629 | |
---|
| 630 | JPanel mondo = new JPanel(); |
---|
| 631 | gbL = new GridBagLayout(); |
---|
| 632 | mondo.setLayout(gbL); |
---|
| 633 | gbC = new GridBagConstraints(); |
---|
| 634 | // gbC.anchor = GridBagConstraints.WEST; |
---|
| 635 | // gbC.fill = GridBagConstraints.HORIZONTAL; |
---|
| 636 | gbC.gridy = 0; gbC.gridx = 0; |
---|
| 637 | gbL.setConstraints(p3, gbC); |
---|
| 638 | mondo.add(p3); |
---|
| 639 | |
---|
| 640 | JPanel bts = new JPanel(); |
---|
| 641 | m_PerformBut.setMnemonic('t'); |
---|
| 642 | m_SaveOutBut.setMnemonic('S'); |
---|
| 643 | bts.setLayout(new GridLayout(1,2,5,5)); |
---|
| 644 | bts.add(m_PerformBut); |
---|
| 645 | bts.add(m_SaveOutBut); |
---|
| 646 | |
---|
| 647 | gbC = new GridBagConstraints(); |
---|
| 648 | gbC.anchor = GridBagConstraints.NORTH; |
---|
| 649 | gbC.fill = GridBagConstraints.HORIZONTAL; |
---|
| 650 | gbC.gridy = 1; gbC.gridx = 0; |
---|
| 651 | gbC.insets = new Insets(5,5,5,5); |
---|
| 652 | gbL.setConstraints(bts, gbC); |
---|
| 653 | mondo.add(bts); |
---|
| 654 | gbC = new GridBagConstraints(); |
---|
| 655 | //gbC.anchor = GridBagConstraints.NORTH; |
---|
| 656 | gbC.fill = GridBagConstraints.BOTH; |
---|
| 657 | gbC.gridy = 2; gbC.gridx = 0; gbC.weightx = 0; |
---|
| 658 | gbC.weighty = 100; |
---|
| 659 | gbL.setConstraints(m_History, gbC); |
---|
| 660 | mondo.add(m_History); |
---|
| 661 | /*gbC = new GridBagConstraints(); |
---|
| 662 | gbC.fill = GridBagConstraints.BOTH; |
---|
| 663 | gbC.gridy = 0; gbC.gridx = 1; |
---|
| 664 | gbC.gridheight = 3; |
---|
| 665 | gbC.weightx = 100; gbC.weighty = 100; |
---|
| 666 | gbL.setConstraints(output, gbC);*/ |
---|
| 667 | //mondo.add(output); |
---|
| 668 | JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, |
---|
| 669 | mondo, output); |
---|
| 670 | splitPane.setOneTouchExpandable(true); |
---|
| 671 | //splitPane.setDividerLocation(100); |
---|
| 672 | |
---|
| 673 | setLayout(new BorderLayout()); |
---|
| 674 | add(p1, BorderLayout.NORTH); |
---|
| 675 | //add(mondo , BorderLayout.CENTER); |
---|
| 676 | add(splitPane , BorderLayout.CENTER); |
---|
| 677 | } |
---|
| 678 | |
---|
| 679 | /** |
---|
| 680 | * Sets the combo-boxes to a fixed size so they don't take up too much room |
---|
| 681 | * that would be better devoted to the test output box. |
---|
| 682 | */ |
---|
| 683 | protected void setComboSizes() { |
---|
| 684 | |
---|
| 685 | m_TesterClasses.setPreferredSize(COMBO_SIZE); |
---|
| 686 | m_PanelDatasetResultKeys.setPreferredSize(COMBO_SIZE); |
---|
| 687 | m_CompareCombo.setPreferredSize(COMBO_SIZE); |
---|
| 688 | m_SigTex.setPreferredSize(COMBO_SIZE); |
---|
| 689 | m_SortCombo.setPreferredSize(COMBO_SIZE); |
---|
| 690 | |
---|
| 691 | m_TesterClasses.setMaximumSize(COMBO_SIZE); |
---|
| 692 | m_PanelDatasetResultKeys.setMaximumSize(COMBO_SIZE); |
---|
| 693 | m_CompareCombo.setMaximumSize(COMBO_SIZE); |
---|
| 694 | m_SigTex.setMaximumSize(COMBO_SIZE); |
---|
| 695 | m_SortCombo.setMaximumSize(COMBO_SIZE); |
---|
| 696 | |
---|
| 697 | m_TesterClasses.setMinimumSize(COMBO_SIZE); |
---|
| 698 | m_PanelDatasetResultKeys.setMinimumSize(COMBO_SIZE); |
---|
| 699 | m_CompareCombo.setMinimumSize(COMBO_SIZE); |
---|
| 700 | m_SigTex.setMinimumSize(COMBO_SIZE); |
---|
| 701 | m_SortCombo.setMinimumSize(COMBO_SIZE); |
---|
| 702 | } |
---|
| 703 | |
---|
| 704 | /** |
---|
| 705 | * Tells the panel to use a new experiment. |
---|
| 706 | * |
---|
| 707 | * @param exp a value of type 'Experiment' |
---|
| 708 | */ |
---|
| 709 | public void setExperiment(Experiment exp) { |
---|
| 710 | |
---|
| 711 | m_Exp = exp; |
---|
| 712 | m_FromExpBut.setEnabled(exp != null); |
---|
| 713 | } |
---|
| 714 | |
---|
| 715 | /** |
---|
| 716 | * Queries the user enough to make a database query to retrieve experiment |
---|
| 717 | * results. |
---|
| 718 | */ |
---|
| 719 | protected void setInstancesFromDBaseQuery() { |
---|
| 720 | |
---|
| 721 | try { |
---|
| 722 | if (m_InstanceQuery == null) { |
---|
| 723 | m_InstanceQuery = new InstanceQuery(); |
---|
| 724 | } |
---|
| 725 | String dbaseURL = m_InstanceQuery.getDatabaseURL(); |
---|
| 726 | String username = m_InstanceQuery.getUsername(); |
---|
| 727 | String passwd = m_InstanceQuery.getPassword(); |
---|
| 728 | /*dbaseURL = (String) JOptionPane.showInputDialog(this, |
---|
| 729 | "Enter the database URL", |
---|
| 730 | "Query Database", |
---|
| 731 | JOptionPane.PLAIN_MESSAGE, |
---|
| 732 | null, |
---|
| 733 | null, |
---|
| 734 | dbaseURL);*/ |
---|
| 735 | |
---|
| 736 | |
---|
| 737 | |
---|
| 738 | DatabaseConnectionDialog dbd= new DatabaseConnectionDialog(null,dbaseURL,username); |
---|
| 739 | dbd.setVisible(true); |
---|
| 740 | |
---|
| 741 | //if (dbaseURL == null) { |
---|
| 742 | if (dbd.getReturnValue()==JOptionPane.CLOSED_OPTION) { |
---|
| 743 | m_FromLab.setText("Cancelled"); |
---|
| 744 | return; |
---|
| 745 | } |
---|
| 746 | dbaseURL=dbd.getURL(); |
---|
| 747 | username=dbd.getUsername(); |
---|
| 748 | passwd=dbd.getPassword(); |
---|
| 749 | m_InstanceQuery.setDatabaseURL(dbaseURL); |
---|
| 750 | m_InstanceQuery.setUsername(username); |
---|
| 751 | m_InstanceQuery.setPassword(passwd); |
---|
| 752 | m_InstanceQuery.setDebug(dbd.getDebug()); |
---|
| 753 | |
---|
| 754 | m_InstanceQuery.connectToDatabase(); |
---|
| 755 | if (!m_InstanceQuery.experimentIndexExists()) { |
---|
| 756 | System.err.println("not found"); |
---|
| 757 | m_FromLab.setText("No experiment index"); |
---|
| 758 | m_InstanceQuery.disconnectFromDatabase(); |
---|
| 759 | return; |
---|
| 760 | } |
---|
| 761 | System.err.println("found"); |
---|
| 762 | m_FromLab.setText("Getting experiment index"); |
---|
| 763 | Instances index = m_InstanceQuery.retrieveInstances("SELECT * FROM " |
---|
| 764 | + InstanceQuery.EXP_INDEX_TABLE); |
---|
| 765 | if (index.numInstances() == 0) { |
---|
| 766 | m_FromLab.setText("No experiments available"); |
---|
| 767 | m_InstanceQuery.disconnectFromDatabase(); |
---|
| 768 | return; |
---|
| 769 | } |
---|
| 770 | m_FromLab.setText("Got experiment index"); |
---|
| 771 | |
---|
| 772 | DefaultListModel lm = new DefaultListModel(); |
---|
| 773 | for (int i = 0; i < index.numInstances(); i++) { |
---|
| 774 | lm.addElement(index.instance(i).toString()); |
---|
| 775 | } |
---|
| 776 | JList jl = new JList(lm); |
---|
| 777 | jl.setSelectedIndex(0); |
---|
| 778 | int result; |
---|
| 779 | // display dialog only if there's not just one result! |
---|
| 780 | if (jl.getModel().getSize() != 1) { |
---|
| 781 | ListSelectorDialog jd = new ListSelectorDialog(null, jl); |
---|
| 782 | result = jd.showDialog(); |
---|
| 783 | } |
---|
| 784 | else { |
---|
| 785 | result = ListSelectorDialog.APPROVE_OPTION; |
---|
| 786 | } |
---|
| 787 | if (result != ListSelectorDialog.APPROVE_OPTION) { |
---|
| 788 | m_FromLab.setText("Cancelled"); |
---|
| 789 | m_InstanceQuery.disconnectFromDatabase(); |
---|
| 790 | return; |
---|
| 791 | } |
---|
| 792 | Instance selInst = index.instance(jl.getSelectedIndex()); |
---|
| 793 | Attribute tableAttr = index.attribute(InstanceQuery.EXP_RESULT_COL); |
---|
| 794 | String table = InstanceQuery.EXP_RESULT_PREFIX |
---|
| 795 | + selInst.toString(tableAttr); |
---|
| 796 | setInstancesFromDatabaseTable(table); |
---|
| 797 | |
---|
| 798 | } catch (Exception ex) { |
---|
| 799 | // 1. print complete stacktrace |
---|
| 800 | ex.printStackTrace(); |
---|
| 801 | // 2. print message in panel |
---|
| 802 | m_FromLab.setText("Problem reading database: '" + ex.getMessage() + "'"); |
---|
| 803 | } |
---|
| 804 | } |
---|
| 805 | |
---|
| 806 | /** |
---|
| 807 | * Examines the supplied experiment to determine the results destination |
---|
| 808 | * and attempts to load the results. |
---|
| 809 | * |
---|
| 810 | * @param exp a value of type 'Experiment' |
---|
| 811 | */ |
---|
| 812 | protected void setInstancesFromExp(Experiment exp) { |
---|
| 813 | |
---|
| 814 | if ((exp.getResultListener() instanceof CSVResultListener)) { |
---|
| 815 | File resultFile = ((CSVResultListener) exp.getResultListener()) |
---|
| 816 | .getOutputFile(); |
---|
| 817 | if ((resultFile == null)) { |
---|
| 818 | m_FromLab.setText("No result file"); |
---|
| 819 | } else { |
---|
| 820 | setInstancesFromFile(resultFile); |
---|
| 821 | } |
---|
| 822 | } else if (exp.getResultListener() instanceof DatabaseResultListener) { |
---|
| 823 | String dbaseURL = ((DatabaseResultListener) exp.getResultListener()) |
---|
| 824 | .getDatabaseURL(); |
---|
| 825 | try { |
---|
| 826 | if (m_InstanceQuery == null) { |
---|
| 827 | m_InstanceQuery = new InstanceQuery(); |
---|
| 828 | } |
---|
| 829 | m_InstanceQuery.setDatabaseURL(dbaseURL); |
---|
| 830 | m_InstanceQuery.connectToDatabase(); |
---|
| 831 | String tableName = m_InstanceQuery |
---|
| 832 | .getResultsTableName(exp.getResultProducer()); |
---|
| 833 | setInstancesFromDatabaseTable(tableName); |
---|
| 834 | } catch (Exception ex) { |
---|
| 835 | m_FromLab.setText("Problem reading database"); |
---|
| 836 | } |
---|
| 837 | } else { |
---|
| 838 | m_FromLab.setText("Can't get results from experiment"); |
---|
| 839 | } |
---|
| 840 | } |
---|
| 841 | |
---|
| 842 | |
---|
| 843 | /** |
---|
| 844 | * Queries a database to load results from the specified table name. The |
---|
| 845 | * database connection must have already made by m_InstanceQuery. |
---|
| 846 | * |
---|
| 847 | * @param tableName the name of the table containing results to retrieve. |
---|
| 848 | */ |
---|
| 849 | protected void setInstancesFromDatabaseTable(String tableName) { |
---|
| 850 | |
---|
| 851 | try { |
---|
| 852 | m_FromLab.setText("Reading from database, please wait..."); |
---|
| 853 | final Instances i = m_InstanceQuery.retrieveInstances("SELECT * FROM " |
---|
| 854 | + tableName); |
---|
| 855 | SwingUtilities.invokeAndWait(new Runnable() { |
---|
| 856 | public void run() { |
---|
| 857 | setInstances(i); |
---|
| 858 | } |
---|
| 859 | }); |
---|
| 860 | m_InstanceQuery.disconnectFromDatabase(); |
---|
| 861 | } catch (Exception ex) { |
---|
| 862 | m_FromLab.setText(ex.getMessage()); |
---|
| 863 | } |
---|
| 864 | } |
---|
| 865 | |
---|
| 866 | /** |
---|
| 867 | * Loads results from a set of instances contained in the supplied |
---|
| 868 | * file. |
---|
| 869 | * |
---|
| 870 | * @param f a value of type 'File' |
---|
| 871 | */ |
---|
| 872 | protected void setInstancesFromFile(File f) { |
---|
| 873 | |
---|
| 874 | String fileType = f.getName(); |
---|
| 875 | try { |
---|
| 876 | m_FromLab.setText("Reading from file..."); |
---|
| 877 | if (f.getName().toLowerCase().endsWith(Instances.FILE_EXTENSION)) { |
---|
| 878 | fileType = "arff"; |
---|
| 879 | Reader r = new BufferedReader(new FileReader(f)); |
---|
| 880 | setInstances(new Instances(r)); |
---|
| 881 | r.close(); |
---|
| 882 | } else if (f.getName().toLowerCase().endsWith(CSVLoader.FILE_EXTENSION)) { |
---|
| 883 | fileType = "csv"; |
---|
| 884 | CSVLoader cnv = new CSVLoader(); |
---|
| 885 | cnv.setSource(f); |
---|
| 886 | Instances inst = cnv.getDataSet(); |
---|
| 887 | setInstances(inst); |
---|
| 888 | } else { |
---|
| 889 | throw new Exception("Unrecognized file type"); |
---|
| 890 | } |
---|
| 891 | } catch (Exception ex) { |
---|
| 892 | m_FromLab.setText("File '" + f.getName() + "' not recognised as an " |
---|
| 893 | +fileType+" file."); |
---|
| 894 | if (JOptionPane.showOptionDialog(ResultsPanel.this, |
---|
| 895 | "File '" + f.getName() |
---|
| 896 | + "' not recognised as an " |
---|
| 897 | +fileType+" file.\n" |
---|
| 898 | + "Reason:\n" + ex.getMessage(), |
---|
| 899 | "Load Instances", |
---|
| 900 | 0, |
---|
| 901 | JOptionPane.ERROR_MESSAGE, |
---|
| 902 | null, |
---|
| 903 | new String[] {"OK"}, |
---|
| 904 | null) == 1) { |
---|
| 905 | |
---|
| 906 | } |
---|
| 907 | } |
---|
| 908 | } |
---|
| 909 | |
---|
| 910 | /** |
---|
| 911 | * Returns a vector with column names of the dataset, listed in "list". If |
---|
| 912 | * a column cannot be found or the list is empty the ones from the default |
---|
| 913 | * list are returned. |
---|
| 914 | * |
---|
| 915 | * @param list comma-separated list of attribute names |
---|
| 916 | * @param defaultList the default list of attribute names |
---|
| 917 | * @param inst the instances to get the attribute names from |
---|
| 918 | * @return a vector containing attribute names |
---|
| 919 | */ |
---|
| 920 | protected Vector determineColumnNames(String list, String defaultList, Instances inst) { |
---|
| 921 | Vector result; |
---|
| 922 | Vector atts; |
---|
| 923 | StringTokenizer tok; |
---|
| 924 | int i; |
---|
| 925 | String item; |
---|
| 926 | |
---|
| 927 | // get attribute names |
---|
| 928 | atts = new Vector(); |
---|
| 929 | for (i = 0; i < inst.numAttributes(); i++) |
---|
| 930 | atts.add(inst.attribute(i).name().toLowerCase()); |
---|
| 931 | |
---|
| 932 | // process list |
---|
| 933 | result = new Vector(); |
---|
| 934 | tok = new StringTokenizer(list, ","); |
---|
| 935 | while (tok.hasMoreTokens()) { |
---|
| 936 | item = tok.nextToken().toLowerCase(); |
---|
| 937 | if (atts.contains(item)) { |
---|
| 938 | result.add(item); |
---|
| 939 | } |
---|
| 940 | else { |
---|
| 941 | result.clear(); |
---|
| 942 | break; |
---|
| 943 | } |
---|
| 944 | } |
---|
| 945 | |
---|
| 946 | // do we have to return defaults? |
---|
| 947 | if (result.size() == 0) { |
---|
| 948 | tok = new StringTokenizer(defaultList, ","); |
---|
| 949 | while (tok.hasMoreTokens()) |
---|
| 950 | result.add(tok.nextToken().toLowerCase()); |
---|
| 951 | } |
---|
| 952 | |
---|
| 953 | return result; |
---|
| 954 | } |
---|
| 955 | |
---|
| 956 | /** |
---|
| 957 | * Sets up the panel with a new set of instances, attempting |
---|
| 958 | * to guess the correct settings for various columns. |
---|
| 959 | * |
---|
| 960 | * @param newInstances the new set of results. |
---|
| 961 | */ |
---|
| 962 | public void setInstances(Instances newInstances) { |
---|
| 963 | |
---|
| 964 | m_Instances = newInstances; |
---|
| 965 | m_TTester.setInstances(m_Instances); |
---|
| 966 | m_FromLab.setText("Got " + m_Instances.numInstances() + " results"); |
---|
| 967 | |
---|
| 968 | // setup row and column names |
---|
| 969 | Vector rows = determineColumnNames( |
---|
| 970 | ExperimenterDefaults.getRow(), "Key_Dataset", m_Instances); |
---|
| 971 | Vector cols = determineColumnNames( |
---|
| 972 | ExperimenterDefaults.getColumn(), "Key_Scheme,Key_Scheme_options,Key_Scheme_version_ID", m_Instances); |
---|
| 973 | |
---|
| 974 | // Do other stuff |
---|
| 975 | m_DatasetKeyModel.removeAllElements(); |
---|
| 976 | m_ResultKeyModel.removeAllElements(); |
---|
| 977 | m_CompareModel.removeAllElements(); |
---|
| 978 | m_SortModel.removeAllElements(); |
---|
| 979 | m_SortModel.addElement("<default>"); |
---|
| 980 | m_TTester.setSortColumn(-1); |
---|
| 981 | String selectedList = ""; |
---|
| 982 | String selectedListDataset = ""; |
---|
| 983 | boolean comparisonFieldSet = false; |
---|
| 984 | for (int i = 0; i < m_Instances.numAttributes(); i++) { |
---|
| 985 | String name = m_Instances.attribute(i).name(); |
---|
| 986 | if (name.toLowerCase().startsWith("key_", 0)) { |
---|
| 987 | m_DatasetKeyModel.addElement(name.substring(4)); |
---|
| 988 | m_ResultKeyModel.addElement(name.substring(4)); |
---|
| 989 | m_CompareModel.addElement(name.substring(4)); |
---|
| 990 | } else { |
---|
| 991 | m_DatasetKeyModel.addElement(name); |
---|
| 992 | m_ResultKeyModel.addElement(name); |
---|
| 993 | m_CompareModel.addElement(name); |
---|
| 994 | if (m_Instances.attribute(i).isNumeric()) |
---|
| 995 | m_SortModel.addElement(name); |
---|
| 996 | } |
---|
| 997 | |
---|
| 998 | if (rows.contains(name.toLowerCase())) { |
---|
| 999 | m_DatasetKeyList.addSelectionInterval(i, i); |
---|
| 1000 | selectedListDataset += "," + (i + 1); |
---|
| 1001 | } else if (name.toLowerCase().equals("key_run")) { |
---|
| 1002 | m_TTester.setRunColumn(i); |
---|
| 1003 | } else if (name.toLowerCase().equals("key_fold")) { |
---|
| 1004 | m_TTester.setFoldColumn(i); |
---|
| 1005 | } else if (cols.contains(name.toLowerCase())) { |
---|
| 1006 | m_ResultKeyList.addSelectionInterval(i, i); |
---|
| 1007 | selectedList += "," + (i + 1); |
---|
| 1008 | } else if (name.toLowerCase().indexOf(ExperimenterDefaults.getComparisonField()) != -1) { |
---|
| 1009 | m_CompareCombo.setSelectedIndex(i); |
---|
| 1010 | comparisonFieldSet = true; |
---|
| 1011 | // break; |
---|
| 1012 | } else if ((name.toLowerCase().indexOf("root_relative_squared_error") != -1) && |
---|
| 1013 | (!comparisonFieldSet)) { |
---|
| 1014 | m_CompareCombo.setSelectedIndex(i); |
---|
| 1015 | comparisonFieldSet = true; |
---|
| 1016 | } |
---|
| 1017 | } |
---|
| 1018 | m_TesterClasses.setEnabled(true); |
---|
| 1019 | m_DatasetKeyBut.setEnabled(true); |
---|
| 1020 | m_ResultKeyBut.setEnabled(true); |
---|
| 1021 | m_SwapDatasetKeyAndResultKeyBut.setEnabled(true); |
---|
| 1022 | m_CompareCombo.setEnabled(true); |
---|
| 1023 | m_SortCombo.setEnabled(true); |
---|
| 1024 | if (ExperimenterDefaults.getSorting().length() != 0) |
---|
| 1025 | setSelectedItem(m_SortCombo, ExperimenterDefaults.getSorting()); |
---|
| 1026 | |
---|
| 1027 | Range generatorRange = new Range(); |
---|
| 1028 | if (selectedList.length() != 0) { |
---|
| 1029 | try { |
---|
| 1030 | generatorRange.setRanges(selectedList); |
---|
| 1031 | } catch (Exception ex) { |
---|
| 1032 | ex.printStackTrace(); |
---|
| 1033 | System.err.println(ex.getMessage()); |
---|
| 1034 | } |
---|
| 1035 | } |
---|
| 1036 | m_TTester.setResultsetKeyColumns(generatorRange); |
---|
| 1037 | |
---|
| 1038 | generatorRange = new Range(); |
---|
| 1039 | if (selectedListDataset.length() != 0) { |
---|
| 1040 | try { |
---|
| 1041 | generatorRange.setRanges(selectedListDataset); |
---|
| 1042 | } catch (Exception ex) { |
---|
| 1043 | ex.printStackTrace(); |
---|
| 1044 | System.err.println(ex.getMessage()); |
---|
| 1045 | } |
---|
| 1046 | } |
---|
| 1047 | m_TTester.setDatasetKeyColumns(generatorRange); |
---|
| 1048 | |
---|
| 1049 | m_SigTex.setEnabled(true); |
---|
| 1050 | |
---|
| 1051 | setTTester(); |
---|
| 1052 | } |
---|
| 1053 | |
---|
| 1054 | /** |
---|
| 1055 | * Sets the selected item of an combobox, since using setSelectedItem(...) |
---|
| 1056 | * doesn't work, if one checks object references! |
---|
| 1057 | * |
---|
| 1058 | * @param cb the combobox to set the item for |
---|
| 1059 | * @param item the item to set active |
---|
| 1060 | */ |
---|
| 1061 | protected void setSelectedItem(JComboBox cb, String item) { |
---|
| 1062 | int i; |
---|
| 1063 | |
---|
| 1064 | for (i = 0; i < cb.getItemCount(); i++) { |
---|
| 1065 | if (cb.getItemAt(i).toString().equals(item)) { |
---|
| 1066 | cb.setSelectedIndex(i); |
---|
| 1067 | break; |
---|
| 1068 | } |
---|
| 1069 | } |
---|
| 1070 | } |
---|
| 1071 | |
---|
| 1072 | /** |
---|
| 1073 | * Updates the test chooser with possible tests. |
---|
| 1074 | */ |
---|
| 1075 | protected void setTTester() { |
---|
| 1076 | |
---|
| 1077 | // default is to display all columns |
---|
| 1078 | m_TTester.setDisplayedResultsets(null); |
---|
| 1079 | |
---|
| 1080 | String name = (new SimpleDateFormat("HH:mm:ss - ")) |
---|
| 1081 | .format(new Date()) |
---|
| 1082 | + "Available resultsets"; |
---|
| 1083 | StringBuffer outBuff = new StringBuffer(); |
---|
| 1084 | outBuff.append("Available resultsets\n" |
---|
| 1085 | + m_TTester.resultsetKey() + "\n\n"); |
---|
| 1086 | m_History.addResult(name, outBuff); |
---|
| 1087 | m_History.setSingle(name); |
---|
| 1088 | |
---|
| 1089 | m_TestsModel.removeAllElements(); |
---|
| 1090 | for (int i = 0; i < m_TTester.getNumResultsets(); i++) { |
---|
| 1091 | String tname = m_TTester.getResultsetName(i); |
---|
| 1092 | /* if (tname.length() > 20) { |
---|
| 1093 | tname = tname.substring(0, 20); |
---|
| 1094 | } */ |
---|
| 1095 | m_TestsModel.addElement(tname); |
---|
| 1096 | } |
---|
| 1097 | |
---|
| 1098 | m_DisplayedModel.removeAllElements(); |
---|
| 1099 | for (int i = 0; i < m_TestsModel.size(); i++) |
---|
| 1100 | m_DisplayedModel.addElement(m_TestsModel.elementAt(i)); |
---|
| 1101 | |
---|
| 1102 | m_TestsModel.addElement("Summary"); |
---|
| 1103 | m_TestsModel.addElement("Ranking"); |
---|
| 1104 | |
---|
| 1105 | m_TestsList.setSelectedIndex(0); |
---|
| 1106 | m_DisplayedList.setSelectionInterval(0, m_DisplayedModel.size() - 1); |
---|
| 1107 | |
---|
| 1108 | m_TestsButton.setEnabled(true); |
---|
| 1109 | m_DisplayedButton.setEnabled(true); |
---|
| 1110 | m_ShowStdDevs.setEnabled(true); |
---|
| 1111 | m_OutputFormatButton.setEnabled(true); |
---|
| 1112 | m_PerformBut.setEnabled(true); |
---|
| 1113 | |
---|
| 1114 | } |
---|
| 1115 | |
---|
| 1116 | |
---|
| 1117 | /** |
---|
| 1118 | * Carries out a t-test using the current configuration. |
---|
| 1119 | */ |
---|
| 1120 | protected void performTest() { |
---|
| 1121 | |
---|
| 1122 | String sigStr = m_SigTex.getText(); |
---|
| 1123 | if (sigStr.length() != 0) { |
---|
| 1124 | m_TTester.setSignificanceLevel((new Double(sigStr)).doubleValue()); |
---|
| 1125 | } else { |
---|
| 1126 | m_TTester.setSignificanceLevel(ExperimenterDefaults.getSignificance()); |
---|
| 1127 | } |
---|
| 1128 | |
---|
| 1129 | // Carry out the test chosen and biff the results to the output area |
---|
| 1130 | m_TTester.setShowStdDevs(m_ShowStdDevs.isSelected()); |
---|
| 1131 | if (m_Instances.attribute(m_SortCombo.getSelectedItem().toString()) != null) |
---|
| 1132 | m_TTester.setSortColumn( |
---|
| 1133 | m_Instances.attribute( |
---|
| 1134 | m_SortCombo.getSelectedItem().toString()).index()); |
---|
| 1135 | else |
---|
| 1136 | m_TTester.setSortColumn(-1); |
---|
| 1137 | int compareCol = m_CompareCombo.getSelectedIndex(); |
---|
| 1138 | int tType = m_TestsList.getSelectedIndex(); |
---|
| 1139 | |
---|
| 1140 | String name = (new SimpleDateFormat("HH:mm:ss - ")) |
---|
| 1141 | .format(new Date()) |
---|
| 1142 | + (String) m_CompareCombo.getSelectedItem() + " - " |
---|
| 1143 | + (String) m_TestsList.getSelectedValue(); |
---|
| 1144 | StringBuffer outBuff = new StringBuffer(); |
---|
| 1145 | outBuff.append(m_TTester.header(compareCol)); |
---|
| 1146 | outBuff.append("\n"); |
---|
| 1147 | m_History.addResult(name, outBuff); |
---|
| 1148 | m_History.setSingle(name); |
---|
| 1149 | m_TTester.setDisplayedResultsets(m_DisplayedList.getSelectedIndices()); |
---|
| 1150 | m_TTester.setResultMatrix(m_ResultMatrix); |
---|
| 1151 | try { |
---|
| 1152 | if (tType < m_TTester.getNumResultsets()) { |
---|
| 1153 | outBuff.append(m_TTester.multiResultsetFull(tType, compareCol)); |
---|
| 1154 | } else if (tType == m_TTester.getNumResultsets()) { |
---|
| 1155 | outBuff.append(m_TTester.multiResultsetSummary(compareCol)); |
---|
| 1156 | } else { |
---|
| 1157 | outBuff.append(m_TTester.multiResultsetRanking(compareCol)); |
---|
| 1158 | } |
---|
| 1159 | outBuff.append("\n"); |
---|
| 1160 | } catch (Exception ex) { |
---|
| 1161 | outBuff.append(ex.getMessage() + "\n"); |
---|
| 1162 | } |
---|
| 1163 | m_History.updateResult(name); |
---|
| 1164 | } |
---|
| 1165 | |
---|
| 1166 | |
---|
| 1167 | public void setResultKeyFromDialog() { |
---|
| 1168 | |
---|
| 1169 | ListSelectorDialog jd = new ListSelectorDialog(null, m_ResultKeyList); |
---|
| 1170 | |
---|
| 1171 | // Open the dialog |
---|
| 1172 | int result = jd.showDialog(); |
---|
| 1173 | |
---|
| 1174 | // If accepted, update the ttester |
---|
| 1175 | if (result == ListSelectorDialog.APPROVE_OPTION) { |
---|
| 1176 | int [] selected = m_ResultKeyList.getSelectedIndices(); |
---|
| 1177 | String selectedList = ""; |
---|
| 1178 | for (int i = 0; i < selected.length; i++) { |
---|
| 1179 | selectedList += "," + (selected[i] + 1); |
---|
| 1180 | } |
---|
| 1181 | Range generatorRange = new Range(); |
---|
| 1182 | if (selectedList.length() != 0) { |
---|
| 1183 | try { |
---|
| 1184 | generatorRange.setRanges(selectedList); |
---|
| 1185 | } catch (Exception ex) { |
---|
| 1186 | ex.printStackTrace(); |
---|
| 1187 | System.err.println(ex.getMessage()); |
---|
| 1188 | } |
---|
| 1189 | } |
---|
| 1190 | m_TTester.setResultsetKeyColumns(generatorRange); |
---|
| 1191 | setTTester(); |
---|
| 1192 | } |
---|
| 1193 | } |
---|
| 1194 | |
---|
| 1195 | public void setDatasetKeyFromDialog() { |
---|
| 1196 | |
---|
| 1197 | ListSelectorDialog jd = new ListSelectorDialog(null, m_DatasetKeyList); |
---|
| 1198 | |
---|
| 1199 | // Open the dialog |
---|
| 1200 | int result = jd.showDialog(); |
---|
| 1201 | |
---|
| 1202 | // If accepted, update the ttester |
---|
| 1203 | if (result == ListSelectorDialog.APPROVE_OPTION) { |
---|
| 1204 | int [] selected = m_DatasetKeyList.getSelectedIndices(); |
---|
| 1205 | String selectedList = ""; |
---|
| 1206 | for (int i = 0; i < selected.length; i++) { |
---|
| 1207 | selectedList += "," + (selected[i] + 1); |
---|
| 1208 | } |
---|
| 1209 | Range generatorRange = new Range(); |
---|
| 1210 | if (selectedList.length() != 0) { |
---|
| 1211 | try { |
---|
| 1212 | generatorRange.setRanges(selectedList); |
---|
| 1213 | } catch (Exception ex) { |
---|
| 1214 | ex.printStackTrace(); |
---|
| 1215 | System.err.println(ex.getMessage()); |
---|
| 1216 | } |
---|
| 1217 | } |
---|
| 1218 | m_TTester.setDatasetKeyColumns(generatorRange); |
---|
| 1219 | setTTester(); |
---|
| 1220 | } |
---|
| 1221 | } |
---|
| 1222 | |
---|
| 1223 | /** |
---|
| 1224 | * Swaps the keys for dataset and result. |
---|
| 1225 | */ |
---|
| 1226 | protected void swapDatasetKeyAndResultKey() { |
---|
| 1227 | int[] tmpSelected; |
---|
| 1228 | Range tmpRange; |
---|
| 1229 | |
---|
| 1230 | // lists |
---|
| 1231 | tmpSelected = m_DatasetKeyList.getSelectedIndices(); |
---|
| 1232 | m_DatasetKeyList.setSelectedIndices(m_ResultKeyList.getSelectedIndices()); |
---|
| 1233 | m_ResultKeyList.setSelectedIndices(tmpSelected); |
---|
| 1234 | |
---|
| 1235 | // tester |
---|
| 1236 | tmpRange = m_TTester.getDatasetKeyColumns(); |
---|
| 1237 | m_TTester.setDatasetKeyColumns(m_TTester.getResultsetKeyColumns()); |
---|
| 1238 | m_TTester.setResultsetKeyColumns(tmpRange); |
---|
| 1239 | setTTester(); |
---|
| 1240 | } |
---|
| 1241 | |
---|
| 1242 | public void setTestBaseFromDialog() { |
---|
| 1243 | ListSelectorDialog jd = new ListSelectorDialog(null, m_TestsList); |
---|
| 1244 | |
---|
| 1245 | // Open the dialog |
---|
| 1246 | jd.showDialog(); |
---|
| 1247 | } |
---|
| 1248 | |
---|
| 1249 | public void setDisplayedFromDialog() { |
---|
| 1250 | ListSelectorDialog jd = new ListSelectorDialog(null, m_DisplayedList); |
---|
| 1251 | |
---|
| 1252 | // Open the dialog |
---|
| 1253 | jd.showDialog(); |
---|
| 1254 | } |
---|
| 1255 | |
---|
| 1256 | /** |
---|
| 1257 | * displays the Dialog for the output format and sets the chosen settings, |
---|
| 1258 | * if the user approves. |
---|
| 1259 | */ |
---|
| 1260 | public void setOutputFormatFromDialog() { |
---|
| 1261 | OutputFormatDialog dialog = new OutputFormatDialog(PropertyDialog.getParentFrame(this)); |
---|
| 1262 | |
---|
| 1263 | m_ResultMatrix.setShowStdDev(m_ShowStdDevs.isSelected()); |
---|
| 1264 | dialog.setResultMatrix(m_ResultMatrix); |
---|
| 1265 | dialog.setLocationRelativeTo(this); |
---|
| 1266 | |
---|
| 1267 | if (dialog.showDialog() == OutputFormatDialog.APPROVE_OPTION) { |
---|
| 1268 | m_ResultMatrix = dialog.getResultMatrix(); |
---|
| 1269 | m_ShowStdDevs.setSelected(m_ResultMatrix.getShowStdDev()); |
---|
| 1270 | } |
---|
| 1271 | } |
---|
| 1272 | |
---|
| 1273 | /** |
---|
| 1274 | * Save the currently selected result buffer to a file. |
---|
| 1275 | */ |
---|
| 1276 | protected void saveBuffer() { |
---|
| 1277 | StringBuffer sb = m_History.getSelectedBuffer(); |
---|
| 1278 | if (sb != null) { |
---|
| 1279 | if (m_SaveOut.save(sb)) { |
---|
| 1280 | JOptionPane.showMessageDialog(this, |
---|
| 1281 | "File saved", |
---|
| 1282 | "Results", |
---|
| 1283 | JOptionPane.INFORMATION_MESSAGE); |
---|
| 1284 | } |
---|
| 1285 | } else { |
---|
| 1286 | m_SaveOutBut.setEnabled(false); |
---|
| 1287 | } |
---|
| 1288 | } |
---|
| 1289 | |
---|
| 1290 | /** |
---|
| 1291 | * sets the currently selected Tester-Class. |
---|
| 1292 | */ |
---|
| 1293 | protected void setTester() { |
---|
| 1294 | Tester tester; |
---|
| 1295 | Tester t; |
---|
| 1296 | int i; |
---|
| 1297 | |
---|
| 1298 | if (m_TesterClasses.getSelectedItem() == null) |
---|
| 1299 | return; |
---|
| 1300 | |
---|
| 1301 | tester = null; |
---|
| 1302 | |
---|
| 1303 | // find display name |
---|
| 1304 | try { |
---|
| 1305 | for (i = 0; i < m_Testers.size(); i++) { |
---|
| 1306 | t = (Tester) ((Class) m_Testers.get(i)).newInstance(); |
---|
| 1307 | if (t.getDisplayName().equals(m_TesterClasses.getSelectedItem())) { |
---|
| 1308 | tester = t; |
---|
| 1309 | break; |
---|
| 1310 | } |
---|
| 1311 | } |
---|
| 1312 | } |
---|
| 1313 | catch (Exception e) { |
---|
| 1314 | e.printStackTrace(); |
---|
| 1315 | } |
---|
| 1316 | |
---|
| 1317 | if (tester == null) { |
---|
| 1318 | tester = new PairedCorrectedTTester(); // default |
---|
| 1319 | m_TesterClasses.setSelectedItem(tester.getDisplayName()); |
---|
| 1320 | } |
---|
| 1321 | |
---|
| 1322 | tester.assign(m_TTester); |
---|
| 1323 | m_TTester = tester; |
---|
| 1324 | m_PerformBut.setToolTipText(m_TTester.getToolTipText()); |
---|
| 1325 | System.out.println("Tester set to: " + m_TTester.getClass().getName()); |
---|
| 1326 | } |
---|
| 1327 | |
---|
| 1328 | /** |
---|
| 1329 | * Tests out the results panel from the command line. |
---|
| 1330 | * |
---|
| 1331 | * @param args ignored |
---|
| 1332 | */ |
---|
| 1333 | public static void main(String [] args) { |
---|
| 1334 | |
---|
| 1335 | try { |
---|
| 1336 | final JFrame jf = new JFrame("Weka Experiment: Results Analysis"); |
---|
| 1337 | jf.getContentPane().setLayout(new BorderLayout()); |
---|
| 1338 | final ResultsPanel sp = new ResultsPanel(); |
---|
| 1339 | //sp.setBorder(BorderFactory.createTitledBorder("Setup")); |
---|
| 1340 | jf.getContentPane().add(sp, BorderLayout.CENTER); |
---|
| 1341 | jf.addWindowListener(new WindowAdapter() { |
---|
| 1342 | public void windowClosing(WindowEvent e) { |
---|
| 1343 | jf.dispose(); |
---|
| 1344 | System.exit(0); |
---|
| 1345 | } |
---|
| 1346 | }); |
---|
| 1347 | jf.pack(); |
---|
| 1348 | jf.setSize(700, 550); |
---|
| 1349 | jf.setVisible(true); |
---|
| 1350 | } catch (Exception ex) { |
---|
| 1351 | ex.printStackTrace(); |
---|
| 1352 | System.err.println(ex.getMessage()); |
---|
| 1353 | } |
---|
| 1354 | } |
---|
| 1355 | } |
---|