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

📄 workflow_rtcview.java

📁 用java实现的工作流
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                  iddd[idd] = Integer.parseInt(e.nextElement().toString());
                  idd = idd + 1;
                }

                GraphConstants.setBounds(node_attrs,
                                         new Rectangle2D.Double(iddd[0],
                    iddd[1],
                    iddd[2], iddd[3]));

                GraphConstants.setBendable(node_attrs, true);

// 这个地方在GXL没有图标的时候,会出现BUG........没有找到问题所在

                if (!getIcon_RTC(node).equals(null)) {
                  if (gi.equals("b")) {

                    Icon icon1 = new ImageIcon(getIcon_RTC(node));
                    GraphConstants.setIcon(node_attrs, icon1);

                  }
                  else if (gi.equals("a")) {

                    Icon icon1 = new ImageIcon("resources/213.gif");
                    GraphConstants.setIcon(node_attrs, icon1);

                  }
                }
                attributes.put(vertex, node_attrs);
                // Add Vertex to new Cells
                newCells.add(vertex);
              }

              // 创建边
            }
            else if (type.equals("edge")) {
              Element edge_node = (Element) node;
              // Fetch Source ID Node
              Node tmp = node.getAttributes().getNamedItem("from");
              // Fetch Source ID Value
              String source = null;
              if (tmp != null) {
                source = tmp.getNodeValue();
                // Fetch Target ID Node
              }
              tmp = node.getAttributes().getNamedItem("to");
              // Fetch Target ID Value
              String target = null;
              if (tmp != null) {
                target = tmp.getNodeValue();
                // Create Edge with label
              }
              DefaultEdge edge = new DefaultEdge(new GPUserObject(label));
              // Find Source Port
              if (source != null) {
                // Fetch Vertex for Source ID
                DefaultGraphCell vertex =
                    (DefaultGraphCell) ids.get(source);
                if (vertex != null) {

                  // Connect to Source Port
                  cs.connect(edge, vertex.getChildAt(0), true);

                }
              }
              // Find Target Port

              if (target != null) {

                // Fetch Vertex for Target ID

                DefaultGraphCell vertex =
                    (DefaultGraphCell) ids.get(target);
                if (vertex != null) {

                  //连接目标顶点的PORT

                  cs.connect(edge, vertex.getChildAt(0), false);
                }
              }

              boolean edge_directed = ("true".equals(edge_node.getAttribute(
                  "isdirected")) || defaultDirected)
                  && ! ("false".equals(edge_node.getAttribute("isdirected")));
              AttributeMap map = new AttributeMap();

              if (edge_directed) {
                GraphConstants.setLineEnd(map, GraphConstants.ARROW_SIMPLE);
                GraphConstants.setEndFill(map, true);
                GraphConstants.setLabelAlongEdge(map, true);
              }

              fetchEdgeViewProperties_RTC(edge_node, map);
              attributes.put(edge, map);

            // Add Edge to new Cells

              newCells.add(edge);
            }
            else if (type.equals("view")) { // Graph view attributes
              // Currently defined: defaultlayout
              defaultLayout = ( (Element) node).getAttribute("defaultlayout");
            }
          }
        }
      }
    }
    // Insert the cells (View stores attributes)
    model.insert(newCells.toArray(), attributes, cs, null, null);

    //   if (defaultLayout != null) {
    //   applyLayout(graph, defaultLayout);
    //  }

  }

  public Map createDefaultAttributes_RTC() {

    // Create an GPAttributeMap

    AttributeMap map = new AttributeMap();

  // Set a Black Line Border (the Border-Attribute must be Null!)
    //  GraphConstants.setBorderColor(map, Color.black);
    //  GraphConstants.setBackground(map, Color.LIGHT_GRAY);

    GraphConstants.setOpaque(map, true);

    //   GraphConstants.setBorder(map, BorderFactory.createRaisedBevelBorder());
    //   GraphConstants.setValue(map,"新节点");
    //   Return the Map

    return map;
  }

  public Map createActiveAttributes_RTC() {
    // Create an GPAttributeMap
    AttributeMap map = new AttributeMap();

    // Set a Black Line Border (the Border-Attribute must be Null!)
    //  GraphConstants.setBorderColor(map, Color.black);
    //   GraphConstants.setBackground(map, Color.red);
    //  GraphConstants.setIcon(map,null);
    //   GraphConstants.setBorder(map, BorderFactory.createRaisedBevelBorder());

    //   Icon  image2 = new ImageIcon("resources/ren.gif");
    GraphConstants.setOpaque(map, true);
    //   GraphConstants.setIcon(map,image2);
    return map;

  }

  public Map createactionAttributes_RTC() {
    // Create an GPAttributeMap
    AttributeMap map = new AttributeMap();

    // Set a Black Line Border (the Border-Attribute must be Null!)
    GraphConstants.setBorderColor(map, Color.BLACK);

    GraphConstants.setBorder(map, BorderFactory.createRaisedBevelBorder());
    GraphConstants.setBackground(map, Color.red);
    //  GraphConstants.setIcon(map,null);
    //  GraphConstants.setBorder(map, BorderFactory.createRaisedBevelBorder());

    //   Icon  image2 = new ImageIcon("resources/ren.gif");
    GraphConstants.setOpaque(map, true);
    //   GraphConstants.setIcon(map,image2);
    return map;

  }

  // 取顶点的名称
  protected static String getLabel_RTC(Node node) {
    String lab = null;
    NodeList children = node.getChildNodes();
    for (int j = 0; j < children.getLength(); j++) {
      Node attr = children.item(j);
      if (attr.getNodeName().equals("attr")
          && attr
          .getAttributes()
          .getNamedItem("name")
          .getNodeValue()
          .equals(
          "Label")) {
        NodeList values = attr.getChildNodes();
        for (int k = 0; k < values.getLength(); k++) {
          if (values.item(k).getNodeName().equals("string")) {
            Node labelNode = values.item(k).getFirstChild();

            if (labelNode != null) {
              lab = labelNode.getNodeValue();
            }
          }
        }
      }
    }
    return (lab != null) ? lab : new String("");
  }

  protected Vector getBound_RTC(Node node) {

    Vector vec = new Vector();
    NodeList children = node.getChildNodes();
    for (int j = 0; j < children.getLength(); j++) {
      Node attr = children.item(j);
      if (attr.getNodeName().equals("attr")
          && attr
          .getAttributes()
          .getNamedItem("name")
          .getNodeValue()
          .equals(
          "Bounds")) {
        NodeList values = attr.getChildNodes();
        for (int k = 0; k < values.getLength(); k++) {
          if (values.item(k).getNodeName().equals("tup")) {
            NodeList tup = values.item(k).getChildNodes();
            for (int i = 0; i < tup.getLength(); i++) {
              if (tup.item(i).getNodeName().equals("int")) {
                Node Bounds = tup.item(i).getFirstChild();
                vec.add(Bounds.getNodeValue());

              }

            }

          }
        }

      }
    }
    return vec;
  }

// 添加获得ICON的方法 //comsci
  protected String getIcon_RTC(Node node) {

    String iconname = null;

    NodeList children = node.getChildNodes();
    for (int jl = 0; jl < children.getLength(); jl++) {
      Node attr = children.item(jl);
      if (attr.getNodeName().equals("attr")
          && attr
          .getAttributes()
          .getNamedItem("name")
          .getNodeValue()
          .equals(
          "Icon")) {

        NodeList values = attr.getChildNodes();
        for (int kl = 0; kl < values.getLength(); kl++) {
          if (values.item(kl).getNodeName().equals("tup")) {

            NodeList tup = values.item(kl).getChildNodes();
            for (int il = 0; il < tup.getLength(); il++) {

              if (tup.item(il).getNodeName().equals("string")) {

                Node icon1 = tup.item(il).getFirstChild();
                if (! (icon1.getNodeValue().equals(""))) {
                  iconname = (String) icon1.getNodeValue();
                  //     iconname = "E:\\project_java\\treeDoc\\" + iconname;
                }

              }

            }

          }

        }

      }

    }

    return iconname;

  }

}

⌨️ 快捷键说明

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