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

📄 subconfigboxparam.java

📁 这是一个从音频信号里提取特征参量的程序
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		String image_name = null;		String image_association= null;		// tells the program which transform it is looking to match		//		image_association = (String)values.get(i);		// scans through the association until it finds the		// smallIcon key		//		for(int j=data.association.indexOf(image_association); 		    j <= data.association.lastIndexOf(image_association);		    j++) {		    if(j != -1) {	   			if(((String)(data.name.get(j))).equals("iconSmall")) {			    // sets the image_name to the value 			    // held in small icon			    //			    image_name = (String)data.values.get(j);			}		    }		}		// check to see if the file exists. If it does not exist,		// use a default image.		//		if(image_name != null){		    File image_file = new File(image_name);		    if (image_file.exists() == false) {			image_name = DEFAULT_PATH + "default.gif";		    }		}		else {		    image_name = DEFAULT_PATH + "default.gif";		}			 image_name = GUI_PATH+"/lib/images/isip_transform_builder/icons/algorithm_00.gif";		// create the icons for the config panel		//		ImageIcon icon = new ImageIcon(image_name);				// create the button for the config panel		//		buttonParam = new Vertex("  Configure ");		buttonParam.association = image_association;		// 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 labels2 = new Vector(5,5);		Vector types2 = new Vector(5,5);		Vector values2 = new Vector(5,5);		for(int j=data.association.indexOf(image_association); 		    j <= data.association.lastIndexOf(image_association);		    j++) {		    if(j != -1) {			labels2.add(data.name.get(j));			types2.add(data.type.get(j));			values2.add(data.values.get(j));		    }		}		// initialize the vertex to the default values for its type		//		//button.initializeConfig(labels2, values2, types2,		//	      image_association, data);				// add subparam button to the vector		//		subVertex.subparam.add(buttonParam);				enteredData.add(buttonParam);		blockType.add("Vertex");		max_subparam++;	    }	    	    // add another pop up frame to set parameters for the class	    //	    else if (types.get(i).equals("class")) {		String image_name = null;		String image_association= null;						// tells the program which transform it is looking to match		//		image_association = (String)values.get(i);				// scans through the association until it finds the		// smallIcon key		//		for(int j=data.association.indexOf(image_association); 		    j <= data.association.lastIndexOf(image_association);		    j++) {		    if(j != -1) {						if(((String)(data.name.get(j))).equals("iconSmall")) {			    				// sets the image_name to the value 				// held in small icon				//			    image_name = (String)data.values.get(j);			}		    }		}		// check to see if the file exists. If it does not exist,		// use a default image.		//		if(image_name != null){		    File image_file = new File(image_name);		    if (image_file.exists() == false) {			image_name = DEFAULT_PATH + "default.gif";		    }		}		else {		    image_name = DEFAULT_PATH + "default.gif";		}				if(image_association.equals("FourierTransform")) {			image_name = GUI_PATH +"/lib/images/isip_transform_builder/icons/fourier_01.gif";		}		// create the icons for the config panel		// 		ImageIcon icon = new ImageIcon(image_name);		    		// create the button for the config panel		//		Vertex button = new Vertex(icon, ALGORITHM);						if(subVertex.max_subclass == subVertex.subclass.size()) {		    // 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 labels2 = new Vector(5,5);		    Vector types2 = new Vector(5,5);		    Vector values2 = new Vector(5,5);		    		    for(int j=data.association.indexOf(image_association); 			j <= data.association.lastIndexOf(image_association);			j++) {			if(j != -1) {			    labels2.add(data.name.get(j));			    types2.add(data.type.get(j));			    values2.add(data.values.get(j));			}		    }		    // initialize the vertex to the default values for its type		    //		    button.initializeConfig(labels2, values2, types2,					    image_association, data);		    // attach an action listener to the button		    //		    button.setActionCommand("class");		    button.addActionListener(this);		    // add subclass button to the vector		    //		    subVertex.subclass.add(button);		}			else {		    // bring back the saved button if all class button's have 		    // been previously saved		    //		    button = (Vertex)subVertex.subclass.get(subVertex.subclass.size()-1);		    //  if (button.actionAdded == false){		    button.setActionCommand("class");		    button.addActionListener(this);		    button.actionAdded = true;		    // }		    subclassIndex++;		}		// add the vertex to the button panel		//		constrain(config_panel,button, gridbag, 1, i,			  1, 1, 1, 0, GridBagConstraints.EAST);		enteredData.add(button);		blockType.add("Vertex");	    }	    // take care of anything of type text	    //	    else if (types.get(i).equals("text")) {		JTextField TextField = 		    new JTextField(((String)subVertex.values.get(i)), 8);		constrain(config_panel,TextField, gridbag, 1, i,			  1, 1, 1, 0, GridBagConstraints.EAST);		enteredData.add(TextField);		blockType.add("text");		TextField.setFont(newFont);		TextField.setForeground(Color.black);	    }	    // take care of type vector	    //	    else if (types.get(i).equals("vector")) {		JTextField TextField = 		    new JTextField(((String)subVertex.values.get(i)), 8);		TextField.setFont(newFont);		TextField.setForeground(Color.black);		constrain(config_panel,TextField, gridbag, 1, i,			  1, 1, 1, 0, GridBagConstraints.EAST);		enteredData.add(TextField);		blockType.add("vector");	    }	    // take care of anything of type double	    //	    else if (types.get(i).equals("double")) {		JTextField TextField = 		    new JTextField(((String)subVertex.values.get(i)), 8);		constrain(config_panel,TextField, gridbag, 1, i,			  1, 1, 1, 0, GridBagConstraints.EAST);		enteredData.add(TextField);		blockType.add("double");		TextField.setFont(newFont);		TextField.setForeground(Color.black);	    }	    	    // creation of input box for unsigned int	    //	    else if (types.get(i).equals("unsigned-integer")) {		JTextField TextField = 		    new JTextField(((String)subVertex.values.get(i)), 8);		constrain(config_panel,TextField, gridbag, 1, i,			  1, 1, 1, 0, GridBagConstraints.EAST);		enteredData.add(TextField);		blockType.add("unsigned-integer");		TextField.setFont(newFont);		TextField.setForeground(Color.black);	    }	    // creation of input box for image	    //	    else if (types.get(i).equals("image")) {		// do nothing in this case	    }	    // creation of input box for float	    //	    else if (types.get(i).equals("float")) {		JTextField TextField = 		    new JTextField(((String)subVertex.values.get(i)), 8);		constrain(config_panel,TextField, gridbag, 1, i,			  1, 1, 1, 0, GridBagConstraints.EAST);		enteredData.add(TextField);		blockType.add("float");		TextField.setFont(newFont);		TextField.setForeground(Color.black);	    } 	    // creation of input box for int	    //	    else if (types.get(i).equals("integer")) {		JTextField TextField = 		    new JTextField(((String)subVertex.values.get(i)), 8);		constrain(config_panel,TextField, gridbag, 1, i,			  1, 1, 1, 0, GridBagConstraints.EAST);		enteredData.add(TextField);		blockType.add("integer");		TextField.setFont(newFont);		TextField.setForeground(Color.black);	    }	    // !!! unexpected data type	    //	    else {		System.err.println();		System.err.println("---------------------------------------");		System.err.println("Error - Unexpected data type in file resource.txt: " + types.get(i));		System.err.println("---------------------------------------");		System.exit(0);	    }	    // check to see if the width of a JComboBox or JTextField	    // is wider than maxwidth and if it is, give that value to 	    // maxwidth	    //    	    String type = (String)blockType.get(i);	    if((!type.equals("Vertex") &&		(!type.equals("image")) &&		(!type.equals("boolean")))) {		Dimension size = (Dimension)((JComponent)enteredData.					     get(i)).getPreferredSize();		int width = (int)size.getWidth();		int height = (int)size.getHeight();		if( width > maxwidth) {		    maxwidth = width;		    maxheight = height;		}	    }	}	for(int i = 0; i < blockType.size(); i++) {	    String type = (String)blockType.get(i);	    if((!type.equals("Vertex") &&		(!type.equals("image")) &&		(!type.equals("boolean")))) {		Dimension size = new Dimension(maxwidth, maxheight);		((JComponent)enteredData.get(i)).		    setPreferredSize(size);		((JComponent)enteredData.get(i)).		    setMinimumSize(size);	    }	}		// create a button panel to place all buttons on so proper spacing 	// can be acheived			JPanel button_panel = new JPanel();	if( max_subparam > 0) {	    // create a button panel to place all buttons on so proper spacing 	    // can be acheived	    //		    button_panel.setLayout(new GridLayout(1,4, 1, 1));	    	    // create the configure button and add the appropriate action handler	    //	    config_button = new JButton("Configure");  	    button_panel.add(config_button);	    config_button.addActionListener(this);	    config_button.setActionCommand("param");	    config_button.setFont(newFont);		    // create the return button and add the appropriate action handler	    //	    save_button = new JButton("Save");	    button_panel.add(save_button);	    save_button.addActionListener(this);	    save_button.setActionCommand("update");	    save_button.setFont(newFont);		    // create the cancel button and add to subpanel	    //	    cancel_button = new JButton("Cancel");	    button_panel.add(cancel_button);	    cancel_button.addActionListener(this);	    cancel_button.setActionCommand("cancel");	    cancel_button.setFont(newFont);	    // create the help button and add to subpanel	    //	    help_button = new JButton("Help");	    button_panel.add(help_button);	    help_button.addActionListener(this);	    help_button.setActionCommand("help");	    help_button.setFont(newFont);	}	else {	    // create a button panel to place all buttons on so proper spacing 	    // can be acheived	    //		    button_panel.setLayout(new GridLayout(1,4, 1, 1));	    	    // create the return button and add the appropriate action handler	    //	    save_button = new JButton("Save");	    button_panel.add(save_button);	    save_button.addActionListener(this);	    save_button.setActionCommand("update");	    save_button.setFont(newFont);			    // create the cancel button and add to subpanel	    //	    cancel_button = new JButton("Cancel");	    button_panel.add(cancel_button);	    cancel_button.addActionListener(this);	    cancel_button.setActionCommand("cancel");	    cancel_button.setFont(newFont);			    // create the default button and add to subpanel	    //	    default_button = new JButton("  Default ");	    button_panel.add(default_button);	    default_button.addActionListener(this);	    default_button.setActionCommand("default");	    default_button.setFont(newFont);			    // create the help button and add to subpanel	    //	    help_button = new JButton("Help");	    button_panel.add(help_button);	    help_button.addActionListener(this);	    help_button.setActionCommand("help");	    help_button.setFont(newFont);			}	constrain(config_panel, button_panel, gridbag, 0, labels.size()+1,		  GridBagConstraints.REMAINDER,1,1,1,		  GridBagConstraints.SOUTH);    }    // method: constrain    //    // arguments:    //    JPanel container      :  panel being added to    //    Component button      :  what is being added to the panel    //    GridBagLayout gridbag :  gridbag layout for config panel    //    int gridx             :  the x grid position of the constraint    //    int gridy             :  the y grid position of the constraint    //    int gridwidth         :  the number of gridspaces wide to constrain    //    int gridheight        :  the number of gridspaces tall to constrain    //    int weightx           :  the horizontal weighting of the constraint    //    int weighty           :  the vertical weighting of the constraint    //    int anchor            :  which side of the constraint to anchor to    //    // return  :  none    //    //  places all the proper input items onto the config panel     //  for configuring any transform    //     public void constrain(JPanel container,Component button, 			  GridBagLayout gridbag, int gridx,int gridy, 			  int gridwidth, int gridheight,			  int weightx, int weighty, int anchor){	GridBagConstraints c = new GridBagConstraints();	c.gridx = gridx;	c.gridy = gridy;	c.gridwidth = gridwidth;	c.gridheight = gridheight;	c.weightx = weightx;	c.weighty = weighty;	c.anchor = anchor;	gridbag.setConstraints(button, c);	container.add(button);    }     // method: validation    //    // arguments:  none    //    // return:  boolean     //    // checks to make sure that all configuration data has been input properly    // and if it has, make the changes to the referrign vertex     //     public boolean validation() {    		subparamInfo =  new Vector(5,5);		for(int i=0; i < labelReference.size(); i++) {	    	    if(blockType.get(i).equals("Vertex")) {		break;	    }	    	    if(blockType.get(i).equals("enum")) {				// set the vertex's value to match the newly selected one		//		subparamInfo.add((String)((JComboBox)enteredData.get(i)).				     getSelectedItem());	    }	}		for(int i=0; i < labelReference.size(); i++) {	    	    // code to use if the data is a text field	    //

⌨️ 快捷键说明

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