【问题标题】:How to change the length of an edge in TreeLayout JUNG?如何更改 TreeLayout JUNG 中边的长度?
【发布时间】:2015-04-16 07:24:46
【问题描述】:

我知道如何更改顶点的大小,但是当我这样做时,TreeLayout 会放置节点以使边缘消失,即。节点重叠,边缘不可见。如果我更改布局(到 KKLayout),边缘会自动变大,并且图形看起来很干净。我想知道是否可以在 TreeLayout 本身中将节点分开/增加边缘的长度? (维护树层次结构的任何其他建议也很棒)

【问题讨论】:

    标签: java jung jung2


    【解决方案1】:

    您可以在构建TreeLayout 时定义节点之间的空间。这会增加边长:

    TreeLayout treeLayout = new TreeLayout<String, Integer>(graph, 500, 500);
    

    如果您不输入 distxdisty 的值,则默认为 50。构造函数:

    /**
     * Creates an instance for the specified graph, X distance, and Y distance.
     */
    public TreeLayout(Forest<V,E> g, int distx, int disty) {
        if (g == null)
            throw new IllegalArgumentException("Graph must be non-null");
        if (distx < 1 || disty < 1)
            throw new IllegalArgumentException("X and Y distances must each be positive");
        this.graph = g;
        this.distX = distx;
        this.distY = disty;
        buildTree();
    }
    

    【讨论】:

    • 我是否必须扩展 TreeLayout 类并覆盖构造函数?
    • 不,只使用给定的构造函数。它已经在 TreeLayout 的类中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多