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

📄 selectoperatorproperty.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*
 *    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/26
 *
 * 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;


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.Hashtable;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.UIManager;
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 javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;


import com.prudsys.pdm.Core.CategoricalAttribute;
import com.prudsys.pdm.Core.Category;
import com.prudsys.pdm.Core.MiningAttribute;
import com.prudsys.pdm.Core.MiningDataSpecification;
import com.prudsys.pdm.Core.MiningException;
import com.prudsys.pdm.Core.NumericAttribute;
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.SelectOperator;
import eti.bi.exception.SysException;
import eti.bi.util.ValueValidator;
import eti.bi.common.Locale.Resource;
/**
 * @author jyung
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public class SelectOperatorProperty extends OperatorProperty implements
		ChangeListener {

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

	private MiningDataSpecification m_MetaData;

	private MiningStoredData m_msd;

	private final static String DEFAULT = Resource.srcStr("SelecetItem");

	private final static String CATEG = Resource.srcStr("Categorical");

	private final static String NUM = Resource.srcStr("Numeric");

	private final static Color DISABLED_COLOR = UIManager
			.getColor("TableHeader.background");

	private final static Color ENABLED_COLOR = UIManager
			.getColor("TextArea.background");

	/*
	 * private double [] m_MinValues; private double [] m_MaxValues;
	 */
	//	 variables
	private Object[][] m_TableItems;

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

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

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

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

	//<< Franky Chan 8/3/2005
	// Layout modified for Select operator
	//	private JRadioButton m_RadioValueKeep = new JRadioButton("Keep");
	//
	//	private JRadioButton m_RadioValueRemove = new JRadioButton("Remove");
	//>>
	private JTextField m_FromTF = new JTextField("");

	private JTextField m_ToTF = new JTextField("");

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

	private JTextField m_SmallerThanTF = new JTextField("");

	private JComboBox m_AttributeJCB = null;

	private JPopupMenu m_Menu = new JPopupMenu();

	private JMenuItem m_MenuItemClear, m_MenuItemSelect;

	private ButtonGroup m_ButtonGroup = new ButtonGroup();

	//	private ButtonGroup m_valueGroup = new ButtonGroup();

	private ButtonGroup m_KeepGroup = new ButtonGroup();

	private JButton m_ButtonReset = new JButton();

	private JButton m_ButtonApply = new JButton();

	private JButton m_ButtonClose = new JButton();

	private String[] m_MetaDataTableHeader = { Resource.srcStr("Category"), Resource.srcStr("Match")};

	private Hashtable<Object, SelectTableModel> m_TableModel;

	private JTable m_Table = new JTable() {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		public boolean isCellEditable(int rowIndex, int vColIndex) {
			if (vColIndex == 1)
				return true;
			else
				return false;
		}
	};

	/**
	 * @throws MiningException
	 * @throws SysException
	 *  
	 */
	public SelectOperatorProperty(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);

		/* Invoke the UI component creation method */
		createOperatorProperty();
													// 2005/02/17

	}

	public void stateChanged(ChangeEvent e) {
		setEnabledByRange(m_RadioByRange.isSelected());
	}

	protected void createOperatorProperty() throws SysException 
	{

		// set size
		//<<03/03/2005 Mark Li: Modify the demension similar to the other
		// panels
		/**
		 * m_FromTF.setPreferredSize(new Dimension(50, 18));
		 * m_FromTF.setMaximumSize(new Dimension(50, 18));
		 * m_FromTF.setMinimumSize(new Dimension(50, 18));
		 * 
		 * m_ToTF.setPreferredSize(new Dimension(50, 18));
		 * m_ToTF.setMaximumSize(new Dimension(50, 18));
		 * m_ToTF.setMinimumSize(new Dimension(50, 18));
		 * 
		 * m_SmallerThanTF.setPreferredSize(new Dimension(50, 20));
		 * m_SmallerThanTF.setMaximumSize(new Dimension(50, 20));
		 * m_SmallerThanTF.setMinimumSize(new Dimension(50, 20));
		 */
		m_FromTF.setPreferredSize(DimensionConstants.TEXT_FIELD_DIM);
		m_FromTF.setMaximumSize(DimensionConstants.TEXT_FIELD_DIM);
		m_FromTF.setMinimumSize(DimensionConstants.TEXT_FIELD_DIM);

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

		m_SmallerThanTF.setPreferredSize(DimensionConstants.TEXT_FIELD_DIM);
		m_SmallerThanTF.setMaximumSize(DimensionConstants.TEXT_FIELD_DIM);
		m_SmallerThanTF.setMinimumSize(DimensionConstants.TEXT_FIELD_DIM);
		//03/03/2005 Mark Li: Modify the demension similar to the other
		// panels>>

		JPanel propertyByRangePanel = new JPanel(new BorderLayout());
		JPanel propertyByValuePanel = new JPanel(new BorderLayout());
		JPanel buttonPanel = new JPanel();
		JPanel tempRangePanel = null;
		JPanel tempValuePanel = null;

		m_ButtonGroup.add(m_RadioByRange);
		m_ButtonGroup.add(m_RadioByValue);

		m_RadioByRange.addChangeListener(this);
		m_RadioByValue.addChangeListener(this);

		// Range Panel
		propertyByRangePanel.add(m_RadioByRange, BorderLayout.NORTH);
		tempRangePanel = new JPanel(new BorderLayout(10, 10));

		Border margin = new EmptyBorder(8, 8, 5, 8);
		TitledBorder m_border1 = new TitledBorder(new EtchedBorder(), "");
		tempRangePanel.setBorder(new CompoundBorder(
				new EmptyBorder(0, 5, 0, 0), new CompoundBorder(m_border1,
						margin)));

		// Set Grid
		//	JPanel rangeGrid = new JPanel(new BorderLayout());

		// 1 Grid
		JPanel rangeGridJPanel_1 = new JPanel();

		rangeGridJPanel_1.setLayout(new BoxLayout(rangeGridJPanel_1,
				BoxLayout.LINE_AXIS));
		rangeGridJPanel_1.add(new JLabel(Resource.srcStr("InstanceRangeLabel")));
		rangeGridJPanel_1.add(Box.createRigidArea(new Dimension(15, 0)));
		rangeGridJPanel_1.add(m_FromTF);
		rangeGridJPanel_1.add(Box.createRigidArea(new Dimension(15, 0)));
		rangeGridJPanel_1.add(new JLabel(Resource.srcStr("toLabel")));
		rangeGridJPanel_1.add(Box.createRigidArea(new Dimension(15, 0)));
		rangeGridJPanel_1.add(m_ToTF);

		//		propertyByRangePanel.setPreferredSize(new Dimension(300, 70));
		//		propertyByRangePanel.setMinimumSize(new Dimension(300, 70));
		//		propertyByRangePanel.setMaximumSize(new Dimension(300, 70));
		//03/03/2005 Mark Li: Modify the size of panel>>
		tempRangePanel.add(rangeGridJPanel_1);

		// Set Range Panel
		//tempRangePanel.add(gridBagRangePanel, BorderLayout.CENTER);
		propertyByRangePanel.add(new JLabel("     "), BorderLayout.WEST);
		propertyByRangePanel.add(tempRangePanel, BorderLayout.CENTER);
		propertyByValuePanel.add(m_RadioByValue, BorderLayout.NORTH);

		//===
		tempValuePanel = new JPanel(new BorderLayout(0, 0));
		tempValuePanel.setBorder(new CompoundBorder(
				new EmptyBorder(0, 5, 0, 0), new CompoundBorder(m_border1,
						new EmptyBorder(8, 5, 5, 8))));
		//JPanel outlierFieldPanelx = new JPanel(new GridLayout(4, 1, 2, 5));
		//tempValuePanel.add(outlierFieldPanelx, BorderLayout.EAST);

		// Set North
		JPanel tempValueNorthPanel = new JPanel();

		GridBagLayout gbl = new GridBagLayout();
		tempValueNorthPanel.setLayout(gbl);

		//<<03/03/2005 Mark Li Modify the dimension size
		//		tempValueNorthPanel.setPreferredSize(new Dimension(300, 45));
		//		tempValueNorthPanel.setMaximumSize(new Dimension(300, 45));
		//		tempValueNorthPanel.setMinimumSize(new Dimension(300, 45));
		//		tempValueNorthPanel.setPreferredSize(new Dimension(300, 75));
		//		tempValueNorthPanel.setMaximumSize(new Dimension(300, 75));
		//		tempValueNorthPanel.setMinimumSize(new Dimension(300, 75));
		//03/03/2005 Mark Li Modify the dimension size>>
		//		JPanel valueNorth = new JPanel();
		//		valueNorth.setLayout(new BoxLayout(valueNorth, BoxLayout.LINE_AXIS));
		//		valueNorth.add(new JLabel("Attribute"));
		//		valueNorth.add(Box.createRigidArea(new Dimension(28, 0)));
		//	

		GridBagConstraints c = new GridBagConstraints();
		c.gridx = 0;
		c.gridy = 0;
		c.insets = new Insets(5, 5, 5, 8);
		c.fill = GridBagConstraints.NONE;
		c.anchor = GridBagConstraints.LINE_START;
		c.weightx = 0.0;
		c.weighty = 0.0;
		JLabel attributeLabel = new JLabel(Resource.srcStr("Attributes"));

		tempValueNorthPanel.add(attributeLabel, c);

		/* Convert the following attriubtes to the corresponding items */
		String[] items = { DEFAULT };

		m_AttributeJCB = new JComboBox(items);
		m_AttributeJCB.setPreferredSize(new Dimension(158, 20));
		m_AttributeJCB.setMaximumSize(new Dimension(158, 20));
		m_AttributeJCB.setMinimumSize(new Dimension(158, 20));

		c.gridx = 1;
		c.gridy = 0;
		c.weightx = 0.0;
		c.weighty = 0.0;

		c.insets = new Insets(5, 0, 5, 0);
		c.anchor = GridBagConstraints.LINE_START;
		c.fill = GridBagConstraints.NONE;
		tempValueNorthPanel.add(m_AttributeJCB, c);

		c.gridx = 0;
		c.gridy = 1;
		c.weightx = 0.0;
		c.weighty = 0.0;

		c.fill = GridBagConstraints.NONE;
		c.anchor = GridBagConstraints.LINE_START;
		c.insets = new Insets(0, 5, 1, 8);
		JLabel smallerLabel = new JLabel(Resource.srcStr("smallerLabel"));

		tempValueNorthPanel.add(smallerLabel, c);

		c.gridx = 1;
		c.gridy = 1;
		c.weightx = 0.0;
		c.weighty = 0.0;

		c.insets = new Insets(0, 0, 1, 0);

		c.fill = GridBagConstraints.NONE;
		c.anchor = GridBagConstraints.LINE_START;
		tempValueNorthPanel.add(m_SmallerThanTF, c);

		c.gridx = 0;
		c.gridy = 2;
		c.weightx = 0.0;
		c.weighty = 0.0;
		c.gridwidth = 2;

		c.insets = new Insets(0, 0, 5, 5);

		c.fill = GridBagConstraints.HORIZONTAL;
		c.anchor = GridBagConstraints.LINE_START;
		tempValueNorthPanel.add(m_MissingValCBox, c);

		// Set Center
		JPanel tempValueCenterPanel = new JPanel(new BorderLayout(0, 0));
		//		 set table default
		/*
		 * create table panel
		 */
		// add the table contents here
		String[] m_Categories = { "Category1", "Category2", "Category3",
				"Category4", "Category5", "Category6", "Category7", "Category8" };

		m_TableItems = new Object[m_Categories.length][2];
		
		// modify the following to get the correct boolean for each category
		for (int i = 0; i < m_Categories.length; i++) {
			m_TableItems[i][0] = m_Categories[i];
			m_TableItems[i][1] = new Boolean(false);
		}

		m_Table = new JTable();
		//		TableColumn column = m_Table.getColumnModel().getColumn(0);
		//		column.setPreferredWidth(160); // to make the category column width
		// wider
		//		m_Table.setDragEnabled(false);
		//		column.setResizable(false);
		//		int [] temp = {1, 2, 3};

		m_Table.setPreferredScrollableViewportSize(new Dimension(270, 112));

		//		JScrollPane tableScrollPane = new JScrollPane(m_Table);

⌨️ 快捷键说明

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