新技術的誕生和更新,新工具的發現和使用是兩件讓人開心的事情。
還記得Visio下苦苦的畫流程圖的時光嗎,現在一切都變得so easy,因為有PlantUML!
這個工具可以和各種IDE集成,本文主要介紹和Eclipse的整合過程。
一、插件安裝
1. 根據Eclipse的版本不同
點擊Help->Install new software 或
點擊Help->Software Update->Find and install
2. 在彈出的對話框中Work with選項中輸入地址
http://files.idi.ntnu.no/publish/plantuml/repository/
3. 全選
4. 下載並安裝
5. 重啟Eclipse
二、安裝校驗
能夠看到如圖1的選項(小紅框)說明安裝成功。
三、使用
1. 編輯文件TestPlantUML
@startuml Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response Alice -> Bob: Another authentication Request Alice <-- Bob: another authentication Response @enduml
2. 顯示結果
點擊Window->Show View->Other->PlantUML->PlantUML
如果看到圖2,恭喜你!可以開啟愉快的流程圖繪制之旅了。
四、導出
在圖2上右鍵可以導出生成的流程圖保存為png等格式。
五、另一個繪圖工具Graphviz
1. 下載安裝不再贅述
2. 和PlantUML的整合配置見圖1中的大紅框部分。
3. 使用時注意在dot的腳本起始加上PlantUML的標識符。
@startuml digraph G { node [peripheries=2 style=filled color="#eecc80"] edge [color="sienna" fontcolor="green"] main -> parse -> execute; main -> init [arrowhead = box]; main -> cleanupi -> main; make_string[label = once shape=parallelogram style=filled ] execute -> make_string[label=go style=dashed arrowtail=diamond]; execute -> printf [shape=box]; init -> make_string; main -> printf[dir=none]; execute -> compare[dir=both]; } @enduml
六、show一下示例dot的產物
七、更多的PlantUML的學習參考
http://translate.plantuml.com/zh/PlantUML_Language_Reference_Guide_ZH.pdf