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

📄 associationoperatorproperty.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	 * Set values input in this AssociationOperatorProperty to the Operator Node.
	 */
	private boolean setContent(){			
		if (m_Node==null  ){  
			return false;
		} else if ( m_MetaData == null){
			m_MessageDialog.showWarning(Resource.srcStr("AttributesMessage"), Resource.srcStr("InvalidInputMessage"));
			return false;
		}
		
		//<< Franky Chan 10/5/2005
		// Commented sine AprioridTID has been replaced by AprioriSimple
		//m_Node.setParameterValue(AssociationOperator.STEPS_TO_APRIORIHYBRID, m_StepsToAprioriTID.getText().trim());
		//<< Franky Chan 10/5/2005
		
		m_Node.setParameterValue(AssociationOperator.MIN_ITEM_SIZE, m_MinItemSize.getText().trim());
		if (m_CheckBoxNoLimit.isSelected())
			m_Node.setParameterValue(AssociationOperator.MAX_ITEM_SIZE, AssociationOperator.VALUE_MAX_ITEM_SIZE_NO_LIMIT);
		else
			m_Node.setParameterValue(AssociationOperator.MAX_ITEM_SIZE, m_MaxItemSize.getText().trim());
		//m_Node.setParameterValue(AssociationOperator.MIN_SUPPORT, String.valueOf(m_SliderMinSupport.getValue()));
		m_Node.setParameterValue(AssociationOperator.MIN_SUPPORT, m_TextFieldMinSupport.getText());
		m_Node.setParameterValue(AssociationOperator.MIN_CONFIDENCE, String.valueOf(m_SliderMinConfidence.getValue()));
		m_Node.setParameterValue(AssociationOperator.GENERATE_RULES, String.valueOf(m_CheckBoxGenerateRules.isSelected()));
		
		if (m_MetaData!=null && m_MetaData.getAttributesNumber()>0) {
			m_Node.setParameterValue(AssociationOperator.ITEM_ID_ATTRIBUTE, m_MetaData.getMiningAttribute(m_AttributesTableModel.getItemID()).getName());
			m_Node.setParameterValue(AssociationOperator.ITEM_ID_ATTRIBUTE_DATA_TYPE, Integer.toString(m_MetaData.getMiningAttribute(m_AttributesTableModel.getItemID()).getDataType()) );
			m_Node.setParameterValue(AssociationOperator.TRANSACTION_ID_ATTRIBUTE, m_MetaData.getMiningAttribute(m_AttributesTableModel.getTransactionID()).getName());
			m_Node.setParameterValue(AssociationOperator.TRANSACTION_ID_ATTRIBUTE_DATA_TYPE, Integer.toString(m_MetaData.getMiningAttribute(m_AttributesTableModel.getTransactionID()).getDataType()) );
		}
			
		//Operator op = m_ParentPanel.getOperator(m_NodeID);
		//((AssociationOperator) m_Operator).clearResult();
		clearOperatorTempResult();
//		m_ParentPanel.getCaseWindow().setModified(true);
		setPropertiesModified();
		return true;
	}
	
	/**
	 * Retrieve information from Operator Node and display those values in this AssociationOperatorProperty.
	 */
	private void getContent() {
		if (m_Node==null)
			return;
		
		//<< Franky Chan 10/5/2005
		// Commented sine AprioridTID has been replaced by AprioriSimple
		/*
		String num = m_Node.getParameterValue(AssociationOperator.STEPS_TO_APRIORIHYBRID);
		if (num==null)
			num = AssociationOperator.DEFAULT_STEPS_TO_APRIORIHYBRID;
		m_StepsToAprioriTID.setText(num);
		*/
		//<< Franky Chan 10/5/2005
		
		String minSize = (String) m_Node.getParameterValue(AssociationOperator.MIN_ITEM_SIZE);
		if (minSize==null)
			minSize = AssociationOperator.DEFAULT_MIN_ITEM_SIZE;
		m_MinItemSize.setText(minSize);
		
		String maxSize = (String) m_Node.getParameterValue(AssociationOperator.MAX_ITEM_SIZE);
		if (maxSize==null || maxSize.equals(AssociationOperator.VALUE_MAX_ITEM_SIZE_NO_LIMIT)) {
			maxSize = AssociationOperator.DEFAULT_MAX_ITEM_SIZE;
			m_CheckBoxNoLimit.setSelected(true);
		}
		else
			m_CheckBoxNoLimit.setSelected(false);
		m_MaxItemSize.setText(maxSize);		

		String support = (String) m_Node.getParameterValue(AssociationOperator.MIN_SUPPORT);
		if (support==null)
			support = AssociationOperator.DEFAULT_MIN_SUPPORT;
		//m_SliderMinSupport.setValue(Integer.parseInt(support));
		m_TextFieldMinSupport.setText(support);
		
		String confidence = (String) m_Node.getParameterValue(AssociationOperator.MIN_CONFIDENCE);
		if (confidence==null)
			confidence = AssociationOperator.DEFAULT_MIN_CONFIDENCE;
		m_SliderMinConfidence.setValue(Integer.parseInt(confidence));
		
		String generateRules = (String) m_Node.getParameterValue(AssociationOperator.GENERATE_RULES);
		if (generateRules==null)
			generateRules=AssociationOperator.DEFAULT_GENERATE_RULES;
		boolean gen = false;
		if (generateRules.equals(String.valueOf(true)))
			gen = true;		
		m_CheckBoxGenerateRules.setSelected(gen);
		
		if (m_MetaData==null)
			return;
		
		MiningAttribute attribute = null;
		String itemAttribute = (String) m_Node.getParameterValue(AssociationOperator.ITEM_ID_ATTRIBUTE);
		String itemDataType = (String) m_Node.getParameterValue(AssociationOperator.ITEM_ID_ATTRIBUTE_DATA_TYPE);
		if (itemAttribute!=null)
		{
			attribute = m_MetaData.getMiningAttribute(itemAttribute);
			if (attribute!=null && attribute instanceof CategoricalAttribute && Integer.toString(attribute.getDataType()).equals(itemDataType))
				((AttributesTableModel)m_TableAttributes.getModel()).setValueAt(new Boolean(true), m_MetaData.getAttributeIndex(attribute), 1);
		}
		
		String transactionAttribute = (String) m_Node.getParameterValue(AssociationOperator.TRANSACTION_ID_ATTRIBUTE);
		String transactionAttributeDataType = (String) m_Node.getParameterValue(AssociationOperator.TRANSACTION_ID_ATTRIBUTE_DATA_TYPE);
		if (transactionAttribute!=null)
		{
			attribute = m_MetaData.getMiningAttribute(transactionAttribute);
			if (attribute!=null  && attribute instanceof CategoricalAttribute && Integer.toString(attribute.getDataType()).equals(transactionAttributeDataType))
				((AttributesTableModel)m_TableAttributes.getModel()).setValueAt(new Boolean(true), m_MetaData.getAttributeIndex(attribute), 2);
		}
	}
	
	public void resetLocale() {
		m_CheckBoxNoLimit.setText(Resource.srcStr("m_CheckBoxNoLimit"));
		m_CheckBoxGenerateRules.setText(Resource.srcStr("m_CheckBoxGenerateRules"));
		m_ColumnName[0] = Resource.srcStr("m_AttributeColumnName");
		m_ColumnName[1] = Resource.srcStr("m_ItemIdColumnName");
		m_ColumnName[2] = Resource.srcStr("m_TransactionIdColunmName");
		
		//for table
		m_AttributesTableModel.setColumnIdentifiers(m_ColumnName);
		
		m_TableAttributes.setValueAt(m_ColumnName[0], 0, 0);
		m_TableAttributes.setValueAt(m_ColumnName[1], 0, 1);
		m_TableAttributes.setValueAt(m_ColumnName[2], 0, 2);
		
		String title = getTitle();
		int index = title.indexOf('[');
		title = Resource.srcStr("AssociationTitle")+title.substring(index);
		setTitle(title);
		
		m_PropertyPane.setTitleAt(0, Resource.srcStr("m_GeneralTab"));
		m_PropertyPane.setTitleAt(1, Resource.srcStr("m_AttributesTab"));
		
		minItemSize.setText(Resource.srcStr("minItemSize"));
		maxItemSize.setText(Resource.srcStr("maxItemSize"));
		
		m_MinSupportLabel.setText(Resource.srcStr("m_MinSupportLabel"));
		
		//m_MinConfidenceLabel,m_MinConfidenceLabel can't be reset locale
		
		((TitledBorder)((CompoundBorder)((CompoundBorder)attributesPanel.getBorder()).getOutsideBorder()).getInsideBorder()).setTitle(Resource.srcStr("AssociationTitledBorder"));
		
		m_ButtonReset.setText(Resource.srcStr("m_ButtonReset"));
		m_ButtonSave.setText(Resource.srcStr("m_ButtonApply"));
		m_ButtonCancel.setText(Resource.srcStr("m_ButtonClose"));
	}
}

