   (bind-window-key window "F" #(full-screen! window))
   (bind-window-key window "ESCAPE" #(full-screen! nil)))
 
-
-
 (defn enable-anti-aliasing
   ([^Graphics g]
     (enable-anti-aliasing g true))

(ns slide-explorer.view
  (:import (javax.swing AbstractAction JComponent JFrame JPanel JLabel KeyStroke)
           (java.awt Color Graphics Graphics2D RenderingHints Window)
           (java.util UUID)
           (java.awt.event ComponentAdapter MouseAdapter WindowAdapter)
           (org.micromanager.utils GUIUpdater))
  (:use [org.micromanager.mm :only (edt)]
        [slide-explorer.image :only (crop overlay lut-object)]))

;; tile/pixels


                         (if on
                           RenderingHints/VALUE_ANTIALIAS_ON
                           RenderingHints/VALUE_ANTIALIAS_OFF)))))

(defn draw-image [g image x y clip-bounds]
  (let [image-rect (Rectangle. x y 512 512)]
    (if (.intersects image-rect clip-bounds)
      (do ;(println "drawn")
          (.drawImage g image x y nil))
      ;(println "not drawn")
      )))

(defn paint-tiles [^Graphics2D g available-tiles zoom clip-bounds [tile-width tile-height]]
  ;(println "paint-tiles")
  ;(println (System/currentTimeMillis))
  ;(timer
  (doseq [[{:keys [nx ny nz nt nc]} image] (get available-tiles zoom)]
    (when image
      (let [[x y] (tile-to-pixels [nx ny] [tile-width tile-height] zoom)]
        (draw-image g image x y clip-bounds)
          ))
    ;)
    ))

(defn paint-screen [graphics screen-state available-tiles]
  (let [original-transform (.getTransform graphics)]
    (doto graphics
      (.setClip 0 0 (:width @screen-state) (:height @screen-state))
      (.translate (+ (:x @screen-state) (/ (:width @screen-state) 2))
                  (+ (:y @screen-state) (/ (:height @screen-state) 2)))
      ;(.rotate @angle)
      enable-anti-aliasing
      (paint-tiles @available-tiles (:zoom @screen-state) (.getClipBounds graphics) [512 512])
      (.setColor Color/YELLOW)
      (.fillOval -30 -30
                 60 60)
