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

📄 configboxsub.java

📁 这是一个从音频信号里提取特征参量的程序
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	    //	    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();		    subWorkArea.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);		    		    // change the connector from the selected source to 		    // the position it wanted in		    //		    cfgVertexFocus.changeConnectors((i +1),						(Vertex)parentCopy.						get(focus.getSelectedIndex()));		}				// close the window and repaint the workArea		//		this.dispose();		subWorkArea.repaint();	    }	}		if(e.getActionCommand().equals("cancel")){	    	    // 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();	    if(isModal()) {		setModal(false);		SubConfigBox class_config_panel = 		    new SubConfigBox(this, data, temp, cfgVertexFocus);		class_config_panel.pack();		class_config_panel.setVisible(true);	    }	}	// create config window if dealing with a nested class for config	//	if(e.getActionCommand().equals("param")){	    	    // if the block we've configured is a subparam	    //	    if(validation()) {			Vertex temp = (Vertex)cfgVertexFocus.subparam.get(cfgVertexFocus.subparam.size()-1);		if(isModal()) {		    setModal(false);		    class_config_panel = 			new SubConfigBoxParam(this, data, temp, cfgVertexFocus, subparamInfo);		    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) {	    int subclass_index = 0;	    	    // get the name of the class we're working on	    //	    String association = cfgVertexFocus.association;	    // get the beginning and end of my search for default data	    //	    int begin = data.association.indexOf(association);	    int end = data.association.lastIndexOf(association);	    	    // change all values back to the default	    //	    for(int i= begin; i <= end; i++) {				// set enum type back to default value		//		if(data.type.get(i).equals("enum")) {		    Vector enum_values = (Vector)data.values.get(i);		    		    // actually change the enum to the default setting		    //		    JComboBox select = (JComboBox)enteredData.get(i - begin);		    select.setSelectedItem((String)enum_values.get(0));		}				// make the check box revert to its previous state		//		else if (data.type.get(i).equals("boolean")){		    		    // get the value for the check box		    //		    String value = (String)(data.values.get(i));		    		    boolean value2;		    if (value.equals("true"))			value2 = true;		    else			value2 = false;		    		    // actually make the change to the check box		    //		    JCheckBox checkBox = 			(JCheckBox)enteredData.get(i - begin); 		    checkBox.setSelected(value2);		}				// do nothing if the type is image		//		else if (data.type.get(i).equals("image")) {		}				// do nothing if type is class		//		else if (data.type.get(i).equals("class")) {		    		    Vertex subclass = 			(Vertex)cfgVertexFocus.subclass.get(subclass_index);		    		    // get the name of the class we're working on		    //		    String association2 = subclass.association;		    		    // get the beginning and end of my search for default data		    //		    int begin2 = data.association.indexOf(association2);		    int end2 = data.association.lastIndexOf(association2);		    		    // change all values back to the default		    //		    for(int j= begin2; j <= end2; j++) {						// set enum type back to default value			//			if(data.type.get(j).equals("enum")) {			    Vector enum_values = (Vector)data.values.get(j);			    subclass.values.				set(j - begin2, enum_values.get(0));			}						// make the check box revert to its default state			//			else if (data.type.get(j).equals("boolean")){			  			    // get the value for the check box			    //			    subclass.values.				set(j - begin2, data.values.get(j));			}						// do nothing if the type is image			//			else if (data.type.get(j).equals("image")) {			}						// set all text field back to defaults			//			else {			    subclass.values.				set(j - begin2, data.values.get(j));			}		    }		    subclass_index++;		}	    		// set all text field back to defaults		//		else {		    		    JTextField text_box			= (JTextField)enteredData.get(i - begin);		    text_box.setText((String)data.values.get(i));			}	    }	}	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 + -