| 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 |
input metauml; |
| 19 |
|
| 20 |
beginfig(1); |
| 21 |
Class.Client("Client")()(); |
| 22 |
|
| 23 |
Class._Component("Component")()(); |
| 24 |
%("+Operation()", "+Add(Component)", "+Remove(Component)", "+GetChild(int)"); |
| 25 |
classStereotype._Component("<<interface>>"); |
| 26 |
|
| 27 |
Class.Leaf("Leaf")()("+Operation()"); |
| 28 |
|
| 29 |
Class.Composite("Composite")()(); |
| 30 |
%("+Operation()", "+Add(Component)", "+Remove(Component)", "+GetChild(int)"); |
| 31 |
|
| 32 |
leftToRight.top(30)(Client, _Component); |
| 33 |
leftToRight.top(20)(Leaf, Composite); |
| 34 |
.5[Leaf.ne, Composite.nw] = below(_Component.s, 45); |
| 35 |
|
| 36 |
drawObjects(Client, _Component, Leaf, Composite); |
| 37 |
|
| 38 |
link(associationUni)(pathHorizontal(Client.e, _Component.left)); |
| 39 |
link(inheritance)(pathStepY(Leaf.n, _Component.s, 20)); |
| 40 |
link(inheritance)(pathStepY(Composite.n, _Component.s, 20)); |
| 41 |
|
| 42 |
link(aggregationUni)(pathStepX(_Component.e, Composite.e, 55)); |
| 43 |
endfig; |
| 44 |
|
| 45 |
beginfig(2); |
| 46 |
Begin.b; |
| 47 |
Activity.eat("Eat something good", "from the kitchen"); |
| 48 |
Branch.enough; |
| 49 |
Fork.fork("h", 50); |
| 50 |
Activity.read("Read a book"); |
| 51 |
Activity.listen("Listen to music", "(and ignore it)"); |
| 52 |
Fork.join("h", 50); |
| 53 |
End.e; |
| 54 |
|
| 55 |
leftToRight.top(10)(read, listen); |
| 56 |
Group.readListen(read, listen); |
| 57 |
|
| 58 |
leftToRight(30)(b, eat); |
| 59 |
topToBottom(20)(eat, enough, fork, readListen, join, e); |
| 60 |
|
| 61 |
drawObjects(b, eat, enough, fork, readListen, join, e); |
| 62 |
|
| 63 |
clink(transition)(b, eat); |
| 64 |
clink(transition)(eat, enough); |
| 65 |
link(transition)(pathStepX(enough.e, eat.e, 80)); |
| 66 |
clink(transition)(enough, fork); |
| 67 |
clink(transition)(fork, read); |
| 68 |
clink(transition)(fork, listen); |
| 69 |
clink(transition)(read, join); |
| 70 |
clink(transition)(listen, join); |
| 71 |
clink(transition)(join, e); |
| 72 |
|
| 73 |
item(iGuard)("still hungry")(obj.sw = enough.e + (20, 0)); |
| 74 |
item(iGuard)("had enough")(obj.nw = enough.s + (0, -4)); |
| 75 |
endfig; |
| 76 |
|
| 77 |
beginfig(3); |
| 78 |
Actor.user("User"); |
| 79 |
Actor.db("Database"); |
| 80 |
|
| 81 |
Usecase.dbquery("Query database"); |
| 82 |
Usecase.auth("Authenticate user"); |
| 83 |
Usecase.authA("Authenticate by", "username, password"); |
| 84 |
Usecase.authB("Authenticate by", "smartcard"); |
| 85 |
|
| 86 |
leftToRight(30)(user.human, auth, dbquery, db.human); |
| 87 |
leftToRight.top(30)(authA, authB); |
| 88 |
.5[authA.ne, authB.nw] = below(auth.s, 20); |
| 89 |
|
| 90 |
drawObjects(user, auth, dbquery, db, authA, authB); |
| 91 |
|
| 92 |
clink(inheritance)(authA, auth); |
| 93 |
clink(inheritance)(authB, auth); |
| 94 |
clink(association)(auth, dbquery); |
| 95 |
clink(association)(user.human, auth); |
| 96 |
clink(association)(dbquery, db.human); |
| 97 |
endfig; |
| 98 |
|
| 99 |
beginfig(4); |
| 100 |
save b, e, reading, processing, composite, exit, error, result, theEnd; |
| 101 |
|
| 102 |
Begin.b; |
| 103 |
State.reading("Reading commands")(); |
| 104 |
State.processing("Processing commands")(); |
| 105 |
End.e; |
| 106 |
|
| 107 |
State.composite("Working")(b, reading, processing, e); |
| 108 |
composite.info.left := composite.info.right := 10; |
| 109 |
composite.info.drawNameLine := 1; |
| 110 |
|
| 111 |
topToBottom(20)(b, reading, processing, e); |
| 112 |
drawObject(composite); |
| 113 |
|
| 114 |
clink(transition)(b, reading); |
| 115 |
clink(transition)(reading, processing); |
| 116 |
clink(transition)(processing, e); |
| 117 |
|
| 118 |
ExitPoint.exit; |
| 119 |
exit.c=(composite.right, reading.midy); |
| 120 |
drawObject(exit); |
| 121 |
item(iAssoc)("error")(obj.nw = exit.s); |
| 122 |
|
| 123 |
clink(transition)(reading, exit); |
| 124 |
|
| 125 |
State.error("Preparing error report")(); |
| 126 |
State.result("Writing result")(); |
| 127 |
End.theEnd; |
| 128 |
|
| 129 |
topToBottom(20)(error, result, theEnd); |
| 130 |
leftToRight(30)(exit, error); |
| 131 |
|
| 132 |
drawObjects(error, result, theEnd); |
| 133 |
|
| 134 |
clink(transition)(exit, error); |
| 135 |
clink(transition)(error, result); |
| 136 |
clink(transition)(result, theEnd); |
| 137 |
|
| 138 |
link(transition)(rpathHorizontal(result.w, composite.right)); |
| 139 |
endfig; |
| 140 |
|
| 141 |
|
| 142 |
beginfig(5); |
| 143 |
save A, B; |
| 144 |
|
| 145 |
Note.A("An important", "UML note"); |
| 146 |
Note.B("Another note"); |
| 147 |
|
| 148 |
leftToRight(20)(A, B); |
| 149 |
drawObjects(A, B); |
| 150 |
|
| 151 |
clink(dashedLink)(A, B); |
| 152 |
endfig; |
| 153 |
|
| 154 |
beginfig(6); |
| 155 |
Class.A("A")()(); |
| 156 |
Class.B("B")()(); |
| 157 |
|
| 158 |
Package.pA("net.foo")(); |
| 159 |
Package.pB("net.foo.bar")(A, B); |
| 160 |
|
| 161 |
leftToRight(20)(A, B); |
| 162 |
leftToRight(50)(pA, pB); |
| 163 |
|
| 164 |
drawObjects(A, B, pA, pB); |
| 165 |
|
| 166 |
clink(nest)(pB, pA); |
| 167 |
endfig; |
| 168 |
|
| 169 |
beginfig(7); |
| 170 |
save A; |
| 171 |
|
| 172 |
Class.A("MyClass") |
| 173 |
("attr1: int", "attr2: int") |
| 174 |
("method1(): void", |
| 175 |
"method2(): void"); |
| 176 |
|
| 177 |
A.nw = (0, 0); % optional, implied |
| 178 |
drawObject(A); |
| 179 |
endfig; |
| 180 |
|
| 181 |
beginfig(8); |
| 182 |
save A, B; |
| 183 |
Class.A("A")()(); |
| 184 |
Class.B("B")()(); |
| 185 |
|
| 186 |
A.nw = (0,0); |
| 187 |
B.w = A.e + (20, 0); |
| 188 |
|
| 189 |
drawObjects(A, B); |
| 190 |
endfig; |
| 191 |
|
| 192 |
beginfig(9); |
| 193 |
save A, B; |
| 194 |
|
| 195 |
Class.A("A")()(); |
| 196 |
Class.B("B")()(); |
| 197 |
B.w = A.e + (20, 0); |
| 198 |
drawObjects(A, B); |
| 199 |
link(inheritance)(B.w -- A.e); |
| 200 |
endfig; |
| 201 |
end |
| 202 |
|
| 203 |
end |