dot命令生成流程图
来源:互联网 发布:手机shell是什么软件 编辑:程序博客网 时间:2024/05/16 10:22
dot命令是graphviz的一部分,通过编写一些类似脚本的语言,可以容易地生成流程图。下面在新建一个文件tmp.dot,内容如下:
digraph G {# 定义全局属性 fontname = "Courier New" fontsize = 8 # 从下往上 rankdir = BT# 定义节点属性 node [ shape = "record" # 矩形,默认是椭圆 color = "blue" # 边框蓝色 ]# 定义边的属性 edge [ fontsize = 9 ]# 换行符是\l,而要新建一个新的单元格,则需要是用|。{}里面的是内容 Reportable [ label = "{Reportable | + getSummary() : Map\<String, Integer\> | + getDetail() : Map\<String, Integer\> | + isDetailVisible() : boolean}" ]# 特殊字符要转义 LineCounter [ label = "{LineCounter | + count(String line) : boolean | + getType() : String}" ] CharCounter [ label = "{CharCounter | + count(Character c) : boolean | + getType() : String}" ] AbstractCharCounter [ label = "{AbstractCharCounter | characterMap : Map\<Character, Integer\> | + count(Character c) : boolean | + getSummary() : Map\<String, Integer\> | +getDetail() : Map\<String, Integer\> }" ] AbstractLineCounter [ label = "{AbstractLineCounter | + count(String line) : boolean | + getSummary() : Map\<String, Integer\> | +getDetail() : Map\<String, Integer\> }" ] PredicateCharacter[label = "{Predicate\<Character\> | + apply(Character c) : boolean}"] PredicateString[label = "{Predicate\<String\> | + apply(String line) : boolean}"] BlankCharCounter[label = "{BlankCharCounter | + apply(Character c) : boolean | + getType() : String | + isDetailVisible() : boolean }"] ChineseCharCounter[label = "{ChineseCharCounter | - chinesePattern : Pattern | + apply(Character c) : boolean | + getType() : String | + isDetailVisible() : boolean }"] LetterCharCounter[label = "{LetterCharCounter | - chinesePattern : Pattern | + apply(Character c) : boolean | + getType() : String | + isDetailVisible() : boolean }"] NumberCharCounter[label = "{NumberCharCounter | + apply(Character c) : boolean | + getType() : String | + isDetailVisible() : boolean }"] LineNumberCounter[label = "{LineNumberCounter | + apply(Character c) : boolean | + getType() : String | + isDetailVisible() : boolean }"] parentInterface [label = "parent interface" color = "green" style=filled] childInterface [label = "child interface" color = "green" style=filled] abstractClass [ label = "abstract class : implement some methods using the abstract methods" color = "green" style=filled] specificClass [ label = "specific class : implement all unimplemented methods" color = "green" style=filled] LineProcessor [label = "{LineProcessor\<List\<Reportable\>\>}" ] ReportableLineProcessor [ label = "{ReportableLineProcessor | + ReportableLineProcessor() | + processsLine(String line) : boolean | + getResult() : List\<Reportable\>}"] # 定义在同一层 {rank = same; parentInterface; Reportable; LineProcessor} {rank = same; childInterface; LineCounter; CharCounter; PredicateCharacter; PredicateString} {rank = same; abstractClass; AbstractLineCounter; AbstractCharCounter;} {rank = same; specificClass; LineNumberCounter; BlankCharCounter; ChineseCharCounter; LetterCharCounter; NumberCharCounter; ReportableLineProcessor} # 箭头为空心,接口之间的继承 LineCounter -> Reportable[arrowhead="empty"] CharCounter -> Reportable[arrowhead="empty"] AbstractCharCounter -> CharCounter[arrowhead="empty"] AbstractLineCounter -> LineCounter[arrowhead="empty"] AbstractCharCounter -> PredicateCharacter[arrowhead="empty"] AbstractLineCounter -> PredicateString[arrowhead="empty"] # 实现类的UML BlankCharCounter -> AbstractCharCounter[arrowhead="empty", style="dashed"] ChineseCharCounter -> AbstractCharCounter[arrowhead="empty", style="dashed"] LetterCharCounter -> AbstractCharCounter[arrowhead="empty", style="dashed"] NumberCharCounter -> AbstractCharCounter[arrowhead="empty", style="dashed"] LineNumberCounter -> AbstractLineCounter[arrowhead="empty", style="dashed"] ReportableLineProcessor -> LineProcessor[arrowhead="empty", style="dashed"]}
首先安装graphviz
sudo apt-get install graphviz
然后生成运行如下命令,生成流程图:
dot -Tpng -o hello.png tmp.dot
打开图片:
xdg-open hello.png
结果如下:
实例2:
digraph otherOp{ node [ shape = "record" color = "blue" ] edge[ arrowhead = "empty" ] // 子图,必须以cluster开头 subgraph cluster0{ // 子图用浅灰色填充 style = filled color = lightgray // 子图名字 label = "web server" // 制定整个client_socket填充,且填充的颜色为red,这时边缘是蓝色。不指定颜色,则会用上面的边缘颜色blue填充,导致无法看到边缘。 // 这里使用s0,s1...占位符号 client_socket [label = "{<s0>|<s1>head|<s2>|<s3>...|<s4>|<s5>tail|<s6>}" style = "filled" fillcolor = "red"] // 指定边上的文字 master_thread -> client_socket : s1[label = "produce socket"] worker_thread [label = "{<w0> worker_thread 1| <w1> worker_thread 2 | <w2>worker_thread 3}"] client_socket : s5 -> worker_thread : w0 client_socket : s4 -> worker_thread : w1 [ label = "consume socket"] client_socket : s3 -> worker_thread : w2 producer[ label = "producer" style = filled fillcolor = "green"] consumer[ label = "comsumer" style = filled fillcolor = "green"] Queue[ label = "Queue" style = filled fillcolor = "green"] {rank = same; producer; master_thread} {rank = same; consumer; worker_thread} {rank = same; Queue; client_socket} } request1 -> master_thread[color = "red"] request2 -> master_thread[color = "red"] request3 -> master_thread[color = "red"] // 边是虚线,且是橙色 request1 -> worker_thread : w0 [ style = "dashed" color = "orange", label = "process request"] request2 -> worker_thread : w1 [ style = "dashed" color = "orange" label = "process request"] request3 -> worker_thread : w2 [ style = "dashed" color = "orange" label = "process request"] Browser[ label = "Browser" style = filled fillcolor = "green"] {rank = same; Browser; request1; request2; request3}}
结果:
多个点相互连接的简便写法是
{a; b} -> {c; d}
参考
http://gashero.iteye.com/blog/1748795
0 0
- dot命令生成流程图
- C#生成Word Dot【转-】
- dot生成pdf格式图片
- linux使用--8.dot 画流程图的hello world
- dot 语言 graphviz 树 图 或者流程图 vimdot 预览
- Graphviz dot,使用dot语言快速生成图表
- JavaScript 生成流程图
- Activiti生成流程图
- activiti动态生成流程图
- 生成流程图的工具: AutoFlowchart
- am命令启动Acitivity流程图
- 用代码画流程图和时序图快餐教程(1) - graphviz的dot图
- android的dmtracedump工具生成trace文件图片 'dot' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
- 我使用过的Linux命令之dot - 绘制DOT语言脚本描述的图形
- 我使用过的Linux命令之dot - 绘制DOT语言脚本描述的图形
- 我使用过的Linux命令之dot - 绘制DOT语言脚本描述的图形
- 我使用过的Linux命令之dot - 绘制DOT语言脚本描述的图形
- 图谱导航Graphviz文件生成,转dot类
- C++命名规则 整型宽度 整型溢出
- 《CLR via C#》读书笔记-线程同步(五)
- 《神经网络:回到未来》(Neural Nets Back to the Future)-ICML 2016
- hadoop2.2.0伪分布式搭建
- bzoj 3245 spfa
- dot命令生成流程图
- [替罪羊树 动态点分治 替罪羊式重构] BZOJ 3435 [Wc2014]紫荆花之恋 & UOJ #55 【WC2014】紫荆花之恋
- 生物密码具有唯一性和不变性,必须掌握在自己手中!
- 《牛客网剑指offer38题》输入一棵二叉树,求该树的深度
- 深入margin
- 消息队列技术的介绍和原理(MQ)
- 中缀表达式转换为后缀表达式 简易实现(c++)(简易表达式计算)
- android webview下载附件几种方法
- 1001. A+B Format (20)