This commit is contained in:
estomm
2021-06-03 11:59:15 +08:00
parent 93ba1141af
commit fa03aa19d2
18 changed files with 3181 additions and 0 deletions

533
PlantUML/1 时序图.puml Normal file
View File

@@ -0,0 +1,533 @@
## 0 标准实例
@startuml
用户 -> 认证中心: 登录操作
认证中心 -> 缓存: 存放(key=token+ip,value=token)token
用户 <- 认证中心 : 认证成功返回token
用户 -> 认证中心: 下次访问头部携带token认证
认证中心 <- 缓存: key=token+ip获取token
其他服务 <- 认证中心: 存在且校验成功则跳转到用户请求的其他服务
其他服务 -> 用户: 信息
@enduml
## 1 箭头类型
### 箭头形状
* 表示一条丢失的消息:末尾加 x
* 让箭头只有上半部分或者下半部分:将<和>替换成\或者 /
* 细箭头:将箭头标记写两次 (如 >> 或 //)
* 虚线箭头:用 -- 替代 -
* 箭头末尾加圈:->o
* 双向箭头:<->
@startuml
Bob ->x Alice
Bob -> Alice
Bob ->> Alice
Bob -\ Alice
Bob \\- Alice
Bob //-- Alice
Bob ->o Alice
Bob o\\-- Alice
Bob <-> Alice
Bob <->o Alice
@enduml
@startuml
participant Alice as a
participant Bob as b
a -> b : ""-> ""
a ->> b : ""->> ""
a -\ b : ""-\ ""
a -\\ b : ""-\\\\""
a -/ b : ""-/ ""
a -// b : ""-// ""
a ->x b : ""->x ""
a x-> b : ""x-> ""
a o-> b : ""o-> ""
a ->o b : ""->o ""
a o->o b : ""o->o ""
a <-> b : ""<-> ""
a o<->o b : ""o<->o""
a x<->x b : ""x<->x""
a ->>o b : ""->>o ""
a -\o b : ""-\o ""
a -\\o b : ""-\\\\o""
a -/o b : ""-/o ""
a -//o b : ""-//o ""
a x->o b : ""x->o ""
@enduml
### 箭头颜色
* []修改箭头颜色
@startuml
Bob -[#red]> Alice : hello
Alice -[#0000FF]->Bob : ok
@enduml
## 2 参与者类型
### 关键字participant用来声明参与者。参与者主要有以下内容
* actor角色
* boundary边界
* control控制
* entity实体
* database数据库
* collections集合
* queue队列
@startuml
participant participant as Foo
actor actor as Foo1
boundary boundary as Foo2
control control as Foo3
entity entity as Foo4
database database as Foo5
collections collections as Foo6
queue queue as Foo7
Foo -> Foo1 : To actor
Foo -> Foo2 : To boundary
Foo -> Foo3 : To control
Foo -> Foo4 : To entity
Foo -> Foo5 : To database
Foo -> Foo6 : To collections
Foo -> Foo7 : To queue
@enduml
### as&color
* 关键字 as 用于重命名参与者。#RGB值或者#颜色名修改参与者的背景颜色。
@startuml
actor Bob #red
' actor 和 participant 只在外观上有区别
participant Alice
participant "很长很长很长\n的名字" as L #99FF99
/' 也可以这样声明:
participant L as "很长很长很长\n的名字" #99FF99
'/
Alice->Bob: 认证请求
Bob->Alice: 认证响应
Bob->L: 记录事务日志
@enduml
### 关键字order
* order自定义顺序来打印参与者。
@startuml
participant 最后 order 30
participant 中间 order 20
participant 首个 order 10
@enduml
### ""引号
* ""引号定义参与者,并用关键字 as 给参与者定义别名。
@startuml
Alice -> "Bob()" : Hello
"Bob()" -> "This is very\nlong" as Long
' You can also declare:
' "Bob()" -> Long as "This is very\nlong"
Long --> "Bob()" : ok
@enduml
### 参与者可以给自己发送消息
@startuml
Alice->Alice: This is a signal to self.\nIt also demonstrates\nmultiline \ntext
@enduml
### 关键字create创建参与者
* 关键字create放在第一次接收到消息之前以强调本次消息实际上是在创建新的对象。
@startuml
Bob -> Alice : hello
create Other
Alice -> Other : new
create control String
Alice -> String
note right : You can also put notes!
Alice --> Bob : ok
@enduml
### 使用<<和>>给参与者添加构造类型
@startuml
participant "Famous Bob" as Bob << Generated >>
participant Alice << (C,#ADD1B2) Testable >>
Bob->Alice: First message
@enduml
## 3 消息类型
### 消息位置
* skinparam responseMessageBelowArrow true命令让响应信息显示在箭头下面。
@startuml
skinparam responseMessageBelowArrow true
Bob -> Alice : hello
Alice -> Bob : ok
@enduml
### 消息编号
关键字 autonumber 用于自动对消息编号。
* 语句 autonumber //start// 用于指定编号的初始值,
* 而 autonumber //start// //increment// 可以同时指定编号的初始值和每次增加的值。
@startuml
autonumber
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response
@enduml
@startuml
autonumber
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response
autonumber 15
Bob -> Alice : Another authentication Request
Bob <- Alice : Another authentication Response
autonumber 40 10
Bob -> Alice : Yet another authentication Request
Bob <- Alice : Yet another authentication Response
@enduml
### 消息组合
通过以下关键词来组合消息:
* alt/else
* opt
* loop
* par
* break
* critical
* group后面紧跟着消息内容
关键词 end 用来结束分组
@startuml
Alice -> Bob: 认证请求
alt 成功情况
Bob -> Alice: 认证接受
else 某种失败情况
Bob -> Alice: 认证失败
group 我自己的标签
Alice -> Log : 开始记录攻击日志
loop 1000次
Alice -> Bob: DNS 攻击
end
Alice -> Log : 结束记录攻击日志
end
else 另一种失败
Bob -> Alice: 请重复
end
@enduml
### 消息注释
* 通过在消息后面添加 note left 或者 note right 关键词来给消息添加注释。note across可以跨所有参与者
* 通过使用 end note 来添加多行注释。
* 可以通过修改背景色来高亮显示注释。
* 使用 hnote 和 rnote 这两个关键字还可以改变备注的形状。hnote代表六边形hexagonal的备注框rnote代表正方形rectangle的备注框。
* 支持html格式的注释
* 添加\n使长文本换行
@startuml
Alice->Bob : hello
note left: this is a first note
Bob->Alice : ok
note right #aqua: this is another note
Bob->Bob : I am thinking
note across
a note
can also be defined
on several lines
end note
@enduml
@startuml
caller -> server : conReq
hnote over caller : 空闲
caller <- server : conConf
rnote over server
"r"是正方形
"h"是六边形
endrnote
rnote over server
文本
endrnote
hnote over caller
文本
endhnote
@enduml
### 进入和发出消息
使用方括号[和]表示图示的左、右两侧。
@startuml
[-> A: DoWork
activate A
A -> A: Internal call
activate A
A ->] : << createRequest >>
A<--] : RequestCreated
deactivate A
[<- A: Done
deactivate A
@enduml
### 短发出消息
短发出信息(使用'?'
@startuml
participant Alice as a
participant Bob as b
a -> b : //Long long label//
a ->? : ""->? ""
a ->>? : ""->>? ""
a -\? : ""-\? ""
a -\\? : ""-\\\\?""
a -/? : ""-/? ""
a -//? : ""-//? ""
a ->x? : ""->x? ""
a x->? : ""x->? ""
a o->? : ""o->? ""
a ->o? : ""->o? ""
a o->o? : ""o->o? ""
a <->? : ""<->? ""
a o<->o? : ""o<->o?""
a x<->x? : ""x<->x?""
a ->>o? : ""->>o? ""
a -\o? : ""-\o? ""
a -\\o? : ""-\\\\o?""
a -/o? : ""-/o? ""
a -//o? : ""-//o? ""
a x->o? : ""x->o? ""
@enduml
## 4 页面控制
### 页眉和页脚
* 使用title关键词增加标题
* 使用header关键词增加页眉
* 使用footer关键词增加页脚
@startuml
header Page Header
footer Page %page% of %lastpage%
title Example Title
Alice -> Bob : message 1
Alice -> Bob : message 2
@enduml
### 关键字 newpage 分页
用于把一张图分割成多张
@startuml
Alice -> Bob : message 1
Alice -> Bob : message 2
newpage
Alice -> Bob : message 3
Alice -> Bob : message 4
newpage A title for the\nlast page
Alice -> Bob : message 5
Alice -> Bob : message 6
@enduml
### ==关键词来将你的图表分割成多个逻辑步骤
@startuml
== 初始化 ==
Alice -> Bob: 认证请求
Bob --> Alice: 认证响应
== 重复 ==
Alice -> Bob: 认证请求
Alice <-- Bob: 认证响应
@enduml
### ...来表示延迟,并且还可以给延迟添加注释
@startuml
Alice -> Bob: 认证请求
...
Bob --> Alice: 认证响应
...5分钟后...
Bob --> Alice: 再见!
@enduml
### 使用|||来增加空间
还可以使用数字指定增加的像素的数量。
@startuml
Alice -> Bob: message 1
Bob --> Alice: ok
|||
Alice -> Bob: message 2
Bob --> Alice: ok
||45||
Alice -> Bob: message 3
Bob --> Alice: ok
@enduml
## 5 生命线
### 生命线的激活与撤销
* 关键字activate和deactivate用来表示参与者的生命活动
@startuml
participant User
User -> A: DoWork
activate A
A -> B: << createRequest >>
activate B
B -> C: DoWork
activate C
C --> B: WorkDone
destroy C
B --> A: RequestCreated
deactivate B
A -> User: Done
deactivate A
@enduml
### 嵌套生命线
* 使用不同颜色标注
@startuml
participant User
User -> A: DoWork
activate A #FFBBBB
A -> A: Internal call
activate A #DarkSalmon
A -> B: << createRequest >>
activate B
B --> A: RequestCreated
deactivate B
deactivate A
A -> User: Done
deactivate A
@enduml
### 自动激活生命线
* 自动激活关键字autoactivate这需要与return关键字配合
@startuml
autoactivate on
alice -> bob : hello
bob -> bob : self call
bill -> bob #005500 : hello from thread 2
bob -> george ** : create
return done in thread 2
return rc
bob -> george !! : delete
return success
@enduml
### 激活撤销创建销毁快捷语法
* ++ 激活目标(可选择在后面加上#color
* -- 撤销激活源
* ** 创建目标实例
* !! 摧毁目标实例
@startuml
alice -> bob ++ : hello
bob -> bob ++ : self call
bob -> bib ++ #005500 : hello
bob -> george ** : create
return done
return rc
bob -> george !! : delete
return success
@enduml
### 实线和虚线
* nosolid 虚线(默认)
* solid 实线
@startuml
skinparam lifelineStrategy solid
Bob -> Alice : hello
Alice -> Bob : ok
@enduml

View File

@@ -0,0 +1,82 @@
## 1 可视化JSON数据
@startjson
{
"firstName": "John",
"lastName": "Smith",
"isAlive": true,
"age": 27,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021-3100"
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "office",
"number": "646 555-4567"
}
],
"children": [],
"spouse": null
}
@endjson
@startjson
#highlight "lastName"
#highlight "address" / "city"
#highlight "phoneNumbers" / "0" / "number"
{
"firstName": "John",
"lastName": "Smith",
"isAlive": true,
"age": 28,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021-3100"
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "office",
"number": "646 555-4567"
}
],
"children": [],
"spouse": null
}
@endjson
@startjson
{
"null": null,
"true": true,
"false": false,
"JSON_Number": [-1, -1.1, "<color:green>TBC"],
"JSON_String": "a\nb\rc\td <color:green>TBC...",
"JSON_Object": {
"{}": {},
"k_int": 123,
"k_str": "abc",
"k_obj": {"k": "v"}
},
"JSON_Array" : [
[],
[true, false],
[-1, 1],
["a", "b", "c"],
["mix", null, true, 1, {"k": "v"}]
]
}
@endjso

View File

@@ -0,0 +1,60 @@
## mindmap
### 兼容 orgmode 语法
@startmindmap
* Debian
** Ubuntu
*** Linux Mint
*** Kubuntu
*** Lubuntu
*** KDE Neon
** LMDE
** SolydXK
** SteamOS
** Raspbian with a very long name
*** <s>Raspmbc</s> => OSMC
*** <s>Raspyfi</s> => Volumio
@endmindmap
### 兼容markdown语法
@startmindmap
* root node
* some first level node
* second level node
* another second level node
* another first level node
@endmindmap
### 用运算符决定方向
@startmindmap
+ OS
++ Ubuntu
+++ Linux Mint
+++ Kubuntu
+++ Lubuntu
+++ KDE Neon
++ LMDE
++ SolydXK
++ SteamOS
++ Raspbian
-- Windows 95
-- Windows 98
-- Windows NT
--- Windows 8
--- Windows 10
@endmindmap
## 2 设置颜色和其他属性
@startmindmap
*[#Orange] Colors
**[#lightgreen] Green
**[#FFBBCC] Rose
**[#lightblue] Blue
@endmindmap

178
PlantUML/2 用例图.puml Normal file
View File

@@ -0,0 +1,178 @@
## 0 实例
@startuml
left to right direction
skinparam packageStyle rectangle
actor customer
actor clerk
rectangle checkout {
customer -- (checkout)
(checkout) .> (payment) : include
(help) .> (checkout) : extends
(checkout) -- clerk
}
@enduml
## 1 定义
### 用例
* 用例用圆括号括起来(两个圆括号看起来就像椭圆)。
* 也可以用关键字usecase来定义用例。
### 角色
角色用两个冒号包裹起来。
也可以用actor关键字来定义角色。
@startuml
(First usecase)
(Another usecase) as (UC2)
usecase UC3
usecase (Last\nusecase) as UC4
:First Actor:
:Another\nactor: as Man2
actor Woman3
actor :Last actor: as Person1
@enduml
## 2 角色样式
* 火柴人样式:默认
* 用户头像样式skinparam actorStyle awesome
* 透明人样式skinparam actorStyle hollow
## 3 用例描述
* --(横线)
* ..(虚线)
* ==(双横线)
* __下划线
@startuml
usecase UC1 as "You can use
several lines to define your usecase.
You can also use separators.
--
Several separators are possible.
==
And you can add titles:
..Conclusion..
This allows large description."
@enduml
## 4 用例包
* package 可以一使用包来对角色或用例进行分组。
@startuml
left to right direction
actor Guest as g
package Professional {
actor Chef as c
actor "Food Critic" as fc
}
package Restaurant {
usecase "Eat Food" as UC1
usecase "Pay for Food" as UC2
usecase "Drink" as UC3
usecase "Review" as UC4
}
fc --> UC4
g --> UC1
g --> UC2
g --> UC3
@enduml
## 5 继承关系
如果一个角色或者用例继承于另一个,那么可以用<|--符号表示。
@startuml
:Main Admin: as Admin
(Use the application) as (Use)
User <|-- Admin
(Start) <|-- (Use)
@enduml
## 6 使用注释
可以用note left of , note right of , note top of , note bottom of等关键字给一个对象添加注释。
@startuml
:Main Admin: as Admin
(Use the application) as (Use)
User -> (Start)
User --> (Use)
Admin ---> (Use)
note right of Admin : This is an example.
note right of (Use)
A note can also
be on several lines
end note
note "This note is connected\nto several objects." as N2
(Start) .. N2
N2 .. (Use)
@enduml
## 7 构造类型
用 << 和 >> 来定义角色或者用例的构造类型。
@startuml
User << Human >>
:Main Database: as MySql << Application >>
(Start) << One Shot >>
(Use the application) as (Use) << Main >>
User -> (Start)
User --> (Use)
MySql --> (Use)
@enduml
## 8 改变箭头方向
默认连接是竖直方向的,用--表示,可以用一个横杠或点来表示水平连接。
@startuml
:user: --> (Use case 1)
:user: -> (Use case 2)
@enduml
还可以通过给箭头添加left, right, up或down等关键字来改变方向
@startuml
:user: -left-> (dummyLeft)
:user: -right-> (dummyRight)
:user: -up-> (dummyUp)
:user: -down-> (dummyDown)
@enduml
## 9 改变风格
* 改变箭头风格
@startuml
actor foo
foo --> (bar) : normal
foo --> (bar1) #line:red;line.bold;text:red : red bold
foo --> (bar2) #green;line.dashed;text:green : green dashed
foo --> (bar3) #blue;line.dotted;text:blue : blue dotted
@enduml
* 改变用例风格
@startuml
actor a
actor b #pink;line:red;line.bold;text:red
usecase c #palegreen;line:green;line.dashed;text:green
usecase d #aliceblue;line:blue;line.dotted;text:blue
@enduml

266
PlantUML/3 类图.puml Normal file
View File

@@ -0,0 +1,266 @@
## 1 类元素
### 元素声明
@startuml
abstract abstract
abstract class "abstract class"
annotation annotation
circle circle
() circle_short_form
class class
diamond diamond
<> diamond_short_form
entity entity
enum enum
interface interface
@enduml
## 2 类间关系
### 基本关系
* 虚线箭头指向依赖;
* 实线箭头指向关联;
* 虚线三角指向接口;
* 实线三角指向父类;
* 空心菱形能分离而独立存在,是聚合;
* 实心菱形精密关联不可分,是组合;
@startuml
Class01 <|-- Class02
Class01 <|.. Class02
note bottom:继承、实现
Class03 <--* Class04
Class03 <--o Class04
note bottom:聚合、组合
Class05 <-- Class06
Class05 <.. Class06
note bottom:关联、依赖
Class07 -- Class08
Class07 .. Class08
note bottom:连接
@enduml
### 拓展关系
@startuml
Class21 #-- Class22
Class23 x-- Class24
Class25 }-- Class26
Class27 +-- Class28
Class29 ^-- Class30
@enduml
## 3 关系标签
* :tag,表示关系上的标签 。
* ""说明端的标签
* 在标签的开始或结束位置添加< 或 >以表明是哪个对象作用到哪个对象上。.
@startuml
Class01 "1" *-- "many" Class02 : contains
Class03 o-- Class04 : aggregation
Class05 --> "1" Class06
class Car
Driver - Car : drives >
Car *- Wheel : have 4 >
Car -- Person : < owns
@enduml
## 4 元素内容
### 字段和方法
* ArrayList:声明字段和方法。系统根据括号自动区分。
* {}中括号包含字段和方法。系统根据括号自动区分。
* 可以(显式地)使用 {field} 和 {method} 修饰符来覆盖解析器的对于字段和方法的默认行为
@startuml
Object <|-- ArrayList
Object : equals()
ArrayList : Object[] elementData
ArrayList : size()
class Dummy {
String data
void methods()
}
class Flight {
flightNumber : Integer
departureTime : Date
}
class Dummy {
{field} A field (despite parentheses)
{method} Some method
}
@enduml
### 访问属性
* -private
* #protect
* ~package private
* +: public
* 采用以下命令停用这些特性skinparam classAttributeIconSize 0
@startuml
skinparam classAttributeIconSize 0
class Dummy {
-field1
#field2
~method1()
+method2()
}
@enduml
### 其他修饰
通过修饰符{static}或者{abstract},可以定义静态或者抽象的方法或者属性。
@startuml
class Dummy {
{static} String id
{abstract} void methods()
}
@enduml
### 内容分组
* 自己定义分隔符来重排方法和属性,下面的分隔符都是可用的:--..==__
@startuml
class Foo1 {
You can use
several lines
..
as you want
and group
==
things together.
__
You can have as many groups
as you want
--
End of class
}
class User {
.. Simple Getter ..
+ getName()
+ getAddress()
.. Some setter ..
+ setName()
__ private data __
int age
-- encrypted --
String password
}
@enduml
## 5 模板、泛型、备注
* 模板通过类关键字("<<"和">>")来定义
* 你可以使用note left of , note right of , note top of , note bottom of这些关键字来添加备注。
* 你还可以在类的声明末尾使用note left, note right,note top, note bottom来添加备注。
* 你可以用 < 和 > 来定义类的泛型。
@startuml
class Object << general >>
Object <|--- ArrayList
note top of Object : In java, every class\nextends this one.
note "This is a floating note" as N1
note "This note is connected\nto several objects." as N2
Object .. N2
N2 .. ArrayList
class Foo
note left: On last defined class
class Foo3<? extends Element> {
int size()
}
Foo *- Element
@enduml
## 6 包和命名空间
### package
@startuml
package "Classic Collections" #DDDDDD {
Object <|-- ArrayList
}
package net.sourceforge.plantuml {
Object <|-- Demo1
Demo1 *- Demo2
}
scale 750 width
package foo1 <<Node>> {
class Class1
}
package foo2 <<Rectangle>> {
class Class2
}
package foo3 <<Folder>> {
class Class3
}
package foo4 <<Frame>> {
class Class4
}
package foo5 <<Cloud>> {
class Class5
}
package foo6 <<Database>> {
class Class6
}
@enduml
### 命名空间
在使用包package区别于命名空间类名是类的唯一标识。 也就意味着在不同的包package中的类不能使用相同的类名。
@startuml
class BaseClass
namespace net.dummy #DDDDDD {
.BaseClass <|-- Person
Meeting o-- Person
.BaseClass <|- Meeting
}
namespace net.foo {
net.dummy.Person <|- Person
.BaseClass <|-- Person
net.dummy.Meeting o-- Person
}
BaseClass <|-- net.unused.Person
@enduml

30
PlantUML/4 对象图.puml Normal file
View File

@@ -0,0 +1,30 @@
## 1 对象
可用用来表示数据库的数据表之间的关系。
@startuml
object firstObject
object "My Second Object" as o2
@enduml
## 2 与类图中的通用特性
* 可见性
* 定义注释
* 使用包
* 美化输出内容
* 对象间关系
## 3 添加属性
*
@startuml
object user
user : name = "Dummy"
user : id = 123
object user2 {
name = "Dummy"
id = 123
}
@enduml

204
PlantUML/5 活动图.puml Normal file
View File

@@ -0,0 +1,204 @@
## 0 活动图实例
@startuml
title Servlet Container
(*) --> "ClickServlet.handleRequest()"
--> "new Page"
if "Page.onSecurityCheck" then
->[true] "Page.onInit()"
if "isForward?" then
->[no] "Process controls"
if "continue processing?" then
-->[yes] ===RENDERING===
else
-->[no] ===REDIRECT_CHECK===
endif
else
-->[yes] ===RENDERING===
endif
if "is Post?" then
-->[yes] "Page.onPost()"
--> "Page.onRender()" as render
--> ===REDIRECT_CHECK===
else
-->[no] "Page.onGet()"
--> render
endif
else
-->[false] ===REDIRECT_CHECK===
endif
if "Do redirect?" then
->[yes] "redirect request"
--> ==BEFORE_DESTROY===
else
if "Do Forward?" then
-left->[yes] "Forward request"
--> ==BEFORE_DESTROY===
else
-right->[no] "Render page template"
--> ==BEFORE_DESTROY===
endif
endif
--> "Page.onDestroy()"
-->(*)
@enduml
## 1 基本元素
* 使用(*)作为活动图的开始点和结束点。用(*top)强制开始点位于图示的顶端。
* 使用-->绘制箭头。默认情况下,箭头开始于最接近的活动。
@startuml
(*) --> "First Activity"
"First Activity" --> (*)
@enduml
* 简略写法
@startuml
(*)
- "First Activity"
- "2First Activity"
- (*)
@enduml
## 2 箭头
### 箭头标签
用[和]放在箭头定义的后面来添加标签。
@startuml
(*) --> "First Activity"
-->[You can put also labels] "Second Activity"
--> (*)
@enduml
### 箭头方向
* -down-> (default arrow)
* -right-> or ->
* -left->
* -up->
@startuml
(*) -up-> "First Activity"
-right-> "Second Activity"
--> "Third Activity"
-left-> (*)
@enduml
## 3 分支同步
### 分支
你可以使用关键字if/then/else创建分支。
@startuml
(*) --> "Initialization"
if "Some Test" then
-->[true] "Some Activity"
--> "Another activity"
-right-> (*)
else
->[false] "Something else"
-->[Ending process] (*)
endif
@enduml
### 分支嵌套
* 默认情况下一个分支连接上一个最新的活动但是也可以使用if关键字进行连接。还可以嵌套定义分支。
@startuml
(*) --> if "Some Test" then
-->[true] "action 1"
if "" then
-> "action 3" as a3
else
if "Other test" then
-left-> "action 5"
else
--> "action 6"
endif
endif
else
->[false] "action 2"
endif
a3 --> if "last test" then
--> "action 7"
else
-> "action 8"
endif
@enduml
### 同步
你可以使用 === code === 来显示同步条。
@startuml
(*) --> ===B1===
--> "Parallel Activity 1"
--> ===B2===
===B1=== --> "Parallel Activity 2"
--> ===B2===
--> (*)
@enduml
## 4 分区
用关键字partition定义分区还可以设置背景色(用颜色名或者颜色值)。
定义活动的时候,它自动被放置到最新的分区中。
用}结束分区的定义。
@startuml
partition Conductor {
(*) --> "Climbs on Platform"
--> === S1 ===
--> Bows
}
partition Audience #LightSkyBlue {
=== S1 === --> Applauds
}
partition Conductor {
Bows --> === S2 ===
--> WavesArmes
Applauds --> === S2 ===
}
partition Orchestra #CCCCEE {
WavesArmes --> Introduction
--> "Play music"
}
@enduml

