jgraph布局不起作用

时间:2011-12-13 21:01:00

标签: java graph graph-visualization

我使用jgraph版本。 5.14.0.0。 (http://www.jgraph.com

当我尝试将布局应用于jgraph时,但由于一些奇怪的原因,它不起作用。

public static void layout(JGraph graph) {
    JGraphFacade facade = new JGraphFacade(graph);
    JGraphSimpleLayout lay = new JGraphSimpleLayout(JGraphSimpleLayout.TYPE_RANDOM, 100, 100);
    lay.run(facade);
}

我运行此代码来布局图形,但单元格不会移动。

我还没找到jgraph库的标签。

1 个答案:

答案 0 :(得分:2)

基于http://anonsvn.jboss.org/repos/jbossas/projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/layout/ReflectionGraphLayout.java,您只缺少几行:

final JGraphSimpleLayout graphLayout =
    new JGraphSimpleLayout(JGraphSimpleLayout.TYPE_RANDOM, 100, 100);
final JGraphFacade graphFacade = new JGraphFacade(jgraph);
graphLayout.run(graphFacade);
final Map nestedMap = graphFacade.createNestedMap(true, true);
jgraph.getGraphLayoutCache().edit(nestedMap);