1

我正在尝试将水平树和分层布局结合起来。我希望我的图表的上半部分是树形布局并水平绘制,下半部分是分层布局。我尝试在同一个 beginUpdate 块中添加树布局和层次布局,但我观察到层次布局优先并覆盖图形的树布局。

有没有办法克服这个问题?以下是我所拥有的 -

graph.getModel().beginUpdate();
try
{
Object v1 = graph.insertVertex(parent, null, "Hello", 1, 1, 80,
                30);
Object v2 = graph.insertVertex(parent, null, "World!", 1, 1,
                80, 30,"shape=rhombus;perimeter=rhombusPerimeter");

graph.insertEdge(parent, null, "Edge", v1, v2);
/* Apply tree Layout*/
mxCompactTreeLayout layout = new mxCompactTreeLayout(graph,true); 
layout.execute(graph.getDefaultParent());

Object v3 = graph.insertVertex(parent, null, "Bye", 1, 1,80, 30,"shape=ellipse;perimeter=ellipsePerimeter");
Object v4 = graph.insertVertex(parent, null, "NoBye", 1, 1,80, 30,"shape=ellipse;perimeter=ellipsePerimeter");

//Object v5 = graph.insertVertex(parent, null, "Desc", 1, 1,
//  80, 30,"shape=ellipse;perimeter=ellipsePerimeter");

Object v6 = graph.insertVertex(parent, null, "World2!", 1, 1,80, 30,"shape=rhombus;perimeter=rhombusPerimeter");

graph.insertEdge(parent, null, "Yes", v2, v3);
graph.insertEdge(parent, null, "No", v2, v4);
graph.insertEdge(parent, null, "", v1, v6);

//Apply Hierarchial layout now
mxHierarchicalLayout layout1 = new mxHierarchicalLayout(graph ); 
layout1.setDisableEdgeStyle(false);
layout1.setFineTuning(true);
layout1.setIntraCellSpacing(50);
layout1.execute(graph.getDefaultParent());
}
finally
{
graph.getModel().endUpdate();
}
4

0 回答 0