0

我正在尝试为我正在编写的工具生成类图,但是我似乎无法正确布局。

这是我从真实数据生成的示例点文件:

digraph G {
    fontname = "Bitstream Vera Sans"
    fontsize = 8
    splines = "ortho"

    node [
        fontname = "Bitstream Vera Sans"
        fontsize = 8
        shape = "record"
    ]

    edge[
        arrowtail="empty"
        dir="back"
    ]

    Baseclass [
        label = "{xxxxxxxxxx::Baseclass||+ xxxxxxxxxxx \l+ xxxxxxx \l+ xxxxxxxxx \l+ xxxxxxxxxxx \l+ xxxxxxxxxxx \l+ xxxxxxxxxxxx \l+ xxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxx \l+ xxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxx \l+ xxxxxxxxxxx \l+ xxxxxxx \l+ xxxxxxxxxxx \l+ xxxxxxxxxx \l+ xxxxxxxx \l+ xxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \l}"
    ]

    SubclassOne [
        label = "{xxxxxxxxxx::SubclassOne||+ xxxxxxxxxxx \l+ xxxxxxxxxxx \l+ xxxxxxxxxxx \l+ xxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxx \l+ xxxxxxx \l+ xxxxxxxxxxx \l+ xxxxxxxxxx \l+ xxxxxxxx \l+ xxxxxxxxxxxxxxx \l- xxxxxxxxxxxxxxxxxxxxx \l- xxxxxxxxxxxxxxxxxxxxxx \l- xxxxxxxxxxxxxxxxxx \l}"
    ]

    SubclassTwo [
        label = "{xxxxxxxxxx::SubclassTwo||+ xxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxx \l+ xxxxxxx \l+ xxxxxxxxxxx \l+ xxxxxxxxxxx \l+ xxxxxxxxxxxx \l+ xxxxxxxxx \l+ xxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxx \l+ xxxxxxxx \l+ xxxxxxxxxxxxxxx \l}"
    ]

    SubclassThree [
        label = "{xxxxxxxxxx::SubclassThree||+ xxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxx \l+ xxxxxxxx \l+ xxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxx \l+ xxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxx \l+ xxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxx \l+ xxxxxxxx \l+ xxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \l- xxxxxxxxxxxxxxxxxxxxxxxx \l- xxxxxxxxxxxxxxxxxxxxxxxxxxxxx \l- xxxxxxxxxxxxxxxxxxxxxxxxxxx \l- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \l- xxxxxxxxxxxxxx \l- xxxxxxxxxxxxxxxxxxxx \l}"
    ]

    SubclassFour [
        label = "{xxxxxxxxxx::SubclassFour||+ xxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxx \l+ xxxxxxxxxxx \l+ xxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxx \l+ xxxxxxxx \l+ xxxxxxxx \l- xxxxxxxxxxxxxxxxxxxxxx \l- xxxxxxxxxxxxxxxxx \l}"
    ]

    SubclassFive [
        label = "{xxxxxxxxxx::SubclassFive||+ xxxxxxxxxxx \l+ xxxxxxxxxxx \l+ xxxxxxxxxxx \l+ xxxxxxx \l+ xxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxxxxxxxxx \l+ xxxxxxxxxxx \l+ xxxxxxxx \l+ xxxxxxxxxxxxxxx \l- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \l}"
    ]

    Baseclass:s -> SubclassOne:n;
    Baseclass:s -> SubclassTwo:n;
    Baseclass:s -> SubclassThree:n;
    Baseclass:s -> SubclassFour:n;
    Baseclass:s -> SubclassFive:n;
}

它使用graphviz生成以下图像: 给定点文件的输出

I changed the order of the edge relationships to point from the base to the subclass (with a tail arrow) so that the subclass would be ordered higher vertically than the base classes. Long method names are overflowing their containers, and the relationship edges aren't obeying the specified ports on the tail end. It looks like their X position is correct, but the y possition is not. I'd prefer it to look something like this where both the subclass relationship arrows are combined to form a single connection with the bottom center point in the superclass container. If I remove the port specifications, the edges no longer clip into the nodes they connect, but the layout is still not what I'd consider ideal.

没有明确的端口规范

4

1 回答 1

2

正如您所知道的,并且如graphviz 网站上所述,splines=ortho不适用于端口:

值 ortho 指定边缘应作为轴对齐线段的折线布线。目前,路由不处理端口或以点表示的边缘标签。

如果你必须使用 graphviz,你可以考虑添加额外的节点。这个答案包含一个使用这种技术的例子。

于 2013-11-06T15:48:09.033 回答