127
PlantUML/6 状态图.puml Normal file
View File

@@ -0,0 +1,127 @@
## 1 简单状态
* 使用([*])开始和结束状态图。
* 使用-->添加箭头。
* hide empty description隐藏元素的空内容
@startuml
[*] --> State1
State1 --> [*]
State1 : this is a string
State1 : this is another string
State1 -> State2
State2 --> [*]
@enduml
## 2 合成状态
一个状态也可能是合成的必须使用关键字state和花括号来定义合成状态。
@startuml
scale 350 width
[*] --> NotShooting
state NotShooting {
[*] --> Idle
Idle --> Configuring : EvConfig
Configuring --> Idle : EvConfig
}
state Configuring {
[*] --> NewValueSelection
NewValueSelection --> NewValuePreview : EvNewValue
NewValuePreview --> NewValueSelection : EvNewValueRejected
NewValuePreview --> NewValueSelection : EvNewValueSaved
state NewValuePreview {
State1 -> State2
}
}
@enduml
## 3 同步状态
`<<fork>>` and `<<join>>` 表示分支与合并
@startuml
state fork_state <<fork>>
[*] --> fork_state
fork_state --> State2
fork_state --> State3
state join_state <<join>>
State2 --> join_state
State3 --> join_state
join_state --> State4
State4 --> [*]
@enduml
## 4 并发状态
用-- or ||作为分隔符来合成并发状态。
@startuml
[*] --> Active
state Active {
[*] -> NumLockOff
NumLockOff --> NumLockOn : EvNumLockPressed
NumLockOn --> NumLockOff : EvNumLockPressed
--
[*] -> CapsLockOff
CapsLockOff --> CapsLockOn : EvCapsLockPressed
CapsLockOn --> CapsLockOff : EvCapsLockPressed
--
[*] -> ScrollLockOff
ScrollLockOff --> ScrollLockOn : EvCapsLockPressed
ScrollLockOn --> ScrollLockOff : EvCapsLockPressed
}
@enduml
## 5 分支状态
`<<choice>>`表示分支状态
@startuml
state "Req(Id)" as ReqId <<sdlreceive>>
state "Minor(Id)" as MinorId
state "Major(Id)" as MajorId
state c <<choice>>
Idle --> ReqId
ReqId --> c
c --> MinorId : [Id <= 10]
c --> MajorId : [Id > 10]
@enduml
## 6 fork/join/choice实例
@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
## 7 相同内容
* 注释
* 箭头方向
* 线条类型

