 (declare -paint)
 (declare -set-state)
 (declare -get-state)
+(declare -reset)
+(declare -save)
 
 (defn -main
   [& args]

  )
(defn -paint [this g]
  (.superpaint this g)
  (.drawImage (.getGraphics this) (get @(.state this) :img) 0 50 nil)
  )
(defn -start []
  (println "starting")
  )
(defn -step [ui]
  (let[
       path (.getState ui :path)
       color (.getState ui :color)
       graphics (.getState ui :graphics)
       angle (.getState ui :angle)
       matrix (fractal/gen-matrix angle)
       ]
    (loop [p path col color]
      (let [[x1 y1 x2 y2] (flatten (take 2 p))]
        (.setColor graphics (Color. col))
        (.drawLine graphics x1 y1 x2 y2)
        (.repaint ui)
        (if (seq (-> p rest rest))
          (recur (rest p) (+ col 10))
          (do
            (.setState ui :color col)
            (.setState ui :path (fractal/do-iteration path matrix))
            ))
       )
     )
   )
  )


(defn -draw []

  )


(defn -init []
  "Sets Initial State"
  [["Levy Curve Generator"] (atom {:path [], :angle 45, :iterations 15, :color 16711680})]
  )

(defn -setup [ui]
  "Setup UI components, listeners"
  (let [screen-size (.getScreenSize (Toolkit/getDefaultToolkit))
        width (- (.width screen-size) 400)
        height (- (.height screen-size) 100)
        comp-size (Dimension. 100 20) ;Component Size
        components {:angle-label (JLabel. "Angle")
                    :angle (JTextField. "45")
                    :step (JButton. "Step")
                    :save (JButton. "Save")
                    :reset (JButton. "Reset")}
        create-listener (fn [f & args]
                          (proxy [ActionListener] []
                            (actionPerformed [e]
                              (apply f args)))
                          )
        actions {:step (create-listener -step ui)
                 :reset (create-listener -reset ui true)
                 :save (create-listener -save ui)
                 }
        img (BufferedImage. width height BufferedImage/TYPE_INT_RGB)
        graphics (.createGraphics img)
        ]
    (doto ui ;Set size and add state
