⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 misetuppanel.java

📁 MILK 提供了一个实现和比较multi-instance学习算法的环境
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* *    This program is free software; you can redistribute it and/or modify *    it under the terms of the GNU General Public License as published by *    the Free Software Foundation; either version 2 of the License, or *    (at your option) any later version. * *    This program is distributed in the hope that it will be useful, *    but WITHOUT ANY WARRANTY; without even the implied warranty of *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *    GNU General Public License for more details. * *    You should have received a copy of the GNU General Public License *    along with this program; if not, write to the Free Software *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *//* *    SetupPanel.java *    Copyright (C) 1999 Len Trigg, Mark Hall * */package milk.gui.experiment;import weka.core.Tag;import weka.core.SelectedTag;import weka.core.Utils;import weka.gui.ExtensionFileFilter;import weka.gui.SelectedTagEditor;import weka.gui.GenericObjectEditor;import weka.gui.GenericArrayEditor;import weka.gui.PropertyPanel;import weka.gui.FileEditor;import weka.experiment.PropertyNode;import milk.experiment.*;import java.beans.PropertyChangeListener;import java.beans.PropertyChangeEvent;import java.beans.PropertyChangeSupport;import java.io.File;import java.io.FileOutputStream;import java.io.ObjectOutputStream;import java.io.BufferedOutputStream;import java.io.FileInputStream;import java.io.ObjectInputStream;import java.io.BufferedInputStream;import java.awt.Component;import java.awt.BorderLayout;import java.awt.GridLayout;import java.awt.GridBagLayout;import java.awt.GridBagConstraints;import java.awt.Dimension;import java.awt.event.KeyAdapter;import java.awt.event.KeyEvent;import java.awt.event.FocusAdapter;import java.awt.event.FocusEvent;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.awt.Insets;import javax.swing.JPanel;import javax.swing.JLabel;import javax.swing.JFrame;import javax.swing.SwingConstants;import javax.swing.JTextField;import javax.swing.Box;import javax.swing.BorderFactory;import javax.swing.BoxLayout;import javax.swing.JTextArea;import javax.swing.JScrollPane;import javax.swing.JButton;import javax.swing.JFileChooser;import javax.swing.JOptionPane;import javax.swing.filechooser.FileFilter;import javax.swing.JRadioButton;import javax.swing.ButtonGroup;/**  * This panel controls the configuration of an experiment. * * @author Len Trigg (trigg@cs.waikato.ac.nz) * @author Mark Hall (mhall@cs.waikato.ac.nz) * @version $Revision: 1.21 $ */public class MISetupPanel extends JPanel {  /** The experiment being configured */  protected MIExperiment m_Exp;  /** Click to load an experiment */  protected JButton m_OpenBut = new JButton("Open...");  /** Click to save an experiment */  protected JButton m_SaveBut = new JButton("Save...");  /** Click to create a new experiment with default settings */  protected JButton m_NewBut = new JButton("New");  /** A filter to ensure only experiment files get shown in the chooser */  protected FileFilter m_ExpFilter =     new ExtensionFileFilter(MIExperiment.FILE_EXTENSION,                             "Experiment configuration files");  /** The file chooser for selecting experiments */  protected JFileChooser m_FileChooser = new JFileChooser(new File(System.getProperty("user.dir")));  /** The ResultProducer editor */  protected GenericObjectEditor m_RPEditor = new GenericObjectEditor();  /** The panel to contain the ResultProducer editor */  protected PropertyPanel m_RPEditorPanel = new PropertyPanel(m_RPEditor);  /** The ResultListener editor */  protected GenericObjectEditor m_RLEditor = new GenericObjectEditor();  /** The panel to contain the ResultListener editor */  protected PropertyPanel m_RLEditorPanel = new PropertyPanel(m_RLEditor);  /** The panel that configures iteration on custom resultproducer property */  protected MIGeneratorPropertyIteratorPanel m_GeneratorPropertyPanel    = new MIGeneratorPropertyIteratorPanel();  /** The panel for configuring run numbers */  protected MIRunNumberPanel m_RunNumberPanel = new MIRunNumberPanel();  /** The panel for enabling a distributed experiment */  protected MIDistributeExperimentPanel m_DistributeExperimentPanel =     new MIDistributeExperimentPanel();  /** The panel for configuring selected datasets */  protected MIDatasetListPanel m_DatasetListPanel = new MIDatasetListPanel();  /** Area for user notes Default of 5 rows */  protected JTextArea m_NotesText = new JTextArea(null, 5, 0);  /**   * Manages sending notifications to people when we change the experiment,   * at this stage, only the resultlistener so the resultpanel can update.   */  protected PropertyChangeSupport m_Support = new PropertyChangeSupport(this);  /** Click to advacne data set before custom generator */  protected JRadioButton m_advanceDataSetFirst =     new JRadioButton("Data sets first");  /** Click to advance custom generator before data set */  protected JRadioButton m_advanceIteratorFirst =     new JRadioButton("Custom generator first");  /** Handle radio buttons */  ActionListener m_RadioListener = new ActionListener() {      public void actionPerformed(ActionEvent e) {	updateRadioLinks();      }    };    // Registers the appropriate property editors  static {    System.err.println("---Registering Weka Editors---");    java.beans.PropertyEditorManager      .registerEditor(java.io.File.class,		      FileEditor.class);    java.beans.PropertyEditorManager      .registerEditor(milk.experiment.MIResultListener.class,		      GenericObjectEditor.class);    java.beans.PropertyEditorManager      .registerEditor(milk.experiment.MIResultProducer.class,		      GenericObjectEditor.class);    java.beans.PropertyEditorManager      .registerEditor(milk.experiment.MISplitEvaluator.class,		      GenericObjectEditor.class);    java.beans.PropertyEditorManager      .registerEditor(milk.classifiers.MIClassifier.class,		      GenericObjectEditor.class);    java.beans.PropertyEditorManager      .registerEditor(weka.classifiers.Classifier.class,		      GenericObjectEditor.class);    java.beans.PropertyEditorManager      .registerEditor(weka.classifiers.Classifier [].class,		      GenericArrayEditor.class);    java.beans.PropertyEditorManager      .registerEditor(Object [].class,		      GenericArrayEditor.class);    java.beans.PropertyEditorManager      .registerEditor(weka.filters.Filter.class,		      GenericObjectEditor.class);    java.beans.PropertyEditorManager      .registerEditor(weka.attributeSelection.ASEvaluation.class,		      GenericObjectEditor.class);    java.beans.PropertyEditorManager      .registerEditor(weka.attributeSelection.ASSearch.class,		      GenericObjectEditor.class);    java.beans.PropertyEditorManager      .registerEditor(weka.clusterers.Clusterer.class,		      GenericObjectEditor.class);    java.beans.PropertyEditorManager      .registerEditor(SelectedTag.class,		      SelectedTagEditor.class);    java.beans.PropertyEditorManager      .registerEditor(weka.classifiers.CostMatrix.class,		      weka.gui.CostMatrixEditor.class);  }    /**   * Creates the setup panel with the supplied initial experiment.   *   * @param exp a value of type 'Experiment'   */  public MISetupPanel(MIExperiment exp) {    this();    setExperiment(exp);  }    /**   * Creates the setup panel with no initial experiment.   */  public MISetupPanel() {    m_DistributeExperimentPanel.      addCheckBoxActionListener(new ActionListener() {	  public void actionPerformed(ActionEvent e) {	    if (m_DistributeExperimentPanel.distributedExperimentSelected()) {	      if (!(m_Exp instanceof MIRemoteExperiment)) {		try {		  MIRemoteExperiment re = new MIRemoteExperiment(m_Exp);		  setExperiment(re);		} catch (Exception ex) {		  ex.printStackTrace();		}	      }	    } else {	      if (m_Exp instanceof MIRemoteExperiment) {		setExperiment(((MIRemoteExperiment)m_Exp).getBaseExperiment());	      }	    }	  }	});	          m_NewBut.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {	setExperiment(new MIExperiment());      }    });    m_SaveBut.setEnabled(false);    m_SaveBut.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {	saveExperiment();      }    });    m_OpenBut.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {	openExperiment();      }    });    m_FileChooser.setFileFilter(m_ExpFilter);    m_FileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);        m_GeneratorPropertyPanel.addActionListener(new ActionListener() {	public void actionPerformed(ActionEvent e) {	  updateRadioLinks();	}      });    m_RPEditor.setClassType(MIResultProducer.class);    m_RPEditor.setEnabled(false);    m_RPEditor.addPropertyChangeListener(new PropertyChangeListener() {      public void propertyChange(PropertyChangeEvent e) {	m_Exp.setResultProducer((MIResultProducer) m_RPEditor.getValue());	m_Exp.setUsePropertyIterator(false);	m_Exp.setPropertyArray(null);	m_Exp.setPropertyPath(null);	m_GeneratorPropertyPanel.setExperiment(m_Exp);	repaint();      }    });    m_RLEditor.setClassType(MIResultListener.class);    m_RLEditor.setEnabled(false);    m_RLEditor.addPropertyChangeListener(new PropertyChangeListener() {      public void propertyChange(PropertyChangeEvent e) {	m_Exp.setResultListener((MIResultListener) m_RLEditor.getValue());	m_Support.firePropertyChange("", null, null);	repaint();      }    });    m_NotesText.setEnabled(false);    m_NotesText.setEditable(true);    m_NotesText.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));    m_NotesText.addKeyListener(new KeyAdapter() {      public void keyReleased(KeyEvent e) {	m_Exp.setNotes(m_NotesText.getText());      }    });    m_NotesText.addFocusListener(new FocusAdapter() {      public void focusLost(FocusEvent e) {	m_Exp.setNotes(m_NotesText.getText());      }    });    // Set up the GUI layout    JPanel buttons = new JPanel();    GridBagLayout gb = new GridBagLayout();    GridBagConstraints constraints = new GridBagConstraints();    buttons.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));    //    buttons.setLayout(new GridLayout(1, 3, 5, 5));    buttons.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);    buttons.add(m_OpenBut,constraints);    constraints.gridx=1;constraints.gridy=0;constraints.weightx=5;    constraints.gridwidth=1;constraints.gridheight=1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -