Plantuml 两个类之间的几个箭头
我试图绘制一个类图,其中两个类之间的几种关系是用多重性定义的。
默认情况下,结果很糟糕:
@startuml
class Movie {
genres: String[]
minutes: Integer
movie_id: String
rating: Float
title: String
type: String
votes: Integer
year: Integer
}
class Person {
birthYear: Integer
deathYear: Integer
name: String
person_id: String
}
Person "0..*" -> "1..*" Movie : acted_in
Person "0..*" -> "1..*" Movie : directed
Person "0..*" -> "1..*" Movie : produced
Person "0..*" -> "1..*" Movie : wrote
@enduml
使用 skinparam Nodesep 200
会好一点,但多重性仍然关闭:
我还尝试过使用 skinparam linetype ortho
,它看起来很有前途,但一旦我添加了 hide Circle
和隐藏方法
...
更不用说最终我还想添加一个关联类,这确实毁了它:
这是最终的代码:
skinparam nodesep 200
skinparam linetype ortho
hide circle
hide methods
class Movie {
genres: String[]
minutes: Integer
movie_id: String
rating: Float
title: String
type: String
votes: Integer
year: Integer
}
class Person {
birthYear: Integer
deathYear: Integer
name: String
person_id: String
}
Person "0..*" -> "1..*" Movie : acted_in
Person "0..*" -> "1..*" Movie : directed
Person "0..*" -> "1..*" Movie : produced
Person "0..*" -> "1..*" Movie : wrote
(Person,Movie) .. Role
class Role {
name: String
}
@enduml
我的问题是:有没有办法用 PlantUML 正确绘制它?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道如何直接达到更清晰的箭头布局的目标,但您可以通过使用 Person 作为四个子类(例如 Actor、Director、Producer 和 ScreenplayWriter)的泛化来避免该问题。每一个都有单独的箭头,它可能会让你的图表总体上更清晰(当然,后者取决于你的品味和图表的目的)
I don’t know how to directly reach your goal of a more legible arrow layout but you could avoid the problem by using Person as a generalisation for four sub-classes such as Actor, Director, Producer and ScreenplayWriter. Each of these would have separate arrows and it might make your diagramme also generally clearer (the latter is, of course, subject to your taste and the diagramme’s purpose)
您必须使课程看起来更大,因此将有更多的协会渲染空间。没有Skinparam(唯一的一个是最小的)。但是有了一个技巧,您可以使班级身体更大。
planuml示例
planuml代码:
You have to make class appear bigger, so there will be more space for associations to render. There is no skinparam for that (the only one is for minWidth). But with a trick, you can make class body bigger.
planuml example
planuml code: