我使用jgraph ver。 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库的标签。

最佳答案

基于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);

07-24 22:26