     :side 100}
    {:type :text
     :text "hello"
-    :color red
+    :color :cyan
     :x 100
     :y 100}
    {:type :arc
-    :l 100
+    :scale 2
+      :mouse-up (fn [x y] (println "yo: " x y))
+     :l 100
      :y 200
      :w 50
      :h 70
      :start-angle 20
      :arc-angle 140
      :arc-boundary :pie}
-   ])+   ])
+
+(defn run-test []
+  (reset! grafix test-data)
+  (canvas-frame grafix))
                 0 0 w h
                 (or arc-radius arc-width)
                 (or arc-radius arc-height))))


(defn font-object
  "Create a java font object with various properties."

    (alter-meta! panel assoc ::data-source reference)
    panel))

;; mouse inputs

(defn create-action [{:keys [shape] :as widget} action-type]
  (let [offset-x (.. shape getBounds getX)
        offset-y (.. shape getBounds getY)]
    (fn [x y] ((widget action-type)
                 (- x offset-x) (- y offset-y)))))

(defn triggered-mouse-actions [action-type [x y] data]
  (->> data
       expand
       ;show
       (filter #(and (% action-type)
                     (-> (.createTransformedShape
                           (% :transform) (% :shape)) (.contains x y))))
       (map #(create-action % action-type))))

(defn run-mouse-actions [e action-type reference]
  (let [x (.getX e) y (.getY e)]                    
    (doseq [action (triggered-mouse-actions action-type [x y] @reference)]
      (action x y))))

(defn activate-dragging! [e reference canvas]
  (let [x (.getX e) y (.getY e)]
    (alter-meta! canvas assoc ::dragging-action
                 (last (mouse-actions :on-mouse-drag [x y] @reference)))))

(defn stop-dragging! [canvas]
  (alter-meta! canvas dissoc ::dragging-action))

(defn continue-dragging [e canvas]
  (let [x (.getX e) y (.getY e)]
    (when-let [action ((meta canvas) ::dragging-action)]
      (action x y))))

(defn interactive-canvas
  [reference]
  (let [canvas (canvas reference)
        data @reference
        mouse-adapter
        (proxy [MouseAdapter] []
          (mouseClicked [e] (run-mouse-actions e :mouse-click reference))
          (mousePressed [e] (activate-dragging! e reference canvas)
                            (run-mouse-actions e :mouse-down reference))
          (mouseReleased [e] (stop-dragging! canvas)
                             (run-mouse-actions e :mouse-up reference))
          (mouseEntered [e] (run-mouse-actions e :mouse-enter reference))
          (mouseExited [e] (run-mouse-actions e :mouse-exit reference))
          (mouseDragged [e] (continue-dragging e canvas)))]
    (doto canvas
      (.addMouseListener mouse-adapter)
      (.addMouseMotionListener mouse-adapter))))


;; test

(def grafix (atom nil))

(defn canvas-frame [reference]
  (let [panel (interactive-canvas reference)]
    (doto (JFrame. "canvas")
      (.. getContentPane (add panel))
      (.setBounds 10 10 500 500)
