本文共 1811 字,大约阅读时间需要 6 分钟。
使用Clojure封装了Graphviz的使用。眼下主要实现了UML的绘制
以命令模式的UML为例,演示cdraw的使用
cdraw是对Graphviz的简单封装。请先安装Graphviz
[com.ivaneye/cdraw "0.2.0"]
(ns uml.core (:require [cdraw.uml :refer :all])) (defclass Client) (defclass Inboker) (defclass Receiver { :m ["Action()"]}) (defclass Command { :m ["Execute()"]}) (defclass ConcreteCommand { :f ["state"] :m ["Execute()"]})
(defrelation Client :u Receiver) (defrelation ConcreteCommand :u Receiver { :t "reveiver"}) (defrelation Client :d ConcreteCommand)(defrelation ConcreteCommand :e Command)(defrelation Invoker :p Command)
关联 :u 依赖 :d聚合 :p组合 :c继承 :e实现 :i
(label ConcreteCommand "receive-\\>Action()")
(defsub "Sub Command" Command ConcreteCommand)
(watch (to-file "/t.dot") "/t.png")
(ns uml.core (:require [cdraw.uml :refer :all]))(defclass Client)(defclass Invoker)(defclass Receiver { :m ["Action()"]})(defclass Command { :m ["Execute()"]})(defclass ConcreteCommand { :f ["state"] :m ["Execute()"]})(defrelation Client :u Receiver)(defrelation ConcreteCommand :u Receiver { :t "reveiver"})(defrelation Client :d ConcreteCommand)(defrelation ConcreteCommand :e Command)(defrelation Invoker :p Command)(label ConcreteCommand "receive-\\>Action()")(defsub "Sub Command" Command ConcreteCommand)
(watch (to-file "/t.dot") "/t.png")
本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5193593.html,如需转载请自行联系原作者