我正在尝试为我正在编写的工具生成类图,但是我似乎无法使布局正确。
这是我从真实数据生成的示例点文件:
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- xxxxxxx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xxxx \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生成以下图像:
我将边缘关系的顺序更改为从基点到子类(带有尾部箭头),以便子类的顺序高于基类。长方法名称溢出其容器,并且关系边缘不遵循尾端的指定端口。看起来他们的X位置是正确的,但是y的位置不是。我希望它看起来something like this,其中两个子类关系箭头被组合在一起形成与超类容器中底部中心点的单个连接。如果我删除端口规范,边缘不再夹在它们连接的节点中,但布局仍然不是我认为理想的。
答案 0 :(得分:2)
正如您所想,并且如graphviz web site所述,splines=ortho
不适用于端口:
值ortho指定边缘应路由为轴对齐线段的折线。目前,路由不处理端口或点,边缘标签。
如果必须使用graphviz,可以考虑添加其他节点。 This answer包含使用此技术的示例。