2011-12-13 158 views
1

我使用jgraph ver。 5.14.0.0。 (http://www.jgraph.comjgraph佈局不起作用

當我嘗試將佈局應用於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 library的標籤。

回答

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