     (let [graphics2d (cast Graphics2D g)]
       (.setRenderingHint graphics2d
                          RenderingHints/KEY_ANTIALIASING
-                         (if on RenderingHints/VALUE_ANTIALIAS_ON
+                         (if on
+                           RenderingHints/VALUE_ANTIALIAS_ON
                            RenderingHints/VALUE_ANTIALIAS_OFF)))))
        
 (defn draw-tile [^Graphics2D g image-data]
   (.drawImage g (buffered-image [512 512] (:pixels image-data))
               (AffineTransform.) nil))
 
-(defn paint-tiles [canvas]
-  (doseq [x (range 10 100 10)]
-    (.drawOval (.getGraphics canvas)
-               x x
-               (- (.getWidth canvas) (* 2 x))
-               (- (.getHeight canvas) (* 2 x)))))
-
-(defn paint-screen [canvas]
-  (enable-anti-aliasing (.getGraphics canvas))
-  (paint-tiles canvas))
+(defn paint-tiles [canvas screen-state]
+  (let [g (.getGraphics canvas)]
+    (doto g
+      enable-anti-aliasing
+      (.setColor Color/YELLOW)
+      (.fillOval (- (+ (/ (:width @screen-state) 2)
+                       (:x @screen-state))
+                    30)
+                 (- (+ (/ (:height @screen-state) 2)
+                       (:y @screen-state))
+                    30)
+                 60 60)
+      (.setColor Color/GRAY)
+      (.drawString (str @screen-state)
+                   (int 0)
+                   (int (- (:height @screen-state) 10))))))
+  
+(defn paint-screen [canvas screen-state]
+  (paint-tiles canvas screen-state))
 
 (defn handle-drags [component position-atom]
   (let [drag-origin (atom nil)

(ns slide_explorer.display
  (:import (javax.swing JFrame JLabel)
           (java.awt Canvas Graphics Graphics2D RenderingHints)
           (java.awt.event MouseAdapter WindowAdapter)
           (java.awt.image BufferedImage WritableRaster)
           (java.awt.geom AffineTransform)
           (java.io ByteArrayInputStream)
           (javax.imageio ImageIO)
           (mmcorej TaggedImage)
           (org.micromanager.utils GUIUpdater ImageUtils MDUtils))

                              + (.getWheelRotation e)))))
  z-atom)

(defn handle-resize [component size-atom]
  (let [update-size #(let [bounds (.getBounds component)]
                       (swap! size-atom merge
                              {:width (.getWidth bounds)
                               :height (.getHeight bounds)}))]
    (update-size)
    (.addComponentListener component
      (proxy [ComponentAdapter] []
        (componentResized [e]
                          (update-size)))))
  size-atom)

(defn reflect-changes [canvas screen-state]
  (add-watch screen-state "display"
    (fn [_ _ _ new-state]
      (.repaint canvas))))     

(defn main-canvas [screen-state]
  (doto
    (proxy [Canvas] []
      (paint [^Graphics g] (paint-screen this screen-state)))
    (.setBackground Color/BLACK)))
    
(defn main-frame []
  (doto (JFrame. "Slide Explorer II")
    .show
    (.setBounds 10 10 500 500)))


(defn show []
  (let [screen-state (atom (sorted-map :x 0 :y 0 :z 0))
        canvas (main-canvas screen-state)
        frame (main-frame)]
    (.add (.getContentPane frame) canvas)
    (setup-fullscreen frame)
    (handle-drags canvas screen-state)
    (handle-wheel canvas screen-state)
    (handle-resize canvas screen-state)
    (reflect-changes canvas screen-state)
    canvas))

;;;;;;;;

