/** gets the data from GUI components. */ private void getData() { if (m_IgnoreChanges) return; // format try { if (!m_ResultMatrix .getClass() .equals(m_OutputFormatClasses.get(m_OutputFormatComboBox.getSelectedIndex()))) { if (m_OutputFormatClasses .get(m_OutputFormatComboBox.getSelectedIndex()) .equals(ExperimenterDefaults.getOutputFormat().getClass())) m_ResultMatrix = ExperimenterDefaults.getOutputFormat(); else m_ResultMatrix = (ResultMatrix) ((Class) m_OutputFormatClasses.get(m_OutputFormatComboBox.getSelectedIndex())) .newInstance(); } } catch (Exception e) { e.printStackTrace(); m_ResultMatrix = new ResultMatrixPlainText(); } // Precision m_ResultMatrix.setMeanPrec(Integer.parseInt(m_MeanPrecSpinner.getValue().toString())); m_ResultMatrix.setStdDevPrec(Integer.parseInt(m_StdDevPrecSpinner.getValue().toString())); // average m_ResultMatrix.setShowAverage(m_ShowAverageCheckBox.isSelected()); // filter names m_ResultMatrix.setRemoveFilterName(m_RemoveFilterNameCheckBox.isSelected()); // update GOE m_ResultMatrixEditor.setValue(m_ResultMatrix); }
/** Creates the results panel with no initial experiment. */ public ResultsPanel() { // defaults m_TTester.setSignificanceLevel(ExperimenterDefaults.getSignificance()); m_TTester.setShowStdDevs(ExperimenterDefaults.getShowStdDevs()); m_ResultMatrix = ExperimenterDefaults.getOutputFormat(); m_ResultMatrix.setShowStdDev(ExperimenterDefaults.getShowStdDevs()); m_ResultMatrix.setMeanPrec(ExperimenterDefaults.getMeanPrecision()); m_ResultMatrix.setStdDevPrec(ExperimenterDefaults.getStdDevPrecision()); m_ResultMatrix.setRemoveFilterName(ExperimenterDefaults.getRemoveFilterClassnames()); m_ResultMatrix.setShowAverage(ExperimenterDefaults.getShowAverage()); // Create/Configure/Connect components m_FileChooser.addChoosableFileFilter(m_csvFileFilter); m_FileChooser.addChoosableFileFilter(m_arffFileFilter); m_FileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); m_FromExpBut.setEnabled(false); m_FromExpBut.setMnemonic('E'); m_FromExpBut.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (m_LoadThread == null) { m_LoadThread = new Thread() { public void run() { setInstancesFromExp(m_Exp); m_LoadThread = null; } }; m_LoadThread.start(); } } }); m_FromDBaseBut.setMnemonic('D'); m_FromDBaseBut.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (m_LoadThread == null) { m_LoadThread = new Thread() { public void run() { setInstancesFromDBaseQuery(); m_LoadThread = null; } }; m_LoadThread.start(); } } }); m_FromFileBut.setMnemonic('F'); m_FromFileBut.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { int returnVal = m_FileChooser.showOpenDialog(ResultsPanel.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final File selected = m_FileChooser.getSelectedFile(); if (m_LoadThread == null) { m_LoadThread = new Thread() { public void run() { setInstancesFromFile(selected); m_LoadThread = null; } }; m_LoadThread.start(); } } } }); setComboSizes(); m_TesterClasses.setEnabled(false); m_DatasetKeyBut.setEnabled(false); m_DatasetKeyBut.setToolTipText("For selecting the keys that are shown as rows."); m_DatasetKeyBut.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setDatasetKeyFromDialog(); } }); m_DatasetKeyList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); m_ResultKeyBut.setEnabled(false); m_ResultKeyBut.setToolTipText("For selecting the keys that are shown as columns."); m_ResultKeyBut.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setResultKeyFromDialog(); } }); m_ResultKeyList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); m_SwapDatasetKeyAndResultKeyBut.setEnabled(false); m_SwapDatasetKeyAndResultKeyBut.setToolTipText( "Swaps the keys for selecting rows and columns."); m_SwapDatasetKeyAndResultKeyBut.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { swapDatasetKeyAndResultKey(); } }); m_CompareCombo.setEnabled(false); m_SortCombo.setEnabled(false); m_SigTex.setEnabled(false); m_TestsButton.setEnabled(false); m_TestsButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setTestBaseFromDialog(); } }); m_DisplayedButton.setEnabled(false); m_DisplayedButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setDisplayedFromDialog(); } }); m_ShowStdDevs.setEnabled(false); m_ShowStdDevs.setSelected(ExperimenterDefaults.getShowStdDevs()); m_OutputFormatButton.setEnabled(false); m_OutputFormatButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setOutputFormatFromDialog(); } }); m_PerformBut.setEnabled(false); m_PerformBut.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { performTest(); m_SaveOutBut.setEnabled(true); } }); m_PerformBut.setToolTipText(m_TTester.getToolTipText()); m_SaveOutBut.setEnabled(false); m_SaveOutBut.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { saveBuffer(); } }); m_OutText.setFont(new Font("Monospaced", Font.PLAIN, 12)); m_OutText.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); m_OutText.setEditable(false); m_History.setBorder(BorderFactory.createTitledBorder("Result list")); // Set up the GUI layout JPanel p1 = new JPanel(); p1.setBorder(BorderFactory.createTitledBorder("Source")); JPanel p2 = new JPanel(); GridBagLayout gb = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); p2.setBorder(BorderFactory.createEmptyBorder(5, 5, 10, 5)); // p2.setLayout(new GridLayout(1, 3)); p2.setLayout(gb); constraints.gridx = 0; constraints.gridy = 0; constraints.weightx = 5; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.insets = new Insets(0, 2, 0, 2); p2.add(m_FromFileBut, constraints); constraints.gridx = 1; constraints.gridy = 0; constraints.weightx = 5; constraints.gridwidth = 1; constraints.gridheight = 1; p2.add(m_FromDBaseBut, constraints); constraints.gridx = 2; constraints.gridy = 0; constraints.weightx = 5; constraints.gridwidth = 1; constraints.gridheight = 1; p2.add(m_FromExpBut, constraints); p1.setLayout(new BorderLayout()); p1.add(m_FromLab, BorderLayout.CENTER); p1.add(p2, BorderLayout.EAST); JPanel p3 = new JPanel(); p3.setBorder(BorderFactory.createTitledBorder("Configure test")); GridBagLayout gbL = new GridBagLayout(); p3.setLayout(gbL); int y = 0; GridBagConstraints gbC = new GridBagConstraints(); gbC.anchor = GridBagConstraints.EAST; gbC.gridy = y; gbC.gridx = 0; gbC.insets = new Insets(2, 10, 2, 10); gbL.setConstraints(m_TesterClassesLabel, gbC); m_TesterClassesLabel.setDisplayedMnemonic('w'); m_TesterClassesLabel.setLabelFor(m_TesterClasses); p3.add(m_TesterClassesLabel); gbC = new GridBagConstraints(); gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; gbC.insets = new Insets(5, 0, 5, 0); gbC.fill = GridBagConstraints.HORIZONTAL; gbL.setConstraints(m_TesterClasses, gbC); p3.add(m_TesterClasses); m_TesterClasses.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setTester(); } }); setSelectedItem(m_TesterClasses, ExperimenterDefaults.getTester()); y++; gbC = new GridBagConstraints(); gbC.anchor = GridBagConstraints.EAST; gbC.gridy = y; gbC.gridx = 0; gbC.insets = new Insets(2, 10, 2, 10); gbL.setConstraints(m_DatasetAndResultKeysLabel, gbC); m_DatasetAndResultKeysLabel.setDisplayedMnemonic('R'); m_DatasetAndResultKeysLabel.setLabelFor(m_DatasetKeyBut); p3.add(m_DatasetAndResultKeysLabel); m_PanelDatasetResultKeys.add(m_DatasetKeyBut); m_PanelDatasetResultKeys.add(m_ResultKeyBut); m_PanelDatasetResultKeys.add(m_SwapDatasetKeyAndResultKeyBut); gbC = new GridBagConstraints(); gbC.fill = GridBagConstraints.HORIZONTAL; gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; gbC.insets = new Insets(5, 0, 5, 0); gbL.setConstraints(m_PanelDatasetResultKeys, gbC); p3.add(m_PanelDatasetResultKeys); y++; JLabel lab = new JLabel("Comparison field", SwingConstants.RIGHT); lab.setDisplayedMnemonic('m'); lab.setLabelFor(m_CompareCombo); gbC = new GridBagConstraints(); gbC.anchor = GridBagConstraints.EAST; gbC.gridy = y; gbC.gridx = 0; gbC.insets = new Insets(2, 10, 2, 10); gbL.setConstraints(lab, gbC); p3.add(lab); gbC = new GridBagConstraints(); gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; gbC.insets = new Insets(5, 0, 5, 0); gbC.fill = GridBagConstraints.HORIZONTAL; gbL.setConstraints(m_CompareCombo, gbC); p3.add(m_CompareCombo); y++; lab = new JLabel("Significance", SwingConstants.RIGHT); lab.setDisplayedMnemonic('g'); lab.setLabelFor(m_SigTex); gbC = new GridBagConstraints(); gbC.anchor = GridBagConstraints.EAST; gbC.gridy = y; gbC.gridx = 0; gbC.insets = new Insets(2, 10, 2, 10); gbL.setConstraints(lab, gbC); p3.add(lab); gbC = new GridBagConstraints(); gbC.fill = GridBagConstraints.HORIZONTAL; gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; gbL.setConstraints(m_SigTex, gbC); p3.add(m_SigTex); y++; lab = new JLabel("Sorting (asc.) by", SwingConstants.RIGHT); lab.setDisplayedMnemonic('S'); lab.setLabelFor(m_SortCombo); gbC = new GridBagConstraints(); gbC.anchor = GridBagConstraints.EAST; gbC.gridy = y; gbC.gridx = 0; gbC.insets = new Insets(2, 10, 2, 10); gbL.setConstraints(lab, gbC); p3.add(lab); gbC = new GridBagConstraints(); gbC.anchor = GridBagConstraints.WEST; gbC.fill = GridBagConstraints.HORIZONTAL; gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; gbC.insets = new Insets(5, 0, 5, 0); gbL.setConstraints(m_SortCombo, gbC); p3.add(m_SortCombo); y++; lab = new JLabel("Test base", SwingConstants.RIGHT); lab.setDisplayedMnemonic('b'); lab.setLabelFor(m_TestsButton); gbC = new GridBagConstraints(); gbC.anchor = GridBagConstraints.EAST; gbC.gridy = y; gbC.gridx = 0; gbC.insets = new Insets(2, 10, 2, 10); gbL.setConstraints(lab, gbC); p3.add(lab); gbC = new GridBagConstraints(); gbC.fill = GridBagConstraints.HORIZONTAL; gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; gbC.insets = new Insets(5, 0, 5, 0); gbL.setConstraints(m_TestsButton, gbC); p3.add(m_TestsButton); y++; lab = new JLabel("Displayed Columns", SwingConstants.RIGHT); lab.setDisplayedMnemonic('i'); lab.setLabelFor(m_DisplayedButton); gbC = new GridBagConstraints(); gbC.anchor = GridBagConstraints.EAST; gbC.gridy = y; gbC.gridx = 0; gbC.insets = new Insets(2, 10, 2, 10); gbL.setConstraints(lab, gbC); p3.add(lab); gbC = new GridBagConstraints(); gbC.fill = GridBagConstraints.HORIZONTAL; gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; gbC.insets = new Insets(5, 0, 5, 0); gbL.setConstraints(m_DisplayedButton, gbC); p3.add(m_DisplayedButton); y++; lab = new JLabel("Show std. deviations", SwingConstants.RIGHT); lab.setDisplayedMnemonic('a'); lab.setLabelFor(m_ShowStdDevs); gbC = new GridBagConstraints(); gbC.anchor = GridBagConstraints.EAST; gbC.gridy = y; gbC.gridx = 0; gbC.insets = new Insets(2, 10, 2, 10); gbL.setConstraints(lab, gbC); p3.add(lab); gbC = new GridBagConstraints(); gbC.anchor = GridBagConstraints.WEST; gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; gbC.insets = new Insets(5, 0, 5, 0); gbL.setConstraints(m_ShowStdDevs, gbC); p3.add(m_ShowStdDevs); y++; lab = new JLabel("Output Format", SwingConstants.RIGHT); lab.setDisplayedMnemonic('O'); lab.setLabelFor(m_OutputFormatButton); gbC = new GridBagConstraints(); gbC.anchor = GridBagConstraints.EAST; gbC.gridy = y; gbC.gridx = 0; gbC.insets = new Insets(2, 10, 2, 10); gbL.setConstraints(lab, gbC); p3.add(lab); gbC = new GridBagConstraints(); gbC.anchor = GridBagConstraints.WEST; gbC.fill = GridBagConstraints.HORIZONTAL; gbC.gridy = y; gbC.gridx = 1; gbC.weightx = 100; gbC.insets = new Insets(5, 0, 5, 0); gbL.setConstraints(m_OutputFormatButton, gbC); p3.add(m_OutputFormatButton); JPanel output = new JPanel(); output.setLayout(new BorderLayout()); output.setBorder(BorderFactory.createTitledBorder("Test output")); output.add(new JScrollPane(m_OutText), BorderLayout.CENTER); JPanel mondo = new JPanel(); gbL = new GridBagLayout(); mondo.setLayout(gbL); gbC = new GridBagConstraints(); // gbC.anchor = GridBagConstraints.WEST; // gbC.fill = GridBagConstraints.HORIZONTAL; gbC.gridy = 0; gbC.gridx = 0; gbL.setConstraints(p3, gbC); mondo.add(p3); JPanel bts = new JPanel(); m_PerformBut.setMnemonic('t'); m_SaveOutBut.setMnemonic('S'); bts.setLayout(new GridLayout(1, 2, 5, 5)); bts.add(m_PerformBut); bts.add(m_SaveOutBut); gbC = new GridBagConstraints(); gbC.anchor = GridBagConstraints.NORTH; gbC.fill = GridBagConstraints.HORIZONTAL; gbC.gridy = 1; gbC.gridx = 0; gbC.insets = new Insets(5, 5, 5, 5); gbL.setConstraints(bts, gbC); mondo.add(bts); gbC = new GridBagConstraints(); // gbC.anchor = GridBagConstraints.NORTH; gbC.fill = GridBagConstraints.BOTH; gbC.gridy = 2; gbC.gridx = 0; gbC.weightx = 0; gbC.weighty = 100; gbL.setConstraints(m_History, gbC); mondo.add(m_History); /*gbC = new GridBagConstraints(); gbC.fill = GridBagConstraints.BOTH; gbC.gridy = 0; gbC.gridx = 1; gbC.gridheight = 3; gbC.weightx = 100; gbC.weighty = 100; gbL.setConstraints(output, gbC);*/ // mondo.add(output); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mondo, output); splitPane.setOneTouchExpandable(true); // splitPane.setDividerLocation(100); setLayout(new BorderLayout()); add(p1, BorderLayout.NORTH); // add(mondo , BorderLayout.CENTER); add(splitPane, BorderLayout.CENTER); }
/** performs the creation of the dialog and all its components. */ protected void initGUI() { JPanel panel; SpinnerNumberModel model; JPanel panel2; getContentPane().setLayout(new BorderLayout()); panel = new JPanel(new GridLayout(6, 1)); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); getContentPane().add(panel, BorderLayout.CENTER); // mean precision m_MeanPrecSpinner = new JSpinner(); m_MeanPrecSpinner.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { getData(); } }); model = (SpinnerNumberModel) m_MeanPrecSpinner.getModel(); model.setMaximum(new Integer(20)); model.setMinimum(new Integer(0)); m_MeanPrecLabel = new JLabel("Mean Precision"); m_MeanPrecLabel.setDisplayedMnemonic('M'); m_MeanPrecLabel.setLabelFor(m_MeanPrecSpinner); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_MeanPrecLabel); panel2.add(m_MeanPrecSpinner); panel.add(panel2); // stddev precision m_StdDevPrecSpinner = new JSpinner(); m_StdDevPrecSpinner.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { getData(); } }); model = (SpinnerNumberModel) m_StdDevPrecSpinner.getModel(); model.setMaximum(new Integer(20)); model.setMinimum(new Integer(0)); m_StdDevPrecLabel = new JLabel("StdDev. Precision"); m_StdDevPrecLabel.setDisplayedMnemonic('S'); m_StdDevPrecLabel.setLabelFor(m_StdDevPrecSpinner); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_StdDevPrecLabel); panel2.add(m_StdDevPrecSpinner); panel.add(panel2); // Format m_OutputFormatComboBox = new JComboBox(m_OutputFormatNames); m_OutputFormatComboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { getData(); } }); m_OutputFormatLabel = new JLabel("Output Format"); m_OutputFormatLabel.setDisplayedMnemonic('F'); m_OutputFormatLabel.setLabelFor(m_OutputFormatComboBox); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_OutputFormatLabel); panel2.add(m_OutputFormatComboBox); panel.add(panel2); // Average m_ShowAverageCheckBox = new JCheckBox(""); m_ShowAverageCheckBox.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { getData(); } }); m_ShowAverageLabel = new JLabel("Show Average"); m_ShowAverageLabel.setDisplayedMnemonic('A'); m_ShowAverageLabel.setLabelFor(m_ShowAverageCheckBox); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_ShowAverageLabel); panel2.add(m_ShowAverageCheckBox); panel.add(panel2); // Remove filter classname m_RemoveFilterNameCheckBox = new JCheckBox(""); m_RemoveFilterNameCheckBox.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { getData(); } }); m_RemoveFilterNameLabel = new JLabel("Remove filter classnames"); m_RemoveFilterNameLabel.setDisplayedMnemonic('R'); m_RemoveFilterNameLabel.setLabelFor(m_RemoveFilterNameCheckBox); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_RemoveFilterNameLabel); panel2.add(m_RemoveFilterNameCheckBox); panel.add(panel2); // Advanced setup m_ResultMatrix = ExperimenterDefaults.getOutputFormat(); m_ResultMatrixEditor = new GenericObjectEditor(true); m_ResultMatrixEditor.setClassType(ResultMatrix.class); m_ResultMatrixEditor.setValue(m_ResultMatrix); m_ResultMatrixEditor.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { // user selected different class? if (!m_ResultMatrix.getClass().equals(m_ResultMatrixEditor.getValue().getClass())) { // if it's the preferred class, then automaticallly use the Experimenter defaults if (m_ResultMatrixEditor .getValue() .getClass() .equals(ExperimenterDefaults.getOutputFormat().getClass())) { m_ResultMatrix = ExperimenterDefaults.getOutputFormat(); m_ResultMatrixEditor.setValue(ExperimenterDefaults.getOutputFormat()); } else { m_ResultMatrix = (ResultMatrix) m_ResultMatrixEditor.getValue(); } setData(); } repaint(); } }); ((GenericObjectEditor.GOEPanel) m_ResultMatrixEditor.getCustomEditor()) .addOkListener( new ActionListener() { public void actionPerformed(ActionEvent e) { m_ResultMatrix = (ResultMatrix) m_ResultMatrixEditor.getValue(); setData(); } }); m_ResultMatrixPanel = new PropertyPanel(m_ResultMatrixEditor, false); m_ResultMatrixLabel = new JLabel("Advanced setup"); panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(m_ResultMatrixLabel); panel2.add(m_ResultMatrixPanel); panel.add(panel2); // Buttons panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(panel, BorderLayout.SOUTH); m_CancelButton = new JButton("Cancel"); m_CancelButton.setMnemonic('C'); m_CancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { m_Result = CANCEL_OPTION; setVisible(false); } }); m_OkButton = new JButton("OK"); m_OkButton.setMnemonic('O'); m_OkButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { getData(); m_Result = APPROVE_OPTION; setVisible(false); } }); panel.add(m_OkButton); panel.add(m_CancelButton); // default button getRootPane().setDefaultButton(m_OkButton); // initial layout (to get widths and heights) pack(); // adjust dimensions m_MeanPrecLabel.setPreferredSize( new Dimension(m_RemoveFilterNameLabel.getWidth(), m_MeanPrecLabel.getHeight())); m_MeanPrecSpinner.setPreferredSize( new Dimension(m_MeanPrecSpinner.getWidth() * 3, m_MeanPrecSpinner.getHeight())); m_StdDevPrecLabel.setPreferredSize( new Dimension(m_RemoveFilterNameLabel.getWidth(), m_StdDevPrecLabel.getHeight())); m_StdDevPrecSpinner.setPreferredSize( new Dimension(m_StdDevPrecSpinner.getWidth() * 3, m_StdDevPrecSpinner.getHeight())); m_OutputFormatLabel.setPreferredSize( new Dimension(m_RemoveFilterNameLabel.getWidth(), m_OutputFormatLabel.getHeight())); m_ShowAverageLabel.setPreferredSize( new Dimension(m_RemoveFilterNameLabel.getWidth(), m_ShowAverageLabel.getHeight())); m_ResultMatrixLabel.setPreferredSize( new Dimension(m_RemoveFilterNameLabel.getWidth(), m_ResultMatrixLabel.getHeight())); m_ResultMatrixPanel.setPreferredSize( new Dimension( (int) (m_ResultMatrixPanel.getWidth() * 1.5), m_ResultMatrixPanel.getHeight())); // final layout pack(); }