| 645 | } |
| 646 | |
| 647 | public void emit(Graph parent, PrintWriter writer, String indent) { |
| 648 | for (String s : commentsBefore) { |
| 649 | writer.println(indent + "// " + s); |
| 650 | } |
| 651 | writer.print(indent); |
| 652 | writer.print('"' + from.id() + '"'); |
| 653 | if (fromPort != null) { |
| 654 | writer.print(":\"" + fromPort + '"'); |
| 655 | } |
| 656 | writer.print(parent.directed ? " -> " : " -- "); |
| 657 | writer.print('"' + to.id() + '"'); |
| 658 | if (toPort != null) { |
| 659 | writer.print(":\"" + toPort + '"'); |
| 660 | } |
| 661 | LinkedList<String> opts = new LinkedList<>(); |
| 662 | emit(opts); |
| 663 | if (head != null) { |
| 664 | head.emit(opts); |
| 665 | } |
| 666 | if (tail != null) { |
| 667 | tail.emit(opts); |
| 668 | } |
| 669 | if (!opts.isEmpty()) { |
| 670 | writer.print(" " + opts); |
| 671 | } |
| 672 | writer.println(); |
| 673 | for (String s : commentsAfter) { |
| 674 | writer.println(indent + "// " + s); |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | public Connection head(Arrow head) { |
| 679 | this.head = head; |