Grappa Graphviz点可视化问题 [英] Grappa Graphviz dot-Visualization Problem and Questions

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

问题描述

我在测试中使用此点代码:

digraph G { edge [dir=none];
p1 [shape=circle,style=filled,label="",height="0.01",width="0.01"];
q1 [shape=circle,style=filled,label="",height="0.01",width="0.01"];
q2 [shape=circle,style=filled,label="",height="0.01",width="0.01"];
q3 [shape=circle,style=filled,label="",height="0.01",width="0.01"];
{rank=same; father->p1; mother->p1};
{rank=same; q1->q2->q3};
{rank=same; son1; daughter1; daughter2};
p1->q2;
q1->son1;
q2->daughter1;
q3->daughter2;
}

创建图的我的Java代码如下:

Graph graph = null;

    graph = program.getGraph();

    JScrollPane jsp = new JScrollPane();
    jsp.getViewport().setBackingStoreEnabled(true);

    GrappaPanel gp = new GrappaPanel(graph);
    gp.addGrappaListener(new GrappaAdapter());
    gp.setScaleToFit(false);
    jsp.setViewportView(gp);

输出是这样的:链接

树的格式为何如此错误?是否有可能让该树从左到右显示?

解决方案

您必须先询问" graphviz(任何工具,点","neato" ...),然后才能格式化"图形在GrappaPanel中显示它(以一种吸引人的方式).在构造GrappaPanel之前,需要执行以下操作:

String [] processArgs = {"dot"}; // You can use "neato" or whatever formatter you want
Process formatProcess = Runtime.getRuntime().exec(processArgs, null, null);
GrappaSupport.filterGraph(graph, formatProcess);
formatProcess.getOutputStream().close();

在GrappaSupport.filterGraph中的图形"是您的图形.之后,您的图形将正确格式化,并且可以使用GrappaPanel进行查看.结果将比您在链接中发布的内容更加令人愉悦.

希望能有所帮助.

PS:为了使上面的代码起作用,您必须在路径中包含点"(或使用的任何其他格式化程序),否则需要给它提供可执行文件的完整路径./p>

i am using this dot-Code for my Test:

digraph G { edge [dir=none];
p1 [shape=circle,style=filled,label="",height="0.01",width="0.01"];
q1 [shape=circle,style=filled,label="",height="0.01",width="0.01"];
q2 [shape=circle,style=filled,label="",height="0.01",width="0.01"];
q3 [shape=circle,style=filled,label="",height="0.01",width="0.01"];
{rank=same; father->p1; mother->p1};
{rank=same; q1->q2->q3};
{rank=same; son1; daughter1; daughter2};
p1->q2;
q1->son1;
q2->daughter1;
q3->daughter2;
}

My Java Code to create the Graph is the following:

Graph graph = null;

    graph = program.getGraph();

    JScrollPane jsp = new JScrollPane();
    jsp.getViewport().setBackingStoreEnabled(true);

    GrappaPanel gp = new GrappaPanel(graph);
    gp.addGrappaListener(new GrappaAdapter());
    gp.setScaleToFit(false);
    jsp.setViewportView(gp);

The Output is this: Link

Why is the Tree formatted so wrong? And is there an possibility to let the Tree display from left to right?

解决方案

You have to "ask" graphviz (any of the tools, "dot", "neato"...) to "format" the graph before you can display it (in an appealing way) in a GrappaPanel. Before you construct the GrappaPanel, you need to do the following:

String [] processArgs = {"dot"}; // You can use "neato" or whatever formatter you want
Process formatProcess = Runtime.getRuntime().exec(processArgs, null, null);
GrappaSupport.filterGraph(graph, formatProcess);
formatProcess.getOutputStream().close();

Where "graph" in GrappaSupport.filterGraph is your graph. After that, your graph is formatted properly and you can use the GrappaPanel to view it. The result will be more pleasant than what you posted in the link.

Hope that helps, regards.

PS: In order for the above code to work, you have to have "dot" (or any other formatter you use) to be in the path, otherwise you need to give it the full path of the executable file.

这篇关于Grappa Graphviz点可视化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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