📄 outliertreatmentoperatorproperty.java
字号:
/*
* 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/18
*
* 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.Dimension;
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.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
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 com.prudsys.pdm.Core.CategoricalAttribute;
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.MiningInputStream;
import com.prudsys.pdm.Input.MiningStoredData;
import com.prudsys.pdm.Models.Statistics.SimpleStats;
import com.prudsys.pdm.Transform.OneToOne.TreatOutlierAttributeValue;
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.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 OutlierTreatmentOperatorProperty extends OperatorProperty implements ChangeListener {
/**
*
*/
private static final long serialVersionUID = 1L;
public static final Border TITLED_BORDER = new CompoundBorder(new TitledBorder((new EtchedBorder(
EtchedBorder.LOWERED)), Resource.srcStr("Replace")), new EmptyBorder(10, 12, 10, 12));
private MiningDataSpecification m_MetaData;
private MiningStoredData m_msd = null;
private double[] m_MinValues;
private double[] m_MaxValues;
private final static String DEFAULT = Resource.srcStr("SelectItem");
private final static String CATEG = Resource.srcStr("Categorical");
private final static String NUM = Resource.srcStr("Numeric");
// << Franky Chan 23/03/2005
// Keep those dummy variables after BAT requirement changes
// Can be removed if options are not required in the future
private JRadioButton m_RadioMissingVal = new JRadioButton(Resource.srcStr("m_RadioMissingVal"));
private JRadioButton m_RadioExtremeVal = new JRadioButton(Resource.srcStr("m_RadioExtremeVal"));
private JTextField m_MinText = new JTextField();
private JTextField m_MaxText = new JTextField();
// >> Franky Chan 23/03/2005
private JComboBox m_AttributeCombo = new JComboBox();
private JTextField m_LowerBoundText = new JTextField("-10.0");
private JTextField m_UpperBoundText = new JTextField("10.0");
private ButtonGroup m_OutlierGroup = new ButtonGroup();
private JButton m_ButtonReset = new JButton();
private JButton m_ButtonApply = new JButton();
private JButton m_ButtonClose = new JButton();
/**
* @throws MiningException
* @throws SysException
*
*/
public OutlierTreatmentOperatorProperty(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 */
createOutlierTreatmentOperatorProperty();
this.setTitle(Resource.srcStr("OutlierTreatment") + " [" + a_NodeID + "]"); // Added
// title
// menu by Joyce
// 2005/02/17
}
public void stateChanged(ChangeEvent e) {
}
private void createOutlierTreatmentOperatorProperty() throws MiningException {
JPanel outlierCentralPanel = new JPanel(new BorderLayout());
outlierCentralPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 5, 0));
JPanel buttonPanel = new JPanel();
m_OutlierGroup.add(m_RadioMissingVal);
m_OutlierGroup.add(m_RadioExtremeVal);
m_RadioMissingVal.addChangeListener(this);
m_RadioExtremeVal.addChangeListener(this);
// Create attribute panel
m_AttributeCombo.setPreferredSize(new Dimension(223, 20));
m_AttributeCombo.setMaximumSize(new Dimension(223, 20));
m_AttributeCombo.setMinimumSize(new Dimension(223, 20));
JPanel propertyAttributePanel = new JPanel();
propertyAttributePanel.setLayout(new BoxLayout(propertyAttributePanel, BoxLayout.LINE_AXIS));
propertyAttributePanel.add(new JLabel(Resource.srcStr("m_AttributeLabel")));
propertyAttributePanel.add(Box.createRigidArea(new Dimension(15, 0)));
propertyAttributePanel.add(m_AttributeCombo);
propertyAttributePanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 0));
// Create range panel
JPanel boundInputFieldPanel = new JPanel();
boundInputFieldPanel.setBorder(TITLED_BORDER);
boundInputFieldPanel.setLayout(new BoxLayout(boundInputFieldPanel, BoxLayout.LINE_AXIS));
boundInputFieldPanel.add(new JLabel(Resource.srcStr("LowerLabel")));
boundInputFieldPanel.add(Box.createRigidArea(new Dimension(10, 0)));
boundInputFieldPanel.add(m_LowerBoundText);
boundInputFieldPanel.add(Box.createRigidArea(new Dimension(10, 0)));
boundInputFieldPanel.add(new JLabel(Resource.srcStr("UpperLabel")));
boundInputFieldPanel.add(Box.createRigidArea(new Dimension(10, 0)));
boundInputFieldPanel.add(m_UpperBoundText);
m_UpperBoundText.setPreferredSize(DimensionConstants.TEXT_FIELD_DIM);
m_LowerBoundText.setPreferredSize(DimensionConstants.TEXT_FIELD_DIM);
// << Franky Chan 23/03/2005
// Commented according to requirement changes after BAT
// boundInputFieldPanel.add(m_MinText);
// boundInputFieldPanel.add(m_MaxText);
// Radio
// JPanel outlierFieldPanel = new JPanel(new GridLayout(4, 1, 2, 5));
// outlierFieldPanel.setBorder(BorderFactory.createEmptyBorder(0, 10,5,
// 0));
// outlierFieldPanel.add(new JLabel("Replace as"));
// outlierFieldPanel.add(m_RadioMissingVal );
// outlierFieldPanel.add(m_RadioExtremeVal );
// m_RadioMissingVal.setSelected(true);
// m_MinText.setEnabled(false);
// m_MaxText.setEnabled(false);
// << Franky Chan 23/03/2005
// << Franky Chan 23/03/2005
// Commented according to requirement changes after BAT
// aPanel.add(outlierFieldPanel, BorderLayout.EAST);
// tempPanel.add(boundLabelPanel, BorderLayout.WEST);
// << Franky Chan 23/03/2005
outlierCentralPanel.add(propertyAttributePanel, BorderLayout.NORTH);
outlierCentralPanel.add(boundInputFieldPanel, BorderLayout.SOUTH);
// Button
m_ButtonReset.setText(Resource.srcStr("m_ButtonReset"));
m_ButtonApply.setText(Resource.srcStr("m_ButtonApply"));
m_ButtonClose.setSelected(false);
m_ButtonClose.setText(Resource.srcStr("m_ButtonClose"));
buttonPanel.add(m_ButtonApply);
buttonPanel.add(m_ButtonReset);
buttonPanel.add(m_ButtonClose);
m_ButtonReset.addActionListener(this);
m_ButtonApply.addActionListener(this);
m_ButtonClose.addActionListener(this);
m_RadioMissingVal.addActionListener(this);
m_RadioExtremeVal.addActionListener(this);
m_AttributeCombo.addActionListener(this);
this.getContentPane().add(outlierCentralPanel, BorderLayout.CENTER);
this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
this.setSize(312, 193);
initContent();
getContent();
// << added by Joyce 2005/03/14 for bug 196
if (m_RadioMissingVal.isSelected()) {
m_MinText.setEnabled(false);
m_MaxText.setEnabled(false);
} else if (m_RadioExtremeVal.isSelected()) {
m_MinText.setEnabled(true);
m_MaxText.setEnabled(true);
}
// >>
}
/**
* @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
*/
public void actionPerformed(ActionEvent e) {
if (e.getSource() == m_ButtonApply) {
if (setContent()) {
m_ParameterChanged = true;
// m_ParentPanel.getCaseWindow().setModified(true);
setPropertiesModified();
}
} else if (e.getSource() == m_ButtonReset) {
getContent();
// << added by Joyce 2005/03/14 for bug 158
if (m_RadioMissingVal.isSelected()) {
m_MinText.setEnabled(false);
m_MaxText.setEnabled(false);
} else if (m_RadioExtremeVal.isSelected()) {
m_MinText.setEnabled(true);
m_MaxText.setEnabled(true);
}
// >>
} else if (e.getSource() == m_ButtonClose) {
close();
} else if (e.getSource() == m_RadioMissingVal) {
if (m_RadioMissingVal.isSelected()) {
m_MinText.setEnabled(false);
m_MaxText.setEnabled(false);
}
} else if (e.getSource() == m_RadioExtremeVal) {
if (m_RadioExtremeVal.isSelected()) {
m_MinText.setEnabled(true);
m_MaxText.setEnabled(true);
}
} else if (e.getSource() == m_AttributeCombo) {
String attrName = (String) m_AttributeCombo.getSelectedItem();
if (attrName != null && !attrName.equalsIgnoreCase(Resource.srcStr("SelectItem"))) {
MiningAttribute mAtt = m_MetaData.getMiningAttribute(attrName);
if (mAtt != null) {
if (mAtt instanceof CategoricalAttribute) {
EnabledCategoricalAttribute();
} else if (mAtt instanceof NumericAttribute) {
// m_MinText.setText(Double.toString(m_MinValues[index]));
// m_MaxText.setText(Double.toString(m_MaxValues[index]));
if (m_RadioMissingVal.isSelected()) {
EnabledNumericAttribute(true);
} else {
EnabledNumericAttribute(false);
}
}
}
}
}
}
/*
* @ enable some CategoricalAttribute Text Field
*/
private void EnabledCategoricalAttribute() {
m_LowerBoundText.setEnabled(false);
m_UpperBoundText.setEnabled(false);
// m_MinText.setEnabled(false);
// m_MaxText.setEnabled(false);
// m_RadioExtremeVal.setEnabled(false);
// m_RadioMissingVal.setEnabled(true);
// m_RadioMissingVal.setSelected(true);
}
/*
* @ enable some CategoricalAttribute Text Field
*/
private void EnabledNumericAttribute(boolean a_OutlierMissingVal) {
m_LowerBoundText.setEnabled(true);
m_UpperBoundText.setEnabled(true);
// m_RadioExtremeVal.setEnabled(true);
// m_RadioMissingVal.setEnabled(true);
// if (a_OutlierMissingVal)
// {
// m_MinText.setEnabled(false);
// m_MaxText.setEnabled(false);
// } else
// {
// m_MinText.setEnabled(true);
// m_MaxText.setEnabled(true);
// }
}
protected void initContent() throws MiningException {
if (m_ParentOperators.size() > 0) {
Operator parentOp = (Operator) m_ParentOperators.elementAt(0);
if (parentOp.getOutputBIObject() != null && parentOp.getOutputBIObject().getBIData() != null) {
m_MetaData = parentOp.getOutputBIObject().getBIData().getMetaData();
m_msd = parentOp.getOutputBIObject().getBIData().getMiningStoredData();
}
if (m_MetaData == null) {
throw new MiningException("Meta data of the node is null");
}
if (m_msd == null) {
throw new MiningException("Mining stored data of the node is null");
// TODO handle this
// throw new MiningException ("No input data from parent node");
}
calcMinMaxValues(m_msd);
}
}
private void getContent() {
/*
* set valeus independent of parent
*/
String value = null;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -