             (if strikethrough TextAttribute/STRIKETHROUGH_ON false))
       (.put TextAttribute/UNDERLINE
             (if underline TextAttribute/UNDERLINE_ON -1)))
-    (let [font2 (Font. attributes)]
+    (let [font2 (Font. attributes)
+          ;context (.getFontRenderContext g2d)
+          ;obj (.getOutline (.createGlyphVector font2 context text))
+          ]
+      ;(.translate g2d x y)
+      ;(draw-shape g2d obj fill stroke)
+      ;(.translate g2d (- x) (- y))
       (.setFont g2d font2)
-      (draw-string-center g2d text x y))))
+      (draw-string-center g2d text x y)
+      )))
 
 (defn draw-primitives [g2d items]
   (enable-anti-aliasing g2d)
   (doseq [[type params inner] items]
     (let [params+ (complete-coordinates params)]
       (with-g2d-state [g2d params+]
-                      (draw-primitive g2d type params+)))))
+                      (draw-primitive g2d (make-obj type params+) params+)))))
 
 (defn paint-canvas-graphics [^Graphics graphics data]
   (draw-primitives graphics data))

        y (or y (+? t (half? h)))]
    (merge the-map {:w w :h h :l l :t t :r r :b b :x x :y y})))
   
(defmulti draw-primitive (fn [g2d shape params] shape))

(defmethod draw-primitive :arc
  [g2d shape {:keys [l t w h filled start-angle arc-angle]}]
  (if filled
    (.fillArc g2d l t w h start-angle arc-angle)
    (.drawArc g2d l t w h start-angle arc-angle)))

(defmethod draw-primitive :ellipse
  [g2d shape {:keys [l t w h filled]}]
  (if filled
    (.fillOval g2d l t w h)
    (.drawOval g2d l t w h)))

(defmethod draw-primitive :image
  [g2d shape {:keys [image l t w h]}]
  (.drawImage g2d image
              l t
              (or w (.getWidth image))
              (or h (.getHeight image)) nil))

(defmethod draw-primitive :line
  [g2d shape {:keys [l t r b filled]}]
  (.drawLine g2d l t r b))

(defmethod draw-primitive :polygon
  [g2d shape {:keys [vertices filled closed]}]
  (let [xs (int-array (map :x vertices))
        ys (int-array (map :y vertices))
        n (count vertices)]
    (if filled
      (.fillPolygon g2d xs ys n)
      (if closed
        (.drawPolygon g2d xs ys n)))
        (.drawPolyline g2d xs ys n)))

(defmethod draw-primitive :rect
  [g2d shape {:keys [l t w h filled]}]
  (if filled
    (.fillRect g2d l t w h)
    (.drawRect g2d l t w h)))

(defmethod draw-primitive :round-rect
  [g2d shape {:keys [l t w h filled arc-radius arc-width arc-height]}]
  (if filled
    (.fillRoundRect g2d l t w h
                    (or arc-radius arc-width)
                    (or arc-radius arc-height))
    (.drawRoundRect g2d l t w h
                    (or arc-radius arc-width)
                    (or arc-radius arc-height))))

(defn draw-string-center
  "Draw a string centered at position x,y."

                 (float (- x (/ width 2)))
                 (float (+ y (/ height 2))))))

(defmethod draw-primitive String
  [g2d text {:keys [x y font fill stroke]}]
  (let [{:keys [name bold italic underline strikethrough size]} font
        style (bit-or (if bold Font/BOLD 0) (if italic Font/ITALIC 0))
        font1 (Font. name style size)
