2013-09-03 1 views
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); 
    } 
} 

수율 :

enter image description here

하지만 다음 줄의 주석을 해제하는 경우 :

  Object loads = graph.insertVertex(parent, null, "Loads", 0, 0, 200, 400, "shape=swimlane;"); 
      graph.groupCells(loads, 5, new Object[] { load1, load2 }); 

I 예를 들어

, 여기에 간단한 그래프이다 얻으세요 :

enter image description here

나는 mxHierarchicalLayout에 다양한 옵션을 시도했지만 아직 작동 아무것도 발견하지 않았습니다. 그룹을 올바른 위치에 배치하려면 어떻게해야합니까?

감사합니다.

답변

0

그룹화 상자가 그룹화되지 않은 노드로 다른 계층 구조를 얻는 것을 발견했습니다. 이것이 각 그룹 상자가 새로운 행으로 이동되는 이유입니다. 나 자신의 레이아웃 알고리즘을 작성하거나 레이아웃 실행 중에 계층 속성을 생성하는 메소드를 대체하는 다른 가능성은 없다고 생각합니다.