     (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)

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

(defn main-canvas []
  (let [updater (GUIUpdater.)]
    (doto (proxy [Canvas] []
            (paint [^Graphics g] (paint-screen this))))))
    
(defn main-frame []
  (doto (JFrame. "Slide Explorer II")
    .show
    (.setBounds 10 10 500 500)))

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

;;;;;;;;


      .show))
  reference)

(defn- default-screen-device []
  (->
    (java.awt.GraphicsEnvironment/getLocalGraphicsEnvironment)
    .getDefaultScreenDevice))

(defn bind-key
  "Maps an input-key on a swing component to an action,
  such that action-fn is executed when key is pressed."
  [component input-key action-fn global?]
  (let [im (.getInputMap component (if global?
                                     JComponent/WHEN_IN_FOCUSED_WINDOW
                                     JComponent/WHEN_FOCUSED))
        am (.getActionMap component)
        input-event (KeyStroke/getKeyStroke input-key)
        action
          (proxy [AbstractAction] []
            (actionPerformed [e]
                (action-fn)))
        uuid (.. UUID randomUUID toString)]
    (.put im input-event uuid)
    (.put am uuid action)))

(defn bind-window-key
  [window input-key action-fn]
  (bind-key (.getContentPane window) input-key action-fn true))

(defn full-screen! ; adapted from seesaw
  "Make the given window/frame full-screen. Pass nil to return all windows
to normal size."
  ([^java.awt.GraphicsDevice device window]
    (if window
      (do
        (.dispose window)
        (.setUndecorated window true)
        (.setFullScreenWindow device window)
        (.show window)
        )
      (let [window (.getFullScreenWindow device)]
        (.setFullScreenWindow device nil)
        (when window
          (.dispose window)
          (.setUndecorated window false)
          (.show window))))
    window)
  ([window]
    (full-screen! (default-screen-device) window)))

(defn setup-fullscreen [window]
  (bind-window-key window "F" #(full-screen! window))
  (bind-window-key window "ESCAPE" #(full-screen! nil)))

(defrecord screen-properties [x y z width height zoom])  

(def screen-state (atom nil))
