public class GraphViz
extends java.lang.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()); String type = "gif"; File out = new File("out." + type); // out.gif in this example gv.writeGraphToFile( gv.getGraph( gv.getDotSource(), type ), out );
Constructor and Description |
---|
GraphViz()
Constructor: creates a new GraphViz object that will contain
a graph.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String line)
Adds a string to the graph's source (without newline).
|
void |
addln()
Adds a newline to the graph's source.
|
void |
addln(java.lang.String line)
Adds a string to the graph's source (with newline).
|
java.lang.String |
end_graph()
Returns a string that is used to end a graph.
|
java.awt.image.BufferedImage |
generateImage()
Generate an Image from this graph
|
java.lang.String |
getDotSource()
Returns the graph's source description in dot language.
|
byte[] |
getGraph(java.lang.String dot_source,
java.lang.String type)
Returns the graph as an image in binary format.
|
void |
readSource(java.lang.String input)
Read a DOT graph from a text file.
|
javax.swing.JFrame |
showGraph(java.lang.String frameTitle) |
java.lang.String |
start_graph()
Returns a string that is used to start a graph.
|
int |
writeGraphToFile(byte[] img,
java.io.File to)
Writes the graph's image in a file.
|
int |
writeGraphToFile(byte[] img,
java.lang.String file)
Writes the graph's image in a file.
|
public GraphViz()
public java.lang.String getDotSource()
public void add(java.lang.String line)
public void addln(java.lang.String line)
public void addln()
public java.awt.image.BufferedImage generateImage()
public javax.swing.JFrame showGraph(java.lang.String frameTitle)
public byte[] getGraph(java.lang.String dot_source, java.lang.String type)
dot_source
- Source of the graph to be drawn.type
- Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png.public int writeGraphToFile(byte[] img, java.lang.String file)
img
- A byte array containing the image of the graph.file
- Name of the file to where we want to write.public int writeGraphToFile(byte[] img, java.io.File to)
img
- A byte array containing the image of the graph.to
- A File object to where we want to write.public java.lang.String start_graph()
public java.lang.String end_graph()
public void readSource(java.lang.String input)
input
- Input text file containing the DOT graph
source.