 
 (ns conexp.contrib.draw.nodes-and-connections
   (:use [conexp.base :only (ns-doc,defvar-, defvar, round, union, difference)]
-	conexp.contrib.draw.scenes)
-  (:use	[clojure.contrib.core :only (-?>)])
+        conexp.contrib.draw.scenes)
+  (:use [clojure.contrib.core :only (-?>)])
   (:import [java.awt Color]
-	   [no.geosoft.cc.graphics GWindow GScene GObject GSegment
-	                           GStyle GInteraction ZoomInteraction
-	                           GText GPosition]))
+           [no.geosoft.cc.graphics GWindow GScene GObject GSegment
+                                   GStyle GInteraction ZoomInteraction
+                                   GText GPosition]))
 
 (ns-doc
  "Namespace for representing nodes and their connections for drawing

    (connect-nodes scn x y (str (get-name x) " -> " (get-name y))))
  ([^GScene scn, ^GObject x, ^GObject y, name]
     (let [line (GSegment.),
	   c    (proxy [GObject] []
		  (draw []
		    (let [[x1 y1] (position (lower-node this))
			  [x2 y2] (position (upper-node this))]
		      (.setGeometry line
				    (double x1) (double y1)
				    (double x2) (double y2)))))]
       (doto scn
	 (.add c))
       (doto line
	 (.setStyle default-line-style))
       (doto c
	 (.addSegment line)
	 (.toBack)
	 (.setUserData (ref {:type :connection,
			     :lower x,
			     :upper y,
			     :name name})))
       (dosync
	(alter (.getUserData x) update-in [:upper] conj c)
	(alter (.getUserData y) update-in [:lower] conj c)))))


;;; move nodes around

    (if (empty? lowers)
      nil
      (reduce max (map (fn [node]
                         ((position node) 1))
                       lowers)))))

(defn- height-of-upper-neighbors
  "Returns minimal height of all upper neighbors."
