summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/metauml/metauml_manual/fig/class_association.mp
blob: 2ff5037a8c845cdbab561a903831568e0a43f7a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
% Part of the MetaUML manual.
% Copyright (C) 2005 Ovidiu Gheorghies
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

input metauml;

beginfig(1);
   save P,B;

   Class.P("Person")()();
   Class.B("Bank")()();

   P.nw = (0,0);
   B.w = P.e + (50,0);

   drawObjects(P, B);

   drawRelation(association)(P.e -- B.w);

   item.assocName(iAssoc)("works for")(assocName.s = .5[P.e,B.w]);

   draw assocName.n -- (assocName.n + (20,20));
   label.urt("association name" infont "tyxtt", assocName.n + (20,20));
endfig;

beginfig(2);
    save P,C;

    Class.P("Person")()();
    Class.C("Company")()();

    C.n = P.s + (0, -70);
    drawObjects(P, C);

    link(association)(P.s -- C.n);

    item(iAssoc)("employee")(obj.nw = P.s);
    item(iAssoc)("1..*")(obj.ne = P.s);

    item(iAssoc)("employer")(obj.sw = C.n);
    item(iAssoc)("0..*")(obj.se = C.n);

    item(iAssoc)("works for")(obj.w = .5[P.s,C.n]);
endfig;

beginfig(3);
    save F, O;

    Class.F("Factory")()();
    Class.O("Object")()();

    O.n = F.s - (0, 50);
    drawObjects(F, O);

    clink(dependency)(F, O);
    item(iStereo)("<<creates>>")(obj.w = .5[F.s,O.n])
endfig;

end