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

📄 digraph.java

📁 这是一个从音频信号里提取特征参量的程序
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	    // Create an instance of java.awt.Cursor	    Cursor c = new Cursor ( Cursor.HAND_CURSOR );	    // Set cursor for the frame component	    this.setCursor (c);	}    }    // method: createIOData    //    // arguments:    //   String label: data label    //    // this method creates a name data node (SAMPLE_DATA or FEATURES)    //    public void createIOData(int type, int impl) {	iotype = type;	ioimpl = impl;		// Create an instance of java.awt.Cursor	Cursor c = new Cursor ( Cursor.HAND_CURSOR );	// Set cursor for the frame component	this.setCursor (c);    }    // method: createData    //    // arguments:    //   String label: data label    //    // this method creates a name data node (SAMPLE_DATA or FEATURES)    //    public void createData() {	// declare local variables	//	Vertex vertex = null;	// currently we only allow one sample input/output and one	// feature input/output but not one of both	//	if ((dataLabels.contains("Start")) &&  	     (iotype == START) && (ioimpl == START)) {	    JFrame frame = new JFrame("Warning");	    JOptionPane.showMessageDialog(frame, "An start** block is already present.");			    // Create an instance of java.awt.Cursor	    //	    Cursor c = new Cursor ( Cursor.DEFAULT_CURSOR );	    this.setCursor (c);	    return;	}		if ((dataLabels.contains("Stop")) && 	    (iotype == STOP) && (ioimpl == STOP)) {	    JFrame frame = new JFrame("Warning");	    JOptionPane.showMessageDialog(frame, "An stop block is already present.");	   	    // Create an instance of java.awt.Cursor	    //	    Cursor c = new Cursor ( Cursor.DEFAULT_CURSOR );	    this.setCursor (c);	    	    return;	    	}		if ((dataLabels.contains("Start")) && 	    (iotype == START) && (ioimpl == START)) {	    JFrame frame = new JFrame("Warning");	    JOptionPane.showMessageDialog(frame, "An start block is already present.");	    // Create an instance of java.awt.Cursor	    //	    Cursor c = new Cursor ( Cursor.DEFAULT_CURSOR );	    this.setCursor (c);	    	    return;	    	}	if ((dataLabels.contains("Stop")) && 	    (iotype == STOP) && (ioimpl == STOP)) {	    JFrame frame = new JFrame("Warning");	    JOptionPane.showMessageDialog(frame, "An stop block is already present.");	    // Create an instance of java.awt.Cursor	    //	    Cursor c = new Cursor ( Cursor.DEFAULT_CURSOR );	    this.setCursor (c);	    	    return;   	}		// when the type is SAMPLED_DATA	//	if (iotype == START) {	    // when the implementation is START	    //	    if (ioimpl == START) {		// create a unique label for the input vertex		//		currVertexLabel = new String("Start");				// create a vertex to be added in the work area		//		ImageIcon vertex_icon = new ImageIcon(START_IMAGE);		vertex = new Vertex(vertex_icon, currVertexLabel, 				    START, START);		dataLabels.addElement("Start");		// set the tool tip for the vertex		//		vertex.setToolTipText("Start");		// set flag for input block		//		inputBlockExist = true;	    }	    // when the implementation is stop	    //	    if (ioimpl == STOP) {		// create a unique label for the input vertex		//		currVertexLabel = new String("Stop");				// create a vertex to be added in the work area		//		ImageIcon vertex_icon = new ImageIcon(TERM_IMAGE);		vertex = new Vertex(vertex_icon, currVertexLabel, 				    STOP, STOP);		dataLabels.addElement("Stop");		// set the tool tip for the vertex		//		vertex.setToolTipText("Stop");		// set flag for input block		//		outputBlockExist = true;				// add the output block name as the system target		//		targetStr = currVertexLabel;       	    }	}	// when the type is FEATURE_DATA	//	else if (iotype == STOP) {	    // when the implementation is START	    //	    if (ioimpl == START) {		// create a unique label for the input vertex		//		currVertexLabel = new String("Start");				// create a vertex to be added in the work area		//		ImageIcon vertex_icon = new ImageIcon(START_IMAGE);		vertex = new Vertex(vertex_icon, currVertexLabel, 				    START, START);		dataLabels.addElement("Start");		// set the tool tip for the vertex		//		vertex.setToolTipText("Start");				// set flag for input block		//		inputBlockExist = true;	    }	    	    // when the implementation is STOP	    //	    if (ioimpl == STOP) {		// create a unique label for the input vertex		//		currVertexLabel = new String("Stop");				// create a vertex to be added in the work area		//		ImageIcon vertex_icon = new ImageIcon(TERM_IMAGE);		vertex = new Vertex(vertex_icon, currVertexLabel,				    STOP, STOP);		dataLabels.addElement("Stop");		// set the tool tip for the vertex		//		vertex.setToolTipText("Stop");		// set flag for input block		//		outputBlockExist = true;		// add the output block name as the system target		//		targetStr =  currVertexLabel;	      	    }	}		// when the type is CONTAINER	//	else if (iotype == CONTAINER) {	    	    // generate a new feature label if the original is not unique	    //	    int tmpInputVertices = 0;	    currVertexLabel = new String("S" + tmpInputVertices);	    while (coeffLabels.contains(currVertexLabel)) {		tmpInputVertices++;		currVertexLabel = new String("S" + tmpInputVertices);	    }	    if(tmpInputVertices > maxInputVertices)		maxInputVertices = tmpInputVertices;	    /*	    // create a unique label for the input vertex	    //	    currVertexLabel = new String("S" + maxInputVertices);	    	    // generate a new feature label if the original is not unique	    //	    while (coeffLabels.contains(currVertexLabel)) {		maxInputVertices++;		currVertexLabel = new String("S" + maxInputVertices);	    }	    	    */	    // create a vertex to be added in the work area	    //	    ImageIcon vertex_icon = new ImageIcon(CONTAINER_IMAGE);	    vertex = new Vertex(vertex_icon, currVertexLabel, 				CONTAINER, NONE);	    coeffLabels.addElement(currVertexLabel);	    // set the tool tip for the vertex	    //	    vertex.setToolTipText("Node");	    // initialize Node parameters	    //	    vertex.names.add("Word_List");	    vertex.types.add("enum");	    // add the token that has already been taken	    //	    // vertex.values.add("word1");	}	// we have an undefined type	//	else {	    return;	}		// attach a mouse motion listener to the vertex	//	vertex.addMouseListener(this);	vertex.addMouseMotionListener(this);       		// add the vertex to the vector	//	vertex.setFont(newCoeffFont);	// set the current vertex selected	//	initVertexFocus = vertex;	    }    // method: initializeDataBuffer    //    // arguments:    // returns  : new data buffer vertex    //    // method initializes the container object    //    public Vertex initializeDataBuffer() {	return (new Vertex());    }    // method: initializeContainer    //    // arguments:    //      String name: (input) name of the container    // returns  : new container vertex    //    // method initializes the container object    //    public Vertex initializeContainer(String name) {	ImageIcon vertex_icon = new ImageIcon(CONTAINER_IMAGE);	return (new Vertex(vertex_icon, name, CONTAINER, NONE));    }    // method: initializeAlgorithm    //    // arguments:    //   String name: (input) name of the algorithm object    //   BufferedReader file: (input) input file buffered reader    // returns  : new algorithm vertex    //    // method initializes the algorithm    //    public Vertex initializeAlgorithm(String name, BufferedReader file, String typeAlgo) {	// initialize variables	//	StringTokenizer tokens = null;	String line = null;	String type = typeAlgo;	String image_name = null;	String image_association= null;			// when the name indicates a start or term vertex	//	if (name.equals(BUFFER_TAG)) {		    // switch based on the type of the object	    //	    if (type.equals("Start") || type.equals(INPUTGEN_STR)) {		// declare local variables		//		Vertex START_VERTEX = new Vertex(new ImageIcon(START_IMAGE), ALGORITHM);				// set the location of the vertices		//		START_VERTEX.setLocation(new Point(INIT_START_XLOC, 						   INIT_START_YLOC));				// set the dimensions of the vertices		//		START_VERTEX.setSize(ICON_WIDTH, ICON_HEIGHT);		START_VERTEX.setPreferredSize(new Dimension(ICON_WIDTH, 							    ICON_HEIGHT));		START_VERTEX.setMinimumSize(new Dimension(ICON_WIDTH, 							  ICON_HEIGHT));		START_VERTEX.setVertexWidth(ICON_WIDTH);		START_VERTEX.setVertexHeight(ICON_HEIGHT);				// set the font of the vertices		//		START_VERTEX.setFont(newCoeffFont);				// set the type of the vertex		//		START_VERTEX.setType(START);				// set the vertex papameters		//		START_VERTEX.association = new String(BUFFER_TAG);		START_VERTEX.names = new Vector();		START_VERTEX.types = new Vector();				// return the vertex		//		return START_VERTEX;	    }	     	    if (type.equals("Stop")) {				// declare local variables		//		Vertex TERM_VERTEX = new Vertex(new ImageIcon(TERM_IMAGE), ALGORITHM);				// set the location of the vertices		//		TERM_VERTEX.setLocation(new Point(INIT_TERM_XLOC, 						  INIT_TERM_YLOC));				// set the dimensions of the vertices		//		TERM_VERTEX.setSize(ICON_WIDTH, ICON_HEIGHT);		TERM_VERTEX.setPreferredSize(new Dimension(ICON_WIDTH, 							   ICON_HEIGHT));		TERM_VERTEX.setMinimumSize(new Dimension(ICON_WIDTH, 							 ICON_HEIGHT));		TERM_VERTEX.setVertexWidth(ICON_WIDTH);		TERM_VERTEX.setVertexHeight(ICON_HEIGHT);				// set the font of the vertices		//		TERM_VERTEX.setFont(newCoeffFont);				// set the type of the vertex		//		TERM_VERTEX.setType(STOP);				// set the vertex papameters		//		TERM_VERTEX.association = new String(BUFFER_TAG);		TERM_VERTEX.names = new Vector();		TERM_VERTEX.types = new Vector();			// return the vertex		//		return TERM_VERTEX;	    }		}	// which transform it is looking to match?	//	name = name.replace('\"',' ');	name = name.replace(';', ' ');	name = name.trim();	image_association = name;			// create a vertex to be added in the work area	//	ImageIcon vertex_icon = new ImageIcon(CONTAINER_IMAGE);	Vertex algoVertex = new Vertex(vertex_icon, name, 				CONTAINER, NONE);	// set the tool tip for the vertex	//	algoVertex.setToolTipText("Node");	algoVertex.setVertexName(name);	if (name.length() > 4) {	    algoVertex.setText(name.substring(0, 4));	}	else {	    algoVertex.setText(name);	}	coeffLabels.addElement(name);		// initialize Node parameters	//		algoVertex.names.add("Word_List");	algoVertex.types.add("enum");		Vector enum_var = new Vector(5,5);	//enum_var.add(typeAlgo);			tokens = new StringTokenizer(typeAlgo);	String ww = ""; 	while(tokens.hasMoreTokens()) {	    String xvar = new String(tokens.nextToken());	    xvar.trim();	    ww =ww+xvar + " ";	    enum_var.addElement(xvar);	}			// add the token that has already been taken	//	algoVertex.values.addElement(typeAlgo);	// return the initialize vertex	//	return algoVertex;    }    // method: removeVertex    //    // arguments:    //   Vertex target: (input) vertex to be removed    // returns  : none    //    // method that removes the specified vertex from the work area as    // well as removing all parent and corresponding children links    //    public void removeVertex(Vertex target) {	// verify that the vertex to be deleted is valid	//	if (target == null) {	    return;	}	// reset the vertex focus	//	resetVertexFocus();	// get the parents of the traget and all accurances of target	//	Vector parents = target.getParents();	for (int i=0; i<parents.size(); i++) {	    if (((Vertex)(parents.elementAt(i))).containsChild(target)) {		((Vertex)(parents.elementAt(i))).removeChild(target);	    }	}	// get the children of the traget and all accurances of target	//	Vector children = target.getChildren();	for (int i=0; i<children.size(); i++) {	    if (((Vertex)(children).elementAt(i)).containsParent(target)) {		((Vertex)(children.elementAt(i))).removeParent(target);	    }	}		// remove the node form the work area	//	workArea.remove(target);	vertices.remove(target);	// remove the label from the vector depending on the implementation	//	if (target.getVertexImpl() == START) {	    dataLabels.remove(target.getText()); 	    dataLabels.remove(START_STR);	    iotype = -1;	    inputBlockExist = false;	 	}	else if (target.getVertexImpl() == STOP) {	    dataLabels.remove(target.getText());	    iotype = -1;	    outputBlockExist = false;		    dataLabels.remove(STOP_STR);	}	else {	    coeffLabels.remove(target.getText());	    maxInputVertices--;	}	String targetStr = target.getVertexName();	for(int k = 0; k < graphArc.from.size(); k++) {	    Vertex from = (Vertex)graphArc.from.get(k);	    String fromStr = from.getVertexName();	    Vertex to  = (Vertex)graphArc.to.get(k);	    String toStr = to.getVertexName();	    	    if (targetStr.equals(toStr) || targetStr.equals(fromStr)) {		graphArc.from.remove(k);                graphArc.to.remove(k);		graphArc.weights.remove(k);		graphArc.epsilon.remove(k);		graphArc.xloc.remove(k);		graphArc.yloc.remove(k);		graphArc.width.remove(k);		graphArc.height.remove(k);		k = k-1;

⌨️ 快捷键说明

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