public 用+表示
private 用-表示
protected 用#表示
package 用~表示
元素声明
abstract 抽象
abstract class 抽象(等同abstract)
annotation 注解
circle 圆
() 圆缩写形式
class 类
diamond 菱形
<> 菱形写形式
entity 实例
enum 枚举
interface 接口
类之间的关系
类型
符号
扩展
`<
组成
*--
聚合
o--
关系代码
@startuml
'https://plantuml.com/class-diagram
left to right direction
'泛化和实现'
abstract class AbstractList extends AbstractCollection implements List{
+ add():boolean
}
abstract class AbstractCollection<E> implements Collection
{
+ add():boolean
}
interface List<E> extends Collection {
+ add():boolean
}
interface Collection{
+ add():boolean
}
'关联'
class LoginForm {
JButton loginButton;
}
class JButton {
}
LoginForm --> JButton:关联
ClassOne -- ClassTwo:关联
'聚合'
class Car {
+ Engine engine;
+ Car(Engine engine):void
+ setEngine(Engine engine):void
}
class Engine {
}
Car o--Engine:聚合
'组合'
class Head {
- Mouth mouth;
+ Head();
}
class Mouth {
}
Head *--Mouth:拥有
'依赖'
class Driver {
+ drive(Car car):void
}
class Car {
+ move():void
}
Driver ..> Car:依赖
@enduml
效果图
用例图
代码
@startuml
left to right direction
actor 收银员 as a
actor 供应商 as b
actor 顾客 as c
c --> (买饮料)
b --> (放置饮料)
(放置饮料) ..> (打开机器)
(放置饮料) ..> (关闭机器)
a --> (收钱)
(收钱) ..> (打开机器)
(收钱) ..> (关闭机器)
@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
state start1 <<start>>
state choice1 <<choice>>
state fork1 <<fork>>
state join2 <<join>>
state end3 <<end>>
[*] --> choice1 : from start\nto choice
start1 --> choice1 : from start stereo\nto choice
choice1 --> fork1 : from choice\nto fork
choice1 --> join2 : from choice\nto join
choice1 --> end3 : from choice\nto end stereo
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
skinparam sequenceArrowThickness 2
skinparam roundcorner 20
skinparam maxmessagesize 60
skinparam sequenceParticipant underline
actor User
participant "First Class" as A
participant "Second Class" as B
participant "Last Class" as C
User -> A: DoWork
activate A
A -> B: Create Request
activate B
B -> C: DoWork
activate C
C --> B: WorkDone
destroy C
B --> A: Request Created
deactivate B
A --> User: Done
deactivate A
@enduml
样式
思维导图
代码
@startmindmap
'https://plantuml.com/mindmap-diagram
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
header
My super header
endheader
center footer My super footer
legend right
Short
legend
endlegend
@endmindmap