1

JGraphX では、ほとんどのレイアウト アルゴリズムは移動できない頂点を移動しません。残念ながら mxHierarchicalLayout は、頂点が移動可能かどうかを無視します。このレイアウト アルゴリズムは isVertexMovable をまったく使用していないことがわかりました。頂点が可動かどうかのチェックをどこに追加する必要がありますか。

私が試した位置は、無限ループを生成するか、効果がありません。

[編集]

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);
    }
}
4

1 に答える 1

1

JGraphX の階層レイアウト (私はその作成者です) では、レイアウト内で移動できない頂点を考慮することは非常に困難です。それらの頂点がランクを簡単に割り当てられない位置に固定されている場合、使用されるアルゴリズムは機能しません。

レイアウト内の頂点を無視することは可能ですが、それは移動可能にしない場合とは大きく異なります。

したがって、短い答えは、使用されているアルゴリズムでは、このレイアウトで可動フラグを考慮に入れることができないということです。この機能が一般の読者に利益をもたらさない特定のケースがある場合は、ここでの詳細な議論ではなく、 github プロジェクトの問題トラッカーで問題を提起することをお勧めします。

于 2013-08-31T12:38:57.963 に答える