org.atemsource.atem.utility.doc.dot.DotBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of atem-utility Show documentation
Show all versions of atem-utility Show documentation
Atem utilities for cloning, comparing and transforming
The newest version!
package org.atemsource.atem.utility.doc.dot;
import java.util.HashSet;
import java.util.Set;
public class DotBuilder
{
private Set nodes = new HashSet();
public String create()
{
StringBuilder builder = new StringBuilder();
builder.append("digraph{\r\nrankdir=BT\r\nnode [shape=record]\r\n");
Set connections = new HashSet();
for (NodeBuilder node : nodes)
{
node.create(builder);
connections.addAll(node.getConnections());
}
for (ConnectionBuilder connection : connections)
{
connection.create(builder);
}
builder.append("}");
return builder.toString();
}
public NodeBuilder createNode(String id, String label)
{
NodeBuilder nodeBuilder = new NodeBuilder(id, label);
nodes.add(nodeBuilder);
return nodeBuilder;
}
}