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

📄 decisiontreeoperatorproperty.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 2004/9/7
 * 
 * $Author$
 * $Date$
 * $Revision$
 *
 */
package eti.bi.alphaminer.patch.standard.operation.property;
 

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

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.border.CompoundBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

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.property.OperatorProperty;
import eti.bi.alphaminer.patch.standard.operation.operator.DecisionTreeOperator;
import eti.bi.common.Locale.Resource;
import eti.bi.exception.SysException;
import eti.bi.util.ValueValidator;


/**
 * DecisionTreeOperatorProperty is a kind of OperatorProperty
 */
public class DecisionTreeOperatorProperty extends OperatorProperty {

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

	/* UI controls */
	private JButton m_ButtonReset = new JButton();

	private JButton m_ButtonSave = new JButton();

	private JButton m_ButtonCancel = new JButton();

	private JTabbedPane m_PropertyPane = new JTabbedPane();

	private JCheckBox m_CheckBoxPruning = new JCheckBox(Resource.srcStr("m_CheckBoxPruning"));

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

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

	private JTextField m_ConfidenceThreshold = new JTextField();

	private JCheckBox m_CheckBoxSubtreeRaising = new JCheckBox(Resource.srcStr("m_CheckBoxSubtreeRaising"));

	private JTextField m_NumFolds = new JTextField();

	private JTextField m_RandomSeed = new JTextField();

	private JCheckBox m_CheckBoxCleanup = new JCheckBox(Resource.srcStr("m_CheckBoxCleanup"));

	private JTextField m_MinNodeSize = new JTextField();

	private JCheckBox m_CheckBoxBinarySplits = new JCheckBox(Resource.srcStr("m_CheckBoxBinarySplits"));
	private JPanel treeSettingsPanel;
	private JLabel confidenceThreshold;
	private JLabel numFolds;
	private JLabel minNode;
	private JLabel randomSeed;
	
	private JPanel modelSelectionPanel;
	/**
	 * Constructs an DecisionTreeOperatorProperty object.
	 * @param a_CaseID
	 *            ID of the Case containing the Operator Node to be set by this
	 *            DecisionTreeOperatorProperty.
	 * @param a_NodeID
	 *            ID of the Operator node to be set by this
	 *            DecisionTreeOperatorProperty.
	 * @throws SysException
	 */
	public DecisionTreeOperatorProperty(String a_CaseID, String a_NodeID, String a_Name,  INodeInfo a_NodeInfo, ICaseHandler a_CaseHandler) throws SysException {
		super(a_CaseID, a_NodeID, Resource.srcStr("DecisionTree")+" [" + a_NodeID + "]",  a_NodeInfo, a_CaseHandler);
		createDecisionTreeOperatorProperty();
	}

