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

📄 configboxarc.java

📁 这是一个从音频信号里提取特征参量的程序
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		try {		    float value = Float.valueOf(text).floatValue();		    //cfgVertexFocus.values.set(i, text);		    //System.out.println("text="+ text);		    digraph.tmpweight = ""+text;		}		catch (java.lang.NumberFormatException event) {		    JFrame frame = new JFrame("Warning");		    String warningMessage = new 			String("The value entered for " + 			       cfgVertexFocus.names.get(i) + 			       " is not a floating point number.");		    JOptionPane.showMessageDialog(frame, warningMessage);		    return false;		}	    }	    // code to get information from a double variable	    //	    if(blockType.get(i).equals("double")) {		String text = ((JTextField)enteredData.get(i)).getText();		try {		    double value = Double.valueOf(text).doubleValue();		    cfgVertexFocus.values.set(i, text);		}		catch (java.lang.NumberFormatException event) {		    JFrame frame = new JFrame("Warning");		    String warningMessage = new 			String("The value entered for " + 			       cfgVertexFocus.names.get(i) + 			       " is not a floating point number.");		    JOptionPane.showMessageDialog(frame, warningMessage);		    return false;		}	    }	    	    // code to get information from an unsigned integer variable	    //	    if(blockType.get(i).equals("unsigned-integer")) {		String text = ((JTextField)enteredData.get(i)).getText();		try {		    int value = Integer.valueOf(text).intValue();		    if (value >= 0) {			cfgVertexFocus.values.set(i, text);		    } else {			JFrame frame = new JFrame("Warning"); 			String warningMessage = new 			    String("The value entered for " + 				   cfgVertexFocus.names.get(i) + 				   " is not an unsigned integer.");			JOptionPane.showMessageDialog(frame,warningMessage);			return false;		    }		}		catch (java.lang.NumberFormatException event) {		    JFrame frame = new JFrame("Warning");		    String warningMessage = new 			String("The value entered for " + 			       cfgVertexFocus.names.get(i) + 			       " is not an unsigned integer.");		    JOptionPane.showMessageDialog(frame, warningMessage);		    return false;		}	    }	    // code to get information from an integer variable	    //	    if(blockType.get(i).equals("integer")) {		String text = ((JTextField)enteredData.get(i)).getText();		try {		    int value = Integer.valueOf(text).intValue();		    cfgVertexFocus.values.set(i, text);		}		catch (java.lang.NumberFormatException event) {		    JFrame frame = new JFrame("Warning");		    String warningMessage = new 			String("The value entered for " + 			       cfgVertexFocus.names.get(i) + 			       " is not an integer.");		    JOptionPane.showMessageDialog(frame, warningMessage);		    return false;		}	    }	}	return true;    }    // method: itemStateChanged    //    // arguments:      //     ItemEvent e:  event thrown when one of the combo boxes is changed    //    // return:  boolean     //    // prevents duplicates from being formed when changing the order in     // a connector configuration screen    //     public void itemStateChanged(ItemEvent e) {		// the combo box that caused the event to fire	//	JComboBox changedBox = (JComboBox)e.getSource();		// the value that the box was changed to	//	int newSetting = changedBox.getSelectedIndex();		// holds the index of the combo box that called this even handler	//	int newSettingIndex = -1;		// the value the box was changed from	//	int oldSetting = -1;		// the index of the combo box that is set to what the other combo box	// was changed to	//	int oldSettingIndex = -1;	for(int i=0; i < connBox.size(); i++) {	    	    // gets the value of the currently selected combo box	    //	    int needToChange = ((JComboBox)connBox.get(i)).getSelectedIndex();	    	    // if the new setting is equal to the value that the box is being	    // changed to, this is either the box that was changed or the one	    // that needs to be changed 	    //	    if (newSetting == needToChange) {		// gets the value that the combobox was set to before changes		// were made to it		//		int change = ((Integer)connection_order.get(i)).intValue();				// if these are equal, we are dealing with the combo box		// that was not changed		//		if ((newSetting == change) && (newSettingIndex == -1)) {		    newSettingIndex = i;		}				// if these are not equal, then this is the one that was 		// changed		//		if ((newSetting != change ) && (oldSettingIndex == -1)) {		    oldSettingIndex = i;		    oldSetting = change;		}				// if we've found both the one that are involved in the change		// make the changes		//		if ((newSettingIndex != -1)&&(oldSettingIndex != -1)) {				    // changes the combo box so that there are no 		    // duplicate inputs		    //		    ((JComboBox)connBox.get(newSettingIndex)).			setSelectedIndex(oldSetting);		    		    // corrects the connection order vector to show the 		    // new order of the inputs		    //		    Integer value = new Integer(oldSetting);		    connection_order.set(newSettingIndex, value);		    		    Integer value2 = new Integer(newSetting);		    connection_order.set(oldSettingIndex, value2);		    		    return;		}	    }	}    }        // method: actionPerformed    //    // arguments:    //    ActionEvent e: event that was fired    //    // return   : none    //    // listens for actions taking place on the components    //    public void actionPerformed(ActionEvent e) {		if(e.getActionCommand().equals("update")){		    // if the block we've configured is a transform	    //	    if(cfgType == 0) {				// validate the inputs and if they are all valid, 		// dispose of the box		//				if(validation()) {		    this.dispose();		    workArea.repaint();		}	    }	    	    // if the block being congifured is a connector block	    //	    else if(cfgType == 1) {				// make a copy of the parent vector for this connector		//		Vector parentCopy = new Vector(cfgVertexFocus.getParents());			// change all connections as the config box has told		//		for(int i=0; i < connBox.size(); i++) {		    		    // get the combo box in question		    //		    JComboBox focus = (JComboBox)connBox.get(i);		    int selected_index = focus.getSelectedIndex();		    // change the connector from the selected source to 		    // the position it wanted in		    //		    cfgVertexFocus.changeConnectors((i + 1),						    (Vertex)parentCopy.						    get(selected_index));		}				// close the window and repaint the workArea		//		this.dispose();		workArea.repaint();	    }	}		if(e.getActionCommand().equals("cancel")){	    digraph.tmpweight = (String)digraph.graphArc.weights.get(index);	    digraph.tmpepi = (String)digraph.graphArc.epsilon.get(index);	    // dispose of the changes and revert to the old ways	    //	    this.dispose();	}		if(e.getActionCommand().equals("default")){	    defaultSettings();	}		if(e.getActionCommand().equals("revert")){	    revertSettings();	}		if(e.getActionCommand().equals("help")){			    // display a help message: "under construction"	    //	    JFrame frame = new JFrame("Help");	    JOptionPane.showMessageDialog(frame, 					  "The help message is under construction");	}		// create config window if dealing with a nested class for config	//	if(e.getActionCommand().equals("class")){	    Vertex temp = (Vertex)e.getSource();	    /*	    SubConfigBoxSys class_config_panel = 		new SubConfigBoxSys(data, temp, cfgVertexFocus);	    class_config_panel.pack();	    class_config_panel.setVisible(true);	    */	}    }    // method: defaultSettings    //    // arguments:  none    //    // return:  none    //    //  resets all configuartion items to the default values as given in     //  the gui configuration file    //    public void defaultSettings() {	if(cfgType == 0) {	      	    JTextField text_box		= (JTextField)enteredData.get(0);	    text_box.setText("1.0");	    boolean value2 = false;	    	    // actually make the change to the check box	    //	    JCheckBox checkBox = 		(JCheckBox)enteredData.get(1); 	    checkBox.setSelected(value2);	    	}	else if(cfgType == 1) {	    for(int i=0; i < connBox.size(); i++) {				// set all the combo boxes to show their original values		//		((JComboBox)connBox.get(i)).setSelectedIndex(i);				// reset the connection order vector to the original setting		//		Integer value = new Integer(i);		connection_order.set(i, value);	    }	}    }    // method: revertSettings    //    // arguments:  none    //    // return:  none    //    //  resets all configuartion items to the values that were stored in the     //  referring vertex before the configuration began     //        public void revertSettings() {		// changes all of the settings back to what they were before the 	// user started changing things	//	if(cfgType == 1) {	    for(int i=0; i < connBox.size(); i++) {				// set all the combo boxes to show their original values		//		((JComboBox)connBox.get(i)).setSelectedIndex(i);				// reset the connection order vector to the original setting		//		Integer value = new Integer(i);		connection_order.set(i, value);	    }	}	else if(cfgType == 0) {		    // now run through these and add labels and input 	    // fields as appropriate	    //	    for(int i=0; i < cfgVertexFocus.values.size(); i++) {		// make the selected option revert to its previous state		//		if(cfgVertexFocus.types.get(i).equals("enum")){		    		    JComboBox select = (JComboBox)enteredData.get(i);		    select.setSelectedItem(cfgVertexFocus.values.get(i));		}				// make the check box revert to its previous state		//		else if (cfgVertexFocus.types.get(i).equals("boolean")){				    // get the value for the check box		    //		    String value = (String)(cfgVertexFocus.values.get(i));		    JCheckBox checkBox = (JCheckBox)enteredData.get(i); 		    boolean value2;		    if (value.equals("true"))			value2 = true;		    else			value2 = false;		    checkBox.setSelected(value2);		}				// do nothing if the type is image		//		else if (cfgVertexFocus.types.get(i).equals("image")) {		}				// do nothing if type is class		//		else if (cfgVertexFocus.types.get(i).equals("class")) {		}				// take care of anything of type text		//		else if (cfgVertexFocus.types.get(i).equals("text")) {		    		    JTextField text_box = (JTextField)enteredData.get(i);		    String text = (String)cfgVertexFocus.values.get(i);		    text_box.setText(text);		    		}		// creation of input box for unsigned int		//		else if (cfgVertexFocus.types.get(i).equals("unsigned-integer")) {		    		    JTextField text_box = (JTextField)enteredData.get(i);		    String text = (String)cfgVertexFocus.values.get(i);		    text_box.setText(text);	    		}				// creation of input box for float		//		else if (cfgVertexFocus.types.get(i).equals("float")) {		    		    JTextField text_box = (JTextField)enteredData.get(i);		    String text = (String)cfgVertexFocus.values.get(i);		    text_box.setText(text);		}				// creation of input box for int		//		else if (cfgVertexFocus.types.get(i).equals("integer")) {		    		    JTextField text_box = (JTextField)enteredData.get(i);		    String text = (String)cfgVertexFocus.values.get(i);		    text_box.setText(text);	    		}	    }	}     }}//// end of file

⌨️ 快捷键说明

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