root/gaphor-doc/trunk/diagram-model.php

Revision 174, 5.1 kB (checked in by arjanmol, 6 years ago)

*** empty log message ***

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php    $title = "Diagram elements and the Model";
2     include "header.inc"; ?>
3
4 <p class="first">In contrast to applications like Rational Rose, Gaphor relies
5 heavily on diagrams. Since UML is a <i>graphical</i> language, all information
6 of your model should be visualized in the diagrams.
7 Therefore those diagrams are the center of Gaphor's functionality.
8
9 <p>As a result of the visual oriented character of Gaphor, all new model
10 elements are created through the diagram interface. Gaphor will not follow
11 any specific development method which will increase its usability for
12 smaller projects.
13
14 <h2>Defining Model Elements</h2>
15
16 <p class="first">In UML all classes are inherited from <tt>ModelElement</tt>.
17 When creating diagram items we can try to use the same strategy:
18
19 <p class="image"><img src="images/diagram-model1.png" alt="1"><br>
20 Metamodel like inheritance structure.
21
22 <p class="first">However, we like to make use of the
23 <a href="http://diacanvas.sourceforge.net">DiaCanvas2</a> predefined classes
24 wherever possible. Those classes already have good support for &quot;undo&quot;
25 and other nifty features.
26
27 <p class="image"><img src="images/diagram-model2.png" alt="2"><br>
28 Diagram structure using DiaCanvas2 classes.
29
30 <p class="first">The <tt>ModelElement</tt> (note that this is the
31 <tt>ModelElement</tt> diagram item, not the model object as defined by
32 the UML Metamodel) is now defined as base class for
33 every box-like element on a diagram (class, state, etc.). A
34 <tt>Relationship</tt> adds Gaphor specific behavior to the line. Line like UML
35 elements include associations, dependencies and state transitions.
36
37 <p><tt>ModelElement</tt>s and <tt>Relationship</tt>s handle their
38 <tt>subject</tt> in a different way:
39 <ul>
40   <li>A model element is assigned one subject and holds it for as long
41   as it exists.
42   <li>A relationship does not hold a subject by default, it tries to find an
43   existing data object if it is connected to a model element and releases the
44   subject if it is disconnected (this will avoid the creation of a lot of
45   objects with the same contents).
46 </ul>
47 <p class="first">One thing is typical about UML elements: they all contain
48 a lot of text. The <tt>TextField</tt> class is a simple diagram item that
49 holds a text shape and has the ability to change the text.
50 Simple text fields represent an attribute of its parents subject (for example
51 it's &quot;name&quot;). Editing the text will update the attribute and the
52 text will be updated in return.
53 For classes however, a text field can represent a data object (like an attribute
54 or an operation). It should be possible to connect comment fields too.
55
56 <h2>Model-diagram interaction</h2>
57
58 <p class="first">Since the <tt>UML</tt> module contains the data model it
59 should not know about anything diagram related (except <tt>UML.PresentationElement</tt>, which is defined in the meta-model). In the metamodel definition this
60 relationship is created between a model element and its representation:
61
62 <p class="image"><img src="images/presentationelement.png" alt="3"><br>
63 model element-representation relationship as defined my the UML MetaModel.
64
65 <p class="first">Gaphor will try to keep this relationship true, but some
66 tweaking has to be done... The <tt>PresentationElement</tt>'s are not part
67 of the <tt>UML</tt> module.
68
69 <p>If a model element is represented on a diagram a relation is created from
70 <tt>ModelElement</tt>s base class, <tt>Element</tt>, to the diagram item
71 representing the object.
72
73 <p class="image"><img src="images/gaphor-representation.png" alt="4"><br>
74 model element-representation relationship in Gaphor.
75  
76 <p class="first">Note that the relationship is bidirectional. The code in the
77 diagram item will call <tt>Element.add_presentation()</tt> when it is assigned
78 a subject and <tt>Element.remove_presentation()</tt> when the diagram item is
79 removed from the canvas. If the last representation is removed from the model
80 element, it is <tt>unlink</tt>ed. When unlinking a model element all
81 relationships with other model elements are destroyed. The model element is not
82 actually destroyed since it might wants to reinstate itself when a diagram item
83 is &quot;undone&quot;.
84
85 <p>All diagram items have the <tt>subject</tt> property. This means that you
86 can always retrieve the model element that is represented by the item as
87 <tt>item.subject</tt>.
88 There is no reason for the diagram items to have the same inheritance
89 structure as the data model. The dependencies within the diagram module
90 are as shown below. The inheritance structure in the <tt>diagram</tt> module
91 is based on functional requirements of the diagram item.
92
93 <p class="image"><img src="images/diagramitems.png" alt="5"><br>
94 Diagram items.
95
96 <p class="first">Model elements like classes, use cases and comments all
97 represent one data object (<tt>subject</tt>). All objects that are not
98 line like objects will be inherited from <tt>ModelElement</tt> is possible.
99
100 <p><tt>Relationship</tt> contains all line like objects. Text fields may be
101 attached to the lines as is usually the case for <tt>Association</tt>s.
102
103 <p><tt>CommentLine</tt> is a special case: is creates a relationship between a
104 comment and a model element, but does not have a <tt>subject</tt>.
105
106 <?php include "trailer.inc" ?>
107
108
109
Note: See TracBrowser for help on using the browser.