         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]}]
+(defmulti make-obj (fn [obj-keyword params] obj-keyword))
+
+(defmethod make-obj :arc
+  [_ {:keys [l t w h start-angle arc-angle arc-boundary closed]}]
+  (let [type (condp = (or arc-boundary closed)
+                             true Arc2D/PIE
+                             :pie Arc2D/PIE
+                             :chord Arc2D/CHORD
+                             :open Arc2D/OPEN
+                             Arc2D/OPEN)]
+      (Arc2D$Double. l t w h start-angle arc-angle type)))
+
+(defmethod make-obj :ellipse
+  [_ {:keys [l t w h]}]
+  (Ellipse2D$Double. l t w h))
+
+(defmethod make-obj :rect
+  [_ {:keys [l t w h]}]
+  (Rectangle2D$Double. l t w h))
+
+(defmethod make-obj :round-rect
+  [_ {:keys [l t w h arc-radius arc-width arc-height]}]
+  (RoundRectangle2D$Double. l t w h
+                              (or arc-radius arc-width)
+                              (or arc-radius arc-height)))
+
+(defmethod make-obj :line
+  [_ {:keys [l t r b]}]
+  (Line2D$Double. l t r b))
+
+(defmethod make-obj :polygon
+  [_ {:keys [vertices]}]
+  (let [xs (int-array (map :x vertices))
+        ys (int-array (map :y vertices))
+        n (count vertices)]
+    (Polygon. xs ys n)))
+
+(defmethod make-obj :polyline
+  [_ {:keys [vertices]}]
+  (let [path (Path2D$Double.)]
+    (let [{:keys [x y]} (first vertices)]
+      (.moveTo path x y))
+    (doseq [{:keys [x y]} (rest vertices)]
+      (.lineTo path x y))
+    path))
+
+(defmethod make-obj :text
+  [_ {:keys [text]}]
+  text)
+
+(defmethod make-obj :image
+  [_ {:keys [data]}]
+  data)
+
+(defn stroke? [stroke]
+  (and stroke (pos? (:width stroke))))
+
+(defmulti draw-primitive (fn [g2d obj params] (type obj)))
+
+(defmethod draw-primitive Shape
+  [g2d shape {:keys [fill stroke]}]
+  (when fill
+    (.fill g2d shape))
+  (when (stroke? stroke)
+    (.draw g2d shape)))
+
+(defmethod draw-primitive Image
+  [g2d image {:keys [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."

(ns slide-explorer.core
  (:import (java.awt AlphaComposite BasicStroke Color Font Graphics Graphics2D
                     Polygon RenderingHints)
           (java.awt.font TextAttribute)
           (javax.swing JFrame JPanel)))

;; possible 

   [:arc
    {:l 30 :t 20 :w 150 :h 100
     :start-angle 30 :arc-angle 100 :color 0x004000
     :fill false
     :stroke {:width 10}
     :alpha 0.7}]
   ])
