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

📄 normalizationpanel.java

📁 利用Java实现的神经网络工具箱
💻 JAVA
字号:
/* * $RCSfile: NormalizationPanel.java,v $ * $Revision: 1.2 $ * $Date: 2005/02/24 21:20:32 $ * * NeuralNetworkToolkit * Copyright (C) 2004 Universidade de Brasília * * This file is part of NeuralNetworkToolkit. * * NeuralNetworkToolkit 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. * * NeuralNetworkToolkit 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 NeuralNetworkToolkit; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 - USA. */package neuralnetworktoolkit.gui.options.normalization;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.util.ResourceBundle;import javax.swing.ButtonGroup;import javax.swing.JComboBox;import javax.swing.JPanel;import javax.swing.JRadioButton;import javax.swing.border.TitledBorder;import neuralnetworktoolkit.normalization.NormalizationParameters;/** *  *  * @version $Revision: 1.2 $ - $Date: 2005/02/24 21:20:32 $ *  * @author <a href="mailto:rodbra@pop.com.br">Rodrigo C. M. Coimbra</a> * @author <a href="mailto:hugoiver@yahoo.com.br">Hugo Iver V. Gonçalves</a> */public class NormalizationPanel extends JPanel {	private NormalizationParameters parameters;		private JRadioButton noNormalizeRadio;	private JRadioButton inputRadio;	private JRadioButton allRadio;	private ButtonGroup normalizeGroup;	private JComboBox normalizationCombo;	private JPanel componentsPanel;	private Dimension dim;		private String[] normalization = {"EuclideanNorm1", "Linear", "Sum1",			"ZeroMean", "ZeroMeanAndUnitStandardDeviation"};	private String[] normalizationNames;		private Insets borderInsets;		private ResourceBundle resource;		/**	 * @param parameters	 */	public NormalizationPanel(NormalizationParameters parameters) {		super();		resource = ResourceBundle				.getBundle("neuralnetworktoolkit.gui.options.normalization.resources.NormalizationPanelResource");		this.parameters = parameters;				borderInsets = new Insets(5, 5, 5, 5);				noNormalizeRadio = new JRadioButton(resource.getString("noNormalize"));		noNormalizeRadio.addActionListener(new RadioListener());		inputRadio = new JRadioButton(resource.getString("input"));		inputRadio.addActionListener(new RadioListener());		allRadio = new JRadioButton(resource.getString("all"));		allRadio.addActionListener(new RadioListener());				normalizeGroup = new ButtonGroup();		normalizeGroup.add(noNormalizeRadio);		normalizeGroup.add(inputRadio);		normalizeGroup.add(allRadio);				normalizationNames = new String[normalization.length];		normalizationNames[0] = resource.getString("euclideanNorm1");		normalizationNames[1] = resource.getString("linear");		normalizationNames[2] = resource.getString("sum1");		normalizationNames[3] = resource.getString("zeroMean");		normalizationNames[4] = resource.getString("zeroMeanAndUnitStandardDeviation");		normalizationCombo = new JComboBox(normalizationNames);				componentsPanel = new JPanel();		componentsPanel.setLayout(new GridBagLayout());		componentsPanel.add(noNormalizeRadio,				new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,						GridBagConstraints.CENTER,						GridBagConstraints.HORIZONTAL, borderInsets,						67, 0));		componentsPanel.add(inputRadio,				new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0,						GridBagConstraints.CENTER,						GridBagConstraints.HORIZONTAL, borderInsets,						67, 0));		componentsPanel.add(allRadio,				new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0,						GridBagConstraints.CENTER,						GridBagConstraints.HORIZONTAL, borderInsets,						67, 0));		componentsPanel.add(normalizationCombo,				new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,						GridBagConstraints.CENTER,						GridBagConstraints.VERTICAL, borderInsets,						67, 0));		componentsPanel.setBorder(new TitledBorder(""));				this.setLayout(new GridBagLayout());		this.add(componentsPanel,				new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,						GridBagConstraints.CENTER,						GridBagConstraints.REMAINDER, borderInsets,						67, 0));				// Initialize containers		switch (parameters.getType()) {		case (NormalizationParameters.NO_NORMALIZE): {			normalizeGroup.setSelected(noNormalizeRadio.getModel(), true);			normalizationCombo.setEnabled(false);					} break;		case (NormalizationParameters.NORMALIZE_INPUT): {			normalizeGroup.setSelected(inputRadio.getModel(), true);			normalizationCombo.setEnabled(true);					} break;		case (NormalizationParameters.NORMALIZE_ALL): {			normalizeGroup.setSelected(allRadio.getModel(), true);			normalizationCombo.setEnabled(true);		} break;		default: 			normalizeGroup.setSelected(noNormalizeRadio.getModel(), true);			normalizationCombo.setEnabled(true);					}		normalizationCombo.setSelectedIndex(normalizationIndex(parameters				.getNormalizer()));			} //NormalizationPanel()		/**	 * 	 * @param normalization	 * @return	 */	private int normalizationIndex(String normalization) {		int index = -1;				for(int i = 0; i < this.normalization.length; i++) {			if(normalization.equals(this.normalization[i])) {				index = i;				break;							}					}		return index;			} //normalizationIndex()		/**	 * @return Returns the parameters.	 */	public NormalizationParameters getParameters() {		if(noNormalizeRadio.isSelected()) {			parameters.setType(NormalizationParameters.NO_NORMALIZE);					} else if(inputRadio.isSelected()) {			parameters.setType(NormalizationParameters.NORMALIZE_INPUT);					} else if(allRadio.isSelected()) {			parameters.setType(NormalizationParameters.NORMALIZE_ALL);					}		parameters.setNormalizer(normalization[normalizationCombo.getSelectedIndex()]);				return parameters;			} //getParameters()		/**	 * 	 */	public class RadioListener implements ActionListener {		public void actionPerformed(ActionEvent arg0) {			if(normalizeGroup.getSelection().equals(noNormalizeRadio.getModel())) {				normalizationCombo.setEnabled(false);							} else {				normalizationCombo.setEnabled(true);							}		} //actionPerformed()	} //InputCheckListener	} //NormalizationPanel

⌨️ 快捷键说明

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