PlantUML

plantuml

PlantUML是一个开源项目,支持快速绘制:

  • 时序图 Sequence diagram
  • 用例图 Usecase diagram
  • 类图 Class diagram
  • 活动图 Activity diagram
  • 组件图 Component diagram
  • 状态图 State diagram
  • 部署图 Deployment diagram
  • 对象图 Object diagram
  • 线框图形界面 wireframe graphical interface
  • 时序图 Timing Diagram

使用方式请参考如下文档:

_官网_

使用 PlantUML 绘制的 UML

安装

PlantUML 显示依赖 Graphviz , 需要先安装 Graphviz

Mac 安装 Graphviz

1
brew install Graphviz

Ubuntu 安装 Graphviz

1
apt-get install graphviz

Windows 下使用choco来安装Graphviz

  • 在cmd中安装chocolatey
1
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://bit.ly/psChocInstall'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
  • 在cmd中安装Graphviz
1
choco install Graphviz

在Atom中安装

安装两个Package : language-plantumlplantuml-preview

language-plantuml

plantuml-preview

在IDE中安装

安装插件 PlantUML integration

InteIIij_PlantUML

使用

在Atom中使用

  • 新建文件,保存为.pu文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
@startuml

abstract class AbstractList
abstract AbstractCollection
interface List
interface Collection

List <|-- AbstractList
Collection <|-- AbstractCollection

Collection <|- List
AbstractCollection <|- AbstractList
AbstractList <|-- ArrayList

class ArrayList {
Object[] elementData
size()
}

enum TimeUnit {
DAYS
HOURS
MINUTES
}

@enduml
  • 打开 plantuml-preview

plantuml-preview

如果出现下列错误情况,是需要指定plantuml.jar

error

plantuml.jar 可以通过PlantUML官网下载

  • 设置 plantuml-preview 的 plantuml.jar

    plantuml.jar

  • 对应的UML图如下所示

    ok

在IDE中使用

通过File菜单打开:

ide_plantuml


示例效果展示

效果如下:

TCLMOVE框架图

以下为一个框架图 PlantUML code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
@startuml

title TCLMOVE 架构图

skinparam backgroundColor #DBDBD8
skinparam handwritten true

skinparam package {
backgroundColor<<Scenes>> #7BD2F7
borderColor<<Scenes>> #90D2F7
fontSize<<Scenes>> 13

backgroundColor<<Servers>> #DBEAD0
borderColor<<Servers>> #DBEAD0

backgroundColor<<Models>> #FEFECE
borderColor<<Models>> #FEFEAE
}

skinparam folder {
backgroundColor<<Managers>> #BBDAC0
borderColor<<Managers>> #DBEAD0

backgroundColor<<Workers>> #DBEAA0
borderColor<<Workers>> #DBEAD0
}

skinparam interface {
backgroundColor RosyBrown
borderColor orange
}

skinparam entity {
backgroundColor RosyBrown
borderColor orange
}

skinparam cloud {
backgroundColor #00
borderColor #00
}

skinparam database {
backgroundColor #B1BFC3
borderColor #B1BFE3
}

skinparam component {
backgroundColor #5ABAA7
borderColor #7ABAA7
}

skinparam node {
backgroundColor #E68274
borderColor #E68274
}

package "UI Layer" <<Scenes>> {

[View1] as v1
[ViewModel1] as vm1
v1 -(0)- vm1
[View2] as v2
[ViewModel2] as vm2
v2 -(0)- vm2
[View3] as v3
[ViewModel3] as vm3
v3 -(0)- vm3
component "View" as v
component "ViewModel" as vm
v -(0)- vm
}

node "State" {

component "App State" as state
component "Reducer" as reducer
component "Action" as action
component "Action Creator" as creator

state <- reducer
reducer <-- action
creator -> action

}

vm <... state
vm1 <.. state
vm2 <.. state
vm3 <.. state

package "Logic Layer" <<Servers>> {

folder Managers <<Managers>> {

[Account Manager] as am
[Device Manager] as dm
[Location Manager] as lm
[Message Manager] as mm
[Notification Manager] as nm
[... Manager] as om
}

creator <-- am
creator <-- dm
creator <-- lm
creator <-- mm
creator <- nm
creator <- om

folder Workers <<Workers>> as workers {
interface "Account Worker Protocl" as awp
[Account Worker] as aw
awp ^-- aw
interface "Device Worker Protocl" as dwp
[Device Worker] as dw
dwp ^-- dw
interface "Location Worker Protocl" as lwp
[Location Worker] as lw
lwp ^-- lw
interface "Message Worker Protocl" as mwp
[Message Worker] as mw
mwp ^-- mw
interface "Notification Worker Protocl" as nwp
[Notification Worker] as nw
nwp ^-- nw
interface "... Worker Protocl" as owp
[... Worker] as ow
owp ^-- ow
}

am --> awp
dm --> dwp
lm --> lwp
mm --> mwp
nm --> nwp
om --> owp

}

node "Repository" as repository

skinparam rectangle {
roundCorner<<API>> 25
roundCorner<<BLE>> 8
roundCorner<<DAO>> 12
roundCorner<<...>> 35

backgroundColor<<API>> #C4DADF
borderColor<<API>> #E0DADF

backgroundColor<<BLE>> #C4DFDA
borderColor<<BLE>> #E4DFDA

backgroundColor<<DAO>> #DFC4DA
borderColor<<DAO>> #DFC4EA

backgroundColor #AFC4DA
borderColor #AFC4EA
}

package "Persistence Layer" <<Models>> as models {

rectangle "... Managements" <<...>> {
rectangle "..." <<...>>
}

rectangle "BLE Managements" <<BLE>> as blem {
rectangle "BLE attributes" <<BLE>> as ble
rectangle "Local Storage"
rectangle "Events"
}

rectangle "DAO Managements" <<DAO>> as daom {
rectangle "DAO" <<DAO>> as dao
rectangle "Change Events"
}

rectangle "API Managements" <<API>> as apim {
rectangle "Resource APIs" <<API>> as rapis
rectangle "Local Cache"
}


[Http Client] as httpclient
[database orm] as orm
[BLE 外设] as blew

rapis <-- httpclient
dao <-- orm
ble <-- blew
}

aw --> repository
dw --> repository
lw --> repository
mw --> repository
nw --> repository
ow --> repository

repository --> apim
repository --> daom
repository --> blem

cloud Cloud as cloud
database "database" as database
entity "BLE" as ble_entity

httpclient --> cloud
orm --> database
blew --> ble_entity

@enduml

Powered by Hexo and Hexo-theme-hiker

Copyright © 2013 - 2021 朝着牛逼的道路一路狂奔 All Rights Reserved.

访客数 : | 访问量 :