/**
 * AttributesTableModel is the TableModel used to show all attributes in a MetaData as the Table data.
 */
class AttributesTableModel extends DefaultTableModel implements TableModelListener{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/* Property of this table model*/
	Class[] types = new Class[] { String.class, Boolean.class, Boolean.class };
	boolean[] canEdit = new boolean[] { false, true, true};	
	
	/* row index of selected Item ID and Transaction ID */
	private int m_ItemID = -1;
	private int m_TransactionID = -1;

	/**
	 * Constructs an AttributesTableModel
	 * @param a_ColumnName header names
	 * @param a_ColumnData table data
	 */
	public AttributesTableModel(String[] a_ColumnName, Object[][] a_ColumnData) {
		super(a_ColumnData, a_ColumnName);
		addTableModelListener(this);
	}
	
	/* (non-Javadoc)
	 * @see javax.swing.table.TableModel#getColumnClass(int)
	 */
	@SuppressWarnings("unchecked")
	public Class getColumnClass(int columnIndex) {
		return types[columnIndex];
	}

	/* (non-Javadoc)
	 * @see javax.swing.table.TableModel#isCellEditable(int, int)
	 */
	public boolean isCellEditable(int rowIndex, int columnIndex) {
		return canEdit[columnIndex];
	}
	
	/**
	 * Returns Item Id.
	 * @return Item Id.
	 */
	public int getItemID() {
		return m_ItemID;
	}

