Debian Codegraph @

texmf-dist/doc/metapost/metauml/manual/fig/class_association.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 save P,B;
22
23 Class.P("Person")()();
24 Class.B("Bank")()();
25
26 P.nw = (0,0);
27 B.w = P.e + (50,0);
28
29 drawObjects(P, B);
30
31 drawRelation(association)(P.e -- B.w);
32
33 item.assocName(iAssoc)("works for")(assocName.s = .5[P.e,B.w]);
34
35 draw assocName.n -- (assocName.n + (20,20));
36 label.urt("association name" infont "tyxtt", assocName.n + (20,20));
37 endfig;
38
39 beginfig(2);
40 save P,C;
41
42 Class.P("Person")()();
43 Class.C("Company")()();
44
45 C.n = P.s + (0, -70);
46 drawObjects(P, C);
47
48 link(association)(P.s -- C.n);
49
50 item(iAssoc)("employee")(obj.nw = P.s);
51 item(iAssoc)("1..*")(obj.ne = P.s);
52
53 item(iAssoc)("employer")(obj.sw = C.n);
54 item(iAssoc)("0..*")(obj.se = C.n);
55
56 item(iAssoc)("works for")(obj.w = .5[P.s,C.n]);
57 endfig;
58
59 beginfig(3);
60 save F, O;
61
62 Class.F("Factory")()();
63 Class.O("Object")()();
64
65 O.n = F.s - (0, 50);
66 drawObjects(F, O);
67
68 clink(dependency)(F, O);
69 item(iStereo)("<<creates>>")(obj.w = .5[F.s,O.n])
70 endfig;
71
72 end