从 *.dot 文件可视化树 [英] Visualize tree from *.dot file
问题描述
我需要通过捕获 ANLR 点生成器生成的控制台输出来可视化我从 ANTLR 解析器获取并写入 .dot 文件的树.
I need to visualize a tree which I have gotten from an ANTLR parser and written to a .dot file by catching console output that the ANLR dot generator produces.
MyDOTTreeGenerator generator = new MyDOTTreeGenerator();
PrintStream old = System.out;
try {
System.setOut(new PrintStream(new FileOutputStream(graphFile)));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
System.out.println(generator.toDOT(root));
System.out.flush();
System.setOut(old);
问题是:
1. 有没有办法在我的程序中可视化 .dot 文件,例如 Swing 组件.
2. 我已经阅读/尝试在 Grappa 库 + Graphviz 工具包的帮助下使用 这种方法 => 有没有一种方法可以在我的程序中打包 Graphviz 工具包,以便我可以可视化图形而无需最终用户下载和/或安装某些东西.
Question is:
1. Is there a way to visualize the .dot file in my program, Swing component for example.
2. I have read/tried to visualize with the help of Grappa library + Graphviz toolkit using this approach => is there a way I can pack the Graphviz toolkit in my program, so that I can visualize the graph without the end user having to download and/or install something.
推荐答案
- 我会先在谷歌上搜索诸如 dot files java 之类的东西,实际上似乎有多种解决方案,例如 ZGRViewer
- 可以从 Java 启动外部程序,并且有多种方法可以创建用于安装附加程序的安装程序.
这篇关于从 *.dot 文件可视化树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!