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

📄 digraph.java

📁 这是一个从音频信号里提取特征参量的程序
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		    line = ALGO_TAG + " " + containerTag + " @";		    file.println(line);		    // write the containers location		    //		    Point point = vertex.getLocation();		    file.println(LOCATION_KEY + " " + point.x + " " + point.y);		    // write the name tag		    //		    line = " name = " + CONTAINER_TAG + ";";		    file.println(line);		    		    // write the variable tag		    //		    line = " variable = " + vertex.getVertexName() + ";";		    file.println(line);		    		    // write out the graph tag		    //		    file.println(" graph_tag = " 				 + containerTag * CONT_OFFSET + ";");		    file.println();		    		    // retrieve the container		    //		    Vector container = vertex.vertexContainer;		    // write the algorithm data contained		    //		    if (container != null) {			for (int k=0; k < container.size(); k++) {			    // get the current vertex			    //			    vertex = (Vertex)container.elementAt(k);			    // write the start and term nodes			    //			    if (vertex.association != null) {				// write the algorithm tag				//				int algorithmTag = (containerTag * CONT_OFFSET) + container.indexOf(vertex);				line = ALGO_TAG + " " + algorithmTag + " @";				file.println(line);				// write the algorithm data				//				writeAlgorithmData(file, vertex);				file.println();			    }			}			// write the DiGraph header			//			file.println(DIGRAPH_TAG + containerTag * CONT_OFFSET + " @");			// indicated that we have a weighted arc			//			file.println(WEIGHTED_KEY);			// write the vertex information			//			writeDiGraphVertices(file, container, true, containerTag);						// write the arcs information			//			writeDiGraphArcs(file, container, true, containerTag);			file.println();		    }		}	    }	    // write the algorithm data if the vertex is a algorithm	    //	    for (int i=0; i < vertices.size(); i++) {		// get the current vertex		//		Vertex vertex = (Vertex)vertices.elementAt(i);		if (vertex.getVertexType() == ALGORITHM) {		    // write the algorithm tag		    //		    line = ALGO_TAG + " " + vertices.indexOf(vertex) + " @";		    file.println(line);		    		    // write the algorithm data		    //		    writeAlgorithmData(file, vertex);		    file.println();		}			    }	    // write the gennerator data if the vertex is a generator	    //	    for (int i=0; i < vertices.size(); i++) {		// get the current vertex		//		Vertex vertex = (Vertex)vertices.elementAt(i);		if (vertex.getVertexType() == GENERATOR_DATA) {		    // write the algorithm tag		    //		    //  line = GENERATOR_TAG + " " + vertices.indexOf(vertex) + " @";		    line = ALGO_TAG + " " + vertices.indexOf(vertex) + " @";		    file.println(line);		    		    // write the algorithm data		    //		    writeGeneratorData(file, vertex);		    file.println();		}			    }	    // write the DiGraph header	    //	    file.println(DIGRAPH_TAG + "0 @");	    // indicated that we have a weighted arc	    //	    file.println(WEIGHTED_KEY);	    // write the vertex information	    //	    writeDiGraphVertices(file, vertices, false, -1);	    // write the arcs information	    //	    writeDiGraphArcs(file, vertices, false, -1);	    // close the file descriptor	    //	    file.close();	}	// catch and deal with any file I/O exceptions	//	catch(IOException e1) {}    }    // method: writeDiGraphVertices    //    // arguments:    //    BufferedReader file: (input) file descriptor    //    Vector vec: (input) vector of input vertices    //    Boolean flag: indicating a container vertex    //    Boolean offset: container sof tag     // return: none    //    // write the vertices that correspond to the digraph    //    public void writeDiGraphVertices(PrintWriter file, Vector vec, 				     boolean flag, int offset) {	// declare local variables	//	String line = null;	// write the vertex tag	//	file.println(VERTICES_TAG);		// loop over all vertices and write the vertex tags	//	for (int i=0; i < vec.size(); i++) {	    int id = i+(offset * CONT_OFFSET);	    if (i == vec.size() - 1) {		if (flag) {		    line = "        {" + id + ", {" + id + "}};";		}		else {		    line = "        {" + i + ", {" + i + "}};";		}	    }	    else {		if (flag) {		    line = "        {" + id + ", {" + id + "}},";		}		else {		    line = "        {" + i + ", {" + i + "}},";		}	    }	    file.println(line);			}	    }    // method: writeDiGraphArcs    //    // arguments:    //    BufferedReader file: (input) file descriptor    //    Vector vec: (input) vector of input vertices    //    Boolean flag: indicating a container vertex    //    Boolean offset: container sof tag     // return: none    //    // write the arcs that correspond to the digraph    //    public void writeDiGraphArcs(PrintWriter file, Vector vec, 				 boolean flag, int offset) {	// declare local variables	//	String src = null;	String dst = null;	String line = null;	// write the arc information	//	file.println(ARCS_TAG);		// loop over all vertices and examine the children	//	boolean start = false;	for (int i=0; i < vec.size(); i++) {	    	    // get the current vertex	    //	    Vertex vertex = (Vertex)vec.elementAt(i);	    	    // check if the vertex has any children	    //	    if (vertex.getOutDegree() > 0) {				// get the vector of children		//		Vector children = (Vector)vertex.getChildren();				// loop over all children and write the arcs		//		for (int j=0; j < children.size(); j++) {		    		    // get the current child		    //		    Vertex child = (Vertex)children.elementAt(j);		    if (start) {			file.println(",");		    }		    if (flag) {			src = new String("" + (vec.indexOf(vertex) +					       (CONT_OFFSET*offset)));			dst = new String("" + (vec.indexOf(child) +					       (CONT_OFFSET*offset)));		    }		    else {			src = new String("" + vec.indexOf(vertex));			dst = new String("" + vec.indexOf(child));		    }		    		    // determine the position of the parent		    //		    int pos = 0;		    Vector parents = child.getParents();		    for (int k=0; k<parents.size(); k++) {			if (vertex == parents.elementAt(k)) {			    pos = k;			    break;			}		    }		    line = "        {" + src + ", " + dst + ", " + pos + "}";		    file.print(line);		    start = true;		}	    }	}	file.println(";");    }        // method: writeSystem    //    // arguments:    //    BufferedReader file: (input) file descriptor    // return: none    //    // write the system configuration parameters    //    public void writeSystem(PrintWriter file) {		// get index for looping through and writing the system 	// data to a file	//	String in_sample_frequency = null;	String in_frame_duration = null;	String in_signal_duration = null;	String in_number_of_features = null;		String in_file_format = null;	String in_data_type = null;		// write system config header	//	file.println(HEADER_TAG_03);	// write the algorithm data if the vertex is a container	//	for (int i=0; i < vertices.size(); i++) {	    	    // get the current vertex	    //	    Vertex vertex = (Vertex)vertices.elementAt(i);	    	    if (vertex.association == "AudioFrontEnd") {		inVertex = vertex;		break;	    }	}	// write the algorithm data	//	writeSystemData(file, inVertex);		if(inputBlockExist == true) {	    file.println(" input_flag" 			 + " = " + "true" 			 + ";");	}	else {	    file.println(" input_flag" 			 + " = " + "false" 			 + ";");	}	    }    // method: writeSystemData    //    // 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 writeSystemData(PrintWriter file, Vertex vertex) {	// write the algorithm name to the file	//	file.println(" name = " + vertex.association + ";"); 		if(inputBlockExist == false) {	    String tmp1, tmp2, tmp3;	    float value3 = (float)sample_frequency;	    	    tmp3 = ""+ value3;	    file.println(" sample_frequency" 			 + " = " + tmp3 			 + ";");	    float value2 = (float)frame_duration;	    	    tmp2 = ""+ value2;	    file.println(" frame_duration" 			 + " = " + tmp2 			 + ";");	    float value1 = (float)signal_duration;	    tmp1 = ""+ value1;	    file.println(" signal_duration" 			 + " = " + tmp1 			 + ";");		}	else {	    // 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));		String value = (String)(vertex.values.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)) {}				// write input class if the variable name is "input_data_type"		//		else if (name.equals("input_data_type")) {		    if(value.equals("FEATURES")) {			file.println(" input_data_type = FEATURES;");			//file.println(" feature_input = {");			inputVariable = "FEATURES";		    }		    else {			file.println(" input_data_type = SAMPLED_DATA;");			//file.println(" audio_input = {");			inputVariable = "SAMPLED_DATA";		    }		}		// 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)) {		    writeSubClassData(file, vertex, i);			    file.println(ALGORITHM_BREAK_00);		}		// output the subparam if the value is a param		//		else if(type.equals(ALGORITHM_PARAM)) {		    		    writeSubParamData(file, vertex, i);		    //file.println("};");		}	    		else {		    if(!vertex.values.get(i).equals(""))			file.println(" " + vertex.names.get(i) 				     + " = " + vertex.values.get(i) + ";");		}	    } // end for loop	}    }    // method: writeAlgorithmData    //    // 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 writeAlgorithmData(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 type to the file	//		if(vertex.association.equals("AudioFrontEnd") && inputBlockExist == true ) {	    file.println(" name = " + "CoefficientLabel" + ";");	    file.println(" variable = " + inputVariable + ";");	    file.println(" type = " + "INPUT" + ";");	}	else {	    // write the algorithm name to the file	    //	    file.println(" name = \"" + vertex.association + "\";"); 	    	    // 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)) {		    writeSubClassData(file, vertex, i);			    file.println(ALGORITHM_BREAK_00);		}		// output the subparam if the value is a param		//		else if(type.equals(ALGORITHM_PARAM)) {		    writeSubParamData(file, vertex, i);			}	    		else {

⌨️ 快捷键说明

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