常见图形案例
PlantUML
Sequence Diagram 时序图
http://plantuml.com/sequence-diagram
- @startuml
skinparam sequenceArrowThickness 2
skinparam roundcorner 20
skinparam maxmessagesize 60
skinparam sequenceParticipant underlineactor User
participant "First Class" as A
participant "Second Class" as B
participant "Last Class" as CUser -> A: DoWork
activate AA -> B: Create Request
activate BB -> C: DoWork
activate C
C —> B: WorkDone
destroy CB —> A: Request Created
deactivate BA —> User: Done
deactivate A
交互草图
更多文档请查看 http://plantuml.com/salt
Activity Diagram 活动图
详细文档 http://plantuml.com/activity-diagram-beta#sdl
- @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
endifif (isPost?) then (yes)
:Page.onPost();
else (no)
:Page.onGet();
endif
:Page.onRender();
endif
else (false)
endifif (do redirect?) then (yes)
:redirect process;
else
if (do forward?) then (yes)
:Forward request;
else (no)
:Render page template;
endif
endifstop
Gantt Diagram 甘特图
详细文档 http://plantuml.com/gantt-diagram
- @startgantt
[Task1] lasts 10 days
then [Task2] lasts 4 days
— Phase Two —
then [Task3] lasts 5 days
then [Task4] lasts 6 days
@endgantt
Timing Diagram
http://plantuml.com/timing-diagram
Deployment Diagram
http://plantuml.com/deployment-diagram
Component Diagram
http://plantuml.com/component-diagram
You can use several keywords to group components and interfaces together:
package
node
folder
frame
cloud
database
- @startuml
package "Some Group" {
HTTP - [First Component]
[Another Component]
}node "Other Groups" {
FTP - [Second Component]
[First Component] —> FTP
}cloud {
[Example 1]
}database "MySql" {
folder "This is my folder" {
[Folder 3]
}
frame "Foo" {
[Frame 4]
}
}[Another Component] —> [Example 1]
[Example 1] —> [Folder 3]
[Folder 3] —> [Frame 4]
Class Diagram 类图
http://plantuml.com/class-diagram
You can use the interface
, annotation
and enum
keywords too.
- @startuml
abstract class AbstractList
abstract AbstractCollection
interface List
interface CollectionList <|— AbstractList
Collection <|— AbstractCollectionCollection <|- List
AbstractCollection <|- AbstractList
AbstractList <|— ArrayListclass ArrayList {
Object[] elementData
size()
}enum TimeUnit {
DAYS
HOURS
MINUTES
}annotation SuppressWarnings
Use Case Diagram 用例图
http://plantuml.com/use-case-diagram
Graphviz
Graphviz 画一个 Hash Table
- digraph g {
- rankdir=LR;
- node [shape=record,width=01,height=.1];
- a[label="<1>Hash Table|<2>Node|<3>Node|...|<4>TreeNode"];
- {
- node1[label="{<1>A1|<2>A2|...|An}"]
- node2[label="{<1>B1|<2>B2|...|Bn}"]
- subgraph cluster_treenode{
- penwidth=0;
- node[shape=circle];
- root[label="", style=filled,fillcolor=black,width=.2];
- n1[label="", style=filled,fillcolor=red,width=.2]
- n2[label="", style=filled,fillcolor=black,width=.2]
- n3[label="", style=filled,fillcolor=black,width=.2]
- n4[label="", style=filled,fillcolor=red,width=.2]
- n5[label="", style=filled,fillcolor=black,width=.2]
- n6[label="", style=filled,fillcolor=black,width=.2]
- root->n1;
- n1->n2;
- n1->n3;
- root->n4;
- n4->n5;
- n4->n6;
- }
- }
- a:2:e->node1:1 [style=dashed];
- a:3:e->node2:1;
- a:4:e->root;
- }
Graphviz 画证书链
- digraph G {
- nodesep=1.0 // increases the separation between nodes
- "Class 3 Public Primary Certification Authority" [style=filled, fillcolor=green]
- "VeriSign Class 3 Public Primary Certification Authority - G5" [style=filled, fillcolor=cyan]
- "DigiCert Global Root G2" [style=filled, fillcolor=cyan]
- "DigiCert Global CA G2" [style=filled, fillcolor=peru]
- "Server证书" [style=filled, fillcolor=peru]
- "Class 3 Public Primary Certification Authority"->{"VeriSign Class 3 Public Primary Certification Authority - G5"}
- "VeriSign Class 3 Public Primary Certification Authority - G5"->{"DigiCert Global Root G2"}
- "DigiCert Global Root G2"->{"DigiCert Global CA G2"}
- "DigiCert Global CA G2"->{"Server证书"}
- }
Graphviz 画公司部门结构
- digraph hierarchy {
- nodesep=1.0 // increases the separation between nodes
- node [shape=box] //All nodes will this shape
- edge [color="#D9D9D9", style=dashed] //All the lines look like this
- 总经理->{市场部 人事部 技术部}
- 市场部->{销售处 广告处}
- 技术部->IT经理
- {rank=same;IT经理 销售处 广告处} // Put them on the same level
- }
Graphviz 画模块依赖图
- digraph G {
- main -> parse -> execute;
- main -> init;
- main -> cleanup;
- execute -> make_string;
- execute -> printf
- init -> make_string;
- main -> printf;
- execute -> compare;
- }
若有收获,就赏束稻谷吧
35 颗稻谷