     (.render (dom/getElement "network"))))
 
 (def font (graphics/Font. 12 "Arial"))
-(def stroke (graphics/Stroke. 1 "#f00"))
 (def fill (graphics/SolidFill. "#f00"))
 
 (defn unit-to-pixel [unit-arg canvas-size]
   (+ (* unit-arg (- canvas-size avatar-size)) (/ avatar-size 2)))
 
 (defn draw-graph [{:keys [locs mentions]} text]
-  (. g (clear))
-
   (let [canvas-size (. g (getPixelSize))]
+    (. g (clear))
 
     ; Draw mention edges
     (doseq [[username {ux1 :x, uy1 :y}] locs

        ; no better graph in the last 'anneal-skipping' steps, so quit trying.
        (anim/unregisterAnimation animation)))))

(events/listen
  (dom/getElement "network")
  (array events/EventType.CLICK)
  (fn [_]
    (reset! animation
      (ann/anneal
        layout/score
        (ann/linear-cooling cooling)
        layout/permute-move
        ann/standard-prob
        (layout/init-state test-users)))
    (anim/registerAnimation animation)))


                  avatar-size avatar-size
                  (get (get mentions username) :image-url default-avatar)))

    (let [text (if (empty? locs)
                 "No locations to graph"
                 text)]
      (when text
        (.drawTextOnLine g text 5 20 (.width canvas-size) 20
                        "left" font nil fill)))))

(def users (atom nil))
(buzz/register :graph-update #(reset! users %))

(def animation (atom nil))

