📄 normalizationoperatorproperty.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.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.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.NormalizeOperator;
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 NormalizationOperatorProperty 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("NewRangeTitle")), new EmptyBorder(6, 12, 8, 12));
private MiningDataSpecification m_MetaData;
private MiningStoredData m_msd = null;
private final static String DEFAULT = Resource.srcStr("SelectItem");
private JRadioButton m_RadioMissingVal = new JRadioButton(
Resource.srcStr("m_RadioMissingVal"));
private JRadioButton m_RadioExtremeVal = new JRadioButton(
Resource.srcStr("m_RadioExtremeVal"));
private JRadioButton m_RadioAsIs = new JRadioButton(Resource.srcStr("m_RadioAsIs"));
//<< Franky Chan 23/03/2005
private JRadioButton m_RadioLinear = new JRadioButton(Resource.srcStr("m_RadioLinear"));
private JRadioButton m_RadioZeta = new JRadioButton(
Resource.srcStr("m_RadioZeta"));
private JComboBox m_AttributeCombo = new JComboBox();
private JTextField m_LowerBoundText = new JTextField("0.0");
private JTextField m_UpperBoundText = new JTextField("1.0");
private JTextField m_MinText = new JTextField();
private JTextField m_MaxText = new JTextField();
private ButtonGroup m_ButtonGroup = new ButtonGroup();
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 NormalizationOperatorProperty(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 */
createNormalizationOperatorProperty();
this.setTitle(Resource.srcStr("Normalization")+" [" + a_NodeID + "]"); // Added title menu
// by Joyce
// 2005/02/17
}
public void stateChanged(ChangeEvent e) {
//setEnabledFile(m_RadioFile.isSelected());
//setEnabledDB(m_RadioDB.isSelected());
}
private void createNormalizationOperatorProperty() throws MiningException {
JPanel propertyAttributePanel = new JPanel(new BorderLayout(0, 20));
JPanel propertyNormalizePanel = new JPanel(new BorderLayout(0, 0));
JPanel buttonPanel = new JPanel();
m_ButtonGroup.add(m_RadioLinear);
m_ButtonGroup.add(m_RadioZeta);
m_RadioLinear.addChangeListener(this);
m_RadioZeta.addChangeListener(this);
m_RadioLinear.setSelected(true);
m_OutlierGroup.add(m_RadioMissingVal);
m_OutlierGroup.add(m_RadioExtremeVal);
m_OutlierGroup.add(m_RadioAsIs);
m_RadioMissingVal.setSelected(true);
/*
* m_RadioMissingVal.addChangeListener(this);
* m_RadioExtremeVal.addChangeListener(this);
* m_RadioAsIs.addChangeListener(this); m_MinText.setEnabled(false);
* m_MaxText.setEnabled(false);
*/
setEnabledLinear(true);
propertyAttributePanel.setBorder(new EmptyBorder(10, 5, 6, 0));
propertyAttributePanel.add(new JLabel(Resource.srcStr("m_AttributeLabel")+" "),
BorderLayout.WEST);
propertyAttributePanel.add(m_AttributeCombo, BorderLayout.CENTER);
m_AttributeCombo.setPreferredSize(new Dimension(10, 20));
m_AttributeCombo.setMaximumSize(new Dimension(10, 20));
m_AttributeCombo.setMinimumSize(new Dimension(10, 20));
propertyNormalizePanel.add(m_RadioLinear, BorderLayout.NORTH);
//<< Franky Chan 23/03/2005
// Commented after BAT requirement changes
// dbSeverLabelPanel.setBorder(BorderFactory
// .createEmptyBorder(0, 10, 3, 0));
// JPanel boundInputFieldPanel = new JPanel(new GridLayout(4, 1, 2, 5));
// boundInputFieldPanel.add(m_LowerBoundText);
// boundInputFieldPanel.add(m_UpperBoundText);
// boundInputFieldPanel.add(m_MinText);
// boundInputFieldPanel.add(m_MaxText);
//<< Franky Chan 23/03/2005
JPanel boundInputFieldPanel = new JPanel();
boundInputFieldPanel.setBorder(new CompoundBorder(new EmptyBorder(0,
18, 7, 0), TITLED_BORDER));
boundInputFieldPanel.setLayout(new BoxLayout(boundInputFieldPanel,
BoxLayout.LINE_AXIS));
boundInputFieldPanel.add(new JLabel(Resource.srcStr("m_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("m_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);
m_UpperBoundText.setMaximumSize(DimensionConstants.TEXT_FIELD_DIM);
m_LowerBoundText.setMaximumSize(DimensionConstants.TEXT_FIELD_DIM);
m_UpperBoundText.setMinimumSize(DimensionConstants.TEXT_FIELD_DIM);
m_LowerBoundText.setMinimumSize(DimensionConstants.TEXT_FIELD_DIM);
//<< Franky Chan 23/03/2005
// Commented after BAT requirement changes
// dbSeverFieldPanel1.setBorder(BorderFactory.createEmptyBorder(0, 10,
// 3,
// 0));
// JPanel outlierFieldPanel = new JPanel(new GridLayout(4, 1, 2, 5));
// outlierFieldPanel.add(new JLabel("Outlier"));
// outlierFieldPanel.add(m_RadioMissingVal);
// outlierFieldPanel.add(m_RadioExtremeVal);
// outlierFieldPanel.add(m_RadioAsIs);
// tempPanel.add(boundLabelPanel, BorderLayout.WEST);
// tempPanel.add(boundInputFieldPanel, BorderLayout.CENTER);
// tempPanel.add(outlierFieldPanel, BorderLayout.EAST);
// propertyNormalizePanel.add(new JLabel(" "), BorderLayout.WEST);
//<< Franky Chan 23/03/2005
propertyNormalizePanel.add(boundInputFieldPanel, BorderLayout.CENTER);
propertyNormalizePanel.add(m_RadioZeta, BorderLayout.SOUTH);
//===
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);
buttonPanel.setBorder(new EmptyBorder(3, 0, 0, 0));
//m_ButtonSelect.addActionListener(this);
m_ButtonReset.addActionListener(this);
m_ButtonApply.addActionListener(this);
m_ButtonClose.addActionListener(this);
m_RadioLinear.addActionListener(this);
m_RadioZeta.addActionListener(this);
m_RadioMissingVal.addActionListener(this);
m_RadioExtremeVal.addActionListener(this);
m_RadioAsIs.addActionListener(this);
m_AttributeCombo.addActionListener(this);
//==
this.getContentPane().add(propertyAttributePanel, BorderLayout.NORTH);
this.getContentPane().add(propertyNormalizePanel, BorderLayout.CENTER);
this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
this.setSize(265, 243);
initContent();
getContent();
}
/**
* @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
*/
public void actionPerformed(ActionEvent e) {
if (e.getSource() == m_ButtonApply) {
if (setContent()) {
m_ParameterChanged = true;
// m_Observer.sendNotify(ObserveMessage.MSG_VALUE_MODIFIED);
setPropertiesModified();
//m_ParentPanel.getCaseWindow().setModified(true);
}
} else if (e.getSource() == m_ButtonReset) {
getContent();
} else if (e.getSource() == m_ButtonClose) {
close();
} else if (e.getSource() == m_RadioLinear) {
if (m_RadioLinear.isSelected())
setEnabledLinear(true);
} else if (e.getSource() == m_RadioZeta) {
setEnabledLinear(false);
}
else if (e.getSource() == m_RadioZeta) {
setEnabledLinear(false);
}
// else if (e.getSource() == m_AttributeCombo ) {
// String attrName = (String)m_AttributeCombo.getSelectedItem();
// if(attrName!=null && !attrName.equalsIgnoreCase(DEFAULT)){
// MiningAttribute mAtt = m_MetaData.getMiningAttribute(attrName);
// int index = m_MetaData.getAttributeIndex(mAtt);
// m_MinText.setText(Double.toString(m_MinValues[index]));
// m_MaxText.setText(Double.toString(m_MaxValues[index]));
// }
//
// }
}
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) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -