2017-09-15 136 views
1

我正在使用jgraphx可視化方法內的控件低。因此,我使用mxHierarchicalLayout。但是在結果圖中兩個節點之間的距離太大。 (見圖片)jgraphx:層次佈局減少節點之間的距離

enter image description here

我想減少黃色標記的區域。

林添加節點具有:

Object v1 = graph.insertVertex(parent, u.toString(), u.toString(), 0, 0, 0, 0); 

將它們全部設置爲相同的位置。之後我使用mxHierarchicalLayout:

// define layout 
mxIGraphLayout layout = new mxHierarchicalLayout(graph); 
// layout graph 
layout.execute(graph.getDefaultParent()); 

有沒有辦法壓縮圖形用戶界面?

回答

1

有兩個參數上的分層佈局節點之間限定間距:

  • intraCellSpacing水平間距
  • interRankCellSpacing垂直間距(行列之間的空間,層,層次)

所以,你正在尋找第二個。

緊湊例如:

var layout = new mxHierarchicalLayout(graph); 
layout.edgeStyle=2; 
layout.intraCellSpacing=20; 
layout.interRankCellSpacing=40; 

Compact mxGraph with hierarchical layout

的擴展案例:

var layout = new mxHierarchicalLayout(graph); 
layout.edgeStyle=4; 
layout.intraCellSpacing=20; 
layout.interRankCellSpacing=70; 

Expanded mxGraph with hierarchical layout

你可以看到有在示例的另一個參數edgeStyle定義不同風格的邊緣

欲瞭解更多信息,看看mxGraph Hierarchical layout documentation

親切的問候