	/**
	 * Set Item Id.
	 * @param index Item id to be set.
	 */
	public void setItemID(int index) {		
		m_ItemID = index;
	}
	
	/**
	 * Change Item id and update Table.
	 * @param index Item id to be changed.
	 */
	public void changeItemID(int index) {		
		Boolean value = (Boolean) getValueAt(index, 1);		
		if (value.booleanValue()) {
			if (getItemID()>=0 && getItemID() != index){				
				setValueAt(new Boolean(false), getItemID(), 1);
				setValueAt(new Boolean(true), index, 1);
			}			
			if (getTransactionID()>=0 && getTransactionID()==index) {
				setValueAt(new Boolean(false), getTransactionID(), 2);
				setTransactionID(-1);
			}
			
			setItemID(index);
		} else if (getItemID()>=0) {
			setValueAt(new Boolean(false), getItemID(), 1);
			setItemID(-1);
		}
	}
	
	/**
	 * Transaction ID.
	 * @return Transaction ID.
	 */
	public int getTransactionID() {
		return m_TransactionID;
	}

	/**
	 * Set Transaction Id.
	 * @param index Transaction id to be set.
	 */
	public void setTransactionID(int index) {		
		m_TransactionID = index;
	}
	
	/**
	 * Change Transaction id and update Table.
	 * @param index Transaction id to be changed.
	 */
	public void changeTransactionID(int index) {
		Boolean value = (Boolean) getValueAt(index, 2);
		if (value.booleanValue()) {
			if (getTransactionID()>=0 && getTransactionID() != index){
				setValueAt(new Boolean(false), getTransactionID(), 2);
				setValueAt(new Boolean(true), index, 2);
			}			
			if (getItemID()>=0 && getItemID()==index) {
				setValueAt(new Boolean(false), getItemID(), 1);
				setItemID(-1);
			}
			
			setTransactionID(index);
		} else if (getTransactionID()>=0){
			setValueAt(new Boolean(false), getTransactionID(), 2);
			setTransactionID(-1);
		}
	}

	/* (non-Javadoc)
	 * @see javax.swing.event.TableModelListener#tableChanged(javax.swing.event.TableModelEvent)
	 */
	public void tableChanged(TableModelEvent e) {
		int row = e.getLastRow();
		int col = e.getColumn();

		removeTableModelListener(this);
		if (col==1)
			changeItemID(row);
		else if (col==2)
			changeTransactionID(row);
		addTableModelListener(this);
	}
}

⌨️ 快捷键说明

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