Class DOT
- 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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
checkUsable()
Checks whether the DOT utility can be successfully invoked.static void
renderDOT(File dotFile, boolean modal)
Renders a GraphVIZ description from aFile
and displays it in a Swing window.static void
renderDOT(Reader r, boolean modal)
Renders a GraphVIZ description from aReader
and displays it in a Swing window.static void
renderDOT(String dotText, boolean modal)
Renders a GraphVIZ description and displays it in a Swing window.static void
renderDOTExternal(File dotFile, String format)
Renders a GraphVIZ description from a file, using an external program for displaying.static void
renderDOTExternal(Reader r, String format)
Renders a GraphVIZ description, using an external program for displaying.static void
renderDOTExternal(String dotText, String format)
Renders a GraphVIZ description from a string, using an external program for displaying.static void
renderDOTFiles(List<Pair<String,File>> files, boolean modal)
Renders multiple (named) GraphVIZ descriptions fromFile
s and displays them in a Swing window.static BufferedImage
renderDOTImage(File dotFile)
Reads a DOT description from a file and returns the PNG rendering result as aBufferedImage
.static BufferedImage
renderDOTImage(Reader dotReader)
Reads a DOT description from a reader and returns the PNG rendering result as aBufferedImage
.static BufferedImage
renderDOTImage(String dotText)
Reads a DOT description from a string and returns the PNG rendering result as aBufferedImage
.static void
renderDOTReaders(List<Pair<String,Reader>> readers, boolean modal)
Renders multiple (named) GraphVIZ descriptions fromReader
s and displays them in a Swing window.static void
renderDOTStrings(List<Pair<String,String>> dotTexts, boolean modal)
Renders multiple (named) GraphVIZ descriptions and displays them in a Swing window.static void
runDOT(File dotFile, String format, File out)
Invokes the DOT utility on a file, producing an output file.static InputStream
runDOT(File dotFile, String format, String... additionalOpts)
Invokes the DOT utility on a file.static void
runDOT(Reader r, String format, File out)
Invokes the GraphVIZ DOT utility for rendering graphs, writing output to the specified file.static InputStream
runDOT(Reader r, String format, String... additionalOpts)
Invokes the GraphVIZ DOT utility for rendering graphs.static void
runDOT(String dotText, String format, File out)
Invokes the DOT utility on a string, producing an output file.static InputStream
runDOT(String dotText, String format, String... additionalOpts)
Invokes the DOT utility on a string.static void
setDotExe(String dotExe)
Explicitly sets the path to the DOT utility executable.
-
-
-
Method Detail
-
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.
-
runDOT
public static InputStream runDOT(File dotFile, String format, String... additionalOpts) throws IOException
Invokes the DOT utility on a file. Convenience method, seerunDOT(Reader, String, String...)
.- Throws:
IOException
- if reading from the file or the call to the DOT utility fails.
-
runDOT
public static InputStream runDOT(Reader r, String format, String... additionalOpts) throws IOException
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, ...- 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.
-
runDOT
public static InputStream runDOT(String dotText, String format, String... additionalOpts) throws IOException
Invokes the DOT utility on a string. Convenience method, seerunDOT(Reader, String, String...)
- Throws:
IOException
- if the call to the DOT utility fails.
-
runDOT
public static void runDOT(File dotFile, String format, File out) throws IOException
Invokes the DOT utility on a file, producing an output file. Convenience method, seerunDOT(Reader, String, File)
.- Throws:
IOException
- if reading from the file, the call to the DOT utility, or writing to the file fails.
-
runDOT
public static void runDOT(Reader r, String format, File out) throws IOException
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.
-
runDOT
public static void runDOT(String dotText, String format, File out) throws IOException
Invokes the DOT utility on a string, producing an output file. Convenience method, seerunDOT(Reader, String, File)
.- Throws:
IOException
- if the call to the DOT utility or writing to the file fails.
-
renderDOTExternal
public static void renderDOTExternal(File dotFile, String format) throws IOException
Renders a GraphVIZ description from a file, using an external program for displaying. Convenience method, seerenderDOTExternal(Reader, String)
.- Throws:
IOException
- if reading from the file or the call to the DOT utility fails.
-
renderDOTExternal
public static void renderDOTExternal(Reader r, String format) throws IOException
Renders a GraphVIZ description, using an external program for displaying. The program is determined by the system's file type associations, using theDesktop.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, ...- Throws:
IOException
- if reading from the reader or the call to the DOT utility fails.
-
renderDOTExternal
public static void renderDOTExternal(String dotText, String format) throws IOException
Renders a GraphVIZ description from a string, using an external program for displaying. Convenience method, seerenderDOTExternal(Reader, String)
.- Throws:
IOException
- if the call to the DOT utility fails.
-
renderDOT
public static void renderDOT(File dotFile, boolean modal) throws IOException
Renders a GraphVIZ description from aFile
and displays it in a Swing window. Convenience method, seerenderDOT(Reader, boolean)
.- Throws:
IOException
- if reading from the file or the call to the DOT utility fails.
-
renderDOT
public static void renderDOT(Reader r, boolean modal) throws IOException
Renders a GraphVIZ description from aReader
and displays it in a Swing window. Convenience method, seerenderDOT(String, boolean)
.- Throws:
IOException
- if reading from the reader or the call to the DOT utility fails.
-
renderDOT
public static void renderDOT(String dotText, boolean modal) throws IOException
Renders a GraphVIZ description and displays it in a Swing window.- Parameters:
dotText
- theString
from which the description is obtained.modal
- whether the dialog should be modal.- Throws:
IOException
- if the call to the DOT utility fails.
-
renderDOTFiles
public static void renderDOTFiles(List<Pair<String,File>> files, boolean modal) throws IOException
Renders multiple (named) GraphVIZ descriptions fromFile
s and displays them in a Swing window. Convenience method, seerenderDOTStrings(List, boolean)
.- Throws:
IOException
- if reading from the files or the calls to the DOT utility fail.
-
renderDOTReaders
public static void renderDOTReaders(List<Pair<String,Reader>> readers, boolean modal) throws IOException
Renders multiple (named) GraphVIZ descriptions fromReader
s and displays them in a Swing window. Convenience method, seerenderDOTStrings(List, boolean)
.- Throws:
IOException
- if reading from the readers or the calls to the DOT utility fail.
-
renderDOTStrings
public static void renderDOTStrings(List<Pair<String,String>> dotTexts, boolean modal) throws IOException
Renders multiple (named) GraphVIZ descriptions and displays them in a Swing window.- Parameters:
dotTexts
- theString
s from which the description is obtained. The first element of thePair
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.
-
renderDOTImage
public static BufferedImage renderDOTImage(File dotFile) throws IOException
Reads a DOT description from a file and returns the PNG rendering result as aBufferedImage
.- 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.
-
renderDOTImage
public static BufferedImage renderDOTImage(Reader dotReader) throws IOException
Reads a DOT description from a reader and returns the PNG rendering result as aBufferedImage
.- 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.
-
renderDOTImage
public static BufferedImage renderDOTImage(String dotText) throws IOException
Reads a DOT description from a string and returns the PNG rendering result as aBufferedImage
.- Parameters:
dotText
- the DOT description- Returns:
- the rendering result
- Throws:
IOException
- if the call to the DOT utility fails.
-
-