annotate src/rlm/visualize.clj @ 9:1065e7d615a4 tip

deactivate some cruft.
author Robert McIntyre <rlm@mit.edu>
date Mon, 08 Jul 2013 12:51:12 -0400
parents 12d1367cf1aa
children
rev   line source
rlm@0 1 (ns rlm.visualize
rlm@0 2 "this namespace has only one purpose -- to enable
rlm@0 3 visual display of as many data structures as possible,
rlm@0 4 with a focus on image processing (for example, raw integers
rlm@0 5 will be shown as the color which they would encode in a RGBA
rlm@0 6 BufferedImage. I want to get as many types as I can in here."
rlm@0 7 {:author "Robert McIntyre"}
rlm@0 8
rlm@0 9 (:import java.awt.image.BufferedImage
rlm@0 10 [ij ImagePlus IJ]))
rlm@0 11
rlm@0 12 (defmulti visual (fn [& args] (class (last args))))
rlm@0 13
rlm@9 14 ;;(import '[org.scilab.forge.jlatexmath TeXConstants TeXFormula TeXIcon])
rlm@0 15 (import java.awt.Insets)
rlm@0 16 (import javax.swing.JLabel)
rlm@0 17 (import java.awt.Color)
rlm@0 18
rlm@0 19
rlm@0 20 (defmethod visual ImagePlus
rlm@0 21 [image]
rlm@4 22 (.show image) image)
rlm@0 23
rlm@0 24 (defmethod visual (class 4)
rlm@0 25 [color]
rlm@0 26 (let [image (BufferedImage. 200 200 BufferedImage/TYPE_INT_RGB)]
rlm@0 27 (doall (for [y (range 200) x (range 200)] (.setRGB image x y color)))
rlm@0 28 (visual (ImagePlus. "color display" image))))
rlm@0 29
rlm@0 30 (defmethod visual BufferedImage
rlm@0 31 [image]
rlm@0 32 (visual (ImagePlus. "visual" image)))
rlm@0 33
rlm@0 34
rlm@9 35 ;; (defmethod visual TeXFormula
rlm@9 36 ;; [formula]
rlm@9 37 ;; (let [icon
rlm@9 38 ;; (doto (.createTeXIcon formula TeXConstants/STYLE_DISPLAY 30)
rlm@9 39 ;; (.setInsets (Insets. 5 5 5 5)))
rlm@9 40 ;; image (BufferedImage. (.getIconWidth icon) (.getIconHeight icon)
rlm@9 41 ;; BufferedImage/TYPE_INT_ARGB)
rlm@9 42 ;; g (.createGraphics image)
rlm@9 43 ;; jl (JLabel.)]
rlm@9 44 ;; (.setForeground jl (Color. 0 0 0))
rlm@9 45 ;; (.setColor g Color/white)
rlm@9 46 ;; (.fillRect g 0 0 (.getIconWidth icon) (.getIconHeight icon))
rlm@9 47 ;; (.paintIcon icon jl g 0 0)
rlm@9 48 ;; (visual image)))
rlm@0 49
rlm@0 50
rlm@0 51
rlm@0 52
rlm@0 53
rlm@0 54
rlm@0 55
rlm@0 56