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

📄 digraph.java

📁 这是一个从音频信号里提取特征参量的程序
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	//	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("enum")) {		if(!vertex.values.isEmpty()) {		    Vector enum_values = new Vector(5,5);		    String ww="" + vertex.values.get(0);		    file.println(" " + vertex.names.get(i) 				 + " = " + ww + ";");		}	    }	    	    // 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 {		if(!vertex.values.get(i).equals(""))		    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_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_PARAM)) {			writeSubParamData(file, subclass_copy, j);		    }		    else {			file.println(" " + subclass_copy.names.get(j) 				     + " = " + subclass_copy.values.get(j) 				     + ";");		    }		}}    // method: readGraph    //    // arguments: none    // return   : none    //    // reads the sof file    //    public void readGraph() {	convertGraph();		   	String name = null;	FileReader fin = null;	BufferedReader file = null;	StringTokenizer tokens = null;	// clear out all existing memory	//	clearAllMemory();	// open the selected file for reading	//	try {	    // initialize the file output stream	    //	    fin = new FileReader(graphFile);	    file = new BufferedReader(fin);	    setVertexSymbol(file);	    setVertex(file);	    setArc(file);	    // close the file descriptor	    //	    file.close();	}	// catch and deal with any file I/O exceptions	//	catch(IOException e1) {}	graphFile.delete();	graphFile = null;    }    // method: setVertexSymbol    //    // arguments: BufferedReader file    // return   : none    //    // reads the sof file    //    public void setVertexSymbol(BufferedReader file) {		String line = null;	wordSymbol = new Vector(100, 50);	// open the selected file for reading	//	try {	    // read the lines form the file	    //	    while ((line = file.readLine()) != null) {			String name = null;				// remove white spaces at the ends of the string		//		line = line.trim();		line_index++;			// check for end of symbol_table		//		if (line.regionMatches(false, 0, "};", 0, 2)) {		    break;		}		// check for symbols		//		if (line.regionMatches(false, 0, "\"", 0, 1)) {		   		        name = line.replace('\"',' ');			name = name.trim();		 			wordSymbol.add(name);		}	    }	}	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);	}    }    // method: setVertex    //    // arguments: BufferedReader file    // return   : none    //    // reads the sof file    //    public void setVertex(BufferedReader file) {		String line = null;	String name = null;	Point location = null;	StringTokenizer tokens = null;	// declare local variables	//	int xloc = 0;	int yloc = 0;		    	// set the location of the object	//	location = new Point(xloc, WORKAREA_WIDTH/2);		// set Start node	//	Vertex vertex = new Vertex();	dataLabels.addElement(START_STR);	vertex.setVertexName("Start");	 vertex.setText("Start");	 if ((vertex != null) && 	     (vertex.getVertexName() != null)) {	     vertex.setType("Start");	 }	 // set the location of the object	 //	 vertex.setLocation(location);	 loadWidthMax = location.x > loadWidthMax ? 	     location.x : loadWidthMax;	 loadHeightMax = location.y > loadHeightMax ? 	     location.y : loadHeightMax;	 // set the vertex font	 //	 vertex.setFont(newCoeffFont);	 // attach a mouse motion listener to the vertex	 //	 if (!vertices.contains(vertex)) {	     vertex.addMouseListener(this);	     vertex.addMouseMotionListener(this);	 }				 // add the vertex to the required data structures	 //	 workArea.add(vertex);	 vertices.addElement(vertex);	 tagToVertex.put("0", vertex);	 	 	 // add internal nodes	 //	 try {	    // read the lines form the file	    //	    while ((line = file.readLine()) != null) {			name = null;		// remove white spaces at the ends of the string		//		line = line.trim();		line_index++;		// check for end of symbol_table		//		if (line.regionMatches(false, 0, "arcs", 0, 4)) {		    break;		}		// check for symbols		//		if (line.regionMatches(false, 0, "{", 0, 1)) {		    		    tokens = new StringTokenizer(line, ",");		    String typestr = "" + tokens.nextToken();		    typestr = typestr.replace('{',' ');		    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.replace(';',' ');			typeAlgo = typeAlgo.trim();		    }		    		    // get the integer equivalent of the tag		    //		    int nodeIndex = Integer.valueOf(typestr).intValue();		    int nodeValue = Integer.valueOf(typeAlgo).intValue();		    String tmp = (String)wordSymbol.elementAt(nodeValue);		    maxInputVertices++;		    name = "S"+typestr;		    vertex = initializeAlgorithm(name, file, tmp);		    		    // set the location of the object		    //		    vertex.setLocation(location);		    loadWidthMax = location.x > loadWidthMax ? 			location.x : loadWidthMax;		    loadHeightMax = location.y > loadHeightMax ? 			location.y : loadHeightMax;		    		    // set the vertex font		    //		    vertex.setFont(newCoeffFont);		    		    // attach a mouse motion listener to the vertex		    //		    if (!vertices.contains(vertex)) {			vertex.addMouseListener(this);			vertex.addMouseMotionListener(this);		    }		    		    // add the vertex to the required data structures		    //		    workArea.add(vertex);		    vertices.addElement(vertex);		    int index = nodeIndex + 1;		    tmp = "" + index;		    tagToVertex.put(tmp, vertex);		}				    }	}	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);	}	// set Stop node	//	vertex = new Vertex();	dataLabels.addElement(START_STR);	vertex.setVertexName("Stop");	 vertex.setText("Stop");	 if ((vertex != null) && 	     (vertex.getVertexName() != null)) {	     vertex.setType("Stop");	 }	 // set the location of the object	 //	 vertex.setLocation(location);	 loadWidthMax = location.x > loadWidthMax ? 	     location.x : loadWidthMax;	 loadHeightMax = location.y > loadHeightMax ? 	     location.y : loadHeightMax;	 // set the vertex font	 //	 vertex.setFont(newCoeffFont);	 // attach a mouse motion listener to the vertex	 //	 if (!vertices.contains(vertex)) {	     vertex.addMouseListener(this);	     vertex.addMouseMotionListener(this);	 }				 // add the vertex to the required data structures	 //	 workArea.add(vertex);	 vertices.addElement(vertex);	 int index = vertices.size()-1;	 String tmp = ""+index;	 tagToVertex.put(tmp, vertex);	    }    // method: setArc    //    // arguments: BufferedReader file    // return   : none    //    // reads the sof file    //    public void setArc(BufferedReader file) {	String line = null;	String name = null;	Point location = null;	StringTokenizer tokens = null;	graphInfo = new Vector(100, 50);	for(int i = 0; i < vertices.size(); i++) {	    	    NodeInfo tmp = new NodeInfo();	    tmp.childIndex = new Vector(50,5);	    graphInfo.add(tmp);	}	// add internal nodes	//	try {	    //	    line = file.readLine();	    	    // read the rest of the data for the object	    //	    while ((line = file.readLine()) != null) {				String parentTag = null;		String childTag = null;		String indexTag = null;		String weightTag = null;		String isWeight = null;		Vertex childVertex = null;		Vertex parentVertex = null;		int index = 0;		int nodeValue;		in

⌨️ 快捷键说明

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