PlantUML

  1. 类图
    1. 辅助布局
    2. 命名空间
  2. 时序图
  3. 用例图
  4. 活动图
  5. 组件图
  6. 状态图
  7. 对象图
  8. 思维导图

类图

@startuml
abstract        抽象
abstract class  抽象(等同abstract)
annotation      注解
circle          圆
()              圆缩写形式
class           类
diamond         菱形
<>              菱形写形式
entity          实例
enum            枚举
interface       接口
@enduml

线标记

  • --|> 继承
  • --* 组合
  • --o 聚合

方法和属性的访问性质

  • + public
  • - private
  • # protected
  • ~ package

辅助布局

@startuml

class Bar1 class Bar2 together { class Together1 class Together2 class Together3 } Together1 - Together2 Together2 - Together3 Together2 -[hidden]--> Bar1 Bar1 -[hidden]> Bar2

@enduml

加入了together-[hidden]-来支持辅助布局

命名空间

@startuml namespace

class net.Network { int address
ip_prefix() } @enduml

时序图

  • ++ 激活目标(可选择在后面加上#color)
  • – 撤销激活源
  • ** 创建目标实例
  • !! 摧毁目标实例
@startuml
alice -> bob ++: hello
bob -> bob ++: self call
bob -> bib ++ #green: hello
bob -> george **: **create**
return done
return rc
bob -> george !! : delete
return succuse
@enduml

锚点和持续时间

@startuml
!pragma teoz true

{start} Alice -> Bob : start doing things during duration Bob -> Max : something Max -> Bob : something else {end} Bob -> Alice : finish
{start} <-> {end} : some time
@enduml

用例图

活动图

@startuml

start :ClickServlet.handleRequest(); :new page; if (Page.onSecurityCheck) then (true) :Page.onInit(); if (isForward?) then (no) :Process controls; if (continue processing?) then (no) stop endif
if (isPost?) then (yes) :Page.onPost(); else (no) :Page.onGet(); endif :Page.onRender(); endif else (false) endif
if (do redirect?) then (yes) :redirect process; else if (do forward?) then (yes) :Forward request; else (no) :Render page template; endif endif
stop
@enduml

组件图

@startuml
title **组件图**

package "ServiceLayer" { [MessageBus] as bus bus -> [Handlers] component "Unit of Work" { [Abstract UoW] as abuow abuow <|. [SQLA UoW] } [Handlers] -> abuow }
cloud cloud cloud --> [API]
[API] --> bus : Commands [Eventconsumer] --> bus : Commands
[API] --> [Bootstrap] [Eventconsumer] --> [Bootstrap] [Bootstrap] --> bus

package "Adapters" { component "Repositories" { [Abstract Repository] as abrepo abrepo <|. [SQLA Repository] } [Redis\nEvent\nPublisher] as redis [etc] }
abuow --> abrepo [SQLA UoW] --> [SQLA Repository]

package "Domain" { [Aggregate] -> [Entity] [Entity] --> [Value Object] [Event] [Command] }
Adapters -> Domain
database database
[External Message Broker] as ex_message ex_message --> [Eventconsumer] ex_message <-- redis
[SQLA Repository] --> database @enduml

状态图

@startuml
state choice1 <<choice>>
state fork1   <<fork>>
state join2   <<join>>
state end3    <<end>>

[*] --> choice1 : from start\nto choice choice1 --> fork1 : from choice\nto fork choice1 --> join2 : from choice\nto join choice1 --> end3 : from choice\nto end
fork1 ---> State1 : from fork\nto state fork1 --> State2 : from fork\nto state
State2 --> join2 : from state\nto join State1 --> [*] : from state\nto end
join2 --> [*] : from join\nto end @enduml

对象图

@startuml
object London
object Washington
object Berlin
object NewYork

map CapitalCity { UK *-> London USA *--> Washington Germany *---> Berlin }
NewYork --> CapitalCity::USA @enduml

思维导图

@startmindmap
caption figure 1
title My super title

* <&flag>Debian ** <&globe>Ubuntu *** Linux Mint *** Kubuntu *** Lubuntu *** KDE Neon ** <&graph>LMDE ** <&pulse>SolydXK ** <&people>SteamOS ** <&star>Raspbian with a very long name *** <s>Raspmbc</s> => OSMC *** <s>Raspyfi</s> => Volumio
left side
** Windows 95 ** Windows 98 ** Windows NT *** Windows 8 *** Windows 10

header My super header endheader
center footer My super footer
legend right Short legend endlegend @endmindmap


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 365433079@qq.com