uml 工具
plantuml 这类使用文本绘制uml图形的工具非常有价值,下面简单整理一下在markdown 文本里面使用plantuml的方法,以及遇到的问题。
- 使用plantuml uml在线绘图工具 绘图,提交后把生成的url拷贝到markdown 文件中。
如果想修改怎么办?
打开在线作图网址,把图片的 url 复制到下面的 url 框里面,点击 Submit ,在上面代码框里面会出现该图片对应的代码,然后修改即可。修改完成后再次生成图片即可。
plantuml例图
http://www.plantuml.com/plantuml/png/dL1BQiCm4DtFAGQlMefzWYxiGdVTjT2r94-fg2mRQLHQsfwafyWwaDk4N2F1mW4F9fYindwV9zwh8wl0gNFmOjaH5W_9juwULFBcdS9Xizt_xmgmdYcyAKEO-SSl3ifm7q3fE7wYSIf6dDib-znVvfiOYOK4vlzu_rkMs1YsdvQ_9tHH95-32H1PmuVGYOudMLMjJbkeSCQa-9MqR9k7aFtm1-vmIDfPWqCWrwis6s_oGJsUM_W3a5DVcI1s4H5h_BBr-eIQV9iwTmG0
- 使用PlantUML + Gravizo
Gravizo - Your Graphviz, UMLGraph or PlantUML for your README
<img src='https://g.gravizo.com/svg?
digraph G {
aize ="4,4";
main [shape=box];
main -> parse [weight=8];
parse -> execute;
main -> init [style=dotted];
main -> cleanup;
execute -> { make_string; printf}
init -> make_string;
edge [color=red];
main -> printf [style=bold,label="100 times"];
make_string [label="make a string"];
node [shape=box,style=filled,color=".7 .3 1.0"];
execute -> compare;
}
'>
<img src='https://g.gravizo.com/svg?
@startuml;
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
'>
This is a class diagram write in UMLGraph
This is a activity diagram write in UMLGraph
Gravizo also supports SVG in JSON format. Starts with @gravizosvg to indicate you are using an svg, use @ for attributes and $ for text nodes. Put attributes before nodes. The image will be reduced to 400 x 400.
- 注意事项
Gravizo url内的 plantuml 不能有空行