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

📄 sentencesgen.java

📁 这是一个从音频信号里提取特征参量的程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// 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 sentencesGen extends JFrame implements ActionListener, 						  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;    // sentences generated    //    public String sentences = "";    JTextArea textArea = new JTextArea();    // Random object    //    public Random random = null;    // result file to be written to    //    public File resultFile = null;    // ---------------------------------------------------    //    // declare class constructors    //    // ---------------------------------------------------    // method: ConfigBox    //    // arguments: none    // returns  : none    //    public sentencesGen(DiGraph parent, WorkArea area) {	      		// invoke the parent default constructor	//	//super("Configuration Box");	//super(parent,"Configuration Box", true);	digraph = parent;	//initialize Random object	//	random = new Random();	//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 = 400;	int width = 500;	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(" Generated Sentences");	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 a text area.       //        //JTextArea textArea = new JTextArea();        //textArea.setFont(new Font("Times", Font.PLAIN, 12));        textArea.setLineWrap(true);        textArea.setWrapStyleWord(true);        JScrollPane areaScrollPane = new JScrollPane(textArea);        areaScrollPane.setVerticalScrollBarPolicy(                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);        areaScrollPane.setPreferredSize(new Dimension(450, 300));        areaScrollPane.setBorder(            BorderFactory.createCompoundBorder(                BorderFactory.createCompoundBorder(                                BorderFactory.createTitledBorder(""),                                BorderFactory.createEmptyBorder(1,1,1,1)),                areaScrollPane.getBorder()));		constrain(config_panel,areaScrollPane, gridbag, 0, 0,			  1, 1, 1, 0, GridBagConstraints.NORTH);		// 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("  Run  ");	button_panel.add(save_button);	save_button.addActionListener(this);	save_button.setActionCommand("run");	save_button.setFont(newFont);			// create the default button and add to subpanel	//	default_button = new JButton("  Save ");	button_panel.add(default_button);	default_button.addActionListener(this);	default_button.setActionCommand("save");	default_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);		// place the button panel onto the config panel	//	constrain(config_panel, button_panel, gridbag, 0, 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 

⌨️ 快捷键说明

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