AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
aud.util.Graphviz Class Reference

Use GraphViz to render graph structures. More...

+ Collaboration diagram for aud.util.Graphviz:

Public Member Functions

File renderDotFileToFile (File dotfile, String format)
 Render dot file. More...
 
void displayAsPDF (String dotCode)
 Render and display dotCode. More...
 
void displayAsPDF (Graphvizable object)
 Display object. More...
 
DotViewer display (String dotCode)
 Render and display dotCode. More...
 
DotViewer display (Graphvizable object)
 Display object. More...
 

Detailed Description

Use GraphViz to render graph structures.

Requires an installation of GraphViz.

See also
Sys
Sys.ExternalProgram
Graphvizable
DotViewer

Definition at line 15 of file Graphviz.java.

Member Function Documentation

◆ display() [1/2]

DotViewer aud.util.Graphviz.display ( Graphvizable  object)

Display object.

Returns
viewer instance

Definition at line 87 of file Graphviz.java.

87 {
88 return DotViewer.displayWindow(object,"aud.util.DotViewer");
89 }

References aud.util.DotViewer.displayWindow().

+ Here is the call graph for this function:

◆ display() [2/2]

DotViewer aud.util.Graphviz.display ( String  dotCode)

Render and display dotCode.

Returns
viewer instance

Definition at line 81 of file Graphviz.java.

81 {
82 return DotViewer.displayWindow(dotCode,"aud.util.DotViewer");
83 }

References aud.util.DotViewer.displayWindow().

+ Here is the call graph for this function:

◆ displayAsPDF() [1/2]

void aud.util.Graphviz.displayAsPDF ( Graphvizable  object)

Display object.

See also
displayAsPDF

Definition at line 75 of file Graphviz.java.

75 {
76 displayAsPDF(object.toDot());
77 }
void displayAsPDF(String dotCode)
Render and display dotCode.
Definition: Graphviz.java:65

References aud.util.Graphviz.displayAsPDF().

+ Here is the call graph for this function:

◆ displayAsPDF() [2/2]

void aud.util.Graphviz.displayAsPDF ( String  dotCode)

Render and display dotCode.

Bug:
The generated PDF file is not removed! (There is no portable and trivial way to ensure removal.)

Definition at line 65 of file Graphviz.java.

65 {
66 File dotfile=Sys.writeToTempFile(dotCode,".dot");
67 File pdffile=renderDotFileToFile(dotfile,"pdf");
68 //dotfile.delete();
69 Sys.viewPDFFile(pdffile.getPath());
70 }
File renderDotFileToFile(File dotfile, String format)
Render dot file.
Definition: Graphviz.java:36

References aud.util.Graphviz.renderDotFileToFile(), aud.util.Sys.viewPDFFile(), and aud.util.Sys.writeToTempFile().

Referenced by aud.util.Graphviz.displayAsPDF().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderDotFileToFile()

File aud.util.Graphviz.renderDotFileToFile ( File  dotfile,
String  format 
)

Render dot file.

Excutes GraphViz dot and writes an output file ditfile+"."+format.

Definition at line 36 of file Graphviz.java.

36 {
37 File out=new File(dotfile.getPath()+"."+format);
38 String command=DOT.getPath()+" -T"+format+" "+dotfile.getPath()+" -o "+out;
39 //System.err.println(command);
40 // note: command is obsolete (used only in error message)
41 try {
42 ProcessBuilder pb = new ProcessBuilder
43 (DOT.getPath(),"-T" + format,dotfile.getPath(),"-o",out.getPath());
44 Process dot=pb.start();
45
46 if (dot.waitFor()!=0) {
47 System.err.println("ERROR: '"+command+"' failed");
48 }
49 }
50 catch (IOException e) {
51 System.err.println("ERROR: "+e.getMessage());
52 return null; // note: probably triggers NullPointerException
53 }
54 catch (InterruptedException e) {
55 System.err.println("ERROR: "+e.getMessage());
56 return null; // note: probably triggers NullPointerException
57 }
58 return out;
59 }

Referenced by aud.util.DotViewer.display(), and aud.util.Graphviz.displayAsPDF().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: