使用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")
原文地址:http://blog.csdn.net/ivan_pig/article/details/46402253