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

📄 subconfigboxparam.java

📁 这是一个从音频信号里提取特征参量的程序
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
// file: SubConfigBox.java//// import java libraries//import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.*;import javax.swing.event.*;import java.util.*;import java.io.*;import java.lang.*;import javax.swing.plaf.*;public class SubConfigBoxParam extends JDialog implements ActionListener, Constants {    // ---------------------------------------------------    //    // declare class member data    //    // ---------------------------------------------------    // set the current vertex that is in focus    //    private Vertex currVertexFocus = null;        // data from the parsed text file    //    Data data = null;        // scroll pane to hold all the parameter fields    //    JScrollPane scroll_pane = null;    // panel to hold all the config data fields    // to be mounted in a scrollable pane    //    JPanel config_panel = null;    // parent dialog    //    JDialog parent = null;    // global representation of the transform type we are dealing with    //    Vertex  cfgVertexFocus;    // transform tyoe this subclass represents    //    Vertex subVertex;    // start index of subclass    //    int subStart = -1;    // end index of subclass    //    int subEnd = -1;    // button to get values an return to process design box    //    JButton save_button = null;    JButton cancel_button = null;    JButton default_button = null;    JButton help_button = null;    JButton config_button = null;    // vector of labels and data blocks (text fields, selection blocks,    // check boxes, etc..)    //    Vector enteredData = null;    Vector blockType = null;    Vector labelReference = null;      Vector subInfo = null;        Vector subparamInfo = null;    // vector of subclass vertices    //    Vector config_vertices = null;    // Max number of subclasses    //    int max_subclass = 0;    // total number of sub params (to prevent re-adding to the subparam vector)    //    int max_subparam = 0;    // parameter button    //    Vertex buttonParam = null;    // maximum font size for the componets    //    private static final int MAX_FONT_SIZE = (int)12;        // isSubDiagOpen     //    public int isSubDiagOpen = 0;    // ---------------------------------------------------    //    // declare class constructors    //    // ---------------------------------------------------    // method: SubConfigBoxParam    //    // arguments: none    // returns  : none    //    public SubConfigBoxParam(JDialog par, Data d, Vertex subparam, Vertex process, Vector subInf) {	// invoke the parent default constructor	//	//super("Subparam Configuration Box");	parent = par;	setModal(true);	Point xy = parent.getLocation();	setLocation((int)xy.getX() + 100,(int)xy.getY() + 200);		// set isSubDiagOpen = 0	//	isSubDiagOpen =0;		// make the passed Data object available globally	//	data = d;	// make parent class information to subInfo	//	subInfo = subInf;		// initialize the enteredData and labelReference vectors for use	//	enteredData = new Vector(5,5);	labelReference = new Vector(5,5);	blockType = new Vector(5,5);		// give the name of the transfrom in question over to its global 	// counterpart	//	subVertex = subparam;	cfgVertexFocus = process;	// create this new panel with gridbag layout	//	config_panel = new JPanel();	addConfig();	// set the sizes of the scroll pane and configuration panel	//	int height = labelReference.size() * 25 + 100;	int width = 335 + 55;	config_panel.setSize(width, height);	config_panel.setMinimumSize(new Dimension(width,height));	config_panel.setPreferredSize(new Dimension(width,height));	config_panel.setMaximumSize(new Dimension(width,height));		// add the scroll pane to the frame	//	this.getContentPane().add(config_panel, BorderLayout.NORTH);	// create, configure, and place a border on the config pane	//	String border_title = 	    new String(subVertex.association + " Configuration:");	BorderUIResource.TitledBorderUIResource border =	    new BorderUIResource.TitledBorderUIResource(border_title);	border.setTitleFont(newFont);	border.setTitleColor(Color.black);	config_panel.setBorder(border);    }        // ---------------------------------------------------    //    // declare class methods    //    // ---------------------------------------------------    // method:  addConfig()    //    // arguments:  none    // return: none    //    //  dynamically adds and constrains all objects on the JPanel    //    public void addConfig() {	GridBagLayout gridbag = new GridBagLayout();	config_panel.setLayout(gridbag);	// to simplify the creation, the data vectors will be trimmed to only	// include the transform we're looking at and saved into these three	// vectors for use in a bit	//	Vector labels = new Vector(5,5);	Vector types = new Vector(5,5);	Vector values = new Vector(5,5);		String transform = subVertex.association;	boolean isParentType = false;	int     tmpStart = -1;	String delimitname = null; 	String delimitvalue = null;	int subclassIndex = 0;	// determine start location and end location of the block in resources	// file  	//	for(int j=data.association.indexOf(transform); 	    j <= data.association.lastIndexOf(transform);	    j++) {	    	    if(j != -1) { 		if(!data.association.get(j).equals(transform) && subStart >= 0) {		    subEnd = j;		    break;		}		if(subStart < 0) {		    for(int k=0; k< subInfo.size(); k++) {			String tmp1 ="["+ subInfo.get(k) + "]";			tmp1.trim();			String tmp2 = ""+data.values.get(j);			if(tmp2.equals(tmp1)) {						    if(k == 0) {				tmpStart =j;				if(0 != subInfo.size()-1) {				    				}			    }			    if(k == subInfo.size()-1) {				delimitname = (String)data.name.get(tmpStart);				delimitvalue = ""+ data.values.get(tmpStart);				subStart = tmpStart;				j++;				break;			    }			    j++;			}			else {			    break;			}		    }		}	     		if(subEnd < 0) {		    String tmp3 = ""+data.name.get(j);		    String tmp4 = ""+data.values.get(j);		    if(tmp3.equals(delimitname)) {			subEnd =j;			break;		    }		    if(subEnd < 0 && j == data.association.lastIndexOf(transform)) {			subEnd = j+1;		    }		}	    }	}		for(int j=subStart; j <subEnd; j++) {	  if(j != -1) { 	      for(int k=0; k< subInfo.size(); k++) {		  String tmp4 = ""+data.values.get(j);		  String tmp5 = "["+subInfo.get(k)+"]";		  if(tmp4.equals(tmp5)) {		      isParentType = true;		      break;		  }	      }	      if(!isParentType) {		  labels.add(data.name.get(j));		  types.add(data.type.get(j));		  values.add(data.values.get(j));	      }	      isParentType = false;	  }      }	String sstart = "start"+ subStart;	String ssend = "end"+ subEnd;	/*	subVertex.values = new Vector(5,5);	subVertex.names = new Vector(5,5);	subVertex.types = new Vector(5,5);*/	Vertex sVertex = null;	// Determine if the subparam exist.	//	int match = 0, index2;	for(index2 = cfgVertexFocus.subparam.size()-1; index2>=0; index2--) {	    sVertex = (Vertex)cfgVertexFocus.subparam.get(index2);	    if(sVertex.identify.size() > 0) {		break;	    }	}	if(sVertex.identify.size() > 0) {	    	    for(int index1 = 0; index1 < subInfo.size(); index1++) {		String strpara = ""+ subInfo.get(index1);			if(sVertex.identify.size() == subInfo.size()) {		    String strvalue =""+sVertex.identify.get(index1);		    if(strpara.equals(strvalue)) {			match++;		    }		}		else {		    break;		}	    }	    	}	if(match == subInfo.size() && index2 != cfgVertexFocus.subparam.size()-1) {		    subVertex.values = new Vector(5,5);	    subVertex.names = new Vector(5,5);	    subVertex.types = new Vector(5,5); 	    	    for(int inf = 0; inf < sVertex.values.size(); inf++) {		subVertex.types.add(sVertex.types.get(inf));		subVertex.values.add(sVertex.values.get(inf));		subVertex.names.add(sVertex.names.get(inf));	    }	    subVertex.identify = new Vector(5,5);	    for(int inf = 0; inf < subInfo.size(); inf++ ) {	    subVertex.identify.add(subInfo.get(inf));	    }	    for(int m = 0; m < sVertex.subclass.size(); m++) {		subVertex.subclass.add(sVertex.subclass.get(m));	    }	    for(int m = 0; m < sVertex.subparam.size(); m++) {		subVertex.subparam.add(sVertex.subparam.get(m));	    }	}	else if(match != subInfo.size()) {	    	    subVertex.values = new Vector(5,5);	    subVertex.names = new Vector(5,5);	    subVertex.types = new Vector(5,5); 	    	    for(int j=subStart; j <subEnd; j++) {		if(j != -1) { 		    for(int k=0; k< subInfo.size(); k++) {			String tmp4 = ""+data.values.get(j);			String tmp5 = "["+subInfo.get(k)+"]";			if(tmp4.equals(tmp5)) {			    isParentType = true;			    break;			}		    }		    if(!isParentType) {			subVertex.names.add(data.name.get(j));			subVertex.types.add(data.type.get(j));			subVertex.values.add(data.values.get(j));		    }		    isParentType = false;		}	    }	    subVertex.identify = new Vector(5,5);	    for(int inf = 0; inf < subInfo.size(); inf++ ) {		subVertex.identify.add(subInfo.get(inf));	    }		    // initialize the vertex to the default values for its type	    //	    subVertex.initializeConfig(subVertex.names, subVertex.values, 				       subVertex.types, transform, data);	    	}	// calculate the total number of subclasses	//	for(int i =0; i < subVertex.types.size(); i++){	    if(subVertex.types.get(i).equals("class"))		max_subclass++;	}	subVertex.max_subclass = max_subclass;	// maximum width of any JTextField or JComboBox	// will set all to this width once they have been added	//	int maxwidth = 0;	int maxheight = 0;	// run through these and add labels and input fields as appropriate	//	for(int i=0; i < labels.size(); i++) {	    // add a label for all labels except the images	    //	    if(types.get(i).equals("image") == false){		String configLabel = (String)labels.get(i);		JLabel jlabel = new JLabel((String)labels.get(i));		if(configLabel.equals("configuration")) {		    jlabel = new JLabel("");		}		jlabel.setFont(newFont);		jlabel.setForeground(Color.black);		constrain(config_panel,jlabel, gridbag, 0, i,			  1, 1, 1, 0, GridBagConstraints.WEST);		labelReference.add(jlabel);	    }	    else {				// keep data alligned so changing values is done easily		// while holding onto these image files		//		enteredData.add("image");		labelReference.add("image");		blockType.add("image");	    }		    // add a drop down list for the enumerated values with first	    // option from file being initially selected	    //	    if(types.get(i).equals("enum")){		//create a drop down list to allow selection from		//		JComboBox select = new JComboBox();				constrain(config_panel,select, gridbag, 1, i,			  1, 1, 1, 0, GridBagConstraints.EAST);				// retrieve and add all possible values to this list		//		Vector enum_values = (Vector)values.get(i);		for(int j=0; j < enum_values.size(); j++) {		    select.addItem(enum_values.get(j));		}		enteredData.add(select);		blockType.add("enum");		select.setSelectedItem(subVertex.values.get(i));		select.setFont(newFont);		select.setForeground(Color.black);	    }	    // make a check box for a boolean type	    //	    else if (types.get(i).equals("boolean")){		//create the check box		//		String value = (String)(subVertex.values.get(i));				// get the default value for the button		//		boolean value2;		if (value.equals("true"))		    value2 = true;		else		    value2 = false;		JCheckBox checkBox = new JCheckBox("", value2);		constrain(config_panel, checkBox, gridbag, 1, i,			  1,1,1,0,GridBagConstraints.EAST);		enteredData.add(checkBox);		blockType.add("boolean");	    }	  	    // add another pop up frame to set parameters for the class	    //	    else if (types.get(i).equals("param")) {

⌨️ 快捷键说明

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