2013-08-30 3 views
1

을 무시합니다. 대부분의 레이아웃 알고리즘은 움직이지 않는 정점을 움직이지 않습니다. 불행히도 mxHierarchicalLayout은 꼭지점이 움직일 수 있는지 여부를 무시합니다. 나는이 레이아웃 어 그리지가 isVertexMovable을 전혀 사용하지 않는다는 것을 알았다. 버텍스가 움직일 수 있는지 여부는 어디에 추가해야합니까?mxHierarchicalLayout은 JGraphX에서 isVertexMovable

무한 루프를 만들었거나 효과가없는 위치를 시도했습니다.

[편집] JGraphX의 계층 레이아웃에서

public void execute(Object parent, List<Object> roots) 
{ 
    super.execute(parent); 
    mxIGraphModel model = graph.getModel(); 
    // If the roots are set and the parent is set, only 
    // use the roots that are some dependent of the that 
    // parent. 
    // If just the root are set, use them as-is 
    // If just the parent is set use it's immediate 
    // children as the initial set 

    if (roots == null && parent == null) 
    { 
     // TODO indicate the problem 
     return; 
    } 

    if (roots != null && parent != null) 
    { 
     for (Object root : roots) 
     { 
      if (!model.isAncestor(parent, root)) 
      { 
       roots.remove(root); 
      } 
     } 
    } 

    this.roots = roots; 

    model.beginUpdate(); 
    try 
    { 
     run(parent); 

     if (isResizeParent() && !graph.isCellCollapsed(parent)) 
     { 
      graph.updateGroupBounds(new Object[] { parent }, getParentBorder(), isMoveParent()); 
     } 
    } 
    finally 
    { 
     model.endUpdate(); 
    } 
} 



/** 
* The API method used to exercise the layout upon the graph description 
* and produce a separate description of the vertex position and edge 
* routing changes made. 
*/ 
public void run(Object parent) 
{ 
    // Separate out unconnected hierarchies 
    List<Set<Object>> hierarchyVertices = new ArrayList<Set<Object>>(); 
    Set<Object> allVertexSet = new LinkedHashSet<Object>(); 

    if (this.roots == null && parent != null) 
    { 
     Set<Object> filledVertexSet = filterDescendants(parent); 

     this.roots = new ArrayList<Object>(); 

     while (!filledVertexSet.isEmpty()) 
     { 
      List<Object> candidateRoots = findRoots(parent, filledVertexSet); 

      for (Object root : candidateRoots) 
      { 
       Set<Object> vertexSet = new LinkedHashSet<Object>(); 

       for (Object o : vertexSet) 
       { 
        vertexSet.remove(o); 
       } 
       hierarchyVertices.add(vertexSet); 

       traverse(root, true, null, allVertexSet, vertexSet, hierarchyVertices, filledVertexSet); 

      } 

      this.roots.addAll(candidateRoots); 
     } 
    } 
    else 
    { 
     // Find vertex set as directed traversal from roots 
     for (int i = 0; i < roots.size(); i++) 
     { 
      Set<Object> vertexSet = new LinkedHashSet<Object>(); 

      for (Object o : vertexSet) 
      { 
       vertexSet.remove(o); 
      } 


      hierarchyVertices.add(vertexSet); 

      traverse(roots.get(i), true, null, allVertexSet, vertexSet, hierarchyVertices, null); 
     } 
    } 

    // Iterate through the result removing parents who have children in this layout 

    // Perform a layout for each separate hierarchy 
    // Track initial coordinate x-positioning 
    double initialX = 0; 
    Iterator<Set<Object>> iter = hierarchyVertices.iterator(); 

    while (iter.hasNext()) 
    { 
     Set<Object> vertexSet = iter.next(); 

     this.model = new mxGraphHierarchyModel(this, vertexSet.toArray(), roots, parent); 

     cycleStage(parent); 
     layeringStage(); 
     crossingStage(parent); 
     initialX = placementStage(initialX, parent); 
    } 
} 
+0

가능한 경우 일부 코드 게시 – grigno

+0

내가 아는 경우 일부 코드를 추가합니다. , 코드의 어떤 위치가 내가 찾고있는 위치입니다. 나는 if 문을 추가 할 위치를 찾고있다. isVertexMovable(). 필자는 execute 메소드 또는 execute 메소드에 의해 호출되는 메소드에이를 추가해야한다고 생각합니다. 실행 또는 실행 등등에 의해 호출되는 메서드 ... – Andreas

+0

몇 가지 코드를 추가했습니다. 어쩌면 그것은 진입 점이 될 것입니다 ... – Andreas

답변

1

(그리고 나는 그것의 저자)는 레이아웃에 이동할 수 없습니다 계정 정점을 고려하는 것은 매우 어려운 일이다. 만약 그 정점들이 위치에 고정되어 쉽게 랭크가 할당되지 않는다면, 사용 된 알고리즘은 작동하지 않을 것입니다.

레이아웃의 정점을 무시할 수는 있지만 움직일 수없는 것과는 매우 다른 것입니다.

따라서 간단한 알고리즘은 사용 된 알고리즘을 사용하여이 레이아웃에서 이동 가능 플래그를 고려하는 것이 불가능하다는 것입니다. 이 기능에 대해 일반적인 독자에게 도움이되지 않는 특정 사례가있는 경우 여기에서 확장 토론이 아닌 github project issue tracker에 문제를 제기하는 것이 좋습니다