public class GraphViz extends Object
GraphViz gv = new GraphViz(); gv.addln(gv.start_graph()); gv.addln("A -> B;"); gv.addln("A -> C;"); gv.addln(gv.end_graph()); System.out.println(gv.getDotSource());
Modifier and Type | Field and Description |
---|---|
private StringBuilder |
graph
The source of the graph written in dot language.
|
private HashSet<String> |
lines
Set made to avoid repetitions.
|
Constructor and Description |
---|
GraphViz()
Constructor: creates a new GraphViz object that will contain
a graph.
|
Modifier and Type | Method and Description |
---|---|
void |
add(String line)
Adds a string to the graph's source (without newline).
|
void |
addConectorWithLabel(String from,
String to,
String cost)
Adds a conector from given node to given node adding a label in the conector
|
void |
addln()
Adds a newline to the graph's source.
|
void |
addln(String line)
Adds a string to the graph's source (with newline).
|
void |
addNodeStep(String node,
String step)
Adds to a node the current given step
|
void |
end_graph()
Adds a instruction to end the tree
|
String |
getDotSource()
Returns the graph's source description in dot language.
|
void |
setFinal(String name)
Changes the color of the final node to red
|
void |
setInitial(String name)
Changes the color of the initial node to green
|
void |
start_graph()
Initialize the tree syntax
|
private StringBuilder graph
public GraphViz()
public String getDotSource()
public void add(String line)
public void addln(String line)
public void addln()
public void addNodeStep(String node, String step)
node
- Node to describestep
- current step of the node that will be displayedpublic void addConectorWithLabel(String from, String to, String cost)
from
- Initial nodeto
- Final nodecost
- Value to be placedpublic void start_graph()
public void end_graph()
public void setInitial(String name)
name
- initial node namepublic void setFinal(String name)
name
- final node name