我是新来的 JUNG 。我想提请使用TreeLayout树的图形,但树从来没有出来像一个真正的树。每当树看起来不同。我怎样才能让树的样子,顶部和节点从它下降的其余部分的根正常的树?

有帮助吗?

解决方案

您必须添加顶点到图形后,初始化TreeLayout,我试过了,它为我工作。

您需要做的像下面这样:(请注意,这是一个1岁多的代码,我有,你可能会发现这是一个有点过时)

Layout<GraphVertex, GraphEdge> layout; //create a layout
layout = new TreeLayout<GraphVertex, GraphEdge>((Forest<GraphVertex, GraphEdge>) g); 
// initialize your layout using the graph you created, which has to be of type forest
vv.setGraphLayout(layout); 
// set the layout of the visualization viewer you are using to be the layout you just created (the tree layout)

GraphVertex是表示在曲线图中的顶点的类,GraphEdge表示在图中的边。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top