java.lang.Object
net.automatalib.visualization.dot.DOT

public final class DOT extends Object
Utility class to simplify operating the GraphVIZ "dot" utility. Please note that all the provided methods require GraphVIZ to be installed on the system, and that the "dot" binary resides in the execution path.
  • Method Details

    • setDotExe

      public static void setDotExe(String dotExe)
      Explicitly sets the path to the DOT utility executable.
      Parameters:
      dotExe - the path to the DOT utility executable
    • checkUsable

      public static boolean checkUsable()
      Checks whether the DOT utility can be successfully invoked.
      Returns:
      whether the DOT utility can be successfully invoked
    • runDOT

      public static InputStream runDOT(File dotFile, String format, String... additionalOpts) throws IOException, InterruptedException
      Invokes the DOT utility on a file. Convenience method for runDOT(Reader, String, String...).
      Parameters:
      dotFile - the file from which the GraphVIZ description is obtained
      format - the output format, as understood by the dot utility, e.g., png, ps, etc.
      additionalOpts - additional parameters passed to the dot invocation
      Returns:
      an input stream from which the image data can be read
      Throws:
      IOException - if reading from the file or the call to the DOT utility fails.
      InterruptedException - if the process is interrupted prior to finishing
    • runDOT

      public static InputStream runDOT(Reader r, String format, String... additionalOpts) throws IOException, InterruptedException
      Invokes the GraphVIZ DOT utility for rendering graphs.
      Parameters:
      r - the reader from which the GraphVIZ description is obtained
      format - the output format, as understood by the dot utility, e.g., png, ps, etc.
      additionalOpts - additional parameters passed to the dot invocation
      Returns:
      an input stream from which the image data can be read
      Throws:
      IOException - if reading from the reader or the call to the DOT utility fails.
      InterruptedException - if the process is interrupted prior to finishing
    • runDOT

      public static InputStream runDOT(String dotText, String format, String... additionalOpts) throws IOException, InterruptedException
      Invokes the DOT utility on a string. Convenience method for runDOT(Reader, String, String...).
      Parameters:
      dotText - the string from which the GraphVIZ description is obtained
      format - the output format, as understood by the dot utility, e.g., png, ps, etc.
      additionalOpts - additional parameters passed to the dot invocation
      Returns:
      an input stream from which the image data can be read
      Throws:
      IOException - if the call to the DOT utility fails.
      InterruptedException - if the process is interrupted prior to finishing
    • runDOT

      public static void runDOT(File dotFile, String format, File out) throws IOException, InterruptedException
      Invokes the DOT utility on a file, producing an output file. Convenience method for runDOT(Reader, String, File).
      Parameters:
      dotFile - the file from which the GraphVIZ description is read
      format - the output format to produce
      out - the file to which the output is written
      Throws:
      IOException - if reading from the file, the call to the DOT utility, or writing to the file fails.
      InterruptedException - if the process is interrupted prior to finishing
    • runDOT

      public static void runDOT(Reader r, String format, File out) throws IOException, InterruptedException
      Invokes the GraphVIZ DOT utility for rendering graphs, writing output to the specified file.
      Parameters:
      r - the reader from which the GraphVIZ description is read
      format - the output format to produce
      out - the file to which the output is written.
      Throws:
      IOException - if reading from the reader, the call to the DOT utility, or writing to the file fails.
      InterruptedException - if the process is interrupted prior to finishing
    • runDOT

      public static void runDOT(String dotText, String format, File out) throws IOException, InterruptedException
      Invokes the DOT utility on a string, producing an output file. Convenience method for runDOT(Reader, String, File).
      Parameters:
      dotText - the string from which the GraphVIZ description is read
      format - the output format to produce
      out - the file to which the output is written
      Throws:
      IOException - if the call to the DOT utility or writing to the file fails.
      InterruptedException - if the process is interrupted prior to finishing
    • renderDOTExternal

      public static void renderDOTExternal(File dotFile, String format) throws IOException, InterruptedException
      Renders a GraphVIZ description from a file, using an external program for displaying. Convenience method for renderDOTExternal(Reader, String).
      Parameters:
      dotFile - the file from which the GraphVIZ description is read
      format - the output format, as understood by the dot utility, e.g., png, ps, etc.
      Throws:
      IOException - if reading from the file or the call to the DOT utility fails.
      InterruptedException - if the process is interrupted prior to finishing
    • renderDOTExternal

      public static void renderDOTExternal(Reader r, String format) throws IOException, InterruptedException
      Renders a GraphVIZ description, using an external program for displaying. The program is determined by the system's file type associations, using the Desktop.open(File) method.
      Parameters:
      r - the reader from which the GraphVIZ description is read
      format - the output format, as understood by the dot utility, e.g., png, ps, etc.
      Throws:
      IOException - if reading from the reader or the call to the DOT utility fails.
      InterruptedException - if the process is interrupted prior to finishing
    • renderDOTExternal

      public static void renderDOTExternal(String dotText, String format) throws IOException, InterruptedException
      Renders a GraphVIZ description from a string, using an external program for displaying. Convenience method for renderDOTExternal(Reader, String).
      Parameters:
      dotText - the string from which the GraphVIZ description is read.
      format - the output format, as understood by the dot utility, e.g., png, ps, etc.
      Throws:
      IOException - if the call to the DOT utility fails.
      InterruptedException - if the process is interrupted prior to finishing
    • renderDOT

      public static void renderDOT(File dotFile, boolean modal) throws IOException, InterruptedException
      Renders a GraphVIZ description from a File and displays it in a Swing window. Convenience method for renderDOT(Reader, boolean).
      Parameters:
      dotFile - the file from which the description is obtained
      modal - whether the dialog should be modal
      Throws:
      IOException - if reading from the file or the call to the DOT utility fails.
      InterruptedException - if the process is interrupted prior to finishing
    • renderDOT

      public static void renderDOT(Reader r, boolean modal) throws IOException, InterruptedException
      Renders a GraphVIZ description from a Reader and displays it in a Swing window. Convenience method for renderDOT(String, boolean).
      Parameters:
      r - the reader from which the description is obtained
      modal - whether the dialog should be modal
      Throws:
      IOException - if reading from the reader or the call to the DOT utility fails.
      InterruptedException - if the process is interrupted prior to finishing
    • renderDOT

      public static void renderDOT(String dotText, boolean modal) throws IOException, InterruptedException
      Renders a GraphVIZ description and displays it in a Swing window.
      Parameters:
      dotText - the string from which the description is obtained
      modal - whether the dialog should be modal
      Throws:
      IOException - if the call to the DOT utility fails.
      InterruptedException - if the process is interrupted prior to finishing
    • renderDOTFiles

      public static void renderDOTFiles(List<Pair<String,File>> files, boolean modal) throws IOException, InterruptedException
      Renders multiple (named) GraphVIZ descriptions from Files and displays them in a Swing window. Convenience method for renderDOTStrings(List, boolean).
      Parameters:
      files - the file from which the description is obtained. The first element of the Pair should contain the name, the second element should contain the DOT file.
      modal - whether the dialog should be modal
      Throws:
      IOException - if reading from the files or the calls to the DOT utility fail.
      InterruptedException - if the process is interrupted prior to finishing
    • renderDOTReaders

      public static void renderDOTReaders(List<Pair<String,Reader>> readers, boolean modal) throws IOException, InterruptedException
      Renders multiple (named) GraphVIZ descriptions from Readers and displays them in a Swing window. Convenience method for renderDOTStrings(List, boolean).
      Parameters:
      readers - the readers from which the description is obtained. The first element of the Pair should contain the name, the second element should contain a reader for the DOT definition.
      modal - whether the dialog should be modal
      Throws:
      IOException - if reading from the readers or the calls to the DOT utility fail.
      InterruptedException - if the process is interrupted prior to finishing
    • renderDOTStrings

      public static void renderDOTStrings(List<Pair<String,String>> dotTexts, boolean modal) throws IOException, InterruptedException
      Renders multiple (named) GraphVIZ descriptions and displays them in a Swing window.
      Parameters:
      dotTexts - the strings from which the description is obtained. The first element of the Pair should contain the name, the second element should contain the DOT code.
      modal - whether the dialog should be modal
      Throws:
      IOException - if the calls to the DOT utility fail.
      InterruptedException - if the process is interrupted prior to finishing
    • renderDOTImage

      public static BufferedImage renderDOTImage(File dotFile) throws IOException, InterruptedException
      Reads a DOT description from a file and returns the PNG rendering result as a BufferedImage.
      Parameters:
      dotFile - the file containing the DOT description
      Returns:
      the rendering result
      Throws:
      IOException - if reading from the file or the call to the DOT utility fails.
      InterruptedException - if the process is interrupted prior to finishing
    • renderDOTImage

      public static BufferedImage renderDOTImage(Reader dotReader) throws IOException, InterruptedException
      Reads a DOT description from a reader and returns the PNG rendering result as a BufferedImage.
      Parameters:
      dotReader - the reader from which to read the description
      Returns:
      the rendering result
      Throws:
      IOException - if reading from the reader or the call to the DOT utility fails.
      InterruptedException - if the process is interrupted prior to finishing
    • renderDOTImage

      public static BufferedImage renderDOTImage(String dotText) throws IOException, InterruptedException
      Reads a DOT description from a string and returns the PNG rendering result as a BufferedImage.
      Parameters:
      dotText - the DOT description
      Returns:
      the rendering result
      Throws:
      IOException - if the call to the DOT utility fails.
      InterruptedException - if the process is interrupted prior to finishing