	/**
	 * Create the UI for this DecisionTreeOperatorProperty
	 */
	private void createDecisionTreeOperatorProperty() {
		treeSettingsPanel = new JPanel(new BorderLayout());
		modelSelectionPanel = new JPanel(new GridLayout(3, 1, 0, 15));
		m_PropertyPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 3, 0));
		m_PropertyPane.addTab(Resource.srcStr("m_TreeTab"), treeSettingsPanel);
		m_PropertyPane.addTab(Resource.srcStr("m_ModelTab"), modelSelectionPanel);
		JPanel buttonPanel = new JPanel();

		// Tree Settings panel
		treeSettingsPanel.setBorder(BorderFactory.createCompoundBorder(
				BorderFactory.createCompoundBorder(BorderFactory
						.createEmptyBorder(3, 5, 5, 5), BorderFactory
						.createTitledBorder(Resource.srcStr("DecisionTree"))),
				BorderFactory.createEmptyBorder(0, 2, 0, 2)));

		ButtonGroup pruningButtonGroup = new ButtonGroup();
		pruningButtonGroup.add(m_RadioNormal);
		pruningButtonGroup.add(m_RadioReducedError);

		m_CheckBoxPruning.addChangeListener(new ChangeListener() {
			public void stateChanged(ChangeEvent e) {
				m_RadioNormal.setEnabled(m_CheckBoxPruning.isSelected());
				m_RadioReducedError.setEnabled(m_CheckBoxPruning.isSelected());
				m_ConfidenceThreshold.setEnabled(m_RadioNormal.isSelected()
						&& m_CheckBoxPruning.isSelected());
				m_CheckBoxSubtreeRaising.setEnabled(m_RadioNormal.isSelected()
						&& m_CheckBoxPruning.isSelected());
				m_NumFolds.setEnabled(m_RadioReducedError.isSelected()
						&& m_CheckBoxPruning.isSelected());
				m_RandomSeed.setEnabled(m_RadioReducedError.isSelected()
						&& m_CheckBoxPruning.isSelected());
			}
		});

		m_RadioNormal.addChangeListener(new ChangeListener() {
			public void stateChanged(ChangeEvent e) {
				m_ConfidenceThreshold.setEnabled(m_RadioNormal.isSelected()
						&& m_CheckBoxPruning.isSelected());
				m_CheckBoxSubtreeRaising.setEnabled(m_RadioNormal.isSelected()
						&& m_CheckBoxPruning.isSelected());
			}
		});

		m_RadioReducedError.addChangeListener(new ChangeListener() {
			public void stateChanged(ChangeEvent e) {
				m_NumFolds.setEnabled(m_RadioReducedError.isSelected()
						&& m_CheckBoxPruning.isSelected());
				m_RandomSeed.setEnabled(m_RadioReducedError.isSelected()
						&& m_CheckBoxPruning.isSelected());
			}
		});

		JPanel pruningContent = new JPanel(new BorderLayout());
		JPanel pruningChoice = new JPanel(new GridLayout(2, 1, 0, 2));

		JPanel normalChoice = new JPanel(new BorderLayout());
		JPanel normalContent = new JPanel();

		normalContent.setBorder(BorderFactory.createCompoundBorder(
				BorderFactory.createEmptyBorder(0, 36, 0, 6), BorderFactory
						.createTitledBorder("")));

		confidenceThreshold = new JLabel(Resource.srcStr("DECISIONTREE_CONFIDENCE_THRESHOLD"));
		//m_ConfidenceThreshold.setColumns(10);
		m_ConfidenceThreshold
				.setPreferredSize(DimensionConstants.TEXT_FIELD_DIM);
		m_ConfidenceThreshold.setMaximumSize(DimensionConstants.TEXT_FIELD_DIM);
		m_ConfidenceThreshold.setMinimumSize(DimensionConstants.TEXT_FIELD_DIM);

		//		int leftMargin = 4;
		//		int topBotomMargin = 2;
		normalContent.setLayout(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		c.fill = GridBagConstraints.NONE;

		c.gridx = 0;
		c.gridy = 0;
		c.gridwidth = 1;
		c.weightx = 0;
		c.weighty = 0.0;
		c.anchor = GridBagConstraints.WEST;
		c.insets = new Insets(4, 12, 0, 10);
		normalContent.add(confidenceThreshold, c);
		c.gridx = 1;
		c.gridy = 0;
		c.gridwidth = 1;
		c.weightx = 0;
		c.weighty = 0;
		c.anchor = GridBagConstraints.EAST;
		c.insets = new Insets(4, 0, 0, 4);
		normalContent.add(m_ConfidenceThreshold, c);

		c.gridx = 0;
		c.gridy = 1;
		c.gridwidth = 1;
		c.weightx = 0.0;
		c.weighty = 0.0;
		c.anchor = GridBagConstraints.NORTHWEST;
		c.insets = new Insets(2, 8, 0, 0);
		normalContent.add(m_CheckBoxSubtreeRaising, c);

		m_RadioNormal.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
		normalChoice.add(m_RadioNormal, BorderLayout.NORTH);
		normalChoice.add(normalContent, BorderLayout.CENTER);

		JPanel reducedErrorChoice = new JPanel(new BorderLayout());
		JPanel reducedErrorContent = new JPanel();
		reducedErrorContent.setBorder(BorderFactory.createCompoundBorder(
				BorderFactory.createEmptyBorder(0, 36, 4, 6), BorderFactory
						.createTitledBorder("")));
		numFolds = new JLabel(Resource.srcStr("numFolds"));
		randomSeed = new JLabel(Resource.srcStr("randomSeed"));
		//		m_NumFolds.setColumns(5);
		//		m_RandomSeed.setColumns(5);
		//		
		m_NumFolds.setPreferredSize(DimensionConstants.TEXT_FIELD_DIM);
		m_NumFolds.setMaximumSize(DimensionConstants.TEXT_FIELD_DIM);
		m_NumFolds.setMinimumSize(DimensionConstants.TEXT_FIELD_DIM);

		m_RandomSeed.setPreferredSize(DimensionConstants.TEXT_FIELD_DIM);
		m_RandomSeed.setMaximumSize(DimensionConstants.TEXT_FIELD_DIM);
		m_RandomSeed.setMinimumSize(DimensionConstants.TEXT_FIELD_DIM);

		reducedErrorContent.setLayout(new GridBagLayout());
		c.fill = GridBagConstraints.NONE;
		c.anchor = GridBagConstraints.WEST;

		c.gridx = 0;
		c.gridy = 0;
		c.gridwidth = 1;
		c.weightx = 0;
		c.weighty = 1.0;
		c.anchor = GridBagConstraints.WEST;
		c.insets = new Insets(4, 10, 0, 14);
		reducedErrorContent.add(numFolds, c);
		c.gridx = 1;
		c.gridy = 0;
		c.gridwidth = 1;
		c.weightx = 1;
		c.weighty = 0;
		c.anchor = GridBagConstraints.EAST;
		c.insets = new Insets(4, 0, 2, 4);
		reducedErrorContent.add(m_NumFolds, c);

		c.gridx = 0;
		c.gridy = 1;
		c.gridwidth = 1;
		c.weightx = 1.0;
		c.weighty = 1.0;
		c.anchor = GridBagConstraints.WEST;
		c.insets = new Insets(0, 10, 0, 14);
		reducedErrorContent.add(randomSeed, c);
		c.gridx = 1;
		c.gridy = 1;
		c.gridwidth = 1;
		c.weightx = 1;
		c.weighty = 0;
		c.anchor = GridBagConstraints.EAST;
		c.insets = new Insets(0, 0, 0, 4);
		reducedErrorContent.add(m_RandomSeed, c);

		m_RadioReducedError.setBorder(BorderFactory.createEmptyBorder(2, 20, 0,
				0));
		reducedErrorChoice.add(m_RadioReducedError, BorderLayout.NORTH);
		reducedErrorChoice.add(reducedErrorContent, BorderLayout.CENTER);

		pruningChoice.add(normalChoice);
		pruningChoice.add(reducedErrorChoice);

		pruningContent.add(pruningChoice, BorderLayout.CENTER);
		m_CheckBoxPruning
				.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));
		pruningContent.add(m_CheckBoxPruning, BorderLayout.NORTH);

		treeSettingsPanel.add(pruningContent, BorderLayout.CENTER);
		//m_CheckBoxCleanup.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
		// Do not show the control on the UI. Always true by default. TWang.
		// treeSettingsPanel.add(m_CheckBoxCleanup, BorderLayout.SOUTH);

		// attributes panel
		modelSelectionPanel.setBorder(BorderFactory.createCompoundBorder(
				BorderFactory.createCompoundBorder(BorderFactory
						.createEmptyBorder(3, 5, 5, 5), BorderFactory
						.createTitledBorder(Resource.srcStr("DecisionTree"))),
				BorderFactory.createEmptyBorder(0, 2, 0, 0)));
		minNode = new JLabel(Resource.srcStr("NodeMinSize"));

		JPanel modelSelectionContent = new JPanel();
		modelSelectionContent.setLayout(new BoxLayout(modelSelectionContent,
				BoxLayout.PAGE_AXIS));

		JPanel minNodeContent = new JPanel(new FlowLayout());
		((FlowLayout) minNodeContent.getLayout())
				.setAlignment(FlowLayout.LEADING);
		minNode.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 15));

⌨️ 快捷键说明

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