예제 #1
0
  /**
   * Creates an Element(or Node in XML in Document d) for single component
   *
   * @param x the component for which Element will be created
   * @param d Where the element will be added
   * @return the Element(for XML) created from component x
   */
  private Element createCmpEle(component x, Document d) {
    Element cmp_el = d.createElement("comp");
    cmp_el.setAttribute("id", String.valueOf(x.getId()));

    Element type_el = d.createElement("comp_type_id");
    Text type_txt = d.createTextNode(String.valueOf(x.getType().getId()));
    type_el.appendChild(type_txt);
    cmp_el.appendChild(type_el);

    Element pkg_el = d.createElement("pkg_name");
    Text pkg_txt = d.createTextNode(x.getType().getType_pkg_name());
    pkg_el.appendChild(pkg_txt);
    cmp_el.appendChild(pkg_el);

    Element pos_el = d.createElement("position");

    Element x_el = d.createElement("x");
    Text x_txt = d.createTextNode(String.valueOf(x.getPosition().x));
    x_el.appendChild(x_txt);
    pos_el.appendChild(x_el);

    Element y_el = d.createElement("y");
    Text y_txt = d.createTextNode(String.valueOf(x.getPosition().y));
    y_el.appendChild(y_txt);
    pos_el.appendChild(y_el);

    cmp_el.appendChild(pos_el);

    return cmp_el;
  }
예제 #2
0
  /**
   * Creates an Element(or Node in XML in Document d) for single line
   *
   * @param x the line for which Element will be created
   * @param d Where the element will be added
   * @return the Element(for XML) created from line x
   */
  private Element createWireEle(line x, Document d) {
    Element wire_el = d.createElement("wire");
    wire_el.setAttribute("id", String.valueOf(x.getId()));

    Element strt_el = d.createElement("start");
    Element strt_cmp_el = d.createElement("comp_id");
    Text strt_cmp_txt = d.createTextNode(String.valueOf(x.getStartCmpId()));
    strt_cmp_el.appendChild(strt_cmp_txt);
    Element strt_mrk_el = d.createElement("mark_point");
    Text strt_mrk_txt = d.createTextNode(String.valueOf(x.getStartMrkPt()));
    strt_mrk_el.appendChild(strt_mrk_txt);
    strt_el.appendChild(strt_cmp_el);
    strt_el.appendChild(strt_mrk_el);
    wire_el.appendChild(strt_el);

    Element inter_el = d.createElement("inter_point");
    inter_el.setAttribute("no", String.valueOf(x.getInter_Line_segs().size()));
    for (Point p : x.getInter_Line_segs()) {
      Element pos_el = d.createElement("position");

      Element x_el = d.createElement("x");
      Text x_txt = d.createTextNode(String.valueOf(p.x));
      x_el.appendChild(x_txt);
      pos_el.appendChild(x_el);
      Element y_el = d.createElement("y");
      Text y_txt = d.createTextNode(String.valueOf(p.y));
      y_el.appendChild(y_txt);
      pos_el.appendChild(y_el);

      inter_el.appendChild(pos_el);
    }
    wire_el.appendChild(inter_el);

    Element end_el = d.createElement("end");
    Element end_cmp_el = d.createElement("comp_id");
    Text end_cmp_txt = d.createTextNode(String.valueOf(x.getEndCmpId()));
    end_cmp_el.appendChild(end_cmp_txt);
    Element end_mrk_el = d.createElement("mark_point");
    Text end_mrk_txt = d.createTextNode(String.valueOf(x.getEndMrkPt()));
    end_mrk_el.appendChild(end_mrk_txt);
    end_el.appendChild(end_cmp_el);
    end_el.appendChild(end_mrk_el);
    wire_el.appendChild(end_el);

    return wire_el;
  }