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

📄 naivebayesoperatorproperty.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
字号:
package eti.bi.alphaminer.patch.standard.operation.property;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import eti.bi.alphaminer.core.handler.ICaseHandler;
import eti.bi.alphaminer.operation.operator.INodeInfo;
import eti.bi.alphaminer.operation.property.OperatorProperty;
import eti.bi.alphaminer.patch.standard.operation.operator.NaiveBayesOperator;
import eti.bi.common.Locale.Resource;
import eti.bi.exception.SysException;

public class NaiveBayesOperatorProperty extends OperatorProperty {

	/* UI controls */
	private static final long serialVersionUID = -2104856718942630953L;
	
	private JButton m_ButtonReset = new JButton();
	private JButton m_ButtonSave = new JButton();
	private JButton m_ButtonCancel = new JButton();
	
	private JCheckBox m_CheckBoxKernal = new JCheckBox(Resource.srcStr("m_useKernal"));
	private JCheckBox m_CheckBoxDiscretization = new JCheckBox(Resource.srcStr("m_useSupervisedDiscretization"));
	
	
	/**
	 * Constructs an NavieBayesOperatorProject 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 NaiveBayesOperatorProperty(String a_CaseID, String a_NodeID, String a_Name, INodeInfo a_NodeInfo, ICaseHandler a_CaseHandler) throws SysException {
		super(a_CaseID, a_NodeID, "NaiveBayes [" + a_NodeID + "]", a_NodeInfo, a_CaseHandler);
		createNavieBayesOperatorProperty();
		this.setTitle(Resource.srcStr("NaiveBayes")+" ["+a_NodeID+"]");
	}

	/**
	 * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
	 */
	public void actionPerformed(ActionEvent e) {

		if (e.getSource() == m_ButtonSave) {
			if (applyContent()) {
				m_ParameterChanged = true;
			}
		} else if (e.getSource() == m_ButtonReset) {
			getContent();
		} else if (e.getSource() == m_ButtonCancel)
			close();
	}
	
	private boolean applyContent() {
		if (validateProperty()) {
			return setContent();
		} else {
			return false;
		}
	}
	
	private void createNavieBayesOperatorProperty() {
		JPanel propertyPanel = new JPanel();
		JPanel buttonPanel = new JPanel();
		
		/*propertyPanel*/
		propertyPanel.setBorder(BorderFactory.createCompoundBorder(
				BorderFactory.createTitledBorder(Resource.srcStr("NaiveBayes")),
				BorderFactory.createEmptyBorder(2,4,0,6)));
		
		m_CheckBoxKernal.addChangeListener(new ChangeListener(){
			public void stateChanged(ChangeEvent e) {
				if(m_CheckBoxKernal.isSelected()){
					m_CheckBoxDiscretization.setSelected(false);
				}
			}
		});
		
		m_CheckBoxDiscretization.addChangeListener(new ChangeListener(){
			public void stateChanged(ChangeEvent e) {
				if(m_CheckBoxDiscretization.isSelected()){
					m_CheckBoxKernal.setSelected(false);
				}
			}
		});
		
		m_CheckBoxKernal.setSelected(new Boolean(NaiveBayesOperator.DEFAULT_KERNAL).booleanValue());
		m_CheckBoxDiscretization.setSelected(new Boolean(NaiveBayesOperator.DEFAULT_DISCRETIZATION).booleanValue());
		
		propertyPanel.setLayout(new GridLayout(3, 2, 0, 5));
		propertyPanel.add(m_CheckBoxKernal,BorderLayout.NORTH);
		propertyPanel.add(m_CheckBoxDiscretization,BorderLayout.NORTH);
		
		/*button panel*/
		m_ButtonReset.setText(Resource.srcStr("m_ButtonReset"));
		m_ButtonSave.setText(Resource.srcStr("m_ButtonApply"));
		m_ButtonCancel.setSelected(false);
		m_ButtonCancel.setText(Resource.srcStr("m_ButtonClose"));
		buttonPanel.add(m_ButtonSave);
		buttonPanel.add(m_ButtonReset);
		buttonPanel.add(m_ButtonCancel);
		
		m_ButtonReset.addActionListener(this);
		m_ButtonSave.addActionListener(this);
		m_ButtonCancel.addActionListener(this);
		
		this.getContentPane().add(propertyPanel, BorderLayout.CENTER);
		this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
		this.setSize(300, 200);
		
		getContent();
	}
	
	/**
	 * Set values input in this NavieBayesOperatorProperty to the Operator Node.
	 */
	public boolean setContent(){
		if(m_Node==null){
			return false;
		}
		
		m_Node.removeParameterValue(NaiveBayesOperator.KERNAL);
		m_Node.setParameterValue(NaiveBayesOperator.KERNAL, String.valueOf(m_CheckBoxKernal.isSelected()));
		m_Node.removeParameterValue(NaiveBayesOperator.DISCRETIZATION);
		m_Node.setParameterValue(NaiveBayesOperator.DISCRETIZATION, String.valueOf(m_CheckBoxDiscretization.isSelected()));
		
		clearOperatorTempResult();
		setPropertiesModified();
		return true;
	}
	
	/**
	 * Retrieve information from Operator Node and display those values in this NavieBayesOperatorProperty.
	 */
	private void getContent(){
		if (m_Node==null)
			return;
		
		m_CheckBoxKernal.setSelected(Boolean.valueOf((String)m_Node.getParameterValue(NaiveBayesOperator.KERNAL)));
		
		m_CheckBoxDiscretization.setSelected(Boolean.valueOf((String)m_Node.getParameterValue(NaiveBayesOperator.DISCRETIZATION)));
		
	}
	
	/**
	 * Validate input values.
	 * 
	 * @return true if all values are valid; false otherwise.
	 */
	private boolean validateProperty() {
		return true;
	}
}

⌨️ 快捷键说明

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