从 *.dot 文件可视化树 [英] Visualize tree from *.dot file

查看:61
本文介绍了从 *.dot 文件可视化树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过捕获 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.

推荐答案

  1. 我会先在谷歌上搜索诸如 dot files java 之类的东西,实际上似乎有多种解决方案,例如 ZGRViewer
  2. 可以从 Java 启动外部程序,并且有多种方法可以创建用于安装附加程序的安装程序.

这篇关于从 *.dot 文件可视化树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