Mercurial > emacs
comparison lisp/emacs-lisp/chart.el @ 105474:0a64442c10e3
Fix typos.
* emacs-lisp/chart.el, emacs-lisp/eieio.el, emacs-lisp/eieio-base.el
* emacs-lisp/eieio-comp.el, emacs-lisp/eieio-custom.el
* emacs-lisp/eieio-datadebug.el, emacs-lisp/eieio-opt.el
* emacs-lisp/eieio-speedbar.el
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Mon, 05 Oct 2009 15:32:08 +0000 |
parents | 7f4c7f5c0eba |
children | df4934f25eef |
comparison
equal
deleted
inserted
replaced
105473:07f6674a0832 | 105474:0a64442c10e3 |
---|---|
85 (defvar chart-face-pixmap-list | 85 (defvar chart-face-pixmap-list |
86 (if (and (fboundp 'display-graphic-p) | 86 (if (and (fboundp 'display-graphic-p) |
87 (display-graphic-p)) | 87 (display-graphic-p)) |
88 '("dimple1" "scales" "dot" "cross_weave" "boxes" "dimple3")) | 88 '("dimple1" "scales" "dot" "cross_weave" "boxes" "dimple3")) |
89 "If pixmaps are allowed, display these background pixmaps. | 89 "If pixmaps are allowed, display these background pixmaps. |
90 Useful if new Emacs is used on B&W display") | 90 Useful if new Emacs is used on B&W display.") |
91 | 91 |
92 (defcustom chart-face-use-pixmaps nil | 92 (defcustom chart-face-use-pixmaps nil |
93 "*Non-nil to use fancy pixmaps in the background of chart face colors." | 93 "*Non-nil to use fancy pixmaps in the background of chart face colors." |
94 :group 'eieio | 94 :group 'eieio |
95 :type 'boolean) | 95 :type 'boolean) |
131 (run-hooks 'chart-mode-hook) | 131 (run-hooks 'chart-mode-hook) |
132 ) | 132 ) |
133 | 133 |
134 (defun chart-new-buffer (obj) | 134 (defun chart-new-buffer (obj) |
135 "Create a new buffer NAME in which the chart OBJ is displayed. | 135 "Create a new buffer NAME in which the chart OBJ is displayed. |
136 Returns the newly created buffer" | 136 Returns the newly created buffer." |
137 (save-excursion | 137 (save-excursion |
138 (set-buffer (get-buffer-create (format "*%s*" (oref obj title)))) | 138 (set-buffer (get-buffer-create (format "*%s*" (oref obj title)))) |
139 (chart-mode) | 139 (chart-mode) |
140 (setq chart-local-object obj) | 140 (setq chart-local-object obj) |
141 (current-buffer))) | 141 (current-buffer))) |
160 (key-label :initarg :key-label | 160 (key-label :initarg :key-label |
161 :initform "Key") | 161 :initform "Key") |
162 (sequences :initarg :sequences | 162 (sequences :initarg :sequences |
163 :initform nil) | 163 :initform nil) |
164 ) | 164 ) |
165 "Superclass for all charts to be displayed in an emacs buffer") | 165 "Superclass for all charts to be displayed in an Emacs buffer.") |
166 | 166 |
167 (defmethod initialize-instance :AFTER ((obj chart) &rest fields) | 167 (defmethod initialize-instance :AFTER ((obj chart) &rest fields) |
168 "Initialize the chart OBJ being created with FIELDS. | 168 "Initialize the chart OBJ being created with FIELDS. |
169 Make sure the width/height is correct." | 169 Make sure the width/height is correct." |
170 (oset obj x-width (- (window-width) 10)) | 170 (oset obj x-width (- (window-width) 10)) |
186 | 186 |
187 (defclass chart-axis-range (chart-axis) | 187 (defclass chart-axis-range (chart-axis) |
188 ((bounds :initarg :bounds | 188 ((bounds :initarg :bounds |
189 :initform '(0.0 . 50.0)) | 189 :initform '(0.0 . 50.0)) |
190 ) | 190 ) |
191 "Class used to display an axis defined by a range of values") | 191 "Class used to display an axis defined by a range of values.") |
192 | 192 |
193 (defclass chart-axis-names (chart-axis) | 193 (defclass chart-axis-names (chart-axis) |
194 ((items :initarg :items | 194 ((items :initarg :items |
195 :initform nil) | 195 :initform nil) |
196 ) | 196 ) |
197 "Class used to display an axis which represents different named items") | 197 "Class used to display an axis which represents different named items.") |
198 | 198 |
199 (defclass chart-sequece () | 199 (defclass chart-sequece () |
200 ((data :initarg :data | 200 ((data :initarg :data |
201 :initform nil) | 201 :initform nil) |
202 (name :initarg :name | 202 (name :initarg :name |
203 :initform "Data") | 203 :initform "Data") |
204 ) | 204 ) |
205 "Class used for all data in different charts") | 205 "Class used for all data in different charts.") |
206 | 206 |
207 (defclass chart-bar (chart) | 207 (defclass chart-bar (chart) |
208 ((direction :initarg :direction | 208 ((direction :initarg :direction |
209 :initform vertical)) | 209 :initform vertical)) |
210 "Subclass for bar charts. (Vertical or horizontal)") | 210 "Subclass for bar charts (vertical or horizontal).") |
211 | 211 |
212 (defmethod chart-draw ((c chart) &optional buff) | 212 (defmethod chart-draw ((c chart) &optional buff) |
213 "Start drawing a chart object C in optional BUFF. | 213 "Start drawing a chart object C in optional BUFF. |
214 Erases current contents of buffer" | 214 Erases current contents of buffer." |
215 (save-excursion | 215 (save-excursion |
216 (if buff (set-buffer buff)) | 216 (if buff (set-buffer buff)) |
217 (erase-buffer) | 217 (erase-buffer) |
218 (insert (make-string 100 ?\n)) | 218 (insert (make-string 100 ?\n)) |
219 ;; Start by displaying the axis | 219 ;; Start by displaying the axis |
254 (if (oref (oref c x-axis) loweredge) nil ylen) | 254 (if (oref (oref c x-axis) loweredge) nil ylen) |
255 ymarg (+ ymarg xlen))) | 255 ymarg (+ ymarg xlen))) |
256 ) | 256 ) |
257 | 257 |
258 (defmethod chart-axis-draw ((a chart-axis) &optional dir margin zone start end) | 258 (defmethod chart-axis-draw ((a chart-axis) &optional dir margin zone start end) |
259 "Draw some axis for A in direction DIR at with MARGIN in boundry. | 259 "Draw some axis for A in direction DIR with MARGIN in boundary. |
260 ZONE is a zone specification. | 260 ZONE is a zone specification. |
261 START and END represent the boundary." | 261 START and END represent the boundary." |
262 (chart-draw-line dir (+ margin (if zone zone 0)) start end) | 262 (chart-draw-line dir (+ margin (if zone zone 0)) start end) |
263 (chart-display-label (oref a name) dir (if zone (+ zone margin 3) | 263 (chart-display-label (oref a name) dir (if zone (+ zone margin 3) |
264 (if (eq dir 'horizontal) | 264 (if (eq dir 'horizontal) |
337 (+ m -1 (round (* lpn (+ 1.0 (float n)))))) | 337 (+ m -1 (round (* lpn (+ 1.0 (float n)))))) |
338 )) | 338 )) |
339 | 339 |
340 (defmethod chart-axis-draw ((a chart-axis-names) &optional dir margin zone start end) | 340 (defmethod chart-axis-draw ((a chart-axis-names) &optional dir margin zone start end) |
341 "Draw axis information based upon A range to be spread along the edge. | 341 "Draw axis information based upon A range to be spread along the edge. |
342 Optional argument DIR the direction of the chart. | 342 Optional argument DIR is the direction of the chart. |
343 Optional argument MARGIN , ZONE, START and END specify boundaries of the drawing." | 343 Optional arguments MARGIN, ZONE, START and END specify boundaries of the drawing." |
344 (call-next-method) | 344 (call-next-method) |
345 ;; We prefer about 5 spaces between each value | 345 ;; We prefer about 5 spaces between each value |
346 (let* ((i 0) | 346 (let* ((i 0) |
347 (s (oref a items)) | 347 (s (oref a items)) |
348 (z (if zone zone 0)) | 348 (z (if zone zone 0)) |
463 (setq s (cdr s)))) | 463 (setq s (cdr s)))) |
464 ) | 464 ) |
465 | 465 |
466 (defmethod chart-sort ((c chart) pred) | 466 (defmethod chart-sort ((c chart) pred) |
467 "Sort the data in chart C using predicate PRED. | 467 "Sort the data in chart C using predicate PRED. |
468 See `chart-sort-matchlist' for more details" | 468 See `chart-sort-matchlist' for more details." |
469 (let* ((sl (oref c sequences)) | 469 (let* ((sl (oref c sequences)) |
470 (s1 (car sl)) | 470 (s1 (car sl)) |
471 (s2 (car (cdr sl))) | 471 (s2 (car (cdr sl))) |
472 (s nil)) | 472 (s nil)) |
473 (if (stringp (car (oref s1 data))) | 473 (if (stringp (car (oref s1 data))) |
484 (oset (oref c x-axis) items s) | 484 (oset (oref c x-axis) items s) |
485 )) | 485 )) |
486 ) | 486 ) |
487 | 487 |
488 (defun chart-sort-matchlist (namelst numlst pred) | 488 (defun chart-sort-matchlist (namelst numlst pred) |
489 "Sort NAMELST and NUMLST (both SEQUENCE objects) based on predicate PRED. | 489 "Sort NAMELST and NUMLST (both sequence objects) based on predicate PRED. |
490 PRED should be the equivalent of '<, except it must expect two | 490 PRED should be the equivalent of '<, except it must expect two |
491 cons cells of the form (NAME . NUM). See SORT for more details." | 491 cons cells of the form (NAME . NUM). See `sort' for more details." |
492 ;; 1 - create 1 list of cons cells | 492 ;; 1 - create 1 list of cons cells |
493 (let ((newlist nil) | 493 (let ((newlist nil) |
494 (alst (oref namelst data)) | 494 (alst (oref namelst data)) |
495 (ulst (oref numlst data))) | 495 (ulst (oref numlst data))) |
496 (while alst | 496 (while alst |
555 (put-text-property (1- (point)) (point) 'face face) | 555 (put-text-property (1- (point)) (point) 'face face) |
556 (setq i (1+ i)))))) | 556 (setq i (1+ i)))))) |
557 | 557 |
558 (defun chart-draw-line (dir zone start end) | 558 (defun chart-draw-line (dir zone start end) |
559 "Draw a line using line-drawing characters in direction DIR. | 559 "Draw a line using line-drawing characters in direction DIR. |
560 Use column or row ZONE between START and END" | 560 Use column or row ZONE between START and END." |
561 (chart-display-label | 561 (chart-display-label |
562 (make-string (- end start) (if (eq dir 'vertical) ?| ?\-)) | 562 (make-string (- end start) (if (eq dir 'vertical) ?| ?\-)) |
563 dir zone start end)) | 563 dir zone start end)) |
564 | 564 |
565 (defun chart-deface-rectangle (dir r1 r2 face) | 565 (defun chart-deface-rectangle (dir r1 r2 face) |
576 | 576 |
577 ;;; Helpful `I don't want to learn eieio just now' washover functions | 577 ;;; Helpful `I don't want to learn eieio just now' washover functions |
578 | 578 |
579 (defun chart-bar-quickie (dir title namelst nametitle numlst numtitle | 579 (defun chart-bar-quickie (dir title namelst nametitle numlst numtitle |
580 &optional max sort-pred) | 580 &optional max sort-pred) |
581 "Wash over the complex eieio stuff and create a nice bar chart. | 581 "Wash over the complex EIEIO stuff and create a nice bar chart. |
582 Create it going in direction DIR ['horizontal 'vertical] with TITLE | 582 Create it going in direction DIR ['horizontal 'vertical] with TITLE |
583 using a name sequence NAMELST labeled NAMETITLE with values NUMLST | 583 using a name sequence NAMELST labeled NAMETITLE with values NUMLST |
584 labeled NUMTITLE. | 584 labeled NUMTITLE. |
585 Optional arguments: | 585 Optional arguments: |
586 Set the charts' max element display to MAX, and sort lists with | 586 Set the chart's max element display to MAX, and sort lists with |
587 SORT-PRED if desired." | 587 SORT-PRED if desired." |
588 (let ((nc (make-instance chart-bar | 588 (let ((nc (make-instance chart-bar |
589 :title title | 589 :title title |
590 :key-label "8-m" ; This is a text key pic | 590 :key-label "8-m" ; This is a text key pic |
591 :direction dir | 591 :direction dir |