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

📄 digraph.java

📁 这是一个从音频信号里提取特征参量的程序
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		    if(!vertex.values.get(i).equals("")) {			String tmp = null;			tmp = ""+ vertex.names.get(i);			if(tmp.equals("signal_duration") && !vertex.association.equals("AudioFrontEnd")) {			    // do nothing			}			else if(tmp.equals("frame_duration") && !vertex.association.equals("AudioFrontEnd")) {			    // do nothing			}			else {			    file.println(" " + vertex.names.get(i) 					 + " = " + vertex.values.get(i) + ";");			}		    }		}	    } // end for(loop)	}     }    // method: writeGeneratorData    //    // arguments:    //    PrintWriter file: (input) file descriptor    //    Vertex vertex: (input) algorithm vertex    // return: none    //    // write the data associated with each algorithm in the algorithm vertex    //    public void writeGeneratorData(PrintWriter file, Vertex vertex) {	// declare local variables	//	Point position = null;	// store the location of the connector 	//	position = (Point)vertex.getLocation();	// write the location of the output to file	//	if (position != null) {	    file.print(LOCATION_KEY + " " + position.x + " " + position.y);	    file.println();	}	// write the algorithm name to the file	//	file.println(" name = \"" + vertex.association + "\";"); 				// write the algorithm type to the file	//	if ((vertex.getType() == INPUT_STR) || 	    (vertex.getType() == OUTPUT_STR)) {	    file.println(" type = \"" + vertex.getType() + "\";"); 	}	// write all other data associated with algorithm	//	for(int i=0; i < vertex.names.size(); i++) {	    String type = (String)(vertex.types.get(i));	    String name = (String)(vertex.names.get(i));	    // write nothing if the type is image	    //	    if (type.equals(ALGORITHM_IMAGE)) {}	    // write nothing if the variable name is buffer_mode	    //	    else if (name.equals(ALGORITHM_BUFF_MODE)) {}	    // add quotes to the value for output if the value is text	    //	    else if (type.equals(ALGORITHM_TEXT)) {		// skip it if there is no text		//		String text = (String)vertex.values.get(i);		text = text.trim();		if(!text.equals("")) {		    file.println(" " + vertex.names.get(i) 				 + " = \"" + vertex.values.get(i) + "\";");		}	    }	    // output the subclass if the value is a class	    //	    else if(type.equals(ALGORITHM_CLASS)) {						// get a copy of the algorithm used to configure the subclass		//		int subclass_index = 0;		for(int j=0; j < vertex.subclass.size(); j++) {		    Vertex temp = (Vertex)vertex.subclass.get(j);		    if (temp.association.equals((String)vertex.values.get(i)))			subclass_index = j;		}		Vertex subclass_copy = 		    (Vertex)vertex.subclass.get(subclass_index);		// output the class name and open the brackets for outputting		// the values of the subclass		//		file.println(" " + vertex.names.get(i) + " = {");		// output all of the values of the subclass		//		for(int j=0; j < subclass_copy.values.size(); j++){		    String subtype = (String)(subclass_copy.types.get(j));		    		    if (subtype.equals(ALGORITHM_IMAGE)) { 					    }		    else if (subtype.equals(ALGORITHM_STRING)) {			if(!subclass_copy.values.get(i).equals("")) {			    file.println("   " + subclass_copy.names.get(j) 					 + " = \"" + subclass_copy.					 values.get(j) + "\";");			}		    }		    else {			file.println(" " + subclass_copy.names.get(j) 				     + " = " + subclass_copy.values.get(j) 				     + ";");		    }		}		file.println(ALGORITHM_BREAK_00);	    }		    // output the sub parameters if the value is a parameter	    //	    else if(type.equals(ALGORITHM_PARAM)) {		writeSubParamData(file, vertex, i);	    }	    else {		file.println(" " + vertex.names.get(i) 			     + " = " + vertex.values.get(i) + ";");	    }	}	    }    // method: writeSubParamData    //    // arguments:    //    PrintWriter file: (input) file descriptor    //    Vertex vertex: (input) algorithm vertex    // return: none    //    // write the data associated with each algorithm in the algorithm vertex    //    public void writeSubParamData(PrintWriter file, Vertex vertex, int index) {	// get a copy of the algorithm used to configure the subclass	//	int subparam_index = 0;		for(int j=0; j < vertex.subparam.size(); j++) {	    Vertex temp = (Vertex)vertex.subparam.get(j);	    if (temp.association.equals((String)vertex.values.get(index))) {		subparam_index = j;		//break;	    }	}		Vertex subparam_copy = 	    (Vertex)vertex.subparam.get(subparam_index);	// output all of the values of the subparam	//	for(int j=0; j < subparam_copy.values.size(); j++){	    	    String subtype = (String)(subparam_copy.types.get(j));	    	    if (subtype.equals(ALGORITHM_IMAGE)) { 			    }	    else if (subtype.equals(ALGORITHM_STRING)) {		if(!subparam_copy.values.get(index).equals("")) {		    file.println("   " + subparam_copy.names.get(j) 				 + " = \"" + subparam_copy.				 values.get(j) + "\";");		}	    }  	    else if(subtype.equals(ALGORITHM_CLASS)) {		writeSubClassData(file, subparam_copy, j);      		file.println(ALGORITHM_BREAK_00);	    }	    else if(subtype.equals(ALGORITHM_PARAM)) {		writeSubParamData(file, subparam_copy, j);	    }	    else {						file.println(" " + subparam_copy.names.get(j) 			     + " = " + subparam_copy.values.get(j) 			     + ";");			    }	}    }    // method: writeSubClassData    //    // arguments:    //    PrintWriter file: (input) file descriptor    //    Vertex vertex: (input) algorithm vertex    // return: none    //    // write the data associated with each algorithm in the algorithm vertex    //    public void writeSubClassData(PrintWriter file, Vertex vertex, int i) {		// get a copy of the algorithm used to configure the subclass		//		int subclass_index = 0;		for(int j=0; j < vertex.subclass.size(); j++) {		    Vertex temp = (Vertex)vertex.subclass.get(j);		    if (temp.association.equals((String)vertex.values.get(i)))			subclass_index = j;		}		Vertex subclass_copy = 		    (Vertex)vertex.subclass.get(subclass_index);		// output the class name and open the brackets for outputting		// the values of the subclass		//		file.println(" " + vertex.names.get(i) + " = {");		// output all of the values of the subclass		//		for(int j=0; j < subclass_copy.values.size(); j++){		    String subtype = (String)(subclass_copy.types.get(j));		    		    if (subtype.equals(ALGORITHM_IMAGE)) { 					    }		    else if (subtype.equals(ALGORITHM_STRING)) {			if(!subclass_copy.values.get(i).equals("")) {			    file.println("   " + subclass_copy.names.get(j) 					 + " = \"" + subclass_copy.					 values.get(j) + "\";");			}		    }		    else if(subtype.equals(ALGORITHM_CLASS)) {			writeSubClassData(file, subclass_copy, j);      			file.println(ALGORITHM_BREAK_00);		    }		    else if(subtype.equals(ALGORITHM_PARAM)) {			writeSubParamData(file, subclass_copy, j);		    }		    else {			file.println("   " + subclass_copy.names.get(j) 				     + " = " + subclass_copy.values.get(j) 				     + ";");		    }		}}    // method: read    //    // arguments: none    // return   : none    //    // read the sof file    //    public void read() {	// declare local variables	//	int xloc = 0;	int yloc = 0;		//Vector to store information for determing subclass	//	Vector paramInfo =  new Vector(5,5);		String name = null;	String tag = null;	String line = null;	String tmpName = null;	Vertex vertex = null;	FileReader fin = null;	BufferedReader file = null;	Point location = null;	StringTokenizer tokens = null;	String type = null;	boolean dataBufferFlag = false;	boolean algorithmFlag = false;	boolean containerFlag = false;	// clear out all existing memory	//	clearAllMemory();	// open the selected file for writing	//	try {	    // initialize the file output stream	    //	    tag = new String();	    fin = new FileReader(paramFile);	    file = new BufferedReader(fin);	    	    // read the lines form the file	    //	    while ((line = file.readLine()) != null) {		// remove white spaces at the ends of the string		//		line = line.trim();		line_index++;		// check for the system configuration properties		//		if (line.equals(HEADER_TAG_03)) {		    readSystem(file);		}		// check for algorithm objects		//		if (line.regionMatches(false, 0, ALGO_TAG, 0, 11)) {		    // reset the flags		    //		    algorithmFlag = false;		    containerFlag = false;		    dataBufferFlag = false;		    // parse the objects unique sof tag		    //		    tokens = new StringTokenizer(line);		    tokens.nextToken();		    tokens.nextToken();		    tag = tokens.nextToken();		    // mark the current position in the buffer stream		    //		    file.mark(100);		    // read the rest of the data for the object		    //		    while ((line = file.readLine()) != null) {			// reset the variables			//			name = null;			type = null;			boolean isCoeff = false;						// remove leading and trailing white space letters			//			line = line.trim();			line_index++;			// break the loop when we have read the object 			//			if (line.regionMatches(false, 0, ALGO_TAG, 0, 11) ||			    line.regionMatches(false, 0, ARCS_TAG, 0, 6) ||			    line.regionMatches(false, 0, DIGRAPH_TAG, 0,15) ||			    line.regionMatches(false, 0, VERTICES_TAG,0,10)) {			    // reset the buffer to the last marked position			    //			    file.reset();			    break;			}			// parse the location of the data object			//			if (line.regionMatches(false, 0, LOCATION_KEY, 0, 2)) {			    // parse the X and Y coordinates			    //			    tokens = new StringTokenizer(line);			    tokens.nextToken();			    if (tokens.hasMoreTokens()) {				String xstr = (tokens.nextToken()).trim();				xloc = Integer.valueOf(xstr).intValue();			    }			    if (tokens.hasMoreTokens()) {				String ystr = (tokens.nextToken()).trim();				yloc = Integer.valueOf(ystr).intValue();			    }			    // set the location of the object			    //			    location = new Point(xloc, yloc);			}			// parse the name of the data object			//			if (line.regionMatches(false,0, NAME_KEY, 0,6)) {			    // tokenize the line			    //			    tokens = new StringTokenizer(line, "=");			    tokens.nextToken();			    			    // get the tag value of the object			    //			    int tagValue = Integer.valueOf(tag).intValue();			    // get the name of the object			    //			    name = null;			 			    if (tokens.hasMoreTokens()) {				name = tokens.nextToken(); 				name = name.replace(';', ' ');				name = name.trim();				if (name.equals("\"CoefficientLabel\"")) {				    isCoeff =true;				    				}				name = name.replace('\"',' ');				name = name.trim();			    }			    // determine if the name is valid			    //			    if (name == null) { break; }			    			    // determine if we are reading a data buffer object			    //			    if (name.equals(BUFFER_TAG) && !isCoeff &&				(tagValue < CONT_OFFSET)) {				dataBufferFlag = true;				vertex = initializeDataBuffer();				continue;			    }			    			    // determine if we are reading a container object			    // 			    else if (name.equals(CONTAINER_TAG) &&				     (tagValue < CONT_OFFSET)) {				containerFlag = true;				vertex = initializeContainer(name);				continue;			    }			    // we must be reading a algorithm object			    //			    else {				algorithmFlag = true;				paramInfo = new Vector(5,5);				// read the next line of the file				//				try {				    line = file.readLine();				    line_index++;				}				catch(IOException e) {				    System.err.println();				    System.err.println("---------------------------------------");				    System.err.println("Caught IOException: " + e.getMessage());				    System.err.println("Line Number: " + line_index);				    System.err.println("File Line: " + line);				    System.err.println("---------------------------------------");				    System.exit(0);				}				catch(ArrayIndexOutOfBoundsException e) {				    System.err.println();				    System.err.println("---------------------------------------");				    System.err.println("Caught ArrayIndexOutOfBoundsException: 1" + e.getMessage());				    System.err.println("Line Number: " + line_index);				    System.err.println("File Line: " + line);				    System.err.println("---------------------------------------");				    System.exit(0);				}				catch(NullPointerException e) {				    System.err.println();				    System.err.println("---------------------------------------");				    System.err.println("Caught NullPointerException: " + e.getMessage());				    System.err.println("Line Number: " + line_index);				    System.err.println("File Line: " + line);				    System.err.println("---------------------------------------");				    System.exit(0);				}					catch(Exception e) {				    System.err.println();				    System.err.println("---------------------------------------");				    System.err.println("Caught Exception: " + e.getMessage());				    System.err.println("Line Number: " + line_index);				    System.err.println("File Line: " + line);				    System.err.println("---------------------------------------");				    System.exit(0);				}	    				// tokenize the line				//				line = line.trim();				tokens = new StringTokenizer(line, "=");				String typestr = "" + tokens.nextToken();				typestr = typestr.trim();				String typeAlgo = null;				// get the type of the object				//				if (tokens.hasMoreTokens()) {				    typeAlgo = "" + tokens.nextToken();				    typeAlgo = typeAlgo.replace('\"',' ');				    typeAlgo = typeAlgo.replace(';', ' ');   				    typeAlgo = typeAlgo.trim();				}				if(typestr.equals("type")) 				   vertex = initializeAlgorithm(name, file, typeAlgo);				else				    vertex = initializeAlgorithm(name, file, typeAlgo);						int updateValue = vertex.names.indexOf(typestr);				if(updateValue>=0) {				    String type1 =""+vertex.types.get(updateValue);				    if(type1.equals("enum"))

⌨️ 快捷键说明

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