1
그룹을 계층 적 레이아웃으로 배치 된 간단한 그래프에 삽입하면 그룹의 위치가 잘못 지정됩니다. 이 아름다운 그래프그룹이 JGraphX에서 계층 적 레이아웃을 깨기
public class HierarchicalLayoutWithGrouping extends JFrame {
public HierarchicalLayoutWithGrouping() {
super("Hierarchical Layout With Grouping Test");
mxGraph graph = new mxGraph();
Object parent = graph.getDefaultParent();
graph.getModel().beginUpdate();
try {
Object transfer1 = graph.insertVertex(parent, null, "Transfer Data1.csv", 0, 0, 100, 40);
Object transfer2 = graph.insertVertex(parent, null, "Transfer Data2.csv", 0, 0, 100, 40);
Object load1 = graph.insertVertex(parent, null, "Load Data1.csv", 0, 0, 100, 40);
Object load2 = graph.insertVertex(parent, null, "Load Data1.csv", 0, 0, 100, 40);
graph.insertEdge(parent, null, null, transfer1, load1);
graph.insertEdge(parent, null, null, transfer2, load2);
Object calculate = graph.insertVertex(parent, null, "Calculate", 0, 0, 100, 40);
graph.insertEdge(parent, null, null, load1, calculate);
graph.insertEdge(parent, null, null, load2, calculate);
// Object loads = graph.insertVertex(parent, null, "Loads", 0, 0, 200, 400, "shape=swimlane;");
// graph.groupCells(loads, 5, new Object[] { load1, load2 });
mxHierarchicalLayout layout = new mxHierarchicalLayout(graph, SwingConstants.WEST);
layout.execute(parent);
} finally {
graph.getModel().endUpdate();
}
mxGraphComponent graphComponent = new mxGraphComponent(graph);
getContentPane().add(graphComponent);
}
public static void main(String[] args) {
HierarchicalLayoutWithGrouping frame = new HierarchicalLayoutWithGrouping();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 450);
frame.setVisible(true);
}
}
수율 :
하지만 다음 줄의 주석을 해제하는 경우 :
Object loads = graph.insertVertex(parent, null, "Loads", 0, 0, 200, 400, "shape=swimlane;");
graph.groupCells(loads, 5, new Object[] { load1, load2 });
I 예를 들어
, 여기에 간단한 그래프이다 얻으세요 :
나는 mxHierarchicalLayout
에 다양한 옵션을 시도했지만 아직 작동 아무것도 발견하지 않았습니다. 그룹을 올바른 위치에 배치하려면 어떻게해야합니까?
감사합니다.