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

📄 samplingoperatorproperty.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 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.
 */

/*
 * Created on 2005/1/17
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

package eti.bi.alphaminer.patch.standard.operation.property;

/**
 * @author kclai
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */


import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSlider;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SpinnerNumberModel;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;


import com.prudsys.pdm.Core.MiningDataSpecification;
import com.prudsys.pdm.Core.MiningException;
import com.prudsys.pdm.Input.MiningStoredData;

import eti.bi.alphaminer.core.handler.ICaseHandler;
import eti.bi.alphaminer.operation.operator.DimensionConstants;
import eti.bi.alphaminer.operation.operator.INodeInfo;
import eti.bi.alphaminer.operation.operator.Operator;
import eti.bi.alphaminer.operation.property.OperatorProperty;
import eti.bi.alphaminer.patch.standard.operation.operator.SamplingOperator;
import eti.bi.exception.SysException;
import eti.bi.util.ValueValidator;
import eti.bi.common.Locale.Resource;
public class SamplingOperatorProperty extends OperatorProperty implements
		ChangeListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1078661403269229625L;

	// Constants
	private final int SAMPLING_SIZE_DEFAULT_VALUE = 50;

	@SuppressWarnings("unused")
	private final static String DEFAULT = Resource.srcStr("SelectItem");

	private MiningDataSpecification m_MetaData;

	private MiningStoredData m_msd;

	// JComponents
	//	private JTabbedPane m_TabbedPane = new JTabbedPane();

	private JLabel m_RandomSeedLabel = new JLabel(Resource.srcStr("randomSeed"));

	private JLabel m_SampleSizeLabel = new JLabel();

	private JTextField m_RandomSeedTF = new JTextField("1");

	private JSlider m_SampleSizeSlider = new JSlider(0, 100, 50);

	private JSpinner m_OneInNSpinner = new JSpinner(new SpinnerNumberModel(1,
			1, 100, 1));

	private JSpinner m_FirstNSpinner = new JSpinner(new SpinnerNumberModel(1,
			1, 100, 1));

	private JRadioButton m_RadioRandom = new JRadioButton(Resource.srcStr("m_RadioRandom"));

	private JRadioButton m_RadioOneInN = new JRadioButton("1-in-n");

	private JRadioButton m_RadioFirstN = new JRadioButton(Resource.srcStr("m_RadioFirstN"));

	private ButtonGroup m_ModeButtonGroup = new ButtonGroup();

	private JButton m_ButtonReset = new JButton();

	private JButton m_ButtonApply = new JButton();

	private JButton m_ButtonClose = new JButton();

	private final Dimension m_defaultButtonSize = new Dimension(65, 25);

	// variables
	private int m_SliderValue = 50;

	public SamplingOperatorProperty(String a_CaseID, String a_NodeID, String a_Name,  INodeInfo a_NodeInfo, ICaseHandler a_CaseHandler) throws MiningException, SysException {
		super(a_CaseID, a_NodeID, a_Name,  a_NodeInfo, a_CaseHandler);
		createSamplingOperatorProperty();
		this.setTitle(Resource.srcStr("Sampling")+" [" + a_NodeID + "]"); // Added title menu by
													  // Joyce 2005/02/17

	}

	private void createSamplingOperatorProperty() throws MiningException {

		JPanel outterRandomPanel = new JPanel(new BorderLayout(0, 0));
		JPanel outterOneInNPanel = new JPanel(new BorderLayout(0, 0));
		JPanel outterFirstNPanel = new JPanel(new BorderLayout(0, 0));

		m_ModeButtonGroup.add(m_RadioRandom);
		m_ModeButtonGroup.add(m_RadioOneInN);
		m_ModeButtonGroup.add(m_RadioFirstN);

		/*
		 * create random panel
		 */

		// create m_SliderPanel
		JPanel sliderPanel = new JPanel();

		m_SampleSizeSlider.setMajorTickSpacing(50);
		m_SampleSizeSlider.setMinorTickSpacing(10);
		m_SampleSizeSlider.setPaintTicks(true);
		m_SampleSizeSlider.setPreferredSize(new Dimension(100, 30));
		m_SampleSizeSlider.addChangeListener(new ChangeListener() {
			public void stateChanged(ChangeEvent e) {
				m_SliderValue = m_SampleSizeSlider.getValue();
				m_SampleSizeLabel.setText("Sample size (" + m_SliderValue
						+ "%)");

			}
		});
		sliderPanel.add(new JLabel("0"));
		sliderPanel.add(m_SampleSizeSlider);
		sliderPanel.add(new JLabel("100"));

		JPanel randomPanel = new JPanel();
		Border margin1 = new EmptyBorder(0, 20, 5, 0);
		TitledBorder m_border1 = new TitledBorder(new EtchedBorder(), "");
		randomPanel.setBorder(new CompoundBorder(margin1, m_border1));

		GridBagLayout layout = new GridBagLayout();
		randomPanel.setLayout(layout);
		GridBagConstraints c = new GridBagConstraints();

		c.insets = new Insets(8, 5, 0, 0);
		c.gridx = 0;
		c.gridy = 0;
		c.weightx = 0.0;
		c.fill = GridBagConstraints.NONE;
		c.anchor = GridBagConstraints.LINE_START;
		randomPanel.add(m_RandomSeedLabel, c);

		c.insets = new Insets(8, 6, 0, 0);
		c.gridx = 1;
		c.gridy = 0;
		c.fill = GridBagConstraints.NONE;
		c.anchor = GridBagConstraints.LINE_START;
		m_RandomSeedTF.setPreferredSize(DimensionConstants.TEXT_FIELD_DIM);
		m_RandomSeedTF.setMaximumSize(DimensionConstants.TEXT_FIELD_DIM);
		m_RandomSeedTF.setMinimumSize(DimensionConstants.TEXT_FIELD_DIM);
		//		m_RandomSeedTF.setPreferredSize(new Dimension(50, 20));
		randomPanel.add(m_RandomSeedTF, c);

		c.insets = new Insets(0, 5, 0, 0);
		c.gridx = 0;
		c.gridy = 1;
		c.fill = GridBagConstraints.NONE;
		c.anchor = GridBagConstraints.LINE_START;
		m_SampleSizeLabel.setText(Resource.srcStr("SampleSize") + SAMPLING_SIZE_DEFAULT_VALUE
				+ "%)");
		m_SampleSizeLabel.setPreferredSize(new Dimension(100, 50));
		randomPanel.add(m_SampleSizeLabel, c);

		c.insets = new Insets(0, 0, 0, 0);
		c.gridx = 1;
		c.gridy = 1;
		c.fill = GridBagConstraints.NONE;
		c.anchor = GridBagConstraints.LINE_START;
		randomPanel.add(sliderPanel, c);

		c.gridx = 2;
		c.gridy = 0;
		c.gridheight = 2;
		c.weightx = 1.0;
		randomPanel.add(new JLabel(""), c);

		outterRandomPanel.add(m_RadioRandom, BorderLayout.NORTH);
		outterRandomPanel.add(randomPanel, BorderLayout.SOUTH);
		/*
		 * create 1-in-n panel
		 */
		JPanel oneInNPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
		Border margin2 = new EmptyBorder(0, 20, 5, 0);
		TitledBorder m_border2 = new TitledBorder(new EtchedBorder(), "");
		oneInNPanel.setBorder(new CompoundBorder(margin2, m_border2));

		//		oneInNPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15,
		// 15));
		m_OneInNSpinner.setPreferredSize(new Dimension(50,
				DimensionConstants.SPINNER_HEIGHT));
		oneInNPanel.add(new JLabel(Resource.srcStr("nValue")));
		oneInNPanel.add(m_OneInNSpinner);

		outterOneInNPanel.add(m_RadioOneInN, BorderLayout.NORTH);
		outterOneInNPanel.add(oneInNPanel, BorderLayout.SOUTH);
		/*
		 * create First n panel
		 */
		JPanel firstNPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
		Border margin3 = new EmptyBorder(0, 20, 5, 0);
		TitledBorder m_border3 = new TitledBorder(new EtchedBorder(), "");
		firstNPanel.setBorder(new CompoundBorder(margin3, m_border3));

		//		firstNPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15,
		// 15));
		m_FirstNSpinner.setPreferredSize(new Dimension(50,
				DimensionConstants.SPINNER_HEIGHT));
		firstNPanel.add(new JLabel(Resource.srcStr("nValue")));
		firstNPanel.add(m_FirstNSpinner);

		outterFirstNPanel.add(m_RadioFirstN, BorderLayout.NORTH);
		outterFirstNPanel.add(firstNPanel, BorderLayout.SOUTH);
		/*
		 * create tabbed pane
		 */

		JPanel samplingMainPanel = new JPanel(new BorderLayout());
		samplingMainPanel.setBorder(new EmptyBorder(0, 0, 5, 0));
		samplingMainPanel.add(outterRandomPanel, BorderLayout.NORTH);
		samplingMainPanel.add(outterOneInNPanel, BorderLayout.CENTER);
		samplingMainPanel.add(outterFirstNPanel, BorderLayout.SOUTH);

		/*
		 * create the button panel
		 */
		JPanel buttonPanel = new JPanel();

		m_ButtonApply.setText(Resource.srcStr("m_ButtonApply"));
		m_ButtonApply.setPreferredSize(m_defaultButtonSize);

		m_ButtonReset.setSelected(false);
		m_ButtonReset.setText(Resource.srcStr("m_ButtonReset"));
		m_ButtonReset.setPreferredSize(m_defaultButtonSize);

		m_ButtonClose.setSelected(false);
		m_ButtonClose.setText(Resource.srcStr("m_ButtonClose"));
		m_ButtonClose.setPreferredSize(m_defaultButtonSize);

		buttonPanel.add(m_ButtonApply);
		buttonPanel.add(m_ButtonReset);
		buttonPanel.add(m_ButtonClose);

		this.getContentPane().add(samplingMainPanel, BorderLayout.NORTH);
		this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
		this.setContentPane(this.getContentPane());
		this.setSize(308, 356);
		//this.setVisible(true);remarked by Joyce

		// add listener
		//<< Added by Joyce 2005/01/24
		m_RadioRandom.addChangeListener(this);
		m_RadioOneInN.addChangeListener(this);
		m_RadioFirstN.addChangeListener(this);
		m_ButtonReset.addActionListener(this);
		m_ButtonApply.addActionListener(this);
		m_ButtonClose.addActionListener(this);
		//>>

⌨️ 快捷键说明

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