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

📄 configboxarc.java

📁 这是一个从音频信号里提取特征参量的程序
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
// file: ConfigBox.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 ConfigBoxArc extends JDialog implements ActionListener, 						 ItemListener, Constants {    // ---------------------------------------------------    //    // declare class member data    //    // ---------------------------------------------------    // 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;        // 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 of subclass vertices    //    Vector config_vertices = null;    // Type of configuration box    //    int cfgType = 0;    // arc index    //    int index = 0;        // input Block Exist    //    boolean inputFlag = false;    // Max number of subclasses    //    int max_subclass = 0;    // vertex that is being configured    //    Vertex cfgVertexFocus = null;    // WorkArea that allows the return button to do a proper repaint    //    WorkArea workArea = null;    // jlabels used to lable each of the items in the config box    //    public Vector labels = null;    // vectors user in a connector box configuration    //    Vector connBox = null;    Vector connLabels = null;    Vector connection_order = null;    // DiGraph    //    DiGraph digraph;    // ---------------------------------------------------    //    // declare class constructors    //    // ---------------------------------------------------    // method: ConfigBox    //    // arguments: none    // returns  : none    //    public ConfigBoxArc(DiGraph parent, Data d, Vertex b, WorkArea area, int type, int arcnum) {	      		// invoke the parent default constructor	//	//super("Configuration Box");	super(parent,"Configuration Box", true);	digraph = parent;		index = arcnum;	Point xy = parent.getLocation();	setLocation((int)xy.getX() + 100,(int)xy.getY() + 200);	// Set the configuration type	//	cfgType = type;	// Make the passed Data object available globally	//	data = d;		// Initialize the enteredData and labelReference vectors for use	//	enteredData = new Vector(5,5);	labelReference = new Vector(5,5);	blockType = new Vector(5,5);		// This is the vertex that is being configured	//	cfgVertexFocus = b;	//Create this new panel with gridbag layout	//	config_panel =  new JPanel();	addConfig();	// make reference available globally for work area	//	workArea = area;		//Set the sizes of the scroll pane and configuration panel	//	int height = (labelReference.size()+2) * 25  + 70;	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));	//  create the appropriate string for the border	//	String border_title = null;	if(cfgType == 0)	    border_title = 		new String(" Arc Parameters");	else if (cfgType == 1){	    border_title = 		new String("Connector Configuration:");	}	// create the border and set the proper font	//	BorderUIResource.TitledBorderUIResource border =	    new BorderUIResource.TitledBorderUIResource(border_title);	border.setTitleFont(newFont);	border.setTitleColor(Color.black);	// make the config panel use the proper border	//	config_panel.setBorder(border);	//Add the scroll pane to the frame	//	this.getContentPane().add(config_panel, BorderLayout.NORTH);    }        // ---------------------------------------------------    //    // declare class methods    //    // ---------------------------------------------------    // method:  addConfig()    //    // arguments:  none    // return: none    //    //  dynamically adds and constrains all objects on the JPanel    //    public void addConfig() {	//  make this config panel use grid bag layout	//	GridBagLayout gridbag = new GridBagLayout();	config_panel.setLayout(gridbag);	// create from vertex labels to be included in the arc	//	JLabel fromLabel = new JLabel("from: ");	fromLabel.setFont(newFont);	fromLabel.setForeground(Color.black);	constrain(config_panel,fromLabel, gridbag, 0, 0,			  1, 1, 1, 0, GridBagConstraints.WEST);	Vertex fromv = null;	fromv = (Vertex)digraph.graphArc.from.get(index);	String fromname = null;	JTextField fvertexField = new JTextField(fromv.getVertexName(), 8);	fvertexField.setEditable(false);	fvertexField.setFont(newFont);	fvertexField.setForeground(Color.black);	constrain(config_panel,fvertexField, gridbag, 3, 0,		  1, 1, 1, 0, GridBagConstraints.EAST);	// create to vertex labels to be included in the arc	//	JLabel toLabel = new JLabel("to: ");	toLabel.setFont(newFont);	toLabel.setForeground(Color.black);	constrain(config_panel,toLabel, gridbag, 0, 1,			  1, 1, 1, 0, GridBagConstraints.WEST);	Vertex tov = null;	tov = (Vertex)digraph.graphArc.to.get(index);	String toname = null;	JTextField tvertexField = new JTextField(tov.getVertexName(), 8);	tvertexField.setEditable(false);	tvertexField.setFont(newFont);	tvertexField.setForeground(Color.black);	constrain(config_panel,tvertexField, gridbag, 3, 1,		  1, 1, 1, 0, GridBagConstraints.EAST);	// add the appropriate input values depending on whether the 	// vertex being configured in a transform or a connector	//	if(cfgType == 0) {	    //addTransformConfig(gridbag);	    addArcConfig(gridbag);	}	else if (cfgType == 1){	    addConnectorConfig(gridbag);	}	// create a button panel to place all buttons on so proper spacing 	// can be acheived	//		JPanel button_panel = new JPanel();	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);		// place the button panel onto the config panel	//	constrain(config_panel, button_panel, gridbag, 0, labels.size()+1,		  GridBagConstraints.REMAINDER,1,1,1,		  GridBagConstraints.SOUTH);    }       // method: addConnectorConfig    //    // arguments:    //    GridBagLayout gridbag:  gridbag layout for config panel    //    // return   : none    //    //  places all the proper input items onto the config panel     //  for configuring a connector box    //    public void addConnectorConfig(GridBagLayout gridbag)  {		// get the number of parents this connector vertex has	//	int size = cfgVertexFocus.getInDegree();		// create a vector containing the names of all the connector's 	// parents	//	labels = new Vector(5,5);	// populate the names vector	//	for(int i=0; i < size; i++) {	    Vertex vertex_parent = (Vertex)cfgVertexFocus.vertexParents.get(i);	    String vertex_name = vertex_parent.getVertexName();	    labels.add((i + 1) + ":" + vertex_name);	}	// create a vector of JLabels and JComboBox for use in swapping	//	connLabels = new Vector(size,1);	connBox = new Vector(size,1);	connection_order = new Vector(size,1);	// populate the vector's for display 	//	for(int i=0; i < labels.size(); i++) {	    connLabels.add(new JLabel("Position " + (i+1)));	    connBox.add(new JComboBox(labels));	    ((JComboBox)connBox.get(i)).setSelectedIndex(i);	    ((JComboBox)connBox.get(i)).addItemListener(this);	}		for(int i=0; i < labels.size(); i++) {	  	    // place the label onto the screen	    //	    ((JLabel)connLabels.get(i)).setForeground(Color.black);	    constrain(config_panel,(JLabel)(connLabels.get(i)), gridbag, 0, i,		      1, 1, 1, 0, GridBagConstraints.WEST);	    ((JLabel)connLabels.get(i)).setFont(newFont);	    labelReference.add((JLabel)connLabels.get(i));	    // place the JComboBox on the screen	    //	    ((JComboBox)connBox.get(i)).setForeground(Color.black);	    constrain(config_panel,((JComboBox)connBox.get(i)), gridbag, 1, i,		      1, 1, 1, 0, GridBagConstraints.EAST);	    ((JComboBox)connBox.get(i)).setFont(newFont);	    // populate a vector to tell me connections made	    //	    Integer integer = new Integer(i);	    connection_order.add(integer);	}    }    // method: addArcConfig    //    // arguments:    //    GridBagLayout gridbag:  gridbag layout for config panel    //    // return   : none    //    //  places all the proper input items onto the config panel     //  for configuring any transform    //    public void addArcConfig(GridBagLayout gridbag)  {	labels = new Vector(5,5);		// create labels to be included in the frame	//	JLabel weightLabel = new JLabel("Weight: ");	weightLabel.setFont(newFont);	weightLabel.setForeground(Color.black);	labelReference.add(weightLabel);		constrain(config_panel,weightLabel, gridbag, 0, 2,			  1, 1, 1, 0, GridBagConstraints.WEST);	labels.add("Weight");	String tmpw = null;	tmpw = (String)digraph.graphArc.weights.get(index);	JTextField weightField = null; 	if(tmpw != null) {	    	weightField = new JTextField(tmpw, 8);	}	else {	    weightField = new JTextField("1.0", 8);	}	weightField.setFont(newFont);	weightField.setForeground(Color.black);	constrain(config_panel,weightField, gridbag, 3, 2,		  1, 1, 1, 0, GridBagConstraints.EAST);	enteredData.add(weightField);	blockType.add("float");		JLabel epiLabel = new JLabel("Epsilon: ");	labels.add("Epsilon");	epiLabel.setFont(newFont);	epiLabel.setForeground(Color.black);	labelReference.add(epiLabel);	constrain(config_panel,epiLabel, gridbag, 0, 3,		  1, 1, 1, 0, GridBagConstraints.WEST);			// create the check box	//	boolean value2 = false;		String tmpe = null;	tmpe = (String)digraph.graphArc.epsilon.get(index);	JCheckBox checkBox = null;	// instantiate and place chack box on config panel	//	if(tmpe == "true") {	    checkBox = new JCheckBox("", true);	}	else {	    checkBox = new JCheckBox("", value2);	}	constrain(config_panel, checkBox, gridbag, 3, 3,		  1,1,1,0,GridBagConstraints.EAST);	enteredData.add(checkBox);	blockType.add("boolean");    }    // method: addTransformConfig    //    // arguments:    //    GridBagLayout gridbag:  gridbag layout for config panel    //    // return   : none    //    //  places all the proper input items onto the config panel     //  for configuring any transform    //    public void addTransformConfig(GridBagLayout gridbag)  {

⌨️ 快捷键说明

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