1 ;;; cogre-uml.el --- UML support for COGRE
3 ;;; Copyright (C) 2001 Eric M. Ludlam
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
7 ;; X-RCS: $Id: cogre-uml.el,v 1.1 2007-11-26 15:04:23 michaels Exp $
9 ;; This file is not part of GNU Emacs.
11 ;; This is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; This software is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
28 ;; Provides UML support for COGRE.
30 ;; See http://c2.com/cgi/wiki?UmlAsciiArt for more examples of using
31 ;; ASCII to draw UML diagrams.
36 (defclass cogre-package (cogre-node)
37 ((name-default :initform "Package")
38 (blank-lines-top :initform 0)
39 (blank-lines-bottom :initform 0)
40 (alignment :initform left)
41 (subgraph :initarg :subgraph
43 :type (or null cogre-graph)
45 "A graph which represents the classes within this package.
46 The subgraph should be scanned to extract all the elements drawn into
50 Packages represent other class diagrams, and list the major nodes
51 within them. They can be linked by dependency links.")
53 (defmethod cogre-node-slots ((package cogre-package))
54 "Return a list containing the list of classes in PACKAGE.
55 The `subgraph' slot must be scanned for this information."
59 (defclass cogre-class (cogre-node)
60 ((name-default :initform "Class")
61 (blank-lines-top :initform 0)
62 (blank-lines-bottom :initform 0)
63 (alignment :initform left)
64 (class :initarg :class
66 :type (or string list)
69 "The semantic token representing the class this is drawing.")
70 (attributes :initarg :attributes
75 "A list of attributes belonging to this Class representation.
76 Each attribute must in the form of a semantic token. ei.
77 (\"object-name\" variable \"type\" ... )
78 See `semantic-fetch-tags' for details on possible token forms.
79 These items do not need to be REAL semantic tokens, however.
80 Only the format is needed to get the name/typing information.")
81 (methods :initarg :methods
86 "A list of methods belonging to this Class representation.
87 See `attribute' slot for details on the form of each token in this list.")
90 Class nodes represent a class, and can list the attributes and methods
91 within them. Classes can have attribute links, and class hierarchy links.")
93 (defmethod cogre-uml-stoken->uml ((class cogre-class) stoken &optional text)
94 "For CLASS convert a Semantic style token STOKEN into a uml definition.
95 It also adds properties that enable editing, and interaction with
96 this node. Optional argument TEXT is a preformatted string."
99 (concat (car stoken) ":"
100 (cond ((stringp (nth 2 stoken))
102 ((listp (nth 2 stoken))
103 (car (nth 2 stoken)))
105 ;; Add in some useful properties
106 (add-text-properties 0 (length newtext)
107 (list 'semantic stoken
114 (defmethod cogre-node-slots ((class cogre-class))
115 "Return a list of each section, including title, attributes, and methods.
116 Argument CLASS is the class whose slots are referenced."
118 (mapcar (lambda (s) (cogre-uml-stoken->uml class s)) (oref class attributes))
119 (mapcar (lambda (s) (cogre-uml-stoken->uml class s)) (oref class methods))
122 (defclass cogre-inherit (cogre-link)
123 ((end-glyph :initform [ (" ^ " "/_\\")
127 (horizontal-preference-ratio :initform .1)
129 "This type of link indicates that the two nodes reference infer inheritance.
130 The `start' node is the child, and the `end' node is the parent.
131 This is supposed to infer that START inherits from END.")
133 (defclass cogre-aggrigate (cogre-link)
134 ((start-glyph :initform [ ("/\\ " "\\/" )
137 (horizontal-preference-ratio :initform 1)
139 "This type of link indicates aggregation.
140 The `start' node is the owner of the aggregation, the `end' node is
141 the item being aggregated.
142 This is supposed to infer that START contains END.")
147 ;;; cogre-uml.el ends here