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