具有多个 children 的 Plantuml class 图:有什么方法可以使箭头分叉?
Plantuml class diagram with multiple children: Any way to bifurcate the arrow?
我的尝试:
Animal <|-- Cat
Animal <|-- Dog
结果:
┌────────┐
│ Animal │
└────────┘
Δ Δ
│ │
┌──┴──┐┌──┴──┐
│ Cat ││ Dog │
└─────┘└─────┘
这不是 class 图应该的样子。
我想要的:
┌────────┐
│ Animal │
└────────┘
Δ
┌──┴───┐
┌──┴──┐┌──┴──┐
│ Cat ││ Dog │
└─────┘└─────┘
按照建议,我在 the PlantUML forum 上问这是否可行。
你可以这样做:
@startuml
class Animal
together {
class Dog
class Cat
}
Animal <|-- Cat
Dog -- (Animal, Cat)
@enduml
在 plantUML 中做一件有趣的事情,但是“这不是 class 图应该看起来的样子”是不正确的(至少据我所知)。
inheritance/generalization的符号很清楚,但是你是在箭头前加入线还是用单独的线和单独的箭头是视觉问题preference/making更容易理解:
- 尝试在您链接的那个 wiki 顶部绘制图像,每个 child 到它的 parent 都有不同的箭头,这样会更乱
- 在 wiki 上向下滚动一点到 https://en.wikipedia.org/wiki/Class_diagram#Generalization/Inheritance
有 skinparam groupInheritance 2
可以满足您的目的,尽管它不能像人们预期的那样与 skinparam linetype ortho
一起使用。唉,GraphViz 是渲染引擎,所以它有局限性。
@startuml
skinparam style strictuml
hide empty members
skinparam groupInheritance 2
class Animal
class Cat extends Animal
class Dog extends Animal
@enduml
我的尝试:
Animal <|-- Cat
Animal <|-- Dog
结果:
┌────────┐
│ Animal │
└────────┘
Δ Δ
│ │
┌──┴──┐┌──┴──┐
│ Cat ││ Dog │
└─────┘└─────┘
这不是 class 图应该的样子。
我想要的:
┌────────┐
│ Animal │
└────────┘
Δ
┌──┴───┐
┌──┴──┐┌──┴──┐
│ Cat ││ Dog │
└─────┘└─────┘
按照建议,我在 the PlantUML forum 上问这是否可行。
你可以这样做:
@startuml
class Animal
together {
class Dog
class Cat
}
Animal <|-- Cat
Dog -- (Animal, Cat)
@enduml
在 plantUML 中做一件有趣的事情,但是“这不是 class 图应该看起来的样子”是不正确的(至少据我所知)。
inheritance/generalization的符号很清楚,但是你是在箭头前加入线还是用单独的线和单独的箭头是视觉问题preference/making更容易理解:
- 尝试在您链接的那个 wiki 顶部绘制图像,每个 child 到它的 parent 都有不同的箭头,这样会更乱
- 在 wiki 上向下滚动一点到 https://en.wikipedia.org/wiki/Class_diagram#Generalization/Inheritance
有 skinparam groupInheritance 2
可以满足您的目的,尽管它不能像人们预期的那样与 skinparam linetype ortho
一起使用。唉,GraphViz 是渲染引擎,所以它有局限性。
@startuml
skinparam style strictuml
hide empty members
skinparam groupInheritance 2
class Animal
class Cat extends Animal
class Dog extends Animal
@enduml