comparison org/util.org @ 199:305439cec54d

added video to sense.org
author Robert McIntyre <rlm@mit.edu>
date Mon, 06 Feb 2012 01:40:22 -0700
parents fc0bf33bded2
children d3a2abfac405
comparison
equal deleted inserted replaced
198:fc0bf33bded2 199:305439cec54d
484 484
485 #+name: world-view 485 #+name: world-view
486 #+begin_src clojure :results silent 486 #+begin_src clojure :results silent
487 (in-ns 'cortex.util) 487 (in-ns 'cortex.util)
488 488
489 (defn view-image
490 "Initailizes a JPanel on which you may draw a BufferedImage.
491 Returns a function that accepts a BufferedImage and draws it to the
492 JPanel."
493 []
494 (let [image
495 (atom
496 (BufferedImage. 1 1 BufferedImage/TYPE_4BYTE_ABGR))
497 panel
498 (proxy [JPanel] []
499 (paint
500 [graphics]
501 (proxy-super paintComponent graphics)
502 (.drawImage graphics @image 0 0 nil)))
503 frame (JFrame. "Display Image")]
504 (SwingUtilities/invokeLater
505 (fn []
506 (doto frame
507 (-> (.getContentPane) (.add panel))
508 (.pack)
509 (.setLocationRelativeTo nil)
510 (.setResizable true)
511 (.setVisible true))))
512 (fn [#^BufferedImage i]
513 (reset! image i)
514 (.setSize frame (+ 8 (.getWidth i)) (+ 28 (.getHeight i)))
515 (.repaint panel 0 0 (.getWidth i) (.getHeight i))
516 i)))
517
518 (defprotocol Viewable 489 (defprotocol Viewable
519 (view [something])) 490 (view [something]))
520 491
521 (extend-type com.jme3.scene.Geometry 492 (extend-type com.jme3.scene.Geometry
522 Viewable 493 Viewable