Debian Codegraph @

texmf-dist/doc/metapost/metauml/manual/fig/class_diagrams.mp

raw
1 % Part of the MetaUML manual.
2 % Copyright (C) 2005 Ovidiu Gheorghies
3 %
4 % This program is free software; you can redistribute it and/or
5 % modify it under the terms of the GNU General Public License
6 % as published by the Free Software Foundation; either version 2
7 % of the License, or (at your option) any later version.
8 %
9 % This program is distributed in the hope that it will be useful,
10 % but WITHOUT ANY WARRANTY; without even the implied warranty of
11 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 % GNU General Public License for more details.
13 %
14 % You should have received a copy of the GNU General Public License
15 % along with this program; if not, write to the Free Software
16 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 input metauml;
19
20 beginfig(1);
21 Class.Count("Count")
22 ("#n: int")
23 ("+increase(): void",
24 "+get(): int");
25
26 %Count.nw = (0,0);
27 drawObject(Count);
28 %Class_draw.Count;
29 endfig;
30
31 beginfig(2);
32 Class.A("Point")
33 ("+x: int",
34 "+y: int") ();
35
36 Class.B("Circle")
37 ("radius: int")
38 ("+getRadius(): int",
39 "+setRadius(r: int):void");
40
41 A.nw = (0,0);
42 B.n = A.s - (0,45);
43 Class_draw.A;
44 Class_draw.B;
45
46 drawRelation(aggregationUni)(A.s -- B.n);
47 endfig;
48
49 beginfig(3);
50 Class.Test("Test")("a1","a2","a3")("aLongMethod():void");
51
52 Test.nw = (0,0);
53 Class_draw.Test;
54
55 dotlabel.ulft(btex nw etex, Test.nw);
56 dotlabel.top(btex n etex, Test.n);
57 dotlabel.urt(btex ne etex, Test.ne);
58 dotlabel.rt(btex e etex, Test.e);
59 dotlabel.lrt(btex se etex, Test.se);
60 dotlabel.bot(btex s etex, Test.s);
61 dotlabel.llft(btex sw etex, Test.sw);
62 dotlabel.lft(btex w etex, Test.w);
63
64 dotlabel.lft(btex c etex, Test.c);
65
66 draw Test.nw - (50,0) -- Test.ne + (10,0);
67 label.urt(btex top etex, Test.nw - (50,0));
68
69 draw Test.sw - (50,0) -- Test.se + (10,0);
70 label.lrt(btex bottom etex, Test.sw - (50,0));
71
72 draw Test.nw + (0,10) -- Test.sw - (0, 50);
73 label.bot(btex left etex, Test.sw - (0,50));
74
75 draw Test.ne + (0,10) -- Test.se - (0, 50);
76 label.bot(btex right etex, Test.se - (0,50));
77
78 drawarrow Test.nw - (25,0) -- Test.sw - (25,0);
79 label.lft(btex height etex, .5[Test.nw, Test.sw] - (25,0));
80
81 drawarrow Test.sw - (0,25) -- Test.se - (0,25);
82 label.bot(btex width etex, .5[Test.sw, Test.se] - (0,25));
83 endfig;
84
85 %newAssociationDescription.association;
86 %newAssociationUniDescription.associationUni;
87 %newInheritanceDescription.inheritance;
88 %newAggregationDescription.aggregation;
89 %newAggregationUniDescription.aggregationUni;
90 %newCompositionDescription.composition;
91 %newCompositionUniDescription.compositionUni;
92 %newDashedLinkDescription.dashedLink;
93 %newDependencyDescription.dependency;
94
95 beginfig(4);
96 save X, Y;
97 Class.X("X")()();
98 Class.Y("Y")()();
99
100 X.nw = (0,0);
101 Y.w = X.e + (50,0);
102 Class_draw.X;
103 Class_draw.Y;
104
105 drawRelation(association)(X.e -- Y.w);
106 endfig;
107
108 beginfig(5);
109 save X, Y;
110 Class.X("X")()();
111 Class.Y("Y")()();
112
113 X.nw = (0,0);
114 Y.w = X.e + (50,0);
115 Class_draw.X;
116 Class_draw.Y;
117
118 drawRelation(associationUni)(X.e -- Y.w);
119 endfig;
120
121 beginfig(6);
122 save X, Y;
123 Class.X("X")()();
124 Class.Y("Y")()();
125
126 X.nw = (0,0);
127 Y.w = X.e + (50,0);
128 Class_draw.X;
129 Class_draw.Y;
130
131 drawRelation(inheritance)(X.e -- Y.w);
132 endfig;
133
134 beginfig(7);
135 save X, Y;
136 Class.X("X")()();
137 Class.Y("Y")()();
138
139 X.nw = (0,0);
140 Y.w = X.e + (50,0);
141 Class_draw.X;
142 Class_draw.Y;
143
144 drawRelation(aggregation)(X.e -- Y.w);
145 endfig;
146
147 beginfig(8);
148 save X, Y;
149 Class.X("X")()();
150 Class.Y("Y")()();
151
152 X.nw = (0,0);
153 Y.w = X.e + (50,0);
154 Class_draw.X;
155 Class_draw.Y;
156
157 drawRelation(aggregationUni)(X.e -- Y.w);
158 endfig;
159
160 beginfig(9);
161 save X, Y;
162 Class.X("X")()();
163 Class.Y("Y")()();
164
165 X.nw = (0,0);
166 Y.w = X.e + (50,0);
167 Class_draw.X;
168 Class_draw.Y;
169
170 drawRelation(composition)(X.e -- Y.w);
171 endfig;
172
173 beginfig(10);
174 save X, Y;
175 Class.X("X")()();
176 Class.Y("Y")()();
177
178 X.nw = (0,0);
179 Y.w = X.e + (50,0);
180 Class_draw.X;
181 Class_draw.Y;
182
183 drawRelation(compositionUni)(X.e -- Y.w);
184 endfig;
185
186 beginfig(11);
187 save X, Y;
188 Class.X("X")()();
189 Class.Y("Y")()();
190
191 X.nw = (0,0);
192 Y.w = X.e + (50,0);
193 Class_draw.X;
194 Class_draw.Y;
195
196 drawRelation(dependency)(X.e -- Y.w);
197 endfig;
198
199 beginfig(12);
200 save X, Y;
201 Class.X("X")()();
202 Class.Y("Y")()();
203
204 X.nw = (0,0);
205 Y.w = X.e + (50,0);
206 Class_draw.X;
207 Class_draw.Y;
208
209 drawRelation(realization)(X.e -- Y.w);
210 endfig;
211
212 end