plantuml 之用例图(二)

  • 指定连接箭头方向
  • 添加注释
  • 构造型
  • 改变 actor 与用例背景色

指定连接箭头方向

下面的描述适用于 [连接] 和 [扩展].

  • --> 改为 <-- 可改变方向
  • 默认时, 一个 - 为水平, 多个 - 为垂直
  • left, right, up, down 关键字指定了连接方向

效果见图 2-6.


plantuml 之用例图(二)_第1张图片
图 2-6

图 2-6 代码

@startuml

'
:user 1: --> (Use case 1)
:user 2: <-- (Use case 2)

'
:user 3: -left-> (left)
:user 4: -right-> (right)
:user 5: -up-> (up)
:user 6: -down-> (down)

@enduml

添加注释

  • note, 配合 as 指定别名
  • note left of
  • note right of
  • note top of
  • note bottom of
  • end note 结束多行注释

使用 .. 将注释连接到用例或 actor, 垂直连接. . 的连接形状与 .. 同, 但为
水平连接. 可以加上箭头符号, 如 ..>.

可以用 - 代替 ..

另外, 可以使用 left, right, up, down 关键字指定了连接方向.

效果见图 2-7.


plantuml 之用例图(二)_第2张图片
图 2-7

图 2-7 代码

@startuml

:Admin: ---> (Use)

note right of Admin : Note right

note right of (Use)

Note right
    serveral lines
end note

note "Note\nconnects several objects." as N2

(Start) .. N2
N2 .. (Use)

@enduml

构造型

通过 <> 指定构造型. 效果见图 2-8.


plantuml 之用例图(二)_第3张图片
图 2-8

图 2-8 代码, 来自官方文档

@startuml

User << Human >>
:Main Database: as MySql << Application >>
(Start) << One Shot >>
(Use the application) as (Use) << Main >>
User -> (Start)
User --> (Use)
MySql --> (Use)

@enduml

改变 actor 与用例背景色

使用 #COLOR 语法可以改变 actor 与用例的背景色, 也可以改变连接的颜色.

  • 在 actor 或用例之后使用 #COLOR
  • 在连接语句最后使用 #COLOR

效果如图 2-9 所示.


plantuml 之用例图(二)_第4张图片
图 2-9

图 2-9 代码, 来自官方文档

@startuml

' actor
actor First #Red
Second #Blue

' 用例
(FirstUC) #Red
usecase SecondUC #Blue

' 连接
First -> FirstUC #Green
Second --> SecondUC #Green

@enduml

你可能感兴趣的:(UML)