2017-09-15 69 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

亲切的问候