diff src/laser/rasterize.clj @ 2:5ed873917c34

enabled display
author Robert McIntyre <rlm@mit.edu>
date Fri, 20 Aug 2010 00:39:50 -0400
parents 6d9bdaf919f7
children e6254010c95a
line wrap: on
line diff
     1.1 --- a/src/laser/rasterize.clj	Fri Aug 20 00:32:44 2010 -0400
     1.2 +++ b/src/laser/rasterize.clj	Fri Aug 20 00:39:50 2010 -0400
     1.3 @@ -7,7 +7,7 @@
     1.4  (import '(java.awt Color BorderLayout))
     1.5  (import '(ij ImagePlus IJ))
     1.6  (import '(java.lang Math))
     1.7 -
     1.8 +(import '(java.awt Graphics2D Panel))
     1.9  (import '(ij Macro))
    1.10  
    1.11  (import '(java.io BufferedReader InputStreamReader))
    1.12 @@ -38,7 +38,30 @@
    1.13  (def cut_feed 20)
    1.14  (def corner_radius 0)
    1.15  
    1.16 +(defmulti  display "Creates a JFrame and displays a buffered image"  class)
    1.17  
    1.18 +(defn- makePanel [image] (proxy [Panel] [] (paint [g]  (.drawImage g image 0 0 nil))))
    1.19 +
    1.20 +(defmethod display 
    1.21 +  BufferedImage  [image] 
    1.22 +  (let [panel (makePanel image)
    1.23 +	frame (JFrame. "Oh Yeah!")]
    1.24 +    (.add frame panel) 
    1.25 +    (.pack frame) 
    1.26 +    (.setVisible frame true ) 
    1.27 +    (.setSize frame(.getWidth image) (.getHeight image))))
    1.28 + 
    1.29 +(defmethod display
    1.30 +  ImagePlus [image]
    1.31 +  (display (.getBufferedImage image)))
    1.32 +
    1.33 +(defmethod display
    1.34 +  clojure.lang.PersistentHashMap [frame-hash]
    1.35 +  (display (frame-hash->bufferedImage frame-hash)))
    1.36 +
    1.37 +(defmethod display
    1.38 +    clojure.lang.PersistentArrayMap [frame-hash]
    1.39 +    (display (frame-hash->bufferedImage frame-hash)))
    1.40  
    1.41  
    1.42  (defn raster-preamble []
    1.43 @@ -48,8 +71,6 @@
    1.44  	    "M101"
    1.45  	    "M3 S1"]))
    1.46  
    1.47 -
    1.48 -
    1.49  (defn frame-hash
    1.50    "yields a convienent representation for the pixles in an image.
    1.51     Because of the size of the structvre generated, this must only be used
    1.52 @@ -97,6 +118,14 @@
    1.53  
    1.54  
    1.55  
    1.56 +
    1.57 +
    1.58 +
    1.59 +
    1.60 +
    1.61 +
    1.62 +
    1.63 +
    1.64    
    1.65    
    1.66