📄 associationoperatorproperty.java
字号:
c.gridx = 1;
c.gridy = 3;
c.gridwidth = 2;
c.weightx = 1.0;
c.weighty = 0.0;
c.insets = new Insets(0, 0, 0, 0);
c.fill = GridBagConstraints.BOTH;
generalPanel.add(minSupportPanel, c);
c.gridx = 0;
c.gridy = 4;
c.gridwidth = 1;
c.weightx = 0.0;
c.weighty = 0.0;
c.insets = new Insets(0, leftMargin, 0, 15);
value = m_SliderMinConfidence.getValue();
m_MinConfidenceLabel.setText(Resource.srcStr("m_MinConfidenceLabel")+value+"%)");
m_MinConfidenceLabel.setPreferredSize(new Dimension(110, 1));
c.fill = GridBagConstraints.NONE;
generalPanel.add(m_MinConfidenceLabel, c);
c.gridx = 1;
c.gridy = 4;
c.gridwidth = 2;
c.weightx = 1.0;
c.weighty = 0.0;
c.insets = new Insets(0, 0, 0, 0);
c.fill = GridBagConstraints.BOTH;
generalPanel.add(minConfidencePanel, c);
c.gridx = 0;
c.gridy = 5;
c.gridwidth = 1;
c.weightx = 0.0;
c.weighty = 0.0;
c.fill = GridBagConstraints.NONE;
c.insets = new Insets(0, 0, 0, 0);
// uncomment if we want the Checkbox shown. TWang.
//generalPanel.add(m_CheckBoxGenerateRules, c);
/* "Attributes" tab */
attributesPanel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(3,5,5,5),
BorderFactory.createTitledBorder(Resource.srcStr("AssociationTitledBorder"))),
BorderFactory.createEmptyBorder(2,4,0,6)));
JScrollPane scrollAttributes = new JScrollPane();
m_TableAttributes.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
m_TableAttributes.getTableHeader().setReorderingAllowed(false);
scrollAttributes.getViewport().add(m_TableAttributes);
scrollAttributes.getViewport().setBackground(Color.WHITE);
attributesPanel.add(scrollAttributes, BorderLayout.CENTER);
/* 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(m_PropertyPane, BorderLayout.CENTER);
this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
this.setSize(360, 265);
initContent();
initTable();
getContent();
}
/**
* @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();
}
/**
* Validate values entered in the AssociationOperatorProperty UI before setting
* them into the the Operator Node.
*/
private boolean applyContent(){
if (validateProperty())
{
return setContent();
}else
{
return false;
}
}
/**
* Validate input values.
* @return true if all values are valid; false otherwise.
*/
private boolean validateProperty(){
String message = null;
//<< Franky Chan 10/5/2005
// Commented sine AprioridTID has been replaced by AprioriSimple
/*
String num = m_StepsToAprioriTID.getText().trim();
if (!ValueValidator.isNumber(num)){
message = "Steps to AprioriTID should be an integer greater than or equal to 0";
}
else if (!ValueValidator.isInteger(num)){
message = "Steps to AprioriTID value out of range";
}
else if( !ValueValidator.largerThan(num, 0, true)) {
message = "Steps to AprioriTID should be an integer greater than or equal to 0";
}
if(message != null){
m_PropertyPane.setSelectedIndex(0);
m_StepsToAprioriTID.requestFocus();
m_StepsToAprioriTID.selectAll();
MessageDialog.showWarning(message, "Invalid input value");
return false;
}
*/
//<< Franky Chan 10/5/2005
String num = m_MinItemSize.getText().trim();
if (!ValueValidator.isNumber(num)){
message = Resource.srcStr("MinSizeMessage");
}
else if (!ValueValidator.isInteger(num)){
message = Resource.srcStr("MinOutOfRangeMessage");
}
else if( !ValueValidator.largerThan(num, 2, true)) {
message = message = Resource.srcStr("MinSizeMessage");
}
if (message != null) {
m_PropertyPane.setSelectedIndex(0);
m_MinItemSize.requestFocus();
m_MinItemSize.selectAll();
m_MessageDialog.showWarning(message, Resource.srcStr("InvalidInputMessage"));
return false;
}
if (!m_CheckBoxNoLimit.isSelected()) {
num = m_MaxItemSize.getText().trim();
if (!ValueValidator.isNumber(num)){
message = Resource.srcStr("MaxSizeMessage");
}
else if (!ValueValidator.isInteger(num)){
message = Resource.srcStr("MaxOutOfRangeMessage");
}
else if( !ValueValidator.largerThan(num, 0, true)) {
message = Resource.srcStr("MaxSizeMessage");
}
else if (ValueValidator.smallerThan(num, Integer.parseInt(m_MinItemSize.getText().trim()), false)) {
message = Resource.srcStr("MaxSizeMessage1")+m_MinItemSize.getText().trim();
}
if(message != null){
m_PropertyPane.setSelectedIndex(0);
m_MaxItemSize.requestFocus();
m_MaxItemSize.selectAll();
m_MessageDialog.showWarning(message, Resource.srcStr("InvalidInputMessage"));
return false;
}
}
// <<11/08/2005 Kenneth Lai: Added for checking the value of min. support
message = null;
num = m_TextFieldMinSupport.getText().trim();
if (!ValueValidator.isFloat(num)){
message = Resource.srcStr("MinSupportMessage");
}
else if( ValueValidator.smallerThan(num, 0.1, false) ||
ValueValidator.largerThan(num, 100.0, false) ) {
message = Resource.srcStr("MinSupportMessage");
}
if (message != null) {
m_PropertyPane.setSelectedIndex(0);
m_TextFieldMinSupport.requestFocus();
m_TextFieldMinSupport.selectAll();
m_MessageDialog.showWarning(message, Resource.srcStr("InvalidInputMessage"));
return false;
}
// 11/08/2005 Kenneth Lai: Added for checking the value of min. support>>
if (m_MetaData!=null && m_MetaData.getAttributesNumber()>0) {
if (m_AttributesTableModel.getItemID()<0) {
m_PropertyPane.setSelectedIndex(1);
message = Resource.srcStr("ItemIdMessage");
m_MessageDialog.showWarning(message, Resource.srcStr("InvalidInputMessage"));
return false;
} else if (m_AttributesTableModel.getItemID()==m_AttributesTableModel.getTransactionID()) {
m_PropertyPane.setSelectedIndex(1);
message = Resource.srcStr("SameMessage");
m_MessageDialog.showWarning(message, Resource.srcStr("InvalidInputMessage"));
return false;
} else if (!(m_MetaData.getMiningAttribute(m_AttributesTableModel.getItemID()) instanceof CategoricalAttribute)) {
m_PropertyPane.setSelectedIndex(1);
((AttributesTableModel)m_TableAttributes.getModel()).setValueAt(new Boolean(false), m_AttributesTableModel.getItemID(), 1);
message = Resource.srcStr("ItemIdMessage1");
m_MessageDialog.showWarning(message, Resource.srcStr("InvalidInputMessage"));
return false;
}
if (m_AttributesTableModel.getTransactionID()<0) {
m_PropertyPane.setSelectedIndex(1);
message = Resource.srcStr("TransactionIdMessage");
m_MessageDialog.showWarning(message, Resource.srcStr("InvalidInputMessage"));
return false;
} else if (!(m_MetaData.getMiningAttribute(m_AttributesTableModel.getTransactionID()) instanceof CategoricalAttribute)) {
m_PropertyPane.setSelectedIndex(1);
((AttributesTableModel)m_TableAttributes.getModel()).setValueAt(new Boolean(false), m_AttributesTableModel.getTransactionID(), 2);
message = Resource.srcStr("TransactionIdMessage");
m_MessageDialog.showWarning(message, Resource.srcStr("InvalidInputMessage"));
return false;
}
}
return true;
}
/**
* Retrieve Operator Node object and set output BIObject of its parent node as the input BIObject.
*/
protected void initContent() {
if (m_ParentOperators.size()>0)
{
Operator parentOp = (Operator)m_ParentOperators.elementAt(0);
if (parentOp.getOutputBIObject()!=null && parentOp.getOutputBIObject().getBIData()!=null)
//if (parentOp.hasResult())
{
m_MetaData = parentOp.getOutputBIObject().getBIData().getMetaData();
}
}
}
/**
* Initiate data requires for the attribute table.
*/
private void initTable() {
if (m_MetaData==null || m_Node==null || m_MetaData.getAttributesNumber()==0) {
m_AttributesTableModel = new AttributesTableModel(m_ColumnName, m_ColumnData);
m_TableAttributes.setModel(m_AttributesTableModel);
return;
}
int m_Column = m_MetaData.getAttributesNumber();
String name = null;
MiningAttribute[] miningAttributes = m_MetaData.getAttributesArray();
MiningAttribute attribute = null;
Object[][] content = new Object[m_Column][m_ColumnName.length];
Object[] row = null;
for (int i=0; i<m_Column; i++)
{
row = new Object[m_ColumnName.length];
attribute = miningAttributes[i];
name = attribute.getName();
row[0] = name;
row[1] = new Boolean(false);
content[i] = row;
}
m_ColumnData = content;
m_AttributesTableModel = new AttributesTableModel(m_ColumnName, m_ColumnData);
m_TableAttributes.setModel(m_AttributesTableModel);
}
/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -