@@ -0,0 +1,2024 @@
+package com.github.ferstl.depgraph.dot;%0A%0Aimport java.util.Map;%0Aimport java.util.TreeMap;%0A%0A/**%0A * %3Ca href=http://www.graphviz.org/doc/info/shapes.html#html%3EHTML-like labels%3C/a%3E.%0A */%0Apublic class LabelBuilder %7B%0A%0A  private final StringBuilder labelBuilder = new StringBuilder();%0A%0A  public LabelBuilder text(String text) %7B%0A    this.labelBuilder.append(text);%0A    return this;%0A  %7D%0A%0A  public LabelBuilder italic(String text) %7B%0A    addText(text, %22i%22);%0A    return this;%0A  %7D%0A%0A  public LabelBuilder bold(String text) %7B%0A    addText(text, %22b%22);%0A    return this;%0A  %7D%0A%0A  public LabelBuilder underline(String text) %7B%0A    addText(text, %22u%22);%0A    return this;%0A  %7D%0A%0A  public LabelBuilder newLine() %7B%0A    this.labelBuilder.append(%22%3Cbr/%3E%22);%0A    return this;%0A  %7D%0A%0A  public FontBuilder font() %7B%0A    return new FontBuilder();%0A  %7D%0A%0A  public String build() %7B%0A    return %22%3C%22 + this.labelBuilder + %22%3E%22;%0A  %7D%0A%0A  private void addText(String text, String tagName, String... tagAttributes) %7B%0A    // tag with attributes%0A    this.labelBuilder.append(%22%3C%22).append(tagName);%0A    for (String attribute : tagAttributes) %7B%0A      this.labelBuilder.append(%22 %22).append(attribute);%0A    %7D%0A    this.labelBuilder.append(%22%3E%22);%0A%0A    // text and end tag%0A    this.labelBuilder%0A        .append(text)%0A        .append(%22%3C/%22).append(tagName).append(%22%3E%22);%0A  %7D%0A%0A  class FontBuilder %7B%0A%0A    private final Map%3CString, String%3E attributes = new TreeMap%3C%3E();%0A%0A    public FontBuilder color(String color) %7B%0A      addAttribute(%22color%22, color);%0A      return this;%0A    %7D%0A%0A    public FontBuilder size(int size) %7B%0A      addAttribute(%22point-size%22, size);%0A      return this;%0A    %7D%0A%0A    public FontBuilder name(String font) %7B%0A      addAttribute(%22face%22, font);%0A      return this;%0A    %7D%0A%0A    public LabelBuilder text(String text) %7B%0A      LabelBuilder.this.addText(text, %22font%22, this.attributes.values().toArray(new String%5B0%5D));%0A      return LabelBuilder.this;%0A    %7D%0A%0A    private void addAttribute(String name, Object value) %7B%0A      this.attributes.put(name, name + %22=%5C%22%22 + value + %22%5C%22%22);%0A    %7D%0A  %7D%0A%7D%0A

Introduce builder for labels