📄 digraph.java
字号:
types.add(data.type.get(j)); values.add(data.values.get(j)); } } // initialize the vertex to the default values for its type // vertex.initializeConfig(labels, values, types, image_association, data); // set the tool tip for the algorithm vertex // vertex.setToolTipText(vertex.association); // attach a mouse motion listener to the vertex // vertex.addMouseListener(this); vertex.addMouseMotionListener(this); // set the current vertex selected // initVertexFocus = vertex; // 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); } /*********************************************** // createData() has been commented as the input and output class // have become algorithm-like class // 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(INPUT_STR)) && (iotype == INPUT) && (ioimpl == INPUT)) { JFrame frame = new JFrame("Warning"); JOptionPane.showMessageDialog(frame, "An input** 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(OUTPUT_STR)) && (iotype == OUTPUT) && (ioimpl == OUTPUT)) { JFrame frame = new JFrame("Warning"); JOptionPane.showMessageDialog(frame, "An output 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(INPUT_STR)) && (iotype == INPUT) && (ioimpl == INPUT)) { JFrame frame = new JFrame("Warning"); JOptionPane.showMessageDialog(frame, "An input 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(OUTPUT_STR)) && (iotype == OUTPUT) && (ioimpl == OUTPUT)) { JFrame frame = new JFrame("Warning"); JOptionPane.showMessageDialog(frame, "An output 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 == INPUT) { // when the implementation is INPUT // if (ioimpl == INPUT) { // create a unique label for the input vertex // currVertexLabel = new String("Input"); // create a vertex to be added in the work area // ImageIcon vertex_icon = new ImageIcon(INPUT_IMAGE); vertex = new Vertex(vertex_icon, currVertexLabel, INPUT, INPUT); dataLabels.addElement(SAMPLED_DATA_STR); dataLabels.addElement(INPUT_STR); // set the tool tip for the vertex // vertex.setToolTipText("Input"); // set flag for input block // inputBlockExist = true; } // when the implementation is OUTPUT // if (ioimpl == OUTPUT) { // create a unique label for the input vertex // currVertexLabel = new String("Output"); // create a vertex to be added in the work area // ImageIcon vertex_icon = new ImageIcon(OUTPUT_IMAGE); vertex = new Vertex(vertex_icon, currVertexLabel, OUTPUT, OUTPUT); dataLabels.addElement(SAMPLED_DATA_STR); dataLabels.addElement(OUTPUT_STR); // set the tool tip for the vertex // vertex.setToolTipText("Output"); // 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 == OUTPUT) { // when the implementation is INPUT // if (ioimpl == INPUT) { // create a unique label for the input vertex // currVertexLabel = new String("Input"); // create a vertex to be added in the work area // ImageIcon vertex_icon = new ImageIcon(INPUT_IMAGE); vertex = new Vertex(vertex_icon, currVertexLabel, INPUT, INPUT); dataLabels.addElement(FEATURE_DATA_STR); dataLabels.addElement(INPUT_STR); // set the tool tip for the vertex // vertex.setToolTipText("Input"); // set flag for input block // inputBlockExist = true; } // when the implementation is OUTPUT // if (ioimpl == OUTPUT) { // create a unique label for the input vertex // currVertexLabel = new String("Output"); // create a vertex to be added in the work area // ImageIcon vertex_icon = new ImageIcon(OUTPUT_IMAGE); vertex = new Vertex(vertex_icon, currVertexLabel, OUTPUT, OUTPUT); dataLabels.addElement(FEATURE_DATA_STR); dataLabels.addElement(OUTPUT_STR); // set the tool tip for the vertex // vertex.setToolTipText("Output"); // set flag for input block // outputBlockExist = true; // add the output block name as the system target // targetStr = currVertexLabel; } } // when the type is GENERATOR // else if (iotype == GENERATOR_DATA) { // when the implementation is INPUT // if (ioimpl == INPUT) { // create a unique label for the input vertex // currVertexLabel = new String(GENERATOR_DATA_STR); // create a vertex to be added in the work area // ImageIcon vertex_icon = new ImageIcon(GENERATOR_IMAGE); vertex = new Vertex(vertex_icon, currVertexLabel, GENERATOR_DATA, INPUT); vertex.association = "GENERATOR"; dataLabels.addElement(GENERATOR_DATA_STR); dataLabels.addElement(INPUTGEN_STR); // to simplify the creation, the data vectors will be // trimmed to only include the transform we're looking // at and saved into these three vectors for use in a // bit // Vector labels = new Vector(5,5); Vector types = new Vector(5,5); Vector values = new Vector(5,5); for(int j=data.association.indexOf("GENERATOR"); j <= data.association.lastIndexOf("GENERATOR"); j++) { if(j != -1) { labels.add(data.name.get(j)); types.add(data.type.get(j)); values.add(data.values.get(j)); } } // initialize the vertex to the default values for its type // vertex.initializeConfigGen(labels, values, types, "GENERATOR", data); // set the tool tip for the algorithm vertex // vertex.setToolTipText(vertex.association); // attach a mouse motion listener to the vertex // // set the current vertex selected // initVertexFocus = vertex; } } // when the type is CUSTOM // else if (iotype == CUSTOM) { // create a unique label for the input vertex // currVertexLabel = new String(CUSTOM_STR + maxInputVertices); // generate a new feature label if the original is not unique // while (coeffLabels.contains(currVertexLabel)) { maxInputVertices++; currVertexLabel = new String(CUSTOM_STR + maxInputVertices); } // create a vertex to be added in the work area // ImageIcon vertex_icon = new ImageIcon(CUSTOM_IMAGE); vertex = new Vertex(vertex_icon, currVertexLabel, CUSTOM, NONE); coeffLabels.addElement(currVertexLabel); // set the tool tip for the vertex // vertex.setToolTipText("Custom Data"); } // when the type is CONTAINER // else if (iotype == CONTAINER) { // create a unique label for the input vertex // currVertexLabel = new String(CONTAINER_STR + maxInputVertices); // generate a new feature label if the original is not unique // while (coeffLabels.contains(currVertexLabel)) { maxInputVertices++; currVertexLabel = new String(CONTAINER_STR + 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("Container"); } // 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(INPUT_STR) || type.equals(INPUTGEN_STR)) { // declare local variables // Vertex START_VERTEX = new Vertex(new ImageIcon(ENTER_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(INPUT); // 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(OUTPUT_STR)) { // declare local variables // Vertex TERM_VERTEX = new Vertex(new ImageIcon(EXIT_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(OUTPUT); // 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; // scans through the association until it finds the largeIcon key // int start = data.association.indexOf(image_association); int stop = data.association.lastIndexOf(image_association); String icon_name =null; for(int j=start; j <= stop; j++) { if (j != -1) { if (((String)(data.name.get(j))).equals(ALGORITHM_ICON_BIG)) { // sets image_name to large icon // image_name = (String)data.values.elementAt(j); } if (((String)(data.name.get(j))).equals("iconName")) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -