Debian Codegraph @

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

raw
1 % Sample MetaUML figures.
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
19 input metauml;
20
21 beginfig(1);
22 Class.A("Point")
23 ("#x:int",
24 "#y:int")
25 ("+set(x:int, y:int)",
26 "+getX():int",
27 "+getY():int",
28 "-debug():void",
29 "test():void");
30 drawObject(A);
31 endfig;
32
33 beginfig(2);
34 save A, T;
35
36 Class.A("User")()();
37 Class_stereotypes.A("<<interface>>", "<<home>>");
38
39 drawObject(A);
40 endfig;
41
42 beginfig(3);
43 save A, T;
44
45 Class.A("Vector")()();
46 ClassTemplate.T("T", "size: int")(A);
47
48 drawObjects(A, T);
49 endfig;
50
51 beginfig(4);
52 link(association)( (0,0) -- (50,0) );
53 endfig;
54
55 beginfig(5);
56 link(associationUni)( (0,0) -- (50,0) );
57 endfig;
58
59 beginfig(6);
60 link(inheritance)( (0,0) -- (50,0) );
61 endfig;
62
63 beginfig(7);
64 link(aggregation)( (0,0) -- (50,0) );
65 endfig;
66
67 beginfig(8);
68 link(aggregationUni)( (0,0) -- (50,0) );
69 endfig;
70
71 beginfig(9);
72 link(composition)( (0,0) -- (50,0) );
73 endfig;
74
75 beginfig(10);
76 link(compositionUni)( (0,0) -- (50,0) );
77 endfig;
78
79 beginfig(11);
80 save A;
81 Interface.A("Observer")
82 ("+update(src:Object)");
83
84 drawObject(A);
85 endfig;
86
87 beginfig(12);
88 save A;
89 EClass.A(iAbstractClass)("Observable")
90 ("observers: Observer[0..*]")
91 ("+addObserver(o: Observer)",
92 "+notify()");
93
94 drawObject(A);
95 endfig;
96
97 beginfig(13)
98 save A;
99
100 Class.A("MyModel")()();
101 A.info.iName.top := 10;
102 A.info.iName.bottom := 10;
103 A.info.iAttributeStack.top := 0;
104 A.info.iAttributeStack.bottom := 0;
105 A.info.iMethodStack.top := 0;
106 A.info.iMethodStack.bottom := 0;
107
108 drawObject(A);
109 endfig;
110
111 beginfig(14)
112 save A, B;
113
114 EClass.A(iClassNameOnly)("MyModel")()();
115 ClassName.B("AnotherModel");
116 classStereotypes.B("<<smart>>");
117
118 topToBottom(20)(A, B);
119
120 drawObjects(A, B);
121 endfig;
122
123 beginfig(15);
124 save A;
125
126 Class.A("Point")
127 ("#x:int", "#y:int")
128 ("+toString():String");
129 Class_noVisibilityMarkers.A;
130
131 drawObject(A);
132 endfig;
133
134 end