36
PlantUML/9 ER图.puml Normal file
View File

@@ -0,0 +1,36 @@
## 实例
可以用来表示数据库中数据表的内容和数据表之间的关系
@startuml
' hide the spot
hide circle
' avoid problems with angled crows feet
skinparam linetype ortho
entity "Entity01" as e01 {
*e1_id : number <<generated>>
--
*name : text
description : text
}
entity "Entity02" as e02 {
*e2_id : number <<generated>>
--
*e1_id : number <<FK>>
other_details : text
}
entity "Entity03" as e03 {
*e3_id : number <<generated>>
--
e1_id : number <<FK>>
other_details : text
}
e01 ||..o{ e02
e01 |o..o{ e03
@enduml

View File

@@ -0,0 +1,591 @@
## 0 标准实例
```plantuml
@startuml
用户 -> 认证中心: 登录操作
认证中心 -> 缓存: 存放(key=token+ip,value=token)token
用户 <- 认证中心 : 认证成功返回token
用户 -> 认证中心: 下次访问头部携带token认证
认证中心 <- 缓存: key=token+ip获取token
其他服务 <- 认证中心: 存在且校验成功则跳转到用户请求的其他服务
其他服务 -> 用户: 信息
@enduml
```
## 1 箭头类型
### 箭头形状
* 表示一条丢失的消息:末尾加 x
* 让箭头只有上半部分或者下半部分:将<和>替换成\或者 /
* 细箭头:将箭头标记写两次 (如 >> 或 //)
* 虚线箭头:用 -- 替代 -
* 箭头末尾加圈:->o
* 双向箭头:<->
```plantuml
@startuml
Bob ->x Alice
Bob -> Alice
Bob ->> Alice
Bob -\ Alice
Bob \\- Alice
Bob //-- Alice
Bob ->o Alice
Bob o\\-- Alice
Bob <-> Alice
Bob <->o Alice
@enduml
```
```plantuml
@startuml
participant Alice as a
participant Bob as b
a -> b : ""-> ""
a ->> b : ""->> ""
a -\ b : ""-\ ""
a -\\ b : ""-\\\\""
a -/ b : ""-/ ""
a -// b : ""-// ""
a ->x b : ""->x ""
a x-> b : ""x-> ""
a o-> b : ""o-> ""
a ->o b : ""->o ""
a o->o b : ""o->o ""
a <-> b : ""<-> ""
a o<->o b : ""o<->o""
a x<->x b : ""x<->x""
a ->>o b : ""->>o ""
a -\o b : ""-\o ""
a -\\o b : ""-\\\\o""
a -/o b : ""-/o ""
a -//o b : ""-//o ""
a x->o b : ""x->o ""
@enduml
```
### 箭头颜色
* []修改箭头颜色
```plantuml
@startuml
Bob -[#red]> Alice : hello
Alice -[#0000FF]->Bob : ok
@enduml
```
## 2 参与者类型
### 关键字participant用来声明参与者。参与者主要有以下内容
* actor角色
* boundary边界
* control控制
* entity实体
* database数据库
* collections集合
* queue队列
```plantuml
@startuml
participant participant as Foo
actor actor as Foo1
boundary boundary as Foo2
control control as Foo3
entity entity as Foo4
database database as Foo5
collections collections as Foo6
queue queue as Foo7
Foo -> Foo1 : To actor
Foo -> Foo2 : To boundary
Foo -> Foo3 : To control
Foo -> Foo4 : To entity
Foo -> Foo5 : To database
Foo -> Foo6 : To collections
Foo -> Foo7 : To queue
@enduml
```
### as&color
* 关键字 as 用于重命名参与者。#RGB值或者#颜色名修改参与者的背景颜色。
```plantuml
@startuml
actor Bob #red
' actor 和 participant 只在外观上有区别
participant Alice
participant "很长很长很长\n的名字" as L #99FF99
/' 也可以这样声明:
participant L as "很长很长很长\n的名字" #99FF99
'/
Alice->Bob: 认证请求
Bob->Alice: 认证响应
Bob->L: 记录事务日志
@enduml
```
### 关键字order
* order自定义顺序来打印参与者。
```plantuml
@startuml
participant 最后 order 30
participant 中间 order 20
participant 首个 order 10
@enduml
```
### ""引号
* ""引号定义参与者,并用关键字 as 给参与者定义别名。
```plantuml
@startuml
Alice -> "Bob()" : Hello
"Bob()" -> "This is very\nlong" as Long
' You can also declare:
' "Bob()" -> Long as "This is very\nlong"
Long --> "Bob()" : ok
@enduml
```
### 参与者可以给自己发送消息
```plantuml
@startuml
Alice->Alice: This is a signal to self.\nIt also demonstrates\nmultiline \ntext
@enduml
```
### 关键字create创建参与者
* 关键字create放在第一次接收到消息之前以强调本次消息实际上是在创建新的对象。
```plantuml
@startuml
Bob -> Alice : hello
create Other
Alice -> Other : new
create control String
Alice -> String
note right : You can also put notes!
Alice --> Bob : ok
@enduml
```
### 使用<<和>>给参与者添加构造类型
```plantuml
@startuml
participant "Famous Bob" as Bob << Generated >>
participant Alice << (C,#ADD1B2) Testable >>
Bob->Alice: First message
@enduml
```
## 3 消息类型
### 消息位置
* skinparam responseMessageBelowArrow true命令让响应信息显示在箭头下面。
```plantuml
@startuml
skinparam responseMessageBelowArrow true
Bob -> Alice : hello
Alice -> Bob : ok
@enduml
```
### 消息编号
关键字 autonumber 用于自动对消息编号。
* 语句 autonumber //start// 用于指定编号的初始值,
* 而 autonumber //start// //increment// 可以同时指定编号的初始值和每次增加的值。
```plantuml
@startuml
autonumber
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response
@enduml
```
```plantuml
@startuml
autonumber
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response
autonumber 15
Bob -> Alice : Another authentication Request
Bob <- Alice : Another authentication Response
autonumber 40 10
Bob -> Alice : Yet another authentication Request
Bob <- Alice : Yet another authentication Response
@enduml
```
### 消息组合
通过以下关键词来组合消息:
* alt/else
* opt
* loop
* par
* break
* critical
* group后面紧跟着消息内容
关键词 end 用来结束分组
```plantuml
@startuml
Alice -> Bob: 认证请求
alt 成功情况
Bob -> Alice: 认证接受
else 某种失败情况
Bob -> Alice: 认证失败
group 我自己的标签
Alice -> Log : 开始记录攻击日志
loop 1000次
Alice -> Bob: DNS 攻击
end
Alice -> Log : 结束记录攻击日志
end
else 另一种失败
Bob -> Alice: 请重复
end
@enduml
```
### 消息注释
* 通过在消息后面添加 note left 或者 note right 关键词来给消息添加注释。note across可以跨所有参与者
* 通过使用 end note 来添加多行注释。
* 可以通过修改背景色来高亮显示注释。
* 使用 hnote 和 rnote 这两个关键字还可以改变备注的形状。hnote代表六边形hexagonal的备注框rnote代表正方形rectangle的备注框。
* 支持html格式的注释
* 添加\n使长文本换行
```plantuml
@startuml
Alice->Bob : hello
note left: this is a first note
Bob->Alice : ok
note right #aqua: this is another note
Bob->Bob : I am thinking
note across
a note
can also be defined
on several lines
end note
@enduml
```
```plantuml
@startuml
caller -> server : conReq
hnote over caller : 空闲
caller <- server : conConf
rnote over server
"r"是正方形
"h"是六边形
endrnote
rnote over server
文本
endrnote
hnote over caller
文本
endhnote
@enduml
```
### 进入和发出消息
使用方括号[和]表示图示的左、右两侧。
```plantuml
@startuml
[-> A: DoWork
activate A
A -> A: Internal call
activate A
A ->] : << createRequest >>
A<--] : RequestCreated
deactivate A
[<- A: Done
deactivate A
@enduml
```
### 短发出消息
短发出信息(使用'?'
```plantuml
@startuml
participant Alice as a
participant Bob as b
a -> b : //Long long label//
a ->? : ""->? ""
a ->>? : ""->>? ""
a -\? : ""-\? ""
a -\\? : ""-\\\\?""
a -/? : ""-/? ""
a -//? : ""-//? ""
a ->x? : ""->x? ""
a x->? : ""x->? ""
a o->? : ""o->? ""
a ->o? : ""->o? ""
a o->o? : ""o->o? ""
a <->? : ""<->? ""
a o<->o? : ""o<->o?""
a x<->x? : ""x<->x?""
a ->>o? : ""->>o? ""
a -\o? : ""-\o? ""
a -\\o? : ""-\\\\o?""
a -/o? : ""-/o? ""
a -//o? : ""-//o? ""
a x->o? : ""x->o? ""
@enduml
```
## 4 页面控制
### 页眉和页脚
* 使用title关键词增加标题
* 使用header关键词增加页眉
* 使用footer关键词增加页脚
```plantuml
@startuml
header Page Header
footer Page %page% of %lastpage%
title Example Title
Alice -> Bob : message 1
Alice -> Bob : message 2
@enduml
```
### 关键字 newpage 分页
用于把一张图分割成多张
```plantuml
@startuml
Alice -> Bob : message 1
Alice -> Bob : message 2
newpage
Alice -> Bob : message 3
Alice -> Bob : message 4
newpage A title for the\nlast page
Alice -> Bob : message 5
Alice -> Bob : message 6
@enduml
```
### ==关键词来将你的图表分割成多个逻辑步骤
```plantuml
@startuml
== 初始化 ==
Alice -> Bob: 认证请求
Bob --> Alice: 认证响应
== 重复 ==
Alice -> Bob: 认证请求
Alice <-- Bob: 认证响应
@enduml
```
### ...来表示延迟,并且还可以给延迟添加注释
```plantuml
@startuml
Alice -> Bob: 认证请求
...
Bob --> Alice: 认证响应
...5分钟后...
Bob --> Alice: 再见!
@enduml
```
### 使用|||来增加空间
还可以使用数字指定增加的像素的数量。
```plantuml
@startuml
Alice -> Bob: message 1
Bob --> Alice: ok
|||
Alice -> Bob: message 2
Bob --> Alice: ok
||45||
Alice -> Bob: message 3
Bob --> Alice: ok
@enduml
```
## 5 生命线
### 生命线的激活与撤销
* 关键字activate和deactivate用来表示参与者的生命活动
```plantuml
@startuml
participant User
User -> A: DoWork
activate A
A -> B: << createRequest >>
activate B
B -> C: DoWork
activate C
C --> B: WorkDone
destroy C
B --> A: RequestCreated
deactivate B
A -> User: Done
deactivate A
@enduml
```
### 嵌套生命线
* 使用不同颜色标注
```plantuml
@startuml
participant User
User -> A: DoWork
activate A #FFBBBB
A -> A: Internal call
activate A #DarkSalmon
A -> B: << createRequest >>
activate B
B --> A: RequestCreated
deactivate B
deactivate A
A -> User: Done
deactivate A
@enduml
```
### 自动激活生命线
* 自动激活关键字autoactivate这需要与return关键字配合
```plantuml
@startuml
autoactivate on
alice -> bob : hello
bob -> bob : self call
bill -> bob #005500 : hello from thread 2
bob -> george ** : create
return done in thread 2
return rc
bob -> george !! : delete
return success
@enduml
```
### 激活撤销创建销毁快捷语法
* ++ 激活目标(可选择在后面加上#color
* -- 撤销激活源
* ** 创建目标实例
* !! 摧毁目标实例
```plantuml
@startuml
alice -> bob ++ : hello
bob -> bob ++ : self call
bob -> bib ++ #005500 : hello
bob -> george ** : create
return done
return rc
bob -> george !! : delete
return success
@enduml
```
### 实线和虚线
* nosolid 虚线(默认)
* solid 实线
```plantuml
@startuml
skinparam lifelineStrategy solid
Bob -> Alice : hello
Alice -> Bob : ok
@enduml
```

View File

@@ -0,0 +1,88 @@
## 1 可视化JSON数据
```plantuml
@startjson
{
"firstName": "John",
"lastName": "Smith",
"isAlive": true,
"age": 27,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021-3100"
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "office",
"number": "646 555-4567"
}
],
"children": [],
"spouse": null
}
@endjson
```
```plantuml
@startjson
#highlight "lastName"
#highlight "address" / "city"
#highlight "phoneNumbers" / "0" / "number"
{
"firstName": "John",
"lastName": "Smith",
"isAlive": true,
"age": 28,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021-3100"
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "office",
"number": "646 555-4567"
}
],
"children": [],
"spouse": null
}
@endjson
```
```plantuml
@startjson
{
"null": null,
"true": true,
"false": false,
"JSON_Number": [-1, -1.1, "<color:green>TBC"],
"JSON_String": "a\nb\rc\td <color:green>TBC...",
"JSON_Object": {
"{}": {},
"k_int": 123,
"k_str": "abc",
"k_obj": {"k": "v"}
},
"JSON_Array" : [
[],
[true, false],
[-1, 1],
["a", "b", "c"],
["mix", null, true, 1, {"k": "v"}]
]
}
@endjson
```

View File

@@ -0,0 +1,65 @@
## mindmap
### 兼容 orgmode 语法
```plantuml
@startmindmap
* Debian
** Ubuntu
*** Linux Mint
*** Kubuntu
*** Lubuntu
*** KDE Neon
** LMDE
** SolydXK
** SteamOS
** Raspbian with a very long name
*** <s>Raspmbc</s> => OSMC
*** <s>Raspyfi</s> => Volumio
@endmindmap
```
### 兼容markdown语法
```plantuml
@startmindmap
* root node
* some first level node
* second level node
* another second level node
* another first level node
@endmindmap
```
### 用运算符决定方向
```plantuml
@startmindmap
+ OS
++ Ubuntu
+++ Linux Mint
+++ Kubuntu
+++ Lubuntu
+++ KDE Neon
++ LMDE
++ SolydXK
++ SteamOS
++ Raspbian
-- Windows 95
-- Windows 98
-- Windows NT
--- Windows 8
--- Windows 10
@endmindmap
```
## 2 设置颜色和其他属性
```plantuml
@startmindmap
*[#Orange] Colors
**[#lightgreen] Green
**[#FFBBCC] Rose
**[#lightblue] Blue
@endmindmap
```

View File

@@ -0,0 +1,200 @@
## 0 实例
```plantuml
@startuml
left to right direction
skinparam packageStyle rectangle
actor customer
actor clerk
rectangle checkout {
customer -- (checkout)
(checkout) .> (payment) : include
(help) .> (checkout) : extends
(checkout) -- clerk
}
@enduml
```
## 1 定义
### 用例
* 用例用圆括号括起来(两个圆括号看起来就像椭圆)。
* 也可以用关键字usecase来定义用例。
### 角色
角色用两个冒号包裹起来。
也可以用actor关键字来定义角色。
```plantuml
@startuml
(First usecase)
(Another usecase) as (UC2)
usecase UC3
usecase (Last\nusecase) as UC4
:First Actor:
:Another\nactor: as Man2
actor Woman3
actor :Last actor: as Person1
@enduml
```
## 2 角色样式
* 火柴人样式:默认
* 用户头像样式skinparam actorStyle awesome
* 透明人样式skinparam actorStyle hollow
## 3 用例描述
* --(横线)
* ..(虚线)
* ==(双横线)
* __下划线
```plantuml
@startuml
usecase UC1 as "You can use
several lines to define your usecase.
You can also use separators.
--
Several separators are possible.
==
And you can add titles:
..Conclusion..
This allows large description."
@enduml
```
## 4 用例包
* package 可以一使用包来对角色或用例进行分组。
```plantuml
@startuml
left to right direction
actor Guest as g
package Professional {
actor Chef as c
actor "Food Critic" as fc
}
package Restaurant {
usecase "Eat Food" as UC1
usecase "Pay for Food" as UC2
usecase "Drink" as UC3
usecase "Review" as UC4
}
fc --> UC4
g --> UC1
g --> UC2
g --> UC3
@enduml
```
## 5 继承关系
如果一个角色或者用例继承于另一个,那么可以用<|--符号表示。
```plantuml
@startuml
:Main Admin: as Admin
(Use the application) as (Use)
User <|-- Admin
(Start) <|-- (Use)
@enduml
```
## 6 使用注释
可以用note left of , note right of , note top of , note bottom of等关键字给一个对象添加注释。
```plantuml
@startuml
:Main Admin: as Admin
(Use the application) as (Use)
User -> (Start)
User --> (Use)
Admin ---> (Use)
note right of Admin : This is an example.
note right of (Use)
A note can also
be on several lines
end note
note "This note is connected\nto several objects." as N2
(Start) .. N2
N2 .. (Use)
@enduml
```
## 7 构造类型
用 << 和 >> 来定义角色或者用例的构造类型。
```plantuml
@startuml
User << Human >>
:Main Database: as MySql << Application >>
(Start) << One Shot >>
(Use the application) as (Use) << Main >>
User -> (Start)
User --> (Use)
MySql --> (Use)
@enduml
```
## 8 改变箭头方向
默认连接是竖直方向的,用--表示,可以用一个横杠或点来表示水平连接。
```plantuml
@startuml
:user: --> (Use case 1)
:user: -> (Use case 2)
@enduml
```
还可以通过给箭头添加left, right, up或down等关键字来改变方向
```plantuml
@startuml
:user: -left-> (dummyLeft)
:user: -right-> (dummyRight)
:user: -up-> (dummyUp)
:user: -down-> (dummyDown)
@enduml
```
## 9 改变风格
* 改变箭头风格
```plantuml
@startuml
actor foo
foo --> (bar) : normal
foo --> (bar1) #line:red;line.bold;text:red : red bold
foo --> (bar2) #green;line.dashed;text:green : green dashed
foo --> (bar3) #blue;line.dotted;text:blue : blue dotted
@enduml
```
* 改变用例风格
```plantuml
@startuml
actor a
actor b #pink;line:red;line.bold;text:red
usecase c #palegreen;line:green;line.dashed;text:green
usecase d #aliceblue;line:blue;line.dotted;text:blue
@enduml
```

View File

@@ -0,0 +1,288 @@
## 1 类元素
### 元素声明
```plantuml
@startuml
abstract abstract
abstract class "abstract class"
annotation annotation
circle circle
() circle_short_form
class class
diamond diamond
<> diamond_short_form
entity entity
enum enum
interface interface
@enduml
```
## 2 类间关系
### 基本关系
* 虚线箭头指向依赖;
* 实线箭头指向关联;
* 虚线三角指向接口;
* 实线三角指向父类;
* 空心菱形能分离而独立存在,是聚合;
* 实心菱形精密关联不可分,是组合;
```plantuml
@startuml
Class01 <|-- Class02
Class01 <|.. Class02
note bottom:继承、实现
Class03 <--* Class04
Class03 <--o Class04
note bottom:聚合、组合
Class05 <-- Class06
Class05 <.. Class06
note bottom:关联、依赖
Class07 -- Class08
Class07 .. Class08
note bottom:连接
@enduml
```
### 拓展关系
```plantuml
@startuml
Class21 #-- Class22
Class23 x-- Class24
Class25 }-- Class26
Class27 +-- Class28
Class29 ^-- Class30
@enduml
```
## 3 关系标签
* :tag,表示关系上的标签 。
* ""说明端的标签
* 在标签的开始或结束位置添加< 或 >以表明是哪个对象作用到哪个对象上。.
```plantuml
@startuml
Class01 "1" *-- "many" Class02 : contains
Class03 o-- Class04 : aggregation
Class05 --> "1" Class06
class Car
Driver - Car : drives >
Car *- Wheel : have 4 >
Car -- Person : < owns
@enduml
```
## 4 元素内容
### 字段和方法
* ArrayList:声明字段和方法。系统根据括号自动区分。
* {}中括号包含字段和方法。系统根据括号自动区分。
* 可以(显式地)使用 {field} 和 {method} 修饰符来覆盖解析器的对于字段和方法的默认行为
```plantuml
@startuml
Object <|-- ArrayList
Object : equals()
ArrayList : Object[] elementData
ArrayList : size()
class Dummy {
String data
void methods()
}
class Flight {
flightNumber : Integer
departureTime : Date
}
class Dummy {
{field} A field (despite parentheses)
{method} Some method
}
@enduml
```
### 访问属性
* -private
* #protect
* ~package private
* +: public
* 采用以下命令停用这些特性skinparam classAttributeIconSize 0
```plantuml
@startuml
skinparam classAttributeIconSize 0
class Dummy {
-field1
#field2
~method1()
+method2()
}
@enduml
```
### 其他修饰
通过修饰符{static}或者{abstract},可以定义静态或者抽象的方法或者属性。
```plantuml
@startuml
class Dummy {
{static} String id
{abstract} void methods()
}
@enduml
```
### 内容分组
* 自己定义分隔符来重排方法和属性,下面的分隔符都是可用的:--..==__
```plantuml
@startuml
class Foo1 {
You can use
several lines
..
as you want
and group
==
things together.
__
You can have as many groups
as you want
--
End of class
}
class User {
.. Simple Getter ..
+ getName()
+ getAddress()
.. Some setter ..
+ setName()
__ private data __
int age
-- encrypted --
String password
}
@enduml
```
## 5 模板、泛型、备注
* 模板通过类关键字("<<"和">>")来定义
* 你可以使用note left of , note right of , note top of , note bottom of这些关键字来添加备注。
* 你还可以在类的声明末尾使用note left, note right,note top, note bottom来添加备注。
* 你可以用 < 和 > 来定义类的泛型。
```plantuml
@startuml
class Object << general >>
Object <|--- ArrayList
note top of Object : In java, every class\nextends this one.
note "This is a floating note" as N1
note "This note is connected\nto several objects." as N2
Object .. N2
N2 .. ArrayList
class Foo
note left: On last defined class
class Foo3<? extends Element> {
int size()
}
Foo *- Element
@enduml
```
## 6 包和命名空间
### package
```plantuml
@startuml
package "Classic Collections" #DDDDDD {
Object <|-- ArrayList
}
package net.sourceforge.plantuml {
Object <|-- Demo1
Demo1 *- Demo2
}
scale 750 width
package foo1 <<Node>> {
class Class1
}
package foo2 <<Rectangle>> {
class Class2
}
package foo3 <<Folder>> {
class Class3
}
package foo4 <<Frame>> {
class Class4
}
package foo5 <<Cloud>> {
class Class5
}
package foo6 <<Database>> {
class Class6
}
@enduml
```
### 命名空间
在使用包package区别于命名空间类名是类的唯一标识。 也就意味着在不同的包package中的类不能使用相同的类名。
```plantuml
@startuml
class BaseClass
namespace net.dummy #DDDDDD {
.BaseClass <|-- Person
Meeting o-- Person
.BaseClass <|- Meeting
}
namespace net.foo {
net.dummy.Person <|- Person
.BaseClass <|-- Person
net.dummy.Meeting o-- Person
}
BaseClass <|-- net.unused.Person
@enduml
```

View File

@@ -0,0 +1,34 @@
## 1 对象
可用用来表示数据库的数据表之间的关系。
```plantuml
@startuml
object firstObject
object "My Second Object" as o2
@enduml
```
## 2 与类图中的通用特性
* 可见性
* 定义注释
* 使用包
* 美化输出内容
* 对象间关系
## 3 添加属性
*
```plantuml
@startuml
object user
user : name = "Dummy"
user : id = 123
object user2 {
name = "Dummy"
id = 123
}
@enduml
```

View File

@@ -0,0 +1,222 @@
## 0 活动图实例
```plantuml
@startuml
title Servlet Container
(*) --> "ClickServlet.handleRequest()"
--> "new Page"
if "Page.onSecurityCheck" then
->[true] "Page.onInit()"
if "isForward?" then
->[no] "Process controls"
if "continue processing?" then
-->[yes] ===RENDERING===
else
-->[no] ===REDIRECT_CHECK===
endif
else
-->[yes] ===RENDERING===
endif
if "is Post?" then
-->[yes] "Page.onPost()"
--> "Page.onRender()" as render
--> ===REDIRECT_CHECK===
else
-->[no] "Page.onGet()"
--> render
endif
else
-->[false] ===REDIRECT_CHECK===
endif
if "Do redirect?" then
->[yes] "redirect request"
--> ==BEFORE_DESTROY===
else
if "Do Forward?" then
-left->[yes] "Forward request"
--> ==BEFORE_DESTROY===
else
-right->[no] "Render page template"
--> ==BEFORE_DESTROY===
endif
endif
--> "Page.onDestroy()"
-->(*)
@enduml
```
## 1 基本元素
* 使用(*)作为活动图的开始点和结束点。用(*top)强制开始点位于图示的顶端。
* 使用-->绘制箭头。默认情况下,箭头开始于最接近的活动。
```plantuml
@startuml
(*) --> "First Activity"
"First Activity" --> (*)
@enduml
```
* 简略写法
```plantuml
@startuml
(*)
- "First Activity"
- "2First Activity"
- (*)
@enduml
```
## 2 箭头
### 箭头标签
用[和]放在箭头定义的后面来添加标签。
```plantuml
@startuml
(*) --> "First Activity"
-->[You can put also labels] "Second Activity"
--> (*)
@enduml
```
### 箭头方向
* -down-> (default arrow)
* -right-> or ->
* -left->
* -up->
```plantuml
@startuml
(*) -up-> "First Activity"
-right-> "Second Activity"
--> "Third Activity"
-left-> (*)
@enduml
```
## 3 分支同步
### 分支
你可以使用关键字if/then/else创建分支。
```plantuml
@startuml
(*) --> "Initialization"
if "Some Test" then
-->[true] "Some Activity"
--> "Another activity"
-right-> (*)
else
->[false] "Something else"
-->[Ending process] (*)
endif
@enduml
```
### 分支嵌套
* 默认情况下一个分支连接上一个最新的活动但是也可以使用if关键字进行连接。还可以嵌套定义分支。
```plantuml
@startuml
(*) --> if "Some Test" then
-->[true] "action 1"
if "" then
-> "action 3" as a3
else
if "Other test" then
-left-> "action 5"
else
--> "action 6"
endif
endif
else
->[false] "action 2"
endif
a3 --> if "last test" then
--> "action 7"
else
-> "action 8"
endif
@enduml
```
### 同步
你可以使用 === code === 来显示同步条。
```plantuml
@startuml
(*) --> ===B1===
--> "Parallel Activity 1"
--> ===B2===
===B1=== --> "Parallel Activity 2"
--> ===B2===
--> (*)
@enduml
```
## 4 分区
用关键字partition定义分区还可以设置背景色(用颜色名或者颜色值)。
定义活动的时候,它自动被放置到最新的分区中。
用}结束分区的定义。
```plantuml
@startuml
partition Conductor {
(*) --> "Climbs on Platform"
--> === S1 ===
--> Bows
}
partition Audience #LightSkyBlue {
=== S1 === --> Applauds
}
partition Conductor {
Bows --> === S2 ===
--> WavesArmes
Applauds --> === S2 ===
}
partition Orchestra #CCCCEE {
WavesArmes --> Introduction
--> "Play music"
}
@enduml
```

View File

@@ -0,0 +1,139 @@
## 1 简单状态
* 使用([*])开始和结束状态图。
* 使用-->添加箭头。
* hide empty description隐藏元素的空内容
```plantuml
@startuml
[*] --> State1
State1 --> [*]
State1 : this is a string
State1 : this is another string
State1 -> State2
State2 --> [*]
@enduml
```
## 2 合成状态
一个状态也可能是合成的必须使用关键字state和花括号来定义合成状态。
```plantuml
@startuml
scale 350 width
[*] --> NotShooting
state NotShooting {
[*] --> Idle
Idle --> Configuring : EvConfig
Configuring --> Idle : EvConfig
}
state Configuring {
[*] --> NewValueSelection
NewValueSelection --> NewValuePreview : EvNewValue
NewValuePreview --> NewValueSelection : EvNewValueRejected
NewValuePreview --> NewValueSelection : EvNewValueSaved
state NewValuePreview {
State1 -> State2
}
}
@enduml
```
## 3 同步状态
`<<fork>>` and `<<join>>` 表示分支与合并
```plantuml
@startuml
state fork_state <<fork>>
[*] --> fork_state
fork_state --> State2
fork_state --> State3
state join_state <<join>>
State2 --> join_state
State3 --> join_state
join_state --> State4
State4 --> [*]
@enduml
```
## 4 并发状态
用-- or ||作为分隔符来合成并发状态。
```plantuml
@startuml
[*] --> Active
state Active {
[*] -> NumLockOff
NumLockOff --> NumLockOn : EvNumLockPressed
NumLockOn --> NumLockOff : EvNumLockPressed
--
[*] -> CapsLockOff
CapsLockOff --> CapsLockOn : EvCapsLockPressed
CapsLockOn --> CapsLockOff : EvCapsLockPressed
--
[*] -> ScrollLockOff
ScrollLockOff --> ScrollLockOn : EvCapsLockPressed
ScrollLockOn --> ScrollLockOff : EvCapsLockPressed
}
@enduml
```
## 5 分支状态
`<<choice>>`表示分支状态
```plantuml
@startuml
state "Req(Id)" as ReqId <<sdlreceive>>
state "Minor(Id)" as MinorId
state "Major(Id)" as MajorId
state c <<choice>>
Idle --> ReqId
ReqId --> c
c --> MinorId : [Id <= 10]
c --> MajorId : [Id > 10]
@enduml
```
## 6 fork/join/choice实例
```plantuml
@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
```
## 7 相同内容
* 注释
* 箭头方向
* 线条类型

View File

@@ -0,0 +1,38 @@
## 实例
可以用来表示数据库中数据表的内容和数据表之间的关系
```plantuml
@startuml
' hide the spot
hide circle
' avoid problems with angled crows feet
skinparam linetype ortho
entity "Entity01" as e01 {
*e1_id : number <<generated>>
--
*name : text
description : text
}
entity "Entity02" as e02 {
*e2_id : number <<generated>>
--
*e1_id : number <<FK>>
other_details : text
}
entity "Entity03" as e03 {
*e3_id : number <<generated>>
--
e1_id : number <<FK>>
other_details : text
}
e01 ||..o{ e02
e01 |o..o{ e03
@enduml
```