clojurecup2015-mailhead/src/mailhead/visualize.clj

32 lines
977 B
Clojure
Raw Normal View History

2015-12-05 23:01:54 +01:00
(ns mailhead.visualize
(:use [tangle.core])
(:require [mailhead.parser :as parser]))
2015-12-05 23:41:04 +01:00
(defn nodes [receive-path] ["home" "servera" "target"])
2015-12-05 23:01:54 +01:00
2015-12-05 23:41:04 +01:00
(defn edges [receive-path] [["home" "servera" {:label "200ms" :fillcolor "gray" :color "gray"}]
["servera" "target" {:label "50min" :fillcolor "gray" :color "gray"}]])
2015-12-05 23:01:54 +01:00
(defn draw-path [receive-path]
(-> (graph->dot
(nodes receive-path)
(edges receive-path)
2015-12-05 23:41:04 +01:00
{:node {:shape :box
:fontname "Arial"
:fontsize 12
:style "filled"
:fillcolor "darkgoldenrod1"
:color "darkgoldenrod3"}
:edge {:fontname "Arial"
:fontsize 10}
2015-12-05 23:01:54 +01:00
:directed? true
2015-12-05 23:41:04 +01:00
:graph {:rankdir :LR
:color "transparent"}})
2015-12-05 23:01:54 +01:00
(dot->image "png")))
(defn draw [filename]
(draw-path (parser/parse-from-file filename)))
(draw "/home/aaron/workbench/clojurecup2015/sample-data/header1.eml")