一、类图
- 类的UML图示
@startuml skinparam classAttributeIconSize 0 class Dummy { -field1 : String #field2 : int ~method1() : String +method2() : void } @enduml
- 定义能见度(可访问性)
@startuml class Dummy { -field1 #field2 ~method1() +method2() } @enduml
@startuml skinparam classAttributeIconSize 0 class Dummy { -field1 #field2 ~method1() +method2() } @enduml
- 类之间的关系
@startuml Class01 <|-- Class02 Class03 *-- Class04 Class05 o-- Class06 Class07 .. Class08 Class09 -- Class10 @enduml
@startuml Class11 <|.. Class12 Class13 --> Class14 Class15 ..> Class16 Class17 ..|> Class18 Class19 <--* Class20 @enduml
@startuml Class21 #-- Class22 Class23 x-- Class24 Class25 }-- Class26 Class27 +-- Class28 Class29 ^-- Class30 @enduml
例子1:
@startuml
skinparam classAttributeIconSize 0
class Class01 {
-field1
#field2
~method1()
+method2()
}
class Class02 {
-field1
#field2
~method1()
+method2()
}
Class01 <|-- Class02
@enduml
或者
@startuml
skinparam classAttributeIconSize 0
class Class01 {
-field1
#field2
~method1()
+method2()
}
class Class02 extends Class01 {
-field1
#field2
~method1()
+method2()
}
@enduml
例子2:
@startuml
skinparam classAttributeIconSize 0
class Class01 {
-field1
#field2
~method1()
+method2()
}
class Class02 {
-field1
#field2
~method1()
+method2()
}
class Class03 {
-field1
#field2
~method1()
+method2()
}
Class01 <|-- Class02
Class01 <|-- Class03
@enduml
或者
@startuml
skinparam classAttributeIconSize 0
class Class01 {
-field1
#field2
~method1()
+method2()
}
class Class02 extends Class01 {
-field1
#field2
~method1()
+method2()
}
class Class03 extends Class01 {
-field1
#field2
~method1()
+method2()
}
@enduml
二、用例图
@startuml
left to right direction
actor "Food Critic" as fc
rectangle Restaurant {
usecase "Eat Food" as UC1
usecase "Pay for Food" as UC2
usecase "Drink" as UC3
}
fc --> UC1
fc --> UC2
fc --> UC3
@enduml
三、时序图
例子1:
@startuml
autonumber
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml
例子2:
@startuml
participant user
user -> A: DoWork
activate A
A -> B: <<create Request>>
activate B
B -> C: DoWork
activate C
C --> B: WorkDone
destroy C
B --> A: RequestCreated
deactivate B
A -> user: Done
deactivate A
@enduml
参考资料
官网:文章来源:https://www.toymoban.com/news/detail-840994.html
- PlantUML - 类图
- PlantUML - 用例图
- PlantUML - 序列图
博客:https://blog.csdn.net/pleaseprintf/article/details/130656001文章来源地址https://www.toymoban.com/news/detail-840994.html
到了这里,关于开源绘图工具 PlantUML 入门教程(常用于画类图、用例图、时序图等)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!