用于继承的PlantUML脚本

时间:2017-03-02 09:01:48

标签: plantuml

Inheritance hierarchy diagram

每当我从同一个界面扩展两个接口时,在图中,它会创建单独的箭头。我只想要一个像这样分支的单箭头。 PlantUML中是否有任何脚本可以执行此操作?

2 个答案:

答案 0 :(得分:1)

PlantUML使用的工具集 - GraphViz主要用于绘制图形(即节点和边缘);因此,个人的实现关系。

虽然显示这样的实现在描绘界面层次结构时很有用,但是图表很快就会成为关系的“老鼠窝”,可能会掩盖整体情况。

您可能会考虑更喜欢使用简写的“Lollipop”符号来表示接口的实现。例如,

enter image description here

如果要在同一个图表中显示界面详细信息,布局有时会有点棘手。产生上述内容的脚本如下:

@startuml
together {
   interface Widget {
     callFred()
     callBarney()
   }

   class A
   class B
   class C
}

Widget ()- A
Widget ()- B
Widget ()- C
@enduml

答案 1 :(得分:0)

如果只希望两个继承实体共享一个箭头,则可以将第二个实体连接到将第一个实体与其概括相连接的线:

let temp = 76
switch temp {
case .min ..<  0: print("Too Cold for Outdoors")
case    0 ..< 21: print("Very Cold Weather")
case   21 ..< 41: print("Cold")
case   41 ..< 61: print("Normal")
case   61 ..< 81: print("Nice")
case   81 ..< 91: print("Warm")
default: print("Hot")
}


不幸的是,如果您尝试更多操作,它会产生更多行,因此不起作用。例如

class Entity
class Generalization
class OtherEntity
Generalization <|-- Entity
(Entity, Generalization) -- OtherEntity

给出以下内容:

这不是我们想要的。

相关问题