diff --git a/pom.xml b/pom.xml
index 71c6c4f817c0cf639b436537bc2b770314e75c72..296359213f1fac45fc9721e94940f196b7fe0c0c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,12 +35,6 @@
compile
-
- guru.nidi
- graphviz-java
- 0.8.3
-
-
org.jgrapht
jgrapht-core
diff --git a/src/main/java/tfm/exec/CFGLog.java b/src/main/java/tfm/exec/CFGLog.java
index ebd6b2fe63835fe0c50d36d502fee1d3dc111849..e04a483c0f2649c6a2854ed04f02130706e62a7a 100644
--- a/src/main/java/tfm/exec/CFGLog.java
+++ b/src/main/java/tfm/exec/CFGLog.java
@@ -1,16 +1,9 @@
package tfm.exec;
import com.github.javaparser.ast.Node;
-import guru.nidi.graphviz.engine.Format;
-import guru.nidi.graphviz.engine.Graphviz;
import tfm.graphs.CFGGraph;
-import tfm.utils.FileUtil;
import tfm.visitors.cfg.CFGBuilder;
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-
public class CFGLog extends GraphLog {
public CFGLog() {
diff --git a/src/main/java/tfm/exec/GraphLog.java b/src/main/java/tfm/exec/GraphLog.java
index 5a9db095ed437c27e14ccc64547c27d6aaf0b23c..a3d38faef6a4800ec543f5d5b7769d65df18df0d 100644
--- a/src/main/java/tfm/exec/GraphLog.java
+++ b/src/main/java/tfm/exec/GraphLog.java
@@ -1,16 +1,26 @@
package tfm.exec;
import com.github.javaparser.ast.Node;
-import guru.nidi.graphviz.engine.Format;
-import guru.nidi.graphviz.engine.Graphviz;
import tfm.graphs.Graph;
import tfm.utils.FileUtil;
import tfm.utils.Logger;
-import java.io.File;
-import java.io.IOException;
+import java.io.*;
public abstract class GraphLog {
+ public enum Format {
+ PNG("png"),
+ PDF("pdf");
+
+ private String ext;
+ Format(String ext) {
+ this.ext = ext;
+ }
+
+ public String getExt() {
+ return ext;
+ }
+ }
static final String CFG = "cfg";
static final String PDG = "pdg";
@@ -61,9 +71,22 @@ public abstract class GraphLog {
this.imageName = imageName;
this.format = format;
generated = true;
- Graphviz.fromString(graph.toGraphvizRepresentation())
- .render(format)
- .toFile(getImageFile());
+ File tmpDot = File.createTempFile("graph-source-", ".dot");
+ tmpDot.deleteOnExit();
+ try (Writer w = new FileWriter(tmpDot)) {
+ w.write(graph.toGraphvizRepresentation());
+ }
+ ProcessBuilder pb = new ProcessBuilder("dot",
+ tmpDot.getAbsolutePath(), "-T" + format.getExt(),
+ "-o", getImageFile().getAbsolutePath());
+ try {
+ int result = pb.start().waitFor();
+ if (result != 0) {
+ Logger.log("Image generation failed");
+ }
+ } catch (InterruptedException e) {
+ Logger.log("Image generation failed\n" + e.getMessage());
+ }
}
public void openVisualRepresentation() throws IOException {
@@ -72,6 +95,6 @@ public abstract class GraphLog {
}
protected File getImageFile() {
- return new File("./out/" + imageName + "." + format.name());
+ return new File("./out/" + imageName + "." + format.getExt());
}
}
diff --git a/src/main/java/tfm/exec/PDGLog.java b/src/main/java/tfm/exec/PDGLog.java
index a3efaecb2043b63ae124cd863b1d99f1c4d038b6..a712abe2f2386ee9c6785f4bc02bd210b832f2ae 100644
--- a/src/main/java/tfm/exec/PDGLog.java
+++ b/src/main/java/tfm/exec/PDGLog.java
@@ -1,6 +1,5 @@
package tfm.exec;
-import guru.nidi.graphviz.engine.Format;
import tfm.graphs.PDGGraph;
import tfm.nodes.GraphNode;
import tfm.utils.Logger;