X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=dev%2Fgraphviz%2Fgraphviz-support.lisp;h=16f426135374a5e28c32d40d3ec5f8d52c6c7943;hb=d375a17d37fbba7ccac97c6f54caca1aa5593b25;hp=fe614aaa9438db28d5e626b00f2e666a3c858c0e;hpb=d840dffd43ba6a3db2f08975d66e39f92cefe268;p=cl-graph.git diff --git a/dev/graphviz/graphviz-support.lisp b/dev/graphviz/graphviz-support.lisp index fe614aa..16f4261 100644 --- a/dev/graphviz/graphviz-support.lisp +++ b/dev/graphviz/graphviz-support.lisp @@ -4,10 +4,6 @@ $Id: graphviz-support.lisp,v 1.7 2005/06/21 20:51:51 moody Exp $ -Copyright 1992 - 2005 Experimental Knowledge Systems Lab, -University of Massachusetts Amherst MA, 01003-4610 -Professor Paul Cohen, Director - Author: Gary King, Levente Mészáros, Attila Lendvai DISCUSSION @@ -15,14 +11,7 @@ DISCUSSION This file contains the stuff that does not depend on cl-graphviz. |# -(in-package metabang.graph) - -(export '( - print-dot-key-value - dot-attribute-value - dot-attributes-mixin - *dot-graph-attributes* - )) +(in-package #:metabang.graph) ;;; --------------------------------------------------------------------------- ; @@ -72,7 +61,7 @@ This file contains the stuff that does not depend on cl-graphviz. (princ " [" stream) (when (and directed? directed-edge-tag) (princ directed-edge-tag stream)) - (when edge-key + (when edge-labeler (princ "label=\"" stream) (funcall edge-labeler e stream) (princ "\"," stream)) @@ -94,9 +83,11 @@ This file contains the stuff that does not depend on cl-graphviz. (iterate-vertexes g (lambda (v) + ;(spy v) (iterate-edges v (lambda (e) + ;(spy e (undirected-edge-p e) (item-at-1 edges e)) (when (and (undirected-edge-p e) (not (item-at-1 edges e))) (setf (item-at-1 edges e) t) @@ -253,11 +244,13 @@ B--D [] '((:size coordinate) (:bb bounding-box) (:page text) + (:dpi float) (:ratio (:fill :compress :auto)) ;; Could actually be a float number too (:margin float) (:nodesep float) (:ranksep float) (:ordering (:out)) + (:overlap text) (:rankdir ("LR" "RL" "BT")) (:pagedir text) (:rank (:same :min :max)) @@ -267,12 +260,14 @@ B--D [] (:mclimit float) (:layers text) (:color text) - (:bgcolor text))) + (:bgcolor text) + (:fontname text))) (defparameter *dot-vertex-attributes* '((:pos coordinate) (:height float) (:width float) + (:margin float) (:fixed-size boolean) (:label text) (:shape (:record :plaintext :ellipse :circle :egg :triangle :box @@ -285,7 +280,8 @@ B--D [] (:fillcolor text) (:style (:filled :solid :dashed :dotted :bold :invis)) (:layer text) - (:url text))) + (:url text) + (:peripheries integer))) (defparameter *dot-edge-attributes* '((:pos spline) @@ -347,6 +343,7 @@ B--D [] (defmethod (setf dot-attribute-value) :before (value (attr symbol) (thing dot-attributes-mixin)) + (declare (ignore value)) (ensure-valid-dot-attribute attr thing)) (defmethod (setf dot-attribute-value) (value (attr symbol) (thing dot-attributes-mixin)) @@ -355,6 +352,22 @@ B--D [] (defmethod dot-attribute-value ((attr symbol) (thing dot-attributes-mixin)) (getf (dot-attributes thing) attr)) +(defmacro defpixel-inch-accessors (name attr type) + (bind ((actual-name (form-symbol name "-IN-PIXELS"))) + `(progn + (export ',actual-name) + (defmethod ,actual-name ((thing ,type)) + "Return the attribute in pixels assuming 72 dpi" + (awhen (dot-attribute-value ,attr thing) + (* 72 it))) + (defmethod (setf ,actual-name) (value (thing ,type)) + "Set the attribute in pixels assuming 72 dpi" + (setf (dot-attribute-value ,attr thing) (coerce (/ value 72) 'double-float)))))) + +(defpixel-inch-accessors width :width dot-vertex-mixin) +(defpixel-inch-accessors height :height dot-vertex-mixin) + + (defmethod graph->dot-properties ((graph dot-graph-mixin) (stream t)) (loop for (name value) on (dot-attributes graph) by #'cddr do @@ -437,7 +450,9 @@ B--D [] ((member text) (textify value)) ((member float) - (coerce value 'single-float)) + ;; graphviz does not support the 1.2e-3 format + (with-output-to-string (str) + (format str "~,f" (coerce value 'single-float)))) (list (unless (member value value-type :test 'equal) (error "Invalid value for ~S: ~S is not one of ~S"