Main

## Class GraphViz

- java.lang.Object
- - Main.GraphViz

-     public class GraphViz
      extends java.lang.Object

  Purpose: GraphViz Java API
  Description:
    With this Java class you can simply call dot from your Java programs
  Example usage:

            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 );

  Version:
    v0.4, 2011/02/05 (February) -- Patch of Keheliya Gallaba is added. Now you can specify the type of the output file: gif, dot, fig, pdf, ps, svg, png, etc., v0.3, 2010/11/29 (November) -- Windows support + ability to read the graph from a text file, v0.2, 2010/07/22 (July) -- bug fix, v0.1, 2003/12/04 (December) -- first release
  Author:
    Laszlo Szathmary (jabba.laci@gmail.com) Ramin Mousavi wrote: http://www.loria.fr/~szathmar/off/projects/java/GraphVizAPI/index.php#description NOTE: I did not write this class. You can download the file for free from the above URL This is basically an interface between Java and GraphViz

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DOT` Where is your dot program located? It will be called externally.
    `static java.lang.String` | `TEMP_DIR`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GraphViz()` Constructor: creates a new GraphViz object that will contain a graph.

  - ### Method Summary

    Methods
    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.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.
    `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.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### TEMP_DIR

          public static java.lang.String TEMP_DIR

    - #### DOT

          public static java.lang.String DOT

      Where is your dot program located? It will be called externally.

  - ### Constructor Detail

    - #### GraphViz

          public GraphViz()

      Constructor: creates a new GraphViz object that will contain a graph.

  - ### Method Detail

    - #### getDotSource

          public java.lang.String getDotSource()

      Returns the graph's source description in dot language.
      Returns:
        Source of the graph in dot language.

    - #### add

          public void add(java.lang.String line)

      Adds a string to the graph's source (without newline).

    - #### addln

          public void addln(java.lang.String line)

      Adds a string to the graph's source (with newline).

    - #### addln

          public void addln()

      Adds a newline to the graph's source.

    - #### getGraph

          public byte[] getGraph(java.lang.String dot_source,
                        java.lang.String type)

      Returns the graph as an image in binary format.
      Parameters:
        `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.
      Returns:
        A byte array containing the image of the graph.

    - #### writeGraphToFile

          public int writeGraphToFile(byte[] img,
                             java.lang.String file)

      Writes the graph's image in a file.
      Parameters:
        `img` - A byte array containing the image of the graph.
        `file` - Name of the file to where we want to write.
      Returns:
        Success: 1, Failure: -1

    - #### writeGraphToFile

          public int writeGraphToFile(byte[] img,
                             java.io.File to)

      Writes the graph's image in a file.
      Parameters:
        `img` - A byte array containing the image of the graph.
        `to` - A File object to where we want to write.
      Returns:
        Success: 1, Failure: -1

    - #### start_graph

          public java.lang.String start_graph()

      Returns a string that is used to start a graph.
      Returns:
        A string to open a graph.

    - #### end_graph

          public java.lang.String end_graph()

      Returns a string that is used to end a graph.
      Returns:
        A string to close a graph.

    - #### readSource

          public void readSource(java.lang.String input)

      Read a DOT graph from a text file.
      Parameters:
        `input` - Input text file containing the DOT graph source.