diff options
author | Karl Berry <karl@freefriends.org> | 2019-02-03 22:45:55 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-02-03 22:45:55 +0000 |
commit | c5d84d1a3ab85b1f314ff62717a7af3c6b75c7af (patch) | |
tree | 26333edc4a6082f37d75349f84eded8dbc0d5aef /Master/texmf-dist/doc/metapost/metauml/manual | |
parent | 2dcfe2f07af05124d5ebee4672d67d7eeae7af60 (diff) |
metauml (3feb19)
git-svn-id: svn://tug.org/texlive/trunk@49923 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/metapost/metauml/manual')
53 files changed, 6278 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/activity.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/activity.mp new file mode 100644 index 00000000000..676d1996eb1 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/activity.mp @@ -0,0 +1,52 @@ +% Sample MetaUML figures. +% 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); + Begin.b; + End.e; + FlowFinal.f; + + leftToRight(20)(b, e, f); + + drawObjects(b, e, f); +endfig; + +beginfig(2); + Activity.A("Learn MetaUML -", + "the MetaPost UML library"); + drawObject(A); +endfig; + +beginfig(3); + Fork.forkA("h", 50); + Fork.forkB("v", 20); + + leftToRight(10)(forkA, forkB); + + drawObjects(forkA, forkB); +endfig; + +beginfig(4); + Branch.testA; + + drawObject(testA); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/activity_diagrams.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/activity_diagrams.mp new file mode 100644 index 00000000000..0807619acd9 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/activity_diagrams.mp @@ -0,0 +1,59 @@ +% 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. + +% for f in `find . | grep '.*\.[1-9]'`; do echo $f; done + +input metauml; + +beginfig(1); + Begin.b; + Activity.eat("Eat something good", "from the kitchen"); + Branch.enough; + Fork.fork("h", 50); + Activity.read("Read a book"); + Activity.listen("Listen to music", "(and ignore it)"); + Fork.join("h", 50); + End.e; + + eat.n = b.s + (0,-20); + enough.n = eat.s + (0,-20); + fork.n = enough.s + (0, -20); + + read.top = listen.top = fork.bottom - 30; + listen.left - read.right = 10; + b.midx = .5[listen.left, read.right]; + + join.n = (b.midx, listen.bottom - 20); + e.n = join.s + (0, -20); + + drawObjects(b, eat, enough, fork, read, listen, join, e); + + clink(transition)(b, eat); + clink(transition)(eat, enough); + link(transition)(pathStepX(enough.w, eat.w, -80)); + clink(transition)(enough, fork); + clink(transition)(fork, read); + clink(transition)(fork, listen); + clink(transition)(read, join); + clink(transition)(listen, join); + clink(transition)(join, e); + + item(iGuard)("still hungry")(obj.se = enough.w + (-20, 0)); + item(iGuard)("had enough")(obj.nw = enough.s + (0, -4)); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/appetizer.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/appetizer.mp new file mode 100644 index 00000000000..ed90dc77dc1 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/appetizer.mp @@ -0,0 +1,203 @@ +% Sample MetaUML figures. +% 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); + Class.Client("Client")()(); + + Class._Component("Component")()(); + %("+Operation()", "+Add(Component)", "+Remove(Component)", "+GetChild(int)"); + classStereotype._Component("<<interface>>"); + + Class.Leaf("Leaf")()("+Operation()"); + + Class.Composite("Composite")()(); + %("+Operation()", "+Add(Component)", "+Remove(Component)", "+GetChild(int)"); + + leftToRight.top(30)(Client, _Component); + leftToRight.top(20)(Leaf, Composite); + .5[Leaf.ne, Composite.nw] = below(_Component.s, 45); + + drawObjects(Client, _Component, Leaf, Composite); + + link(associationUni)(pathHorizontal(Client.e, _Component.left)); + link(inheritance)(pathStepY(Leaf.n, _Component.s, 20)); + link(inheritance)(pathStepY(Composite.n, _Component.s, 20)); + + link(aggregationUni)(pathStepX(_Component.e, Composite.e, 55)); +endfig; + +beginfig(2); + Begin.b; + Activity.eat("Eat something good", "from the kitchen"); + Branch.enough; + Fork.fork("h", 50); + Activity.read("Read a book"); + Activity.listen("Listen to music", "(and ignore it)"); + Fork.join("h", 50); + End.e; + + leftToRight.top(10)(read, listen); + Group.readListen(read, listen); + + leftToRight(30)(b, eat); + topToBottom(20)(eat, enough, fork, readListen, join, e); + + drawObjects(b, eat, enough, fork, readListen, join, e); + + clink(transition)(b, eat); + clink(transition)(eat, enough); + link(transition)(pathStepX(enough.e, eat.e, 80)); + clink(transition)(enough, fork); + clink(transition)(fork, read); + clink(transition)(fork, listen); + clink(transition)(read, join); + clink(transition)(listen, join); + clink(transition)(join, e); + + item(iGuard)("still hungry")(obj.sw = enough.e + (20, 0)); + item(iGuard)("had enough")(obj.nw = enough.s + (0, -4)); +endfig; + +beginfig(3); + Actor.user("User"); + Actor.db("Database"); + + Usecase.dbquery("Query database"); + Usecase.auth("Authenticate user"); + Usecase.authA("Authenticate by", "username, password"); + Usecase.authB("Authenticate by", "smartcard"); + + leftToRight(30)(user.human, auth, dbquery, db.human); + leftToRight.top(30)(authA, authB); + .5[authA.ne, authB.nw] = below(auth.s, 20); + + drawObjects(user, auth, dbquery, db, authA, authB); + + clink(inheritance)(authA, auth); + clink(inheritance)(authB, auth); + clink(association)(auth, dbquery); + clink(association)(user.human, auth); + clink(association)(dbquery, db.human); +endfig; + +beginfig(4); + save b, e, reading, processing, composite, exit, error, result, theEnd; + + Begin.b; + State.reading("Reading commands")(); + State.processing("Processing commands")(); + End.e; + + State.composite("Working")(b, reading, processing, e); + composite.info.left := composite.info.right := 10; + composite.info.drawNameLine := 1; + + topToBottom(20)(b, reading, processing, e); + drawObject(composite); + + clink(transition)(b, reading); + clink(transition)(reading, processing); + clink(transition)(processing, e); + + ExitPoint.exit; + exit.c=(composite.right, reading.midy); + drawObject(exit); + item(iAssoc)("error")(obj.nw = exit.s); + + clink(transition)(reading, exit); + + State.error("Preparing error report")(); + State.result("Writing result")(); + End.theEnd; + + topToBottom(20)(error, result, theEnd); + leftToRight(30)(exit, error); + + drawObjects(error, result, theEnd); + + clink(transition)(exit, error); + clink(transition)(error, result); + clink(transition)(result, theEnd); + + link(transition)(rpathHorizontal(result.w, composite.right)); +endfig; + + +beginfig(5); + save A, B; + + Note.A("An important", "UML note"); + Note.B("Another note"); + + leftToRight(20)(A, B); + drawObjects(A, B); + + clink(dashedLink)(A, B); +endfig; + +beginfig(6); + Class.A("A")()(); + Class.B("B")()(); + + Package.pA("net.foo")(); + Package.pB("net.foo.bar")(A, B); + + leftToRight(20)(A, B); + leftToRight(50)(pA, pB); + + drawObjects(A, B, pA, pB); + + clink(nest)(pB, pA); +endfig; + +beginfig(7); + save A; + + Class.A("MyClass") + ("attr1: int", "attr2: int") + ("method1(): void", + "method2(): void"); + + A.nw = (0, 0); % optional, implied + drawObject(A); +endfig; + +beginfig(8); + save A, B; + Class.A("A")()(); + Class.B("B")()(); + + A.nw = (0,0); + B.w = A.e + (20, 0); + + drawObjects(A, B); +endfig; + +beginfig(9); + save A, B; + + Class.A("A")()(); + Class.B("B")()(); + B.w = A.e + (20, 0); + drawObjects(A, B); + link(inheritance)(B.w -- A.e); +endfig; +end + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/boxes_vs_util.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/boxes_vs_util.mp new file mode 100644 index 00000000000..985c9bb158b --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/boxes_vs_util.mp @@ -0,0 +1,92 @@ +% 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 boxes; +input util_commons; +input util_object; +input util_picture; + +beginfig(1); + boxit.a ("yummy"); + boxit.b ("cool"); + + a.nw = (0,0); + b.sw = a.se + (10,0); + + drawboxed (a, b); + draw a.sw -- b.se dashed evenly withpen pencircle scaled 1.1; + + boxit.c ("yummy"); + boxit.d ("cool"); + + c.nw = (0,-20); + d.sw = c.se + (10,0); + + drawunboxed (c, d); + draw c.sw -- d.se dashed evenly withpen pencircle scaled 1.1; +endfig; + +beginfig(2); + save a, b, c, d; + + Picture.a("yummy"); + Picture.b("cool"); + a.info.boxed := b.info.boxed := 1; + + a.nw = (0,0); + b.sw = a.se + (10,0); + + drawObjects(a, b); + draw a.sw -- b.se dashed evenly withpen pencircle scaled 1.1; + + Picture.c("yummy"); + Picture.d("cool"); + + c.nw = (0,-20); + d.sw = c.se + (10,0); + + drawObjects(c, d); + draw c.sw -- d.se dashed evenly withpen pencircle scaled 1.1; +endfig; + +beginfig(3); + save a, b, c, d; + + iPict.ignoreNegativeBase := 1; + + Picture.a("yummy"); + Picture.b("cool"); + a.info.boxed := b.info.boxed := 1; + + a.nw = (0,0); + b.sw = a.se + (10,0); + + drawObjects(a, b); + draw a.sw -- b.se dashed evenly withpen pencircle scaled 1.1; + + Picture.c("yummy"); + Picture.d("cool"); + + c.nw = (0,-20); + d.sw = c.se + (10,0); + + drawObjects(c, d); + draw c.sw -- d.se dashed evenly withpen pencircle scaled 1.1; +endfig; + + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/class.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/class.mp new file mode 100644 index 00000000000..e5d03d3d43d --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/class.mp @@ -0,0 +1,134 @@ +% Sample MetaUML figures. +% 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); + Class.A("Point") + ("#x:int", + "#y:int") + ("+set(x:int, y:int)", + "+getX():int", + "+getY():int", + "-debug():void", + "test():void"); + drawObject(A); +endfig; + +beginfig(2); + save A, T; + + Class.A("User")()(); + Class_stereotypes.A("<<interface>>", "<<home>>"); + + drawObject(A); +endfig; + +beginfig(3); + save A, T; + + Class.A("Vector")()(); + ClassTemplate.T("T", "size: int")(A); + + drawObjects(A, T); +endfig; + +beginfig(4); + link(association)( (0,0) -- (50,0) ); +endfig; + +beginfig(5); + link(associationUni)( (0,0) -- (50,0) ); +endfig; + +beginfig(6); + link(inheritance)( (0,0) -- (50,0) ); +endfig; + +beginfig(7); + link(aggregation)( (0,0) -- (50,0) ); +endfig; + +beginfig(8); + link(aggregationUni)( (0,0) -- (50,0) ); +endfig; + +beginfig(9); + link(composition)( (0,0) -- (50,0) ); +endfig; + +beginfig(10); + link(compositionUni)( (0,0) -- (50,0) ); +endfig; + +beginfig(11); + save A; + Interface.A("Observer") + ("+update(src:Object)"); + + drawObject(A); +endfig; + +beginfig(12); + save A; + EClass.A(iAbstractClass)("Observable") + ("observers: Observer[0..*]") + ("+addObserver(o: Observer)", + "+notify()"); + + drawObject(A); +endfig; + +beginfig(13) + save A; + + Class.A("MyModel")()(); + A.info.iName.top := 10; + A.info.iName.bottom := 10; + A.info.iAttributeStack.top := 0; + A.info.iAttributeStack.bottom := 0; + A.info.iMethodStack.top := 0; + A.info.iMethodStack.bottom := 0; + + drawObject(A); +endfig; + +beginfig(14) + save A, B; + + EClass.A(iClassNameOnly)("MyModel")()(); + ClassName.B("AnotherModel"); + classStereotypes.B("<<smart>>"); + + topToBottom(20)(A, B); + + drawObjects(A, B); +endfig; + +beginfig(15); + save A; + + Class.A("Point") + ("#x:int", "#y:int") + ("+toString():String"); + Class_noVisibilityMarkers.A; + + drawObject(A); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/class_association.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/class_association.mp new file mode 100644 index 00000000000..2ff5037a8c8 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/class_association.mp @@ -0,0 +1,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 diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/class_customization.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/class_customization.mp new file mode 100644 index 00000000000..980915ea00e --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/class_customization.mp @@ -0,0 +1,94 @@ +% 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); + iClass.foreColor := (.9, .9, 0); + + Class.A("A")()(); + Class.B("B")()(); + Class.C("C")()(); + + B.w = A.e + (20,0); + C.n = .5[A.se, B.sw] + (0, -10); + + drawObjects(A, B, C); +endfig; + +beginfig(2); + save A, B, C; + iClass.foreColor := (.9, .9, 0); + + Class.A("A")()(); + Class.B("B")()(); + Class.C("C")()(); + C.info.foreColor := (.7, .7, .9); + C.info.borderColor := blue; + C.info.iName.iFont.scale := 2; + + B.w = A.e + (20,0); + C.n = .5[A.se, B.sw] + (0, -10); + + drawObjects(A, B, C); +endfig; + +beginfig(3); + ClassInfoCopy.iHome(iClass); + iHome.foreColor := (0, .9, .9); + + ClassInfo.iRemote; + iRemote.foreColor := (.9, .9, 0); + iRemote.borderColor := (0, 0, .9); + + save A, B, C, D; + + EClass.A(iHome)("UserHome")()(); + EClass.B(iRemote)("UserRemote")()(); + EClass.C(iHome)("CartHome")()(); + EClass.D(iRemote)("CartRemote")()(); + + + B.nw = A.ne + (20,0); + D.nw = C.ne + (20,0); + A.bottom - C.top = 10; + A.left = C.left; + + drawObjects(A, B, C, D); +endfig; + +beginfig(4); + iClass.foreColor := .9white; + save A; + + Class.A("Foo") + ("a: int", "b: int") + ("foo()", "bar()", "gar()"); + A.info.iName.iFont.name := metauml_defaultFontBold; + A.info.iName.iFont.scale := 1.2; + + A.info.iAttributeStack.iPict.iFont.scale := 0.8; + A.info.iAttributeStack.top := 10; + A.info.iAttributeStack.spacing := 11; + + A.info.iMethodStack.iPict.iFont.scale := 2; + A.info.iMethodStack.spacing := 17; + A.info.iMethodStack.bottom := 10; + drawObject(A); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/class_customization2.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/class_customization2.mp new file mode 100644 index 00000000000..be45e95240b --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/class_customization2.mp @@ -0,0 +1,31 @@ +% 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 Test; + Class.Test("TestClass")("attribute1: int","attribute2: double") + ("oneLongMethod(): void", + "anotherLongMethod(): void"); + + Test.nw = (0,0); + Class_draw.Test; +endfig; + + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/class_diagrams.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/class_diagrams.mp new file mode 100644 index 00000000000..614cdbeca60 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/class_diagrams.mp @@ -0,0 +1,212 @@ +% 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); + Class.Count("Count") + ("#n: int") + ("+increase(): void", + "+get(): int"); + + %Count.nw = (0,0); + drawObject(Count); + %Class_draw.Count; +endfig; + +beginfig(2); + Class.A("Point") + ("+x: int", + "+y: int") (); + + Class.B("Circle") + ("radius: int") + ("+getRadius(): int", + "+setRadius(r: int):void"); + + A.nw = (0,0); + B.n = A.s - (0,45); + Class_draw.A; + Class_draw.B; + + drawRelation(aggregationUni)(A.s -- B.n); +endfig; + +beginfig(3); + Class.Test("Test")("a1","a2","a3")("aLongMethod():void"); + + Test.nw = (0,0); + Class_draw.Test; + + dotlabel.ulft(btex nw etex, Test.nw); + dotlabel.top(btex n etex, Test.n); + dotlabel.urt(btex ne etex, Test.ne); + dotlabel.rt(btex e etex, Test.e); + dotlabel.lrt(btex se etex, Test.se); + dotlabel.bot(btex s etex, Test.s); + dotlabel.llft(btex sw etex, Test.sw); + dotlabel.lft(btex w etex, Test.w); + + dotlabel.lft(btex c etex, Test.c); + + draw Test.nw - (50,0) -- Test.ne + (10,0); + label.urt(btex top etex, Test.nw - (50,0)); + + draw Test.sw - (50,0) -- Test.se + (10,0); + label.lrt(btex bottom etex, Test.sw - (50,0)); + + draw Test.nw + (0,10) -- Test.sw - (0, 50); + label.bot(btex left etex, Test.sw - (0,50)); + + draw Test.ne + (0,10) -- Test.se - (0, 50); + label.bot(btex right etex, Test.se - (0,50)); + + drawarrow Test.nw - (25,0) -- Test.sw - (25,0); + label.lft(btex height etex, .5[Test.nw, Test.sw] - (25,0)); + + drawarrow Test.sw - (0,25) -- Test.se - (0,25); + label.bot(btex width etex, .5[Test.sw, Test.se] - (0,25)); +endfig; + +%newAssociationDescription.association; +%newAssociationUniDescription.associationUni; +%newInheritanceDescription.inheritance; +%newAggregationDescription.aggregation; +%newAggregationUniDescription.aggregationUni; +%newCompositionDescription.composition; +%newCompositionUniDescription.compositionUni; +%newDashedLinkDescription.dashedLink; +%newDependencyDescription.dependency; + +beginfig(4); + save X, Y; + Class.X("X")()(); + Class.Y("Y")()(); + + X.nw = (0,0); + Y.w = X.e + (50,0); + Class_draw.X; + Class_draw.Y; + + drawRelation(association)(X.e -- Y.w); +endfig; + +beginfig(5); + save X, Y; + Class.X("X")()(); + Class.Y("Y")()(); + + X.nw = (0,0); + Y.w = X.e + (50,0); + Class_draw.X; + Class_draw.Y; + + drawRelation(associationUni)(X.e -- Y.w); +endfig; + +beginfig(6); + save X, Y; + Class.X("X")()(); + Class.Y("Y")()(); + + X.nw = (0,0); + Y.w = X.e + (50,0); + Class_draw.X; + Class_draw.Y; + + drawRelation(inheritance)(X.e -- Y.w); +endfig; + +beginfig(7); + save X, Y; + Class.X("X")()(); + Class.Y("Y")()(); + + X.nw = (0,0); + Y.w = X.e + (50,0); + Class_draw.X; + Class_draw.Y; + + drawRelation(aggregation)(X.e -- Y.w); +endfig; + +beginfig(8); + save X, Y; + Class.X("X")()(); + Class.Y("Y")()(); + + X.nw = (0,0); + Y.w = X.e + (50,0); + Class_draw.X; + Class_draw.Y; + + drawRelation(aggregationUni)(X.e -- Y.w); +endfig; + +beginfig(9); + save X, Y; + Class.X("X")()(); + Class.Y("Y")()(); + + X.nw = (0,0); + Y.w = X.e + (50,0); + Class_draw.X; + Class_draw.Y; + + drawRelation(composition)(X.e -- Y.w); +endfig; + +beginfig(10); + save X, Y; + Class.X("X")()(); + Class.Y("Y")()(); + + X.nw = (0,0); + Y.w = X.e + (50,0); + Class_draw.X; + Class_draw.Y; + + drawRelation(compositionUni)(X.e -- Y.w); +endfig; + +beginfig(11); + save X, Y; + Class.X("X")()(); + Class.Y("Y")()(); + + X.nw = (0,0); + Y.w = X.e + (50,0); + Class_draw.X; + Class_draw.Y; + + drawRelation(dependency)(X.e -- Y.w); +endfig; + +beginfig(12); + save X, Y; + Class.X("X")()(); + Class.Y("Y")()(); + + X.nw = (0,0); + Y.w = X.e + (50,0); + Class_draw.X; + Class_draw.Y; + + drawRelation(realization)(X.e -- Y.w); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/class_templates.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/class_templates.mp new file mode 100644 index 00000000000..bf89f9d3cda --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/class_templates.mp @@ -0,0 +1,29 @@ +% 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); + Class.V("Vector")("elements: T(n)")(); + Template.T("T", "n: int"); + Template_attachToClass.T(V); + + drawObjects(V); + drawObjects(T); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/component.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/component.mp new file mode 100644 index 00000000000..da46c9d3465 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/component.mp @@ -0,0 +1,61 @@ +input metauml; + +beginfig(1); + Component.C("Business Logic")(); + drawObject(C); +endfig; + +beginfig(2); + save A, B, C, BigC; + + Class.A("A")()(); + Package.B("B")(); + Component.C("C")(); + + Component.BigC("Big Component")(A, B, C); + + leftToRight(10)(A, B); + topToBottom(10)(A, C); + + drawObject(BigC); +endfig; + +beginfig(3); + save A, B; + Component.A("A")(); + Component.B("B")(); + + leftToRight(80)(A, B); + + drawObjects(A, B); + + link(providedInterface)( A.e -- .5[A.e, B.w] ); +endfig; + +beginfig(4); + save A, B; + Component.A("A")(); + Component.B("B")(); + + leftToRight(80)(A, B); + + drawObjects(A, B); + + link(requiredInterface)( B.w -- .5[A.e, B.w]); +endfig; + +beginfig(5); + save A, B; + Component.A("A")(); + Component.B("B")(); + + leftToRight(80)(A, B); + + drawObjects(A, B); + + link(providedInterface)( A.e -- .5[A.e, B.w] ); + link(requiredInterface)( B.w -- .5[A.e, B.w] ); +endfig; + + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/group.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/group.mp new file mode 100644 index 00000000000..0e25e58ea66 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/group.mp @@ -0,0 +1,51 @@ +% 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 boxes; +input util_commons; +input util_object; +input util_picture; +input util_margins; +input util_group; + +beginfig(1); + iGroup.left:=20; + iGroup.right:=15; + iGroup.boxed:=1; + iPict.boxed:=1; + + Picture.a("yummy"); + Picture.b("cool"); + Picture.c("fool"); + + a.nw = (0,0); + b.nw = (20,20); + c.nw = (15, 40); + + Group.g(a, b, c); + + drawObjects(g); +endfig; + +beginfig(2); +endfig; + +beginfig(3); +endfig; + + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/how-links-work.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/how-links-work.mp new file mode 100644 index 00000000000..c8d8500358d --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/how-links-work.mp @@ -0,0 +1,38 @@ +% 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); + drawRelation(aggregationUni) + ((0,0)--(40,0)); +endfig; + + +beginfig(2); + path myPath; + myPath := (0,0) -- (100,0); + LinkStructure.ls(myPath, + aggregationUni.widthA, + aggregationUni.widthB); + + describeLinkStructure(ls); + drawLinkStructure(ls)(aggregationUni); +endfig; + +end + diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/instance.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/instance.mp new file mode 100644 index 00000000000..9417224306a --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/instance.mp @@ -0,0 +1,9 @@ +input metauml; + +beginfig(1); + Instance.order("o: Order") + ("name='book'", "{placed}", "{payed}"); + drawObject(order); +endfig; + +end
\ No newline at end of file diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/mptextmp.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/mptextmp.mp new file mode 100644 index 00000000000..3e16f83e564 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/mptextmp.mp @@ -0,0 +1 @@ +btex But this is insane: $\sum_1^3 f(x) \over x$! etex diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/note.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/note.mp new file mode 100644 index 00000000000..f04a5b5e4fe --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/note.mp @@ -0,0 +1,74 @@ +% 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; +input TEX; + +beginfig(1); + Note.A("This note", "has two lines."); + drawObject(A); +endfig; + +beginfig(2); + save A, C; + Note.A("This is a class"); + Class.C("Object")()(); + + A.sw = C.ne + (20, 20); + + drawObjects(A, C); + + clink(dashedLink)(A, C); +endfig; + +beginfig(3); + save C; + Note.nA("This is the class name"); + Note.nB("This is a key attribute"); + Note.nC("This is a nice method"); + + Class.C("Object")("+id:int") + ("+clone()", "+serialize()"); + + topToBottom.left(10)(nA, nB, nC); + leftToRight(10)(C, nB); + + drawObjects(C, nA, nB, nC); + + clink(dashedLink)(C.namePict, nA); + clink(dashedLink)(C.attributeStack.pict[0], nB); + clink(dashedLink)(C.methodStack.pict[1], nC); +endfig; + +beginfig(4); + save A; + Note.A("This class implements the formula:", + TEX("$\sum_1^n f(x)\cdot dx$")); + drawObjects(A); +endfig; + +beginfig(5); + save A; + Note.A("Can you do it?", + TEX("$\sum_1^n f(x) \cdot dx " & + "\over \sum_1^m g(y) \cdot dy$")); + A.stack.info.spacing := 30; + A.stack.pict[1].info.ignoreNegativeBase := 0; + drawObjects(A); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/object_stack.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/object_stack.mp new file mode 100644 index 00000000000..b9cd4d32b34 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/object_stack.mp @@ -0,0 +1,46 @@ +% 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 boxes; +input util_commons; +input util_object; +input util_picture; + + +beginfig(1); + iPict.ignoreNegativeBase := 1; + iPict.boxed := 1; + Picture.a0("yummy"); + Picture.a1("cool"); + Picture.a2("fool"); + + a0.nw = (0,0); + setObjectJoin(pa.sw = pb.nw); + + joinObjects(scantokens listArray(a)(3)); + drawObjects(scantokens listArray(a)(3)); + +endfig; + +beginfig(2); +endfig; + +beginfig(3); +endfig; + + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/package.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/package.mp new file mode 100644 index 00000000000..88653b5fee0 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/package.mp @@ -0,0 +1,93 @@ +input metauml; +input metauml_package; +input metauml_package_relations; + +beginfig(1); + Package.P("java.lang")(); + drawObject(P); +endfig; + +beginfig(2); + save P; + Package.P("An important", "package")(); + drawObject(P); +endfig; + +beginfig(3); + save P; + Package.P("java.lang")(); + P.info.forceEmptyContent := 1; + drawObject(P); +endfig; + +beginfig(4); + save P, A, B; + Class.A("A")()(); + Class.B("B")()(); + Package.P("net.metauml")(A, B); + + leftToRight(10)(A, B); + + drawObject(P); +endfig; + +beginfig(5); + Package.X("X")(); + Package.Y("Y")(); + + leftToRight(50)(X, Y); + drawObjects(X, Y); + + link(nest)(X.e -- Y.w); +endfig; + +beginfig(8); + Package.emptyPackage("")(); + + Package.nameOnlyPackage("java.sun.com")(); + + Class.oneClass("A class")()(); + Package.oneClassPackage("One class package")(oneClass); + + Instance.oneInstance("An instance")(); + State.oneState("A state")(); + Activity.oneActivity("An activity"); + Package.multiPackage("Multipackage")(oneInstance, oneState, oneActivity); + + Package.allPackage("This package contains them all")(emptyPackage, nameOnlyPackage, + oneClassPackage, multiPackage); + + nameOnlyPackage.nw = emptyPackage.ne + (30, 0); + oneClassPackage.ne = emptyPackage.s - (0, 50); + + multiPackage.top = oneClassPackage.top; + multiPackage.left = oneClassPackage.right + 20; + + centered_align_top(oneState, oneActivity)(10, below(oneInstance.s, 20)); + + drawObjects(allPackage); +endfig; + +beginfig(8); + Package.nameOnlyOnTopPackage("Name on top")(); + nameOnlyOnTopPackage.info.forceEmptyContent := 1; + Package.nameOnlyInMiddlePackage("By default name", "is in the middle")(); + + Class.cl("A class")("Attribute")("Method"); + Package.notEmptyPackage("Contains class")(cl); + + nameOnlyInMiddlePackage.n = nameOnlyOnTopPackage.s - (0, 40); + notEmptyPackage.w = nameOnlyInMiddlePackage.e + (80, 0); + drawObjects(nameOnlyOnTopPackage, nameOnlyInMiddlePackage, notEmptyPackage); + + %link(import)(pathStepX(notEmptyPackage.w, nameOnlyOnTopPackage.e, -30)); + %link(import)(pathVertical(nameOnlyInMiddlePackage.ne - (10, 0), nameOnlyOnTopPackage.bottom)); + %link(import)(notEmptyPackage.sw -- nameOnlyInMiddlePackage.ne); +endfig; + +beginfig(8); + link(nest)((10,10)--(30,30)); +endfig; + + +end
\ No newline at end of file diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/paths.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/paths.mp new file mode 100644 index 00000000000..06ca5761209 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/paths.mp @@ -0,0 +1,132 @@ +% 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); + pair za, zb; + za = (10,10); + zb = (10,-5); + path cool; + cool := za .. za+(20,10) .. + zb+(20,-20) .. + zb+(-10,-30) -- zb; + link(aggregationUni)(cool); +endfig; + +beginfig(2); + save A, B; + Class.A("A")()(); + Class.B("B")()(); + + B.sw = A.ne + (10,10); + + drawObjects(A, B); + + link(aggregationUni) + (rpathManhattanX(A.e, B.s)); + link(inheritance) + (pathManhattanY(A.n, B.w)); +endfig; + +beginfig(3); + save A, B; + Class.A("A")()(); + Class.B("B")()(); + + B.sw = A.ne + (10,10); + + drawObjects(A, B); + + stepX:=60; + link(aggregationUni) + (pathStepX(A.e, B.e, stepX)); + + stepY:=20; + link(inheritance) + (pathStepY(B.n, A.n, stepY)); + + pair X,Y; + X := A.se + (0,-30); + Y := X + (stepX, 0); + draw A.se -- X dashed evenly; + draw (xpart Y, ypart A.e) -- Y dashed evenly; + drawdblarrow X + (0,15) -- Y + (0,15); + label.top(btex stepX etex, .5[X,Y]); + + pair X,Y; + X := B.n + (-70,-0); + Y := X + (0, stepY); + + draw B.n -- X dashed evenly; + draw B.n + (0,stepY) -- Y dashed evenly; + drawdblarrow X + (15,0) -- Y + (15,0); + label.lft(btex stepY etex, .5[X,Y]); +endfig; + +% horizontal, vertical +beginfig(4); + save A, B; + Class.A("A")()(); + Class.B("B")("b")(); + Class.C("C")("foo: int")(); + + B.sw = A.se + (30,5); + C.sw = A.nw + (0, 30); + + drawObjects(A, B, C); + + untilX := B.left; + drawRelation(association) + (pathHorizontal(A.e, untilX)); + + draw B.nw -- B.sw + (0,-10) dashed evenly; + label.bot(btex untilX etex, B.sw + (0,-10)); + + untilY:= C.bottom; + drawRelation(association)(pathVertical(A.n, untilY)); + + draw C.sw -- C.sw + (-20,0) dashed evenly; + label.lft(btex untilY etex, C.sw + (-20,-0)); + +endfig; + +beginfig(5); + save A,B; + Activity.A("A"); + Activity.B("B"); + + B.nw = A.ne + (40,30); + drawObjects(A,B); + + z = A.se + (30, -10); + link(transition)(pathCut(A, B) + (A.c -- z -- B.c)); +endfig; + +beginfig(6); + save A,B; + Class.A("A")()(); + Class.B("B")()(); + + B.nw = A.ne + (20,30); + drawObjects(A,B); + + clink(inheritance)(A, B); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/paths_man.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/paths_man.mp new file mode 100644 index 00000000000..a6c502f147b --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/paths_man.mp @@ -0,0 +1,143 @@ +% 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 A, B; + Class.A("A")("foo:int")("bar()"); + Class.B("B")()(); + + A.nw = (0,0); + B.s = A.ne + (30,30); + + Class_draw.A; + Class_draw.B; + + drawRelation(aggregationUni) + (A.n ..(30,30)..B.w); + path cool; + cool := A.e .. A.e+(20,10) .. + B.s+(20,-40) .. B.s+(-10,-30) + -- B.s; + drawRelation(inheritance)(cool); +endfig; + +beginfig(2); + save A, B; + Class.A("A")()(); + Class.B("B")()(); + + A.nw = (0,0); + B.sw = A.ne + (10,10); + + Class_draw.A; + Class_draw.B; + + drawRelation(aggregationUni) + (pathManhattanX(A.e, B.s)); + drawRelation(inheritance) + (pathManhattanY(A.n, B.w)); +endfig; + +beginfig(3); + save A, B; + Class.A("A")()(); + Class.B("B")()(); + + A.nw = (0,0); + B.sw = A.ne + (10,10); + + Class_draw.A; + Class_draw.B; + + stepX:=60; + drawRelation(aggregationUni) + (pathStepX(A.e, B.e, stepX)); + + stepY:=20; + drawRelation(inheritance) + (pathStepY(B.n, A.n, stepY)); + + pair X,Y; + X := A.se + (0,-30); + Y := X + (stepX, 0); + draw A.se -- X dashed evenly; + draw (xpart Y, ypart A.e) -- Y dashed evenly; + drawdblarrow X + (0,15) -- Y + (0,15); + label.top(btex stepX etex, .5[X,Y]); + + pair X,Y; + X := B.n + (-70,-0); + Y := X + (0, stepY); + + draw B.n -- X dashed evenly; + draw B.n + (0,stepY) -- Y dashed evenly; + drawdblarrow X + (15,0) -- Y + (15,0); + label.lft(btex stepY etex, .5[X,Y]); +endfig; + +beginfig(4); + save A, B; + Class.A("A")()(); + Class.B("B")("a")(); + + A.nw = (0,0); + B.sw = A.se + (30,5); + + Class_draw.A; + Class_draw.B; + + untilX := B.left; + drawRelation(association) + (pathHorizontal(A.e, untilX)); + + draw B.nw -- B.sw + (0,-10) dashed evenly; + label.bot(btex untilX etex, B.sw + (0,-10)); +endfig; + +beginfig(5); + save A, B; + Class.A("A")()(); + Class.B("B")("a")("foo()"); + + A.nw = (0,0); + B.sw = A.ne + (-20,20); + + Class_draw.A; + Class_draw.B; + + untilY:= B.bottom; + drawRelation(association) + (pathVertical(A.n, untilY)); + + draw B.sw -- B.sw + (-20,0) dashed evenly; + label.lft(btex untilY etex, B.sw + (-20,-0)); +endfig; + +beginfig(6); + save A,B; + Class.A("A")()(); + Class.B("B")()(); + + B.nw = A.ne + (40,30); + drawObjects(A,B); + + link(inheritance)(pathCut(A,B)(A.c -- B.c)); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/picture_info.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/picture_info.mp new file mode 100644 index 00000000000..df3b10145f2 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/picture_info.mp @@ -0,0 +1,86 @@ +% 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 boxes; +input util_commons; +input util_object; +input util_picture; +input util_positioning; + +PictureInfoCopy.iBig(iPict); +iBig.left := iBig.right := 20; +iBig.top := 10; +iBig.bottom := 1; +iBig.boxed := 1; +iBig.ignoreNegativeBase := 1; +iBig.iFont.name := defaultfont; +iBig.iFont.scale := 3; + +PictureInfoCopy.iSmall(iPict); +iSmall.boxed := 1; +iSmall.borderColor := green; + +beginfig(1); + EPicture.a(iBig)("yummy"); + EPicture.b(iSmall)("cool"); +% you can still modify a.info +% and b.info if you wish. + + a.nw = (0,0); + b.nw = a.sw + (0,-10); + + drawObjects(a, b) +endfig; + +beginfig(2); + save a, b, c, myFixed; + PictureInfoCopy.myFixed(iPict); + myFixed.ignoreNegativeBase := 1; + myFixed.fixedWidth := 15; + myFixed.fixedHeight := 20; + myFixed.boxed := 1; + + EPicture.a(myFixed)("a"); + EPicture.b(myFixed)(".-."); + EPicture.c(myFixed)("toolong"); + + leftToRight.bottom(10)(a, b, c); + + drawObjects(a, b, c); +endfig; + +beginfig(3); + save a, b, c, myFixed; + PictureInfoCopy.myFixed(iPict); + myFixed.ignoreNegativeBase := 1; + myFixed.bottom := 4.5; + myFixed.valign := "bottom"; + myFixed.halign := "center"; + myFixed.fixedWidth := 25; + myFixed.fixedHeight := 15; + myFixed.boxed := 1; + + EPicture.a(myFixed)("a"); + EPicture.b(myFixed)("yum"); + EPicture.c(myFixed)("b"); + + leftToRight.bottom(10)(a, b, c); + + drawObjects(a, b, c); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/picture_stack.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/picture_stack.mp new file mode 100644 index 00000000000..ee6e09104b7 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/picture_stack.mp @@ -0,0 +1,44 @@ +% 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 boxes; +input util_commons; +input util_object; +input util_picture; +input util_group; +input util_picture_stack; + +beginfig(1); + iStack.boxed := 1; + iStack.iPict.boxed := 1; + PictureStack.myStack("foo", + "bar: int" infont "tyxtt", + "cool-man-centered" infont defaultfont, + "nice")("vcenter"); + + myStack.nw = (0,0); + drawObject(myStack); +endfig; + +beginfig(2); +endfig; + +beginfig(3); +endfig; + + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/positioning.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/positioning.mp new file mode 100644 index 00000000000..f98de47182f --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/positioning.mp @@ -0,0 +1,139 @@ +% 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); + Class.A("A")()(); + Class.B("B")()(); + Class.C("C")()(); + Class.Base("Base")()(); + + + A.ne = B.nw - (20,0); + B.ne = C.nw - (20,0); + Base.s = B.n + (0,20); + + drawObjects(Base, A, B, C); +endfig; + +beginfig(2); + save A, B, C, Base; + + Class.A("A")()(); + Class.B("B")()(); + Class.C("C")()(); + Class.Base("Base")()(); + + leftToRight(20)(A, B, C); + topToBottom(20)(Base, B); + + drawObjects(Base, A, B, C); +endfig; + +iPict.boxed := 1; +spacing := 5; +string strA, strB, strC; +strA := "a"; +strB := "..."; +strC := "Cyan"; + +beginfig(3); + save A, B, C, X, Y, Z; + + Picture.X(strA); + Picture.Y(strB); + Picture.Z(strC); + + leftToRight.top(spacing)(X, Y, Z); + + drawObjects(X, Y, Z); + + draw (X.left, X.top) -- (Z.right, X.top) dashed evenly withpen pencircle withcolor red; +endfig; + +beginfig(4); + save A, B, C, X, Y, Z; + + Picture.X(strA); + Picture.Y(strB); + Picture.Z(strC); + + leftToRight.midy(spacing)(X, Y, Z); + + drawObjects(X, Y, Z); + + draw (X.left, X.midy) -- (Z.right, X.midy) dashed evenly withpen pencircle withcolor red;; +endfig; + +beginfig(5); + save A, B, C, X, Y, Z; + + Picture.X(strA); + Picture.Y(strB); + Picture.Z(strC); + + leftToRight.bottom(spacing)(X, Y, Z); + + drawObjects(X, Y, Z); + + draw (X.left, X.bottom) -- (Z.right, X.bottom) dashed evenly withpen pencircle withcolor red;; +endfig; + +beginfig(6); + save A, B, C, X, Y, Z; + + Picture.X(strA); + Picture.Y(strB); + Picture.Z(strC); + + topToBottom.left(spacing)(X, Y, Z); + + drawObjects(X, Y, Z); + + draw (X.left, X.top) -- (X.left, Z.bottom) dashed evenly withpen pencircle withcolor red;; +endfig; + +beginfig(7); + save A, B, C, X, Y, Z; + + Picture.X(strA); + Picture.Y(strB); + Picture.Z(strC); + + topToBottom.midx(spacing)(X, Y, Z); + + drawObjects(X, Y, Z); + + draw (X.midx, X.top) -- (X.midx, Z.bottom) dashed evenly withpen pencircle withcolor red;; +endfig; + +beginfig(8); + save A, B, C, X, Y, Z; + + Picture.X(strA); + Picture.Y(strB); + Picture.Z(strC); + + topToBottom.right(spacing)(X, Y, Z); + + drawObjects(X, Y, Z); + + draw (X.right, X.top) -- (X.right, Z.bottom) dashed evenly withpen pencircle withcolor red;; +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/properties.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/properties.mp new file mode 100644 index 00000000000..94f71d772ea --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/properties.mp @@ -0,0 +1,58 @@ +% Sample MetaUML figures. +% 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); + Class.Test("Test")("a1","a2","a3")("aLongMethod():void"); + + Test.nw = (0,0); + Class_draw.Test; + + dotlabel.ulft(btex nw etex, Test.nw); + dotlabel.top(btex n etex, Test.n); + dotlabel.urt(btex ne etex, Test.ne); + dotlabel.rt(btex e etex, Test.e); + dotlabel.lrt(btex se etex, Test.se); + dotlabel.bot(btex s etex, Test.s); + dotlabel.llft(btex sw etex, Test.sw); + dotlabel.lft(btex w etex, Test.w); + + dotlabel.lft(btex c etex, Test.c); + + draw Test.nw - (50,0) -- Test.ne + (10,0); + label.urt(btex top etex, Test.nw - (50,0)); + + draw Test.sw - (50,0) -- Test.se + (10,0); + label.lrt(btex bottom etex, Test.sw - (50,0)); + + draw Test.nw + (0,10) -- Test.sw - (0, 50); + label.bot(btex left etex, Test.sw - (0,50)); + + draw Test.ne + (0,10) -- Test.se - (0, 50); + label.bot(btex right etex, Test.se - (0,50)); + + drawarrow Test.nw - (25,0) -- Test.sw - (25,0); + label.lft(btex height etex, .5[Test.nw, Test.sw] - (25,0)); + + drawarrow Test.sw - (0,25) -- Test.se - (0,25); + label.bot(btex width etex, .5[Test.sw, Test.se] - (0,25)); +endfig; + + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/state.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/state.mp new file mode 100644 index 00000000000..77c7691a9a2 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/state.mp @@ -0,0 +1,55 @@ +% Sample MetaUML figures. +% 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); + State.s("Take order")(); + drawObject(s); +endfig; + +beginfig(2); + Begin.b; + End.e; + State.c("Component")(); + State.composite("Composite")(b, e, c); + + b.midx = e.midx = c.midx; + c.top = b.bottom - 20; + e.top = c.bottom - 20; + + composite.info.drawNameLine := 1; + drawObject(composite); + + link(transition)(b.s -- c.n); + link(transition)(c.s -- e.n); +endfig; + +beginfig(3); + save s; + State.s("An interesting state", + "which is worth mentioning")(); + stateTransitions.s( + "OnEntry / Open eyes", + "OnExit / Sleep well"); + s.info.drawNameLine := 1; + + drawObject(s); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/statemachine_diagrams.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/statemachine_diagrams.mp new file mode 100644 index 00000000000..ff93a74dd5d --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/statemachine_diagrams.mp @@ -0,0 +1,78 @@ +% 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. + +% for f in `find . | grep '.*\.[1-9]'`; do echo $f; done + +input metauml; + +beginfig(1); + Begin.b; + State.on("On")(); + State.off("Off")(); + End.e; + + setObjectJoin(pb.w = pa.e + (20,0)); + joinObjects(b, on, off, e); + drawObjects(b, on, off, e); + + clink(transition)(b, on); + clink(transition)(on, off); + clink(transition)(off, e); +endfig; + +beginfig(2); + save b, reading, processing, e, exit; + + Begin.b; + State.reading("Commands read")(); + State.processing("Processing commands")(); + End.e; + setObjectJoin(pb.n = pa.s + (0, -20)); + joinObjects(b, reading, processing, e); + + State.composite("Work")(b, reading, processing, e); + drawObject(composite); + + clink(transition)(b, reading); + clink(transition)(reading, processing); + clink(transition)(processing, e); + + ExitPoint.exit; + exit.c=(composite.right, reading.midy); + drawObject(exit); + item(iAssoc)("error")(obj.nw = exit.s); + + clink(transition)(reading, exit); + + State.error("Prepare error report")(); + State.result("Display result")(); + End.theEnd; + + error.midx = result.midx = theEnd.midx = composite.right + 90; + error.midy = exit.midy; + result.midy = processing.midy; + theEnd.midy = e.midy; + drawObjects(error, result, theEnd); + + clink(transition)(exit, error); + clink(transition)(error, result); + clink(transition)(result, theEnd); + + link(transition)(rpathHorizontal(result.w, composite.right)); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_activity.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_activity.mp new file mode 100644 index 00000000000..841bdb8a312 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_activity.mp @@ -0,0 +1,46 @@ +% 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); + Begin.b; + End.e; + + e.n = (30,30); + drawObject(b); + show "Object b drawn"; + drawObject(e); + + link(associationUni)(pathCut(b,e)(b.c--e.c)); +endfig; + +beginfig(2); + EActivity.act(iActivity)("go to school", "while singing"); + drawObject(act); + + Branch.br; + br.nw = (50,50); + drawObject(br); + + Fork.fork("h",30); + fork.nw = (30,70); + drawObject(fork); +endfig; + +end + diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_class.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_class.mp new file mode 100644 index 00000000000..94e1fdc130a --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_class.mp @@ -0,0 +1,156 @@ +% 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(0); + show "Copying class info..."; + ClassInfoCopy.foo(iClass); +endfig; + +beginfig(1); + Class.A("A")()(); + Class_setDebugMode.A; + + A.nw=(0,0); + Class_draw.A; +endfig; + +beginfig(2); + save B; + Class.B("B")("+ a:int")(); + Class_setDebugMode.B; + + B.nw=(0,0); + Class_draw.B; +endfig; + +beginfig(3); + save C; + Class.C("C")("+ a-#~+:int", "- b-#~+:int", "- g-#~+:int", "~ c-#~+:int", "# g-#~+:double")(); + Class_setDebugMode.C; + + C.nw=(0,0); + Class_draw.C; +endfig; + +beginfig(4); + save D; + Class.D("D") + ("+ a-#~+:int", "- b-#~+:int", "- g-#~+:int", "~ c-#~+:int", "# g-#~+:double") + ("+ a()-#~+:int", "- b()-#~+:int", "- g()-#~+:int", "~ c()-#~+:int", "# g()-#~+:double"); + Class_setDebugMode.D; + + D.nw=(0,0); + Class_draw.D; +endfig; + +beginfig(5); + save P, Q; + + Class.P("AAA")()(); + Class_stereotypes.P("ooo", "home", "interface"); + Class_setDebugMode.P; + P.nw=(0,0); + Class_draw.P; + + Class.Q("AAA")()(); + Class_stereotypes.Q("ooo", "home", "interface"); + Q.nw=P.ne + (20,0); + Class_draw.Q; +endfig; + +beginfig(6); + save A; + + Class.A("User6")()(); + Class_stereotypes.A("<<interface>>","<<home>>"); + A.nw=(0,0); + drawObject(A); +endfig; + +beginfig(7) + save A; + Class.A("User7")()(); + A.info.iMethodStack.left := A.info.iMethodStack.right := 50; + A.info.iMethodStack.top := A.info.iMethodStack.bottom := 20; + + drawObject(A); +endfig; + +beginfig(8) + save inter; + EClass.inter(iInterface)("Observer")()("+update(src: Object)"); + drawObjects(inter); +endfig; + +beginfig(9) + save inter; + EInterface.inter(iInterface)("Observer")("+update(src: Object)"); + drawObjects(inter); +endfig; + +beginfig(10) + save inter; + Interface.inter("Observer")("+update(src: Object)"); + drawObjects(inter); +endfig; + +beginfig(11) + save A; + EClass.A(iAbstractClass)("AbstractClass")("[]{}")("+update(src: Object)"); + drawObjects(A); +endfig; + +beginfig(12) + save A; + AbstractClass.A("AbstractClass")("[]{}")("+update(src: Object)"); + drawObjects(A); +endfig; + +beginfig(13) + save A; + EClass.A(iClassNameOnly)("AClassWithNoCompartments")()(); + drawObjects(A); +endfig; + +beginfig(14) + save A; + ClassName.A("AnotherClass"); + drawObjects(A); +endfig; + +beginfig(15) + save A; + ClassName.A("AnotherClass"); + classStereotypes.A("<<interface>>","<<remote>>"); + + drawObjects(A); +endfig; + +beginfig(16); + save A, B, C; + + Class.A("Foo") + ("+a: int", "-b: int", "#c: int", "d: int") + ("+x()", "-y()", "#z()", "t()"); + Class_noVisibilityMarkers.A; + + drawObjects(A); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_class_feature_types.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_class_feature_types.mp new file mode 100644 index 00000000000..f35c0b7b685 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_class_feature_types.mp @@ -0,0 +1,53 @@ +% Copyright 2015 Ovidiu Gheorghies +% Licensed under the Apache License, Version 2.0. + +input metauml; + +beginfig(1); + if not metauml_private_isAbstract(abstract "foo"): + 1 = 2; + fi; + + if metauml_private_isAbstract("@abstracp"): + 1 = 2; + fi; +endfig; + +beginfig(2); + if not metauml_private_isStatic(static "bar"): + 1 = 2; + fi; + + if metauml_private_isStatic("@statique"): + 1 = 2; + fi; +endfig; + +beginfig(3); + Class.A("A") + ("+a:int+", static "+b:int") + ("+f+():int", static "+g+():int", abstract "+h():int"); + Class_setDebugMode.A; + drawObjects(A); +endfig; + +beginfig(4); + save A; + Class.A("A") + (static "-instanceCount:int") + (static "+getInstanceCount():int", abstract "+work()"); + drawObjects(A); +endfig; + +beginfig(5); + save A, B; + Class.A("A")()(); + Class.B(abstract "B")()(); + Class.C("C")()(abstract "foo()"); + + leftToRight(5)(A, B, C); + + drawObjects(A, B, C); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_class_qual_assoc.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_class_qual_assoc.mp new file mode 100644 index 00000000000..735bba19e0d --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_class_qual_assoc.mp @@ -0,0 +1,53 @@ +% 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,qa; + + Class.P("Person")()(); + QualifiedAssociation.qa("accountNumber:int", "foo: id"); + + P.nw = (0,0); + qa.n = P.s; + + + P.info.iName.left := 35; + P.info.iName.right := 35; + drawObjects(P); + + drawObject(qa); +endfig; + +beginfig(2); + save P,qa; + + Class.P("Person")()(); + QualifiedAssociation.qa("accountNumber:int", "foo: id", "foolang"); + + P.nw = (0,0); + qa.w = P.e; + + P.info.shade := 0; + P.info.iMethodStack.top := 20; + drawObjects(P); + + drawObject(qa); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_class_templates.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_class_templates.mp new file mode 100644 index 00000000000..c3fc50209c8 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_class_templates.mp @@ -0,0 +1,62 @@ +% 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,template; + + Class.P("Person")()(); + Template.template("foo", "bar"); + + drawObjectAt(P)(P.nw=(0,0)); + + Template_attachToClass.template(P); + drawObject(template); +endfig; + +beginfig(2); + save P,template; + + Class.P("Person")()(); + Template.template("foo: int"); + Template_attachToClass.template(P); + + drawObjectAt(P)(P.nw=(0,0)); + drawObject(template); +endfig; + +beginfig(3); + save CA, TA, CB, TB, CC, TC; + Class.CA("VeryVeryLongClassName")()(); + ClassTemplate.TA("int foo")(CA); + + Class.CB("Shortie")("abracadabra: long long int")(); + ClassTemplate.TB("T")(CB); + + Class.CC("Shortie")("abracadabra: long long int")(); + ClassTemplate.TC("TrulyAmazingLongTypename")(CC); + + CA.s = CB.n + (0,14); + CB.s = CC.n + (0,14); + + drawObjects(CA, TA, CB, TB, CC, TC); +endfig; + + + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_component.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_component.mp new file mode 100644 index 00000000000..94d866c7532 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_component.mp @@ -0,0 +1,30 @@ +input metauml; +input metauml_component; +input metauml_component_relations; + +beginfig(1); + Class.classA("Class A")()(); + Class.classB("Class B")()(); + + Component.compA("Component A")(); + Component.compB("Component B")(); + Component.compC("Component C")(compA, compB, classA, classB); + + compB.w = compA.e + (40, 0); + classA.w = compB.e + (20, 0); + classB.w = classA.e + (20, 0); + + drawObjects(compC); + + path open; + open := compA.e .. compA.e + (20, 0); + path close; + + close := compB.w .. compA.e + (20, 0); + + link(requiredInterface)(open); + + link(providedInterface)(close); +endfig; + +end
\ No newline at end of file diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_font.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_font.mp new file mode 100644 index 00000000000..21e748a4f74 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_font.mp @@ -0,0 +1,81 @@ +% 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; + +string theFont; + +beginfig(1); + theFont := "pcrr"; + + boxjoin(a.sw=b.nw); + + boxit.ff(("Font name: ( ) " & theFont) infont theFont); + boxit.s0("<<stereotype>> text with guillemets. ><>><<" infont theFont ); + boxit.s1("<<a>>, <<b>>, <<c>>" infont theFont); + boxit.s2("[g uard] text with square brackets []]." infont theFont); + boxit.s3("{c onstraint} text with curly brackets {}}." infont theFont); + + drawboxed(ff, s0, s1, s2, s3); +endfig; + +beginfig(2); + save ff,s,g,c; + theFont := "tyxbtt"; + + boxjoin(a.sw=b.nw); + + boxit.ff(("Font name: ( ) " & theFont) infont theFont); + boxit.s0("<<stereotype>> text with guillemets. ><>><<" infont theFont ); + boxit.s1("<<a>>, <<b>>, <<c>>" infont theFont); + boxit.s2("[g uard] text with square brackets []]." infont theFont); + boxit.s3("{c onstraint} text with curly brackets {}}." infont theFont); + + drawboxed(ff, s0, s1, s2, s3);endfig; + +beginfig(3); + picture pA, pB, pC; + string sA, sB, sC; + sA := "assembleElementLocalMatrix(k: KeyType, mat: LocalMatrixType, a: AssembleAction)"; + sB := "assembleElementLocalMatri(k: KeyType, mat: LocalMatrixType, a: AssembleAction)"; + sC := "assembleElntLocalMatri(k: KeyType, mat: LocalMatrixType, a: AssembleAction)"; + + pA := sA infont "tyxbtt"; + pB := sB infont "tyxbtt"; + pC := sC infont "tyxbtt"; + + draw pA; + draw pB shifted (0,-20); + draw pC shifted (0,-40); +endfig; + +beginfig(4); + save ff,s,g,c; + theFont := "ptmr8r"; + + boxjoin(a.sw=b.nw); + boxit.ff(("Font name: ( ) " & theFont) infont theFont); + + boxit.s0("<<stereotype>> text with guillemets. ><>><<" infont theFont ); + boxit.s1("<<a>>, <<b>>, <<c>>" infont theFont); + boxit.s2("[g uard] text with square brackets []]." infont theFont); + boxit.s3("{c onstraint} text with curly brackets {}}." infont theFont); + + drawboxed(ff, s0, s1, s2, s3); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_group.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_group.mp new file mode 100644 index 00000000000..17265c458b2 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_group.mp @@ -0,0 +1,60 @@ +% 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,q,r,t,g; + + EPicture.p(iPictBoxed)("p0"); + EPicture.q(iPictBoxed)("p1"); + p.se = q.nw; + + string f; + f= enumToString(p,q)(""); + show "f=" & f; + + EGroup.g(iGroup)(p,q); + g.nw = (0,0); + + drawObject(g); +endfig; + +beginfig(2); + save g,h,p,gg; + + Group.g(); + g.info.boxed := 1; + g.nw = (30,30); + drawObject(g); + + Picture.p("Test picture in group"); + p.info.boxed := 1; + Group.h(p); + h.info.boxed := 1; + h.nw = (0,0); + drawObject(h); + + Picture.v0("s"); v0.info.boxed := 1; + Picture.v1("s"); v1.info.boxed := 1; + v1.nw = v0.se + (10,10); + Group.gg(v0, v1); gg.info.boxed := 1; + gg.nw = (70,70); + drawObject(gg); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_instance.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_instance.mp new file mode 100644 index 00000000000..d01ff8452e2 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_instance.mp @@ -0,0 +1,35 @@ +% Part of the MetaUML manual. +% Copyright (C) 2005 Radu-George Radulescu +% +% 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); + Instance.A(":Foo")("int: val1", "bool: val2"); + Instance.B(":Bar")("very long text for testing purposes"); + Instance.C("s: Student")("line1", "line2", "line3", "line4", "line5"); + Instance.D("Example")("small"); + Instance.E("g: Yummy")("{placed}", "{color=red}"); + + B.w = A.e + (20, 0); + C.n = A.s - (0, 20); + D.w = C.e + (20, 0); + E.w = D.e + (20, 0); + + drawObjects(A, B, C, D, E); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_lars_issues.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_lars_issues.mp new file mode 100644 index 00000000000..428d7b41445 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_lars_issues.mp @@ -0,0 +1,94 @@ +input metauml; + +numeric u; +u = 1.3cm; + +beginfig(1); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +Class.ElLocSysAcc("ElementLocalSystemAcceptor") +() +("+startElementAssebly()", + "+assembleElementLocalMatrix(k: KeyType, mat: LocalMatrixType, a: AssembleAction)", + "+assembleElementLocalRHS(k: KeyType, rhs: LocalRHSType, a: AssembleAction)", + "+endElementAssembly()"); + +classStereotypes.ElLocSysAcc("<<interface>>"); +ClassTemplate.TEl("KeyType: typename")(ElLocSysAcc); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Class.FaceLocSysAcc("FaceLocalSystemAcceptor") + () + ("+startFaceAssebly()", + "+assembleFaceLocalMatrix(k1: KeyType, k2: KeyType, mat: LocalMatrixType, a: AssembleAction)", + "+assembleFaceLocalRHS(k: KeyType, rhs: LocalRHSType, a: AssembleAction)", + "+endFaceAssembly()"); + + classStereotypes.FaceLocSysAcc("<<interface>>"); + ClassTemplate.TFa("KeyType: typename")(FaceLocSysAcc); + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Class.SolProvider("SolutionProvider") + () + ("+startSortBack()", + "+getLocalSolution(k: KeyType, sol: LocalSolutionType)", + "+endSortBack()"); + + classStereotypes.SolProvider("<<interface>>"); + ClassTemplate.TSol("KeyType: typename")(SolProvider); + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % now inherit from these for LapackMatrixSorter + Class.LapackMS("LapackMatrixSorter") + ("-indMan: IndexManager", + "-A: LaGenMatDouble&", + "-x: LaVectorDouble&", + "-b: LaVectorDouble&" + ) + ("+startElementAssembly()"); + + ClassTemplate.TLap("KeyType: typename", "IndexManager: class")(LapackMS); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% where to draw these: +FaceLocSysAcc.nw = ElLocSysAcc.ne + (1.5u, 0); +SolProvider.nw = FaceLocSysAcc.ne + (1.5u, 0); +LapackMS.n = FaceLocSysAcc.s + (0, -3u); + +drawObjects(ElLocSysAcc, TEl, FaceLocSysAcc, TFa, + SolProvider, TSol, LapackMS, TLap); + +% 50: how much should the path raise upwards before making a horizontal turn. +link(inheritance)(pathStepY(LapackMS.n, FaceLocSysAcc.s, 50)); +link(inheritance)(pathStepY(LapackMS.n, SolProvider.s, 50)); +link(inheritance)(pathStepY(LapackMS.n, ElLocSysAcc.s, 50)); + +endfig; + +beginfig(2); + Begin.b; + Activity.A("Activity A", "on line two"); + Activity.B("Activity B"); + End.e; + + % or other positioning code... + setObjectJoin(pa.s = pb.n + (0,20)); + joinObjects(b, A, B, e); + + % important: first draw the activities + drawObjects(b, A, B, e); + + % you can now draw the transitions + clink(transition)(b, A); + clink(transition)(A, B); + link(transition)(pathStepX(B.e, e.e, 30)); + + item(iGuard)("guard")(obj.sw = .5[b.s, A.n]); +endfig; + +end; diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_lowlevel.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_lowlevel.mp new file mode 100644 index 00000000000..952da34f482 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_lowlevel.mp @@ -0,0 +1,66 @@ +% 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; +input util_infrastructure; + +beginfig(1); + show "Lowlevel test"; + %string foo; + %foo := var_instruction(numeric) x, y; + %show foo; + %foo := foo & ";"; + %show foo; + attributes(foo); + _n_ := "foo"; + %scantokens foo; + %string x; + %x := str(numeric); + var(numeric) x; + + label.top("nothing shown (intentionally)", (0,0)); +endfig; + +vardef _foo@#= + attributes(@#); + var(string) @#a[]; + @#a[0] := "fpp"; + @#a[1] := "gqq"; +enddef; + +% _foo.b; % not working + +vardef _bar@#(text s)= + attributes(@#); + var(string) elements; + @#elements := enumToString(s)(""); +enddef; + +beginfig(2); + for f = scantokens "a, b, c": + show f; + endfor; + _bar.xx(a, b, c, d); + show xx.elements; + for f = scantokens xx.elements: + show f; + endfor; + label.top("nothing shown (intentionally)", (0,0)); +endfig; + +end + diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_note.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_note.mp new file mode 100644 index 00000000000..bf8c1aeb2fa --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_note.mp @@ -0,0 +1,39 @@ +% 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_note; +input metauml_base; +input metauml_paths; +input metauml_links; +input metauml_class_relations; + +beginfig(1); + Note.foo("This is the first line", "and this the second one."); + drawObject(foo); +endfig; + +beginfig(2); + save foo; + Note.foo("Please disregard this note."); + Note.bar("Please take the other note", "very seriously."); + + bar.s = foo.n + (10,20); + drawObjects(foo, bar); + clink(dashedLink)(foo, bar); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_package.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_package.mp new file mode 100644 index 00000000000..6d4f97ea9f8 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_package.mp @@ -0,0 +1,54 @@ +input metauml; +input metauml_package; +input metauml_package_relations; + +beginfig(1); + Package.emptyPackage("")(); + + Package.nameOnlyPackage("java.sun.com")(); + + Class.oneClass("A class")()(); + Package.oneClassPackage("One class package")(oneClass); + + Instance.oneInstance("An instance")(); + State.oneState("A state")(); + Activity.oneActivity("An activity"); + Package.multiPackage("Multipackage")(oneInstance, oneState, oneActivity); + + Package.allPackage("This package contains them all")(emptyPackage, nameOnlyPackage, + oneClassPackage, multiPackage); + + nameOnlyPackage.nw = emptyPackage.ne + (30, 0); + oneClassPackage.ne = emptyPackage.s - (0, 50); + + multiPackage.top = oneClassPackage.top; + multiPackage.left = oneClassPackage.right + 20; + + centered_align_top(oneState, oneActivity)(10, below(oneInstance.s, 20)); + + drawObjects(allPackage); +endfig; + +beginfig(2); + Package.nameOnlyOnTopPackage("Name on top")(); + nameOnlyOnTopPackage.info.forceEmptyContent := 1; + Package.nameOnlyInMiddlePackage("By default, the name", "is in the middle")(); + + Class.cl("A class")("Attribute")("Method"); + Package.notEmptyPackage("Contains class")(cl); + + nameOnlyInMiddlePackage.n = nameOnlyOnTopPackage.s - (0, 40); + notEmptyPackage.w = nameOnlyInMiddlePackage.e + (80, 0); + drawObjects(nameOnlyOnTopPackage, nameOnlyInMiddlePackage, notEmptyPackage); + + %link(import)(pathStepX(notEmptyPackage.w, nameOnlyOnTopPackage.e, -30)); + %link(import)(pathVertical(nameOnlyInMiddlePackage.ne - (10, 0), nameOnlyOnTopPackage.bottom)); + %link(import)(notEmptyPackage.sw -- nameOnlyInMiddlePackage.ne); +endfig; + +beginfig(3); + link(nest)((10,10)--(30,30)); +endfig; + + +end
\ No newline at end of file diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_paths.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_paths.mp new file mode 100644 index 00000000000..eedd11a9b08 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_paths.mp @@ -0,0 +1,100 @@ +% 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; + +iPict.boxed := 1; + +beginfig(1); + iClass.shade := 3; + Class.F("Foo")("a: int","b: int")(); + Class.B("Bar")()(); + + B.nw = F.ne + (20,-20); + + drawObjects(B, F); + + link(association)(B.nw -- F.ne); + + draw objectBorder(B) withcolor red; + draw objectBorder(F) withcolor blue; + + link(association)(pathCut(B,F)(B.c--F.c)); +endfig; + +beginfig(2); + save A, B; + + Picture.A("A"); + Picture.B("Blue"); + + B.sw = A.ne + (20,20); + + drawObjects(A, B); + + link(associationUni)(pathManhattanX(A.e, B)); +endfig; + +beginfig(3); + save A, B, C, D, O; + + Picture.A("Alpha"); + Picture.B("Beta"); + Picture.C("Gamma"); + Picture.D("Delta"); + Picture.O("Omega"); + + A.c = O.c + (-50,50); + B.c = O.c + (50,50); + C.c = O.c + (-50,-50); + D.c = O.c + (50,-50); + + drawObjects(O, A, B, C, D); + + link(associationUni)(pathManhattanX(O, A)); + link(associationUni)(pathManhattanX(O, B)); + link(associationUni)(pathManhattanX(O, C)); + link(associationUni)(pathManhattanX(O, D)); +endfig; + +beginfig(3); + show ""; + show ""; + show " FIGURE 3"; + + save A, B, C, D, O; + + Picture.A("Alpha"); + Picture.B("Beta"); + Picture.C("Gamma"); + Picture.D("Delta"); + Picture.O("Omega"); + + A.c = O.c + (-50,50); + B.c = O.c + (50,50); + C.c = O.c + (-50,-50); + D.c = O.c + (50,-50); + + drawObjects(O, A, B, C, D); + + link(associationUni)(pathManhattanX(O, A)); + link(associationUni)(pathManhattanX(O, B)); + link(associationUni)(pathManhattanX(O, C)); + link(associationUni)(pathManhattanX(O, D)); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_picture.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_picture.mp new file mode 100644 index 00000000000..7a56236e825 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_picture.mp @@ -0,0 +1,273 @@ +% 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; + +string theFont; +theFont := "tyxbtt"; + +beginfig(1); + draw "xxx" infont defaultfont scaled defaultscale shifted (0,0); + draw "yyy" infont (iFont.name) scaled (iFont.scale) shifted (25, 0); + + Picture.p("foo, bar, baz"); + p.nw = (0,0); + drawObject(p); + + Picture.q("qux, norf"); + drawObjectAt(q)( q.nw = (30,30) ); + + FontInfo.foo("tyxbtt", 1); + PictureInfo.iNice(3,6,5,10)(foo); + iNice.boxed := 1; + + EPicture.myPic(iNice)("Custom iPicture"); + drawObjectAt(myPic)( myPic.nw = (70,0)); +endfig; + +beginfig(2); + save p, q, r, t; + + Picture.p("foo"); + Picture.q("bar"); + p.nw = (10, 10); + q.nw = (20, 20); + + drawObject(p); + drawObject(q); + + drawObjects(p, q); + + Picture.a0("root" infont defaultfont); + Picture.a1("toof"); + + a[0].nw = (30, 30); + a[1].nw = (50, 50); + + drawObjects(scantokens listArray(a)(2)); +endfig; + +beginfig(3); + save p, q, r, t, u, pp; + + bboxmargin := 0; + + picture pp; + pp = "a" infont theFont; + Picture.p(pp); + Picture.q("foo" infont theFont); + Picture.r("bar" infont theFont); + Picture.t("baz"); + Picture.u("norf" infont theFont); + + p.nw = (0,0); + setObjectJoin(pa.left=pb.left; pa.bottom = pb.top + 1); + joinDrawObjects(p, q, r, t, u); + + defaultdy:=0; + boxjoin(a.sw=b.nw; a.se=b.ne); + boxit.A0("foo1"); + boxit.A1("bar1"); + boxit.A2("baz2"); + boxit.A3("norf2"); + boxit.A4(".."); + A0.nw=(50,0); + drawboxed(A0,A1,A2,A3,A4); + + myy := 10; + + bboxmargin := 0; + + pair p; + p := (30,myy); + dotlabel.lrt(".", p); + picture x; + x := "f: int" infont theFont; + draw bbox(x) shifted p; + draw x shifted p; + + pair q; + q := (70,myy); + dotlabel.lrt(".", q); + picture y; + y := "goofy: int" infont theFont; + draw bbox(y) shifted q; + draw y shifted q; + + pair qq; + qq := (135,myy); + dotlabel.lrt(".", qq); + picture y; + y := "goot" infont theFont; + draw bbox(y) shifted qq; + draw y shifted qq; + + draw (0,myy)--(150, myy) dashed evenly; + + myyb := 30; + Picture.aa(btex goof etex); + aa.sw = (30, myyb); + Picture_draw.aa; + + draw (0,myyb)--(100, myyb) dashed evenly; +endfig; + +beginfig(4); + save a, b; + FontInfo.myFont(theFont, 1); + PictureInfo.myWay(0,0,0,0)(myFont); + myWay.boxed := 1; + + EPicture.a0(myWay)("goof"); + EPicture.a1(myWay)("Aoorian"); + EPicture.a2(myWay)("fpp"); + EPicture.a3(myWay)("f: int"); + EPicture.a4(myWay)("aa()"); + + a0.nw = (0,0); + setObjectJoin(pa.bottom = pb.bottom; pa.right = pb.left - 10); + joinDrawObjects(scantokens listArray(a)(5)); + + draw a0.sw -- a4.se withcolor black dashed evenly; + + myWay.ignoreNegativeBase := 1; + EPicture.b0(myWay)("foo"); + EPicture.b1(myWay)("Bar baz"); + EPicture.b2(myWay)("qux"); + EPicture.b3(myWay)("f: int"); + EPicture.b4(myWay)("aa()"); + + b0.nw = (0,-20); + setObjectJoin(pa.bottom = pb.bottom; pa.right = pb.left - 10); + joinDrawObjects(scantokens listArray(b)(5)); + + draw b0.sw -- b4.se withcolor black dashed evenly; +endfig; + +beginfig(5); + truecorners := 1; + bboxmargin := 0; + save p; + picture basepict; + basepict := "<<foo>>" infont "tyxtt"; + + draw basepict; + draw bbox basepict; +endfig; + +beginfig(6); + item.foo(iPictBoxed)("foo bar baz")(foo.nw = (0,0)); + item.bar(iPict)("x: int")(bar.nw = (20,20)); + + aitem(iPictBoxed)("an anounymous item")(obj.nw = (40,10)); +endfig; + +beginfig(7); + save a, b, c, d, e, myFixed; + PictureInfoCopy.myFixed(iPict); + myFixed.ignoreNegativeBase := 1; + myFixed.fixedWidth := 20; + myFixed.boxed := 1; + + EPicture.a(myFixed)("a"); + EPicture.b(myFixed)("bar"); + EPicture.c(myFixed)(".-."); + EPicture.d(myFixed)("baz"); + EPicture.e(myFixed)("qux norf"); + + leftToRight.bottom(20)(a, b, c, d, e); + + drawObjects(a, b, c, d, e); +endfig; + +beginfig(8); + save a, b, c, d, e, myFixed; + PictureInfoCopy.myFixed(iPict); + myFixed.halign := "center"; + myFixed.ignoreNegativeBase := 1; + myFixed.fixedWidth := 20; + myFixed.boxed := 1; + + EPicture.a(myFixed)("a"); + EPicture.b(myFixed)("bar"); + EPicture.c(myFixed)(".-."); + EPicture.d(myFixed)("baz"); + EPicture.e(myFixed)("qux norf"); + + leftToRight.bottom(20)(a, b, c, d, e); + + drawObjects(a, b, c, d, e); +endfig; + +beginfig(9); + save a, b, c, d, e, myFixed; + PictureInfoCopy.myFixed(iPict); + myFixed.halign := "center"; + myFixed.ignoreNegativeBase := 1; + myFixed.fixedWidth := 20; + myFixed.fixedHeight := 30; + myFixed.boxed := 1; + + EPicture.a(myFixed)("a"); + EPicture.b(myFixed)("bar"); + EPicture.c(myFixed)(".-."); + EPicture.d(myFixed)("baz"); + EPicture.e(myFixed)("qux norf"); + + leftToRight.bottom(20)(a, b, c, d, e); + + drawObjects(a, b, c, d, e); +endfig; + +beginfig(10); + save a, b, c, d, e, myFixed; + PictureInfoCopy.myFixed(iPict); + myFixed.halign := "center"; + myFixed.valign := "center"; + myFixed.ignoreNegativeBase := 1; + myFixed.fixedWidth := 20; + myFixed.fixedHeight := 30; + myFixed.boxed := 1; + + EPicture.a(myFixed)("a"); + EPicture.b(myFixed)("bar"); + EPicture.c(myFixed)(".-."); + EPicture.d(myFixed)("baz"); + EPicture.e(myFixed)("qux norf"); + + leftToRight.bottom(20)(a, b, c, d, e); + + drawObjects(a, b, c, d, e); +endfig; + +beginfig(11); + save a, b, c; + Picture.a("goo"); + a.info.textDecoration := "underline"; + + Picture.b("foo()"); + b.info.textDecoration := "underline"; + + Picture.c("x"); + c.info.textDecoration := "underline"; + + topToBottom(5)(a, b, c); + + drawObjects(a, b, c); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_picture_stack.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_picture_stack.mp new file mode 100644 index 00000000000..8ad4776fa44 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_picture_stack.mp @@ -0,0 +1,130 @@ +% 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; + +string theFont; +theFont := "tyxtt"; + +util_log_thresholdlevel := 100; + +beginfig(1); + PictureStackInfoCopy.stackWay(iStack); + + EPictureStack.emptyStack(stackWay)()("vcenter"); + emptyStack.nw=(10,10); + drawObject(emptyStack); +endfig; + +beginfig(2); + PictureStack.myStack("foo")("vcenter"); + myStack.nw = (0,0); + PictureStack_draw.myStack; +endfig; + +beginfig(3); + PictureStack.myStackB("foo", "bar")("vcenter"); + myStackB.nw = (0,0); + PictureStack_draw.myStackB; +endfig; + +beginfig(4); + % 1 + PictureStack.stack("item A", "item B long", "C")("vcenter"); + stack.info.boxed := 1; + stack.info.iPict.boxed := 1; % this does nothing, it's too late + + stack.nw = (0,0); + drawObject(stack); + + % 2 + PictureStack.stackb("item A", "item B long", "C")("vcenter"); + stackb.info.boxed := 1; + stackb.pict[0].info.boxed := 1; + stackb.pict[2].info.boxed := 1; + + stackb.nw = (100,0); + drawObject(stackb); + + % 3 + PictureStackInfoCopy.myInfo(iStack); + myInfo.boxed := 1; + myInfo.iPict.boxed := 1; + EPictureStack.stackc(myInfo)("item A", "item B long", "C")("vcenter"); + + stackc.nw = (200,0); + drawObject(stackc); +endfig; + +beginfig(5); + vardef joinCallback= enddef; + PictureStack.custom("A.A", "B__________B", "C-----C") + ("joinCallback"); + + drawObject(custom); +endfig; + +beginfig(6); + save custom; + + pickup pencircle scaled 4pt; + drawdot origin; + + vardef joinCallbackA= + setObjectJoin(pa.bottom = pb.top + index*10; pa.left = pb.left); + setObjectJoinFirst(pa.nw = (30,0)); + enddef; + + PictureStack.customA("go", "further", "and further", "and further still") + ("joinCallbackA"); + + vardef joinCallbackB= + setObjectJoin(pb.bottom = customA.pict[index].bottom; pb.midx = pa.midx); + setObjectJoinFirst(pa.bottom = customA.pict[index].bottom); + enddef; + + PictureStack.customB(".", "..", "...", "....") + ("joinCallbackB"); + + drawObjects(customA, customB); +endfig; + +beginfig(7); + save stackX; + save stylePA, stylePB; + save stylePictureStack; + + PictureInfoCopy.stylePA(iPict); + stylePA.borderColor := green; + stylePA.boxed := 1; + + PictureInfoCopy.stylePB(iPict); + stylePB.borderColor := red; + stylePB.boxed := 1; + + PictureStackInfoCopy.stylePictureStack(iStack); + + def styleSupplier(expr i)= if i mod 2 = 0: stylePA else: stylePB fi enddef; + + stylePictureStack.childStyleSupplier := "styleSupplier"; + + EPictureStack.stackX(stylePictureStack)("a","b","c","d","e")("vcenter"); + + drawObjects(stackX); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_picture_tex_rendering.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_picture_tex_rendering.mp new file mode 100644 index 00000000000..3c041298699 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_picture_tex_rendering.mp @@ -0,0 +1,43 @@ +% 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; + +input TEX; + +beginfig(1); + PictureInfoCopy.myP(iPict); + myP.boxed := 1; + myP.ignoreNegativeBase := 1; + + EPicture.p(myP)( TEX("Hello, world $x=7$") ); + + PictureStackInfoCopy.myPS(iStack); + myPS.boxed := 1; + myPS.iPict.boxed := 1; + myPS.iPict.ignoreNegativeBase := 1; + + EPictureStack.ps(myPS)("Hello, world!", + TEX("This is cool: $x=y$."), + TEX("But this is insane: $\sum_1^3 f(x) \over x$!") ) ("vleft"); + + leftToRight(20)(p, ps); + + drawObjects(p, ps); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_positioning.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_positioning.mp new file mode 100644 index 00000000000..66034767716 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_positioning.mp @@ -0,0 +1,195 @@ +% 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; + +iPict.boxed := 1; +spacing := 5; +string strA, strB, strC; +strA := "a"; +strB := "..."; +strC := "XYZ"; + +beginfig(1); + save A, B, C, X, Y, Z; + + Picture.A(strA); + Picture.B(strB); + Picture.C(strC); + + align(top, left, right)(spacing)("+")(A, B, C); + + drawObjects(A, B, C); + + draw (A.left, A.top) -- (C.right, A.top); + + %%%% + + Picture.X(strA); + Picture.Y(strB); + Picture.Z(strC); + + leftToRight.top(spacing)(X, Y, Z); + + X.top = A.bottom - 10; + + drawObjects(X, Y, Z); + + draw (X.left, X.top) -- (Z.right, X.top); +endfig; + +beginfig(2); + save A, B, C, X, Y, Z; + + Picture.A(strA); + Picture.B(strB); + Picture.C(strC); + + align(midy, left, right)(spacing)("+")(A, B, C); + + drawObjects(A, B, C); + + draw (A.left, A.midy) -- (C.right, A.midy); + + %%%% + + Picture.X(strA); + Picture.Y(strB); + Picture.Z(strC); + + leftToRight.midy(spacing)(X, Y, Z); + + X.top = A.bottom - 10; + + drawObjects(X, Y, Z); + + draw (X.left, X.midy) -- (Z.right, X.midy); +endfig; + +beginfig(3); + save A, B, C, X, Y, Z; + + Picture.A(strA); + Picture.B(strB); + Picture.C(strC); + + align(bottom, left, right)(spacing)("+")(A, B, C); + + drawObjects(A, B, C); + + draw (A.left, A.bottom) -- (C.right, A.bottom); + + %%%% + + Picture.X(strA); + Picture.Y(strB); + Picture.Z(strC); + + leftToRight.bottom(spacing)(X, Y, Z); + + X.top = A.bottom - 10; + + drawObjects(X, Y, Z); + + draw (X.left, X.bottom) -- (Z.right, X.bottom); +endfig; + +beginfig(4); + save A, B, C, X, Y, Z; + + Picture.A(strA); + Picture.B(strB); + Picture.C(strC); + + align(left, top, bottom)(spacing)("-")(A, B, C); + + drawObjects(A, B, C); + + draw (A.left, A.top) -- (A.left, C.bottom); + + %%%% + + Picture.X(strA); + Picture.Y(strB); + Picture.Z(strC); + + topToBottom.left(spacing)(X, Y, Z); + + X.top = C.bottom - 10; + + drawObjects(X, Y, Z); + + draw (X.left, X.top) -- (X.left, Z.bottom); +endfig; + +beginfig(5); + save A, B, C, X, Y, Z; + + Picture.A(strA); + Picture.B(strB); + Picture.C(strC); + + align(midx, top, bottom)(spacing)("-")(A, B, C); + + drawObjects(A, B, C); + + draw (A.midx, A.top) -- (A.midx, C.bottom); + + %%%% + + Picture.X(strA); + Picture.Y(strB); + Picture.Z(strC); + + topToBottom.midx(spacing)(X, Y, Z); + + X.top = C.bottom - 10; + + drawObjects(X, Y, Z); + + draw (X.midx, X.top) -- (X.midx, Z.bottom); +endfig; + +beginfig(6); + save A, B, C, X, Y, Z; + + Picture.A(strA); + Picture.B(strB); + Picture.C(strC); + + align(right, top, bottom)(spacing)("-")(A, B, C); + + drawObjects(A, B, C); + + draw (A.right, A.top) -- (A.right, C.bottom); + + %%%% + + Picture.X(strA); + Picture.Y(strB); + Picture.Z(strC); + + topToBottom.right(spacing)(X, Y, Z); + + X.top = C.bottom - 10; + + drawObjects(X, Y, Z); + + draw (X.right, X.top) -- (X.right, Z.bottom); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_skins.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_skins.mp new file mode 100644 index 00000000000..750cee4e975 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_skins.mp @@ -0,0 +1,26 @@ +% 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; +input metauml_skin_simple; + +beginfig(1); + Class.HelloSkin("HelloSkin")("nice: int")("done(): void"); + drawObject(HelloSkin); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_skins_global_defaults.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_skins_global_defaults.mp new file mode 100644 index 00000000000..aaeffd043b7 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_skins_global_defaults.mp @@ -0,0 +1,29 @@ +% 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. + +string metauml_defaultFont, metauml_defaultFontLight; +metauml_defaultFont := "cmr12"; +metauml_defaultFontLight := "cmr10"; + +input metauml; + +beginfig(1); + Class.HelloSkinB("HelloSkinGlobal")("foo: int")("bar(): void"); + drawObject(HelloSkinB); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_state.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_state.mp new file mode 100644 index 00000000000..54207507492 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_state.mp @@ -0,0 +1,73 @@ +% 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); + EntryPoint.entry; + ExitPoint.exit; + + entry.nw = (0,0); + exit.nw = (50,50); + + drawObjects(entry, exit); + clink(transition)(entry, exit); +endfig; + +beginfig(2); + EState.myState(iState)("The light is", "visibly on")(); + drawObject(myState); + + State.anotherState("Another nice state")(); + anotherState.info.drawNameLine := 1; + drawObjectAt(anotherState)(anotherState.nw = (0,50)); +endfig; + +beginfig(3); + State.interesting("Interesting state")(); + State_internalTransitions.interesting("OnEntry / doVeryHappy", "OnExit / doSomewhatSad"); + interesting.info.drawNameLine := 1; + + drawObject(interesting); +endfig; + +beginfig(4); + Begin.b; + End.e; + State.sa("A state")(); + State.sb("Another state")(); + setObjectJoin(pb.w = pa.e + (40, 0)); + joinObjects(b, sa, sb, e); + + State.composite("Composite state")(b, e, sa, sb); + drawObject(composite); + + clink(transition)(b, sa); + clink(transition)(sa, sb); + clink(transition)(sb, e); +endfig; + +beginfig(5); +endfig; + +beginfig(6); +endfig; + +beginfig(7); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_usecase.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_usecase.mp new file mode 100644 index 00000000000..32688814cfd --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/test_usecase.mp @@ -0,0 +1,185 @@ +% 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; + +HumanInfoCopy.iDwarf(iHuman); +iDwarf.width := 60; +iDwarf.height := 20; +iDwarf.foreColor := blue; +iDwarf.shadeColor := .8blue; + +beginfig(1); + Human.h; + drawObject(h); + draw objectBox(h); + + Human.h1; + h1.n = (35, 0); + h1.info.foreColor := red; + drawObject(h1); + + Human.h2; + h2.info.height := 90; + h2.nw = (50,0); + drawObject(h2); + draw objectBox(h2); + + EHuman.d(iDwarf); + drawObjectAt(d)(d.s = (10,-50)); + + EHuman.d2(iDwarf); + d2.info.shadeColor := red; + drawObjectAt(d2)(d2.s = (10,-80)); +endfig; + +beginfig(2); + save a,b; + + Actor.a("foo"); + drawObject(a); + + Actor.b("Actor line one", "and line two"); + Actor_setDebugMode.b; + b.n = (70,0); + drawObject(b); +endfig; + +beginfig(3); + Usecase.u("foo"); + drawObject(u); + + draw objectBox(u) withpen pencircle scaled .1; + + draw u.n withpen pencircle scaled 2 withcolor red; + draw u.s withpen pencircle scaled 2 withcolor red; + draw u.e withpen pencircle scaled 2 withcolor red; + draw u.w withpen pencircle scaled 2 withcolor red; + + draw u.ulft withpen pencircle scaled 2 withcolor blue; + draw u.urt withpen pencircle scaled 2 withcolor blue; + draw u.llft withpen pencircle scaled 2 withcolor blue; + draw u.lrt withpen pencircle scaled 2 withcolor blue; + + Usecase.login("Log in for an eagerly", "awaiting user", "which spans well into a very long 3rd line."); + login.s = (0, 5); + drawObject(login); + + Usecase.t("Line 1 goo bar", "Line 2"); + t.s = login.n + (0,10); + drawObject(t); + + Usecase.q("Line 1 abcdefg hij", "abcde", "Line 3 abc def ghe jkl", "Line 4 x"); + q.s = t.n + (0,10); + drawObject(q); + +endfig; + +beginfig(4); + Actor.userA("User A2", "line 2", "line 3 long long long"); + % Any Actor object is made of two sub-objects: nameStack and human. + % Each individual picture in the nameStack can be configured individually. + % + % However, it is not possible to configure all the lines in the nameStack at + % once now, saying something like: + % + % userA.nameStack.info.iPict.iFont.scale := 3; + % + % This happens because the information above is copied into the Picture objects + % in the Actor constructor (and it is useless to modify it afterwards). + % + % If you do want to make such global modifications of the settings, see the + % next two examples. + + userA.nameStack.pict[0].info.iFont.scale := 1.2; + userA.nameStack.pict[1].info.iFont.scale := .7; + userA.nameStack.info.borderColor := blue; + userA.nameStack.info.boxed := 1; + userA.nameStack.group.info.left := 30; + userA.nameStack.group.info.right := 5; + userA.human.info.foreColor := red; + + drawObject(userA); + %draw objectBox(userA.nameStack); + %draw objectBox(userA.human); +endfig; + +beginfig(5); + save userA; + % If you want to have preset a info for specific objects + + ActorInfoCopy.iBig(iActor); + + % ActorInfo contains info-s for two objects + % iNameStack: for the stack representing the actor's name + % iHuman: for the little human + + iBig.iNameStack.iPict.iFont.scale := 3; + iBig.iNameStack.spacing := 25; + iBig.iHuman.height := 25; + + EActor.userA(iBig)("User A", "Specifically configured"); + drawObject(userA); +endfig; + +beginfig(6); + save userA; + + iActor.iNameStack.iPict.iFont.scale := 2; + iActor.iNameStack.spacing := 18; + + Actor.userA("User A", "Globally configured"); + drawObject(userA); +endfig; + +beginfig(7); + save usecaseA; + Usecase.usecaseA("A highly customizable", "usecase. Foo bar!"); + usecaseA.info.iNameStack.iPict.iFont.scale := .5; + drawObject(usecaseA); +endfig; + +beginfig(8); + save usecaseA; + Usecase.usecaseA("A highly customizable", "usecase. Foo bar 2!"); + usecaseA.info.iNameStack.iPict.iFont.scale := 1.1; + usecaseA.info.foreColor := red; + usecaseA.info.borderColor := blue; + usecaseA.info.iShade.background := green; + usecaseA.info.iShade.shift := 4; + drawObject(usecaseA); +endfig; + +beginfig(9); + save usecaseA; + UsecaseInfoCopy.iMyUsecase(iUsecase); + iMyUsecase.iNameStack.iPict.iFont.scale := .6; + iMyUsecase.iNameStack.spacing := 5; + iMyUsecase.foreColor := green; + iMyUsecase.iShade.background := red; + + EUsecase.usecaseA(iMyUsecase)("A highly ", " customizable usecase."); + EUsecase.usecaseB(iMyUsecase)("Another very ", " customizable usecase."); + + usecaseB.info.iShade.background := green; + + leftToRight(20)(usecaseA, usecaseB); + drawObjects(usecaseA, usecaseB); +endfig; + +end + diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/usecase.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/usecase.mp new file mode 100644 index 00000000000..ca8040f57b2 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/usecase.mp @@ -0,0 +1,43 @@ +% Sample MetaUML figures. +% 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); + Usecase.U("Authenticate user", + "by name, password"); + drawObject(U); +endfig; + +beginfig(2); + Actor.A("User"); + drawObject(A); +endfig; + +beginfig(3); + save A; + + Actor.A("Administrator"); + drawObject(A); + draw A.nw -- A.ne -- A.se -- A.sw -- cycle; + draw A.human.nw -- A.human.ne -- A.human.se -- A.human.sw -- cycle; + +endfig; + + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/fig/usecase_diagrams.mp b/Master/texmf-dist/doc/metapost/metauml/manual/fig/usecase_diagrams.mp new file mode 100644 index 00000000000..110ca35c072 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/fig/usecase_diagrams.mp @@ -0,0 +1,48 @@ +% 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. + +% for f in `find . | grep '.*\.[1-9]'`; do echo $f; done + +input metauml; + +beginfig(1); + Actor.user("User"); + Actor.db("Database"); + + Usecase.dbquery("Query database"); + Usecase.auth("Authentification"); + Usecase.authA("Authentification by", "username, password"); + Usecase.authB("Authentification by", "smartcard"); + + auth.w = user.human.e + (30,0); + dbquery.s = auth.n + (0,30); + db.human.w = dbquery.e + (30,0); + + authB.left - authA.right = 30; + authB.midy = authA.midy; + .5[authB.w, authA.e] = (auth.midx, auth.bottom - 50); + + drawObjects(user, auth, dbquery, db, authA, authB); + + clink(inheritance)(authA, auth); + clink(inheritance)(authB, auth); + clink(association)(auth, dbquery); + clink(association)(user.human, auth); + clink(association)(dbquery, db.human); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/metauml-manual.bib b/Master/texmf-dist/doc/metapost/metauml/manual/metauml-manual.bib new file mode 100644 index 00000000000..845db1968fa --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/metauml-manual.bib @@ -0,0 +1,64 @@ +@misc{metaobj, + author = "Denis Roegel", + title = "The {METAOBJ} tutorial and reference manual", + year = "2002", + url = "http://texdoc.net/texmf-dist/doc/metapost/metaobj/momanual.pdf" +} +@book{texbook, + author = "Donald E. Knuth", + title = "The {\TeX{}}book", + year = "1986", + publisher = "Addison-Wesley Publishing Company" +} +@book{latexbook, + author = "Leslie Lamport", + title = "{\LaTeX} a {D}ocument {P}reparation {S}ystem", + year = "1994", + publisher = "Addison-Wesley Publishing Company" +} +@misc{metapost, + author = "John D. Hobby", + title = "{METAPOST} {A} {U}ser's {M}anual", + year = "2018", + url = "http://www.tug.org/tutorials/mp/mpman.pdf" +} +@misc{umlsty, + author = "Ellef Fange Gjelstad", + title = "uml.sty, a package for writing {UML} diagrams in {LATEX}", + year = "2010", + url = "http://mirror.hmc.edu/ctan/graphics/pstricks/contrib/uml/uml.pdf" +} + +@misc{pstumlsty, + author = "Maurice Diamantini", + title = "Interface utilisateur du package pst-uml", + year = "2006", + url = "http://mirrors.nxthost.com/ctan/graphics/pstricks/contrib/pst-uml/pst-uml-doc.pdf" +} + +@misc{umldoc, + author = "Doug Palmer", + title = "The umldoc {UML} {D}ocumentation {P}ackage", + year = "1999", + url = "https://www.charvolant.org/elements/umldoc.pdf" +} + +@misc{tikzuml, + author = "Nicolas Kielbasiewicz", + title = "The {T}ik{Z}-{UML} package", + year = "2016", + url = "http://perso.ensta-paristech.fr/~kielbasi/tikzuml/var/files/doc/tikzumlmanual.pdf" +} + +@misc{svglatex, + author = "Johan B. C. Engelen", + title = "How to include an SVG image in LATEX", + url = "http://tug.ctan.org/info/svg-inkscape/InkscapePDFLaTeX.pdf" +} + +@misc{umlomg, + publisher = "Object Management Group", + title = "{OMG}® {U}nified {M}odeling {L}anguage® ({OMG} {UML}®)", + year = "2017", + url = "https://www.omg.org/spec/UML/2.5.1/" +} diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/metauml-manual.tex b/Master/texmf-dist/doc/metapost/metauml/manual/metauml-manual.tex new file mode 100644 index 00000000000..933130a33d3 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/metauml-manual.tex @@ -0,0 +1,2072 @@ +% MetaUML: Tutorial, Reference and Test Suite +% +% Copyright (c) 2005-2019 Ovidiu Gheorghies +% Permission is granted to copy, distribute and/or modify this document +% under the terms of the GNU Free Documentation License, Version 1.2 +% or any later version published by the Free Software Foundation; +% with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +% A copy of the license is included in the section entitled "GNU +% Free Documentation License". + +\documentclass{article} + +\usepackage[utf8]{inputenc} +\usepackage[pdftex,colorlinks=true]{hyperref} +\usepackage{multicol} +\usepackage{multido} +\usepackage[style=ieee]{biblatex} +\addbibresource{metauml-manual.bib} + +\ifx\pdftexversion\undefined + \usepackage[dvips]{graphicx} +\else + \usepackage[pdftex]{graphicx} + \DeclareGraphicsRule{*}{mps}{*}{} +\fi + +\newcommand{\code}{\ttfamily} + +\setcounter{page}{1} + +\begin{document} + +MetaUML: A Manual and Test Suite + +\begin{quote} + Copyright \copyright 2005-2019 Ovidiu Gheorghie\c{s}. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +\end{quote} + +\pagebreak +This page is intentionally left blank. + +\pagebreak +\title{MetaUML: A Manual and Test Suite} + +\author{Ovidiu Gheorghie\c{s}} + +\maketitle + +\begin{abstract} +MetaUML is a MetaPost \cite {metapost} library for creating UML \cite{umlomg} diagrams by means of a textual notation. +While presenting the inner workings of MetaUML, this manual doubles as a step-by-step tutorial. +More importantly, its source code contains many useful examples of diagrams, ranging from the very basic to the +more advanced and customized. +\end{abstract} + +\section{Introduction} + +Here is a quick MetaUML showcase: + +\begin{multicols}{2} +\paragraph{A} Class Diagram\\ +\includegraphics[scale=.55]{fig/appetizer.1} +\paragraph{B} Activity Diagram\\ +\includegraphics[scale=.55]{fig/appetizer.2} +\paragraph{C} Notes\\ +\includegraphics[scale=.55]{fig/appetizer.5} +\columnbreak +\paragraph{D} Use Case Diagram\\ +\includegraphics[scale=.55]{fig/appetizer.3} +\paragraph{E} State Machine Diagram\\ +\includegraphics[scale=.55]{fig/appetizer.4} +\paragraph{F} Package Diagram\\ +\includegraphics[scale=.55]{fig/appetizer.6} +\end{multicols} + +\pagebreak + +The code that generates these diagrams is quite straightforward, combining a natural object-oriented parlance +with the power of MetaPost equation solving. + +For example, a UML class is drawn as follows: + +\begin{multicols}{2} +\begin{verbatim} +Class.A("MyClass") + ("attr1: int", "attr2: int") + ("method1(): void", + "method2(): void"); + +A.nw = (0, 0); % optional, implied +drawObject(A); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/appetizer.7} +\end{multicols} + +This code creates a visual object, referenced by its name {\code A}, of the MetaUML-defined type {\code Class}. +Object {\code A} has the following content properties: a name +({\code MyClass}), a list of attributes ({\code attr1}, {\code attr2}) +and a list of methods ({\code method1}, {\code method2}). To set the object's location, we assign a value to the +so-called ``north-west'' point of the encompassing rectangle, {\code A.nw} --- a point which in actual fact references +the upper-left corner. + +Every MetaUML visual object has the layout properties shown in figure \ref{fig:properties}. +These properties may be used to set the location of any given object, either by assigning to them absolute values, +or by linking them relatively to other objects via equations. + +\begin{figure} +\centering +\includegraphics{fig/properties.1} +\caption{Layout properties of MetaUML objects. Here, a {\code Class} object is depicted.} +\label{fig:properties} +\end{figure} + +The following example demonstrates, respectively, the use of absolute and relative positioning for two classes, {\code A} and {\code B}. + +\begin{multicols}{2} +\begin{verbatim} +A.nw = (0,0); +B.w = A.e + (20, 0); +\end{verbatim} +\columnbreak +\includegraphics{fig/appetizer.8} +\end{multicols} + +After the objects have been drawn, it becomes possible to attach links to them. In a class diagram, inheritance +or association relations are meaningful links between classes, while in a state machine diagram, transitions between +states can be used. Here is the general pattern used by MetaUML for drawing links: + +\begin{verbatim} +link(<how-to-draw-information>)(<path-to-draw>); +\end{verbatim} + +The ``how-to-draw-information'' is an object which defines the style of the line (e.g. solid, dashed) and the appearance +of the heads (e.g. nothing, arrow, diamond). One such object, appropriately called {\code inheritance}, defines a solid +line style and a white triangle head. The other parameter, the ``path-to-draw'', is simply a MetaPost path. + +For example, the following call draws an inheritance relation from class {\code B} to class {\code A}. + +\begin{verbatim} +link(inheritance)(B.e -- A.w); +\end{verbatim} + +The direction of the path is important, as MetaUML uses it to determine the +type of adornment to attach to the link ends (if applicable). In our example, a white triangle, +denoting inheritance, points towards the end of the path, that is towards class {\code A}. + +Let us sum up with a diagram typical for MetaUML use. Firstly, we define the objects that we want to include +in our diagram. Secondly, we position these objects relative to each other. Thirdly, we draw the objects. Finally, we +draw the links, by referencing the layout properties of the previously drawn objects. Note that in our example the +positioning of {\code A} need not be set explicitly because ``floating'' objects are automatically positioned at +{\code (0,0)} by their draw method. + +\begin{multicols}{2} + +\begin{verbatim} +input metauml; + +beginfig(1); + Class.A("A")()(); % 1. Define the objects + Class.B("B")()(); + B.w = A.e + (20, 0); % 2. Position the objects + drawObjects(A, B); % 3. Draw the objects + link(inheritance)(B.w -- A.e); % 4. Draw links between objects +endfig; +end +\end{verbatim} +\columnbreak +\includegraphics{fig/appetizer.9} +\end{multicols} + +As far as a user is concerned, this is all there is to MetaUML. With a reference describing how the +UML elements are created, arbitrarily complex diagrams can be crafted. + +\section{Class Diagrams} + +A class is created as follows: + +\begin{verbatim} +Class.<name>(<class-name>) + (<list-of-attributes>) + (<list-of-methods>); +\end{verbatim} + +The suffix {\code <name>} specifies an identifier for the newly created {\code Class} object +(which, of course, represents a UML class). +The name of the UML class is a string given by {\code <class-name>}; +the attributes and methods are given as list of strings, {\code <list-of-attributes>} and {\code <list-of-methods>} +respectively. The list of attributes and the list of methods may be void. + +An attribute or a method string may begin with a visibility marker: ``$+$'' for +public, ``\#'' for protected, ``$-$'' for private, and ``\textasciitilde'' for package private. +The default visibility is package private. + +\begin{multicols}{2} +\begin{verbatim} +Class.A("Point") + ("#x:int", "#y:int") + ("+set(x:int, y:int)", + "+getX():int", + "+getY():int", + "-debug():void", + "test():void"); +drawObject(A); +\end{verbatim} +\columnbreak +\includegraphics{fig/class.1} +\end{multicols} + +To disable showing the visibility markers, use {\code Class\_noVisibilityMarkers}, as shown below: + +\begin{multicols}{2} +\begin{verbatim} + Class.A("Point") + ("#x:int", "#y:int") + ("+toString():String"); + Class_noVisibilityMarkers.A; + + drawObject(A); +\end{verbatim} +\columnbreak +\includegraphics{fig/class.15} +\end{multicols} + +\subsection{Stereotypes} + +After a class is created, but before it is drawn, its stereotypes may be specified by using {\code Class\_stereotypes}: + +\begin{verbatim} +Class_stereotypes.<name>(<list-of-stereotypes>); +\end{verbatim} + +Here, {\code <name>} is the object name of a previously created class and {\code <list-of-stereotypes>} +is a comma-separated list of strings. Here is an example: + +\begin{multicols}{2} +\begin{verbatim} +Class.A("User")()(); +Class_stereotypes.A("<<interface>>","<<home>>"); + +drawObject(A); +\end{verbatim} +\columnbreak +\hspace{3cm}\includegraphics{fig/class.2} +\end{multicols} + +\subsection{Interfaces and Abstract Classes} + +At times it is preferred to write the name of an interface in an oblique font, rather than using the ``interface'' +stereotype. This can be easily achieved by using the macro {\code Interface}: + +\begin{verbatim} +Interface.name(class-name) + (list-of-methods); +\end{verbatim} + +Here is an example: + +\begin{multicols}{2} +\begin{verbatim} +Interface.A("Observer") + ("+update(src:Object)"); + +drawObject(A); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/class.11} +\end{multicols} + +Since internally {\code Interface} treated as a special kind of {\code Class}, the code above is equivalent to: +\begin{verbatim} +EClass.A(iInterface)("Observer")() + ("+update(src:Object)"); +\end{verbatim} + +Abstract classes can be drawn similarly using the {\code iAbstractClass} style: +\begin{samepage} +\begin{multicols}{2} +\begin{verbatim} +EClass.A(iAbstractClass)("Observable") + ("observers: Observer[0..*]") + ("+addObserver(o: Observer)", + "+notify()"); + +drawObject(A); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/class.12} +\end{multicols} +\end{samepage} + +If you prefer, you can use equivalent construct: + +\begin{verbatim} +AbstractClass.A("Observable") + ("observers: Observer[0..*]") + ("+addObserver(o: Observer)", + "+notify()"); +\end{verbatim} + +\subsection{Displaying Class Name Only} + +If you want the empty methods and attributes compartments in a class not being displayed, one way is to set the spacing +at their top and the bottom to {\code 0}: +\begin{samepage} +\begin{multicols}{2} +\begin{verbatim} +Class.A("MyModel")()(); +A.info.iName.top := 10; +A.info.iName.bottom := 10; +A.info.iAttributeStack.top := 0; +A.info.iAttributeStack.bottom := 0; +A.info.iMethodStack.top := 0; +A.info.iMethodStack.bottom := 0; + +drawObject(A); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/class.13} +\end{multicols} +\end{samepage} + +The same effect can be achieved by using the formatting information object {\code iClassNameOnly} or the {\code ClassName} macro: + +\begin{multicols}{2} +\begin{verbatim} +EClass.A(iClassNameOnly)("MyModel")()(); +ClassName.B("AnotherModel"); +Class_stereotypes.B("<<smart>>"); + +topToBottom(20)(A, B); + +drawObjects(A, B); +\end{verbatim} +\columnbreak +\hspace{2cm}\includegraphics{fig/class.14} +\end{multicols} + +To customize the space around the class name globally, you can set the values of {\code iClassNameOnly.iName.top} and {\code iClassNameOnly.iName.bottom}. Individually, for a given object, say {\code B}, the attributes {\code B.info.iName.top} and {\code B.info.iName.bottom} can be used. + +\subsection{Objects (or Class Instances)} + +A UML object (or class instance) is created as follows: + +\begin{verbatim} +Instance.name(object-name) + (list-of-attributes); +\end{verbatim} + +The suffix {\code name} gives a name to the {\code Instance} object. The name of the object (given by {\code object-name}) is typeset underlined. The attributes are given as a comma-separated list of strings, {\code list-of-attributes}. + +\begin{multicols}{2} +\begin{verbatim} +Instance.order("o: Order") + ("name='book'", "{placed}", "{payed}"); +drawObject(order); +\end{verbatim} +\columnbreak +\hspace{2cm}\includegraphics{fig/instance.1} +\end{multicols} + + +\subsection{Parametrized Classes (Templates)} + +The most convenient way of typesetting a class template in MetaUML is to use the macro {\code ClassTemplate}. +This macro creates a visual object which is appropriately positioned near the class object it adorns. + +\begin{verbatim} +ClassTemplate.name(list-of-templates) + (class-object); +\end{verbatim} + +The {\code name} is the name of the template object, {\code list-of-templates} is a comma-separated list of strings and the {\code class-object} is the name of a class object. + +Here is an example: + +\begin{multicols}{2} +\begin{verbatim} +Class.A("Vector")()(); +ClassTemplate.T("T", "size: int")(A); + +drawObjects(A, T); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/class.3} +\end{multicols} + +The macro {\code Template} can also be used to create a template object, but this time the resulting +object can be positioned freely. + +\begin{verbatim} +Template.name(list-of-templates); +\end{verbatim} + +Of course, it is possible to specify both stereotypes and template parameters for a given class. + +\subsection{Types of Links} + +In this section we enumerate the relations that can be drawn between classes by means +of MetaUML macros. Suppose that we have the declared two points, {\code A} (on the left) +and {\code B} (on the right): + +\begin{verbatim} +pair A, B; +A = (0,0); +B = (50,0); +\end{verbatim} + +\begin{tabular}{||l|c||} +\hline +{\code link(association)(X.e -- Y.w)} & \includegraphics{fig/class_diagrams.4} \\ +\hline +{\code link(associationUni)(X.e -- Y.w)} & \includegraphics{fig/class_diagrams.5} \\ +\hline +{\code link(inheritance)(X.e -- Y.w)} & \includegraphics{fig/class_diagrams.6} \\ +\hline +{\code link(realization)(X.e -- Y.w)} & \includegraphics{fig/class_diagrams.12} \\ +\hline +{\code link(aggregation)(X.e -- Y.w)} & \includegraphics{fig/class_diagrams.7} \\ +\hline +{\code link(aggregationUni)(X.e -- Y.w)} & \includegraphics{fig/class_diagrams.8} \\ +\hline +{\code link(composition)(X.e -- Y.w)} & \includegraphics{fig/class_diagrams.9} \\ +\hline +{\code link(compositionUni)(X.e -- Y.w)} & \includegraphics{fig/class_diagrams.10} \\ +\hline +{\code link(dependency)(X.e -- Y.w)} & \includegraphics{fig/class_diagrams.11} \\ +\hline +\end{tabular} + +\subsection{Associations} +In UML an association typically has two of association ends and may have a name specified for it. +In turn, each association end may specify a multiplicity, a role, a visibility, an ordering. +These entities are treated in MetaUML as pictures having specific drawing information +(spacings, font). + +The first method of creating association ``items'' is by giving them explicit names. +Having a name for an association item comes in handy when referring to its properties +is later needed (see the non UML-compliant diagram below). The last parameter of the macro {\code item} is an equation which may use the item's name to perform positioning. + +\begin{multicols}{2} +\begin{verbatim} +Class.P("Person")()(); +Class.C("Company")()(); +% drawing code ommited + +item.aName(iAssoc)("works for") + (aName.s = .5[P.w, C.w]); +draw aName.n -- (aName.n + (20,20)); +label.urt("association name" infont "tyxtt", + aName.n + (20,20)); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics[scale=.8]{fig/class_association.1} +\end{multicols} + +However, giving names to every association item may become an annoying burden +(especially when there are many of them). Because of this, MetaUML also allows for +``anonymous items''. In this case, the positioning is set by an equation +which refers to the anonymous item as {\code obj}. + +\begin{multicols}{2} +\begin{verbatim} +% P and C defined as in the previous example + +item(iAssoc)("employee")(obj.nw = P.s); +item(iAssoc)("1..*")(obj.ne = P.s); + +% other items are drawn similarly +\end{verbatim} +\columnbreak +\hspace{3cm}\includegraphics{fig/class_association.2} +\end{multicols} + +\subsection{Dependencies and Stereotypes} + +Stereotypes are frequently used with dependencies. Below is an example. +\pagebreak + +\begin{multicols}{2} +\begin{verbatim} +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]) +\end{verbatim} +\columnbreak +\hspace{3cm}\includegraphics{fig/class_association.3} +\end{multicols} + +\section{Notes} + +A note is created as follows: + +\begin{verbatim} +Note.name(list-of-lines); +\end{verbatim} + +The suffix {\code name} is the name of the {\code Note} object. The contents of the note is given by a comma-separated +list of strings, {\code list-of-lines}, gives the text contents of the note object, each string being drawn on its own +line. + +Here is an example: + +\begin{multicols}{2} +\begin{verbatim} +Note.A("This note", "has two lines."); +drawObject(A); +\end{verbatim} +\columnbreak +\hspace{3cm}\includegraphics{fig/note.1} +\end{multicols} + +\subsection{Attaching notes to diagram elements} + +Notes can be attached to diagram elements by using a link of type {\code dashedLink}. + +\begin{multicols}{2} +\begin{verbatim} +Note.A("This is a class"); +Class.C("Object")()(); + +A.sw = C.ne + (20, 20); + +drawObject(A, C); + +clink(dashedLink)(A, C); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/note.2} +\end{multicols} + +Now let us see a more complex example, which demontrates the ability of accessing sub-elements in a MetaUML diagram. +\pagebreak + +\begin{multicols}{2} +\begin{verbatim} +Note.nA("This is the class name"); +Note.nB("This is a key attribute"); +Note.nC("This is a nice method"); + +Class.C("Object")("+id:int") + ("+clone()", "+serialize()"); + +topToBottom.left(10)(nA, nB, nC); +leftToRight(10)(C, nB); + +drawObjects(C, nA, nB, nC); + +clink(dashedLink)(C.namePict, nA); +clink(dashedLink)(C.attributeStack.pict[0], nB); +clink(dashedLink)(C.methodStack.pict[1], nC); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/note.3} +\end{multicols} + +Macros like {\code leftToRight} and {\code topToBottom} are presented in section \ref{section:positioning}. + +\subsection{Using mathematical formulae} + +MetaUML notes can contain mathematical formulae written in TeX \cite{texbook}. Regretably, LaTeX \cite{latexbook} support for formulae is {\bf not} available. +Limited as it may be, this feature is considered experimental, as it is not always straightforward to use. In the example below, note that the MetaPost package {\code TEX} is imported. + +\begin{multicols}{2} +\begin{verbatim} +input metauml; +input TEX; + +beginfig(1); + Note.A("This class implements the formula:", + TEX("$\sum_1^n f(x) \cdot dx$")); + drawObjects(A); +endfig; + +end +\end{verbatim} +\columnbreak +\hspace{0.5cm}\includegraphics{fig/note.4} +\end{multicols} + +For taller formulae, you must be prepared to do some advanced stunts. Remark: {\code "aaa" \& "bbb"} is MetaPost's way to concatenate the strings into {\code "aaabbb"}; +the string containing the formula was split in two for layout reasons. + +\begin{multicols}{2} +\begin{verbatim} +Note.A("Can you do it?", + TEX("$\sum_1^n f(x) \cdot dx " & + "\over \sum_1^m g(y) \cdot dy$")); +A.stack.info.spacing := 30; +A.stack.pict[1].info.ignoreNegativeBase := 0; + +drawObject(A); +\end{verbatim} +\columnbreak +\hspace{3cm}\includegraphics{fig/note.5} +\end{multicols} + +Alas, this trick does not entirely solve the problem: a third line in the note would be badly aligned. Therefore, +until MetaUML's {\code Note} class is upgraded to better support this scenario, you may want to limit yourself +to two lines per note --- at least when tall formulae are involved. + +\section{Packages} + +MetaUML allows for the creation of packages in various forms. Firstly, we have the option of writing the package +name in the middle of the main box. Secondly, we can write the name on the tiny box above the main box, leaving +the main box empty. Lastly, we can write the package name as in the second case, but the main box can have an arbitrary +contents: classes, other packages, or even other UML items. + +The macro that creates a package has the following synopsis: + +\begin{verbatim} +Package.name(package-name)(subitems-list); +\end{verbatim} + +The parameter {\code package-name} is a string or a list of comma-separated strings representing the package's name. +The {\code subitems-list} parameter is used to specify the subitems (tipically classes or packages) of this package; +its form is as a comma-separated list of objects, which can be void. + +\begin{multicols}{2} +\begin{verbatim} +Package.P("java.lang")(); +drawObject(P); +\end{verbatim} +\columnbreak +\hspace{3cm}\includegraphics{fig/package.1} +\end{multicols} + +Below is another example: + +\begin{multicols}{2} +\begin{verbatim} +Package.P("An important", "package")(); +drawObject(P); +\end{verbatim} +\columnbreak +\hspace{3cm}\includegraphics{fig/package.2} +\end{multicols} + +If you wish to leave the main box empty, you can use the following code: + +\begin{multicols}{2} +\begin{verbatim} +Package.P("java.lang")(); +P.info.forceEmptyContent := 1; +drawObject(P); +\end{verbatim} +\columnbreak +\hspace{3cm}\includegraphics{fig/package.3} +\end{multicols} + +The same effect as above can be achieved globally by doing: + +\begin{verbatim} +iPackage.forceEmptyContent := 1; +\end{verbatim} + +More information on MetaUML's way of managing global and per-object configuration data can be found in +section \ref{section:infrastructure} and section \ref{section:customization}. + +Here is an example involving items contained in a package. + +\begin{multicols}{2} +\begin{verbatim} +Class.A("A")()(); +Class.B("B")()(); +Package.P("net.metauml")(A, B); + +leftToRight(10)(A, B); + +drawObject(P); +\end{verbatim} +\columnbreak +\hspace{3cm}\includegraphics{fig/package.4} +\end{multicols} + +\subsection{Types of Links} + +The nesting relation between packages is created by using the {\code nest} link information. + +\begin{tabular}{||l|c||} +\hline +{\code link(nest)(X.e -- Y.w)} & \includegraphics{fig/package.5} \\ +\hline +\end{tabular} + +\section{Component Diagrams} + +A component is created by the macro {\code Component}: + +\begin{verbatim} +Component.name(component-name) + (subitems-list) +\end{verbatim} + +The parameter {\code component-name} is a string representing the component's name. The {\code subitems-list} parameter +is used to specify the subitems of this component (possibly classes, packages or other components); its form is as a +comma-separated list of objects, which can be void. + +\begin{multicols}{2} +\begin{verbatim} +Component.C("Business Logic")(); +drawObject(C); +\end{verbatim} +\columnbreak +\hspace{3cm}\includegraphics{fig/component.1} +\end{multicols} + +Here is an example involving subitems in a component: + +\begin{multicols}{2} +\begin{verbatim} +Class.A("A")()(); +Package.B("B")(); +Component.C("C")(); + +Component.BigC("Big Component")(A, B, C); + +leftToRight(10)(A, B); +topToBottom(10)(A, C); + +drawObject(BigC); +\end{verbatim} +\columnbreak +\hspace{3cm}\includegraphics{fig/component.2} +\end{multicols} + +\subsection{Types of Links} + +\begin{tabular}{||l|c||} +\hline +{\code link(requiredInterface)( A.e -- .5[A.e, B.w] );} & \includegraphics{fig/component.3} \\ +\hline +{\code link(providedInterface)( .5[A.e, B.w] -- B.w );} & \includegraphics{fig/component.4} \\ +\hline +\end{tabular} + +\vspace{0.5cm} + +The {\code requiredInterface} and {\code providedInterface} visual constructs can be easily combined, as shown in the following example: + +\begin{multicols}{2} +\begin{verbatim} +Component.A("A")(); +Component.B("B")(); + +leftToRight(80)(A, B); + +drawObjects(A, B); + +link(providedInterface)( A.e -- .5[A.e, B.w] ); +link(requiredInterface)( B.w -- .5[A.e, B.w] ); +\end{verbatim} +\columnbreak +\hspace{-1cm}\includegraphics{fig/component.5} +\end{multicols} + + +\section{Use Case Diagrams} + +\subsection{Use Cases} +An use case is created by the macro {\code Usecase}: + +\begin{verbatim} +Usecase.name(list-of-lines); +\end{verbatim} + +The {\code list-of-lines} is a comma-separated list of strings. These strings are placed +on top of each other, centered and surrounded by the appropriate visual UML notation. + +Here is an use case example: + +\begin{multicols}{2} +\begin{verbatim} +Usecase.U("Authenticate user", + "by name, password"); +drawObject(U); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/usecase.1} +\end{multicols} + +\subsection{Actors} + +An actor is created by the macro {\code Actor}: + +\begin{verbatim} +Actor.name(list-of-lines); +\end{verbatim} + +Here, {\code list-of-lines} represents the actor's name. For convenience, the name may be +given as a list of strings which are placed on top of each other, to provide support for +the situations when the role is quite long. Otherwise, giving a single string +as an argument to the Actor constructor is perfectly fine. + +Here is an actor example: + +\begin{multicols}{2} +\begin{verbatim} +Actor.A("User"); +drawObject(A); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/usecase.2} +\end{multicols} + +Sometimes it may be preferable to draw diagram relations positioned relatively to +the visual representation of an actor (the ``human'') rather than relatively to the whole +actor object (which also includes the text). Because of that, MetaUML provides access +to the ``human'' of every actor object {\code actor} by means of the sub-object {\code actor.human}. + +\begin{multicols}{2} +\begin{verbatim} +Actor.A("Administrator"); +drawObject(A); +draw objectBox(A); +draw objectBox(A.human); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/usecase.3} +\end{multicols} + +In MetaUML, {\code objectBox(X)} is equivalent to {\code X.nw -- X.ne -- X.se -- X.sw -- cycle} for every object {\code X}. {\code A.human} is considered a MetaUML object, so you can use expressions like {\code A.human.n} or {\code A.human.midx}. + +\subsection{Types of Links} + +Some of the types of links defined for class diagrams (such as inheritance, association etc.) can be used with similar semantics within use case diagrams. + +\section{Activity Diagrams} + +\subsection{Begin, End and Flow End} + +The begin and the end of an activity diagram can be marked by using the macros {\code Begin} +and {\code End} or {\code FlowFinal}, respectively. The constructors of these visual objects take no parameters: + +\begin{verbatim} +Begin.beginName; +End.endName; +\end{verbatim} + +Below is an example: + +\begin{multicols}{2} +\begin{verbatim} +Begin.b; +End.e; +FlowFinal.f; + +leftToRight(20)(b, e, f); + +drawObjects(b, e, f); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/activity.1} +\end{multicols} + +\subsection{Activity} + +An activity is constructed as follows: +\begin{verbatim} +Activity.name(list-of-strings); +\end{verbatim} + +The parameter {\code list-of-strings} is a comma-separated list of strings. These strings are +centered on top of each other to allow for the accommodation of a longer activity description +within a reasonable space. + +An example is given below: + +\begin{multicols}{2} +\begin{verbatim} +Activity.A("Learn MetaUML -", + "the MetaPost UML library"); +drawObject(A); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/activity.2} +\end{multicols} + +\subsection{Fork and Join} + +A fork or join is created by the macro: + +\begin{verbatim} +Fork.name(type, length); +\end{verbatim} + +The parameter {\code type} is a string and can be either of {\code "h"}, {\code "horiz"}, {\code "horizontal"} +for horizontal bars, and either of {\code "v"}, {\code "vert"}, {\code "vertical"} for vertical bars. +The {\code length} gives the bar's length. + +\begin{multicols}{2} +\begin{verbatim} +Fork.forkA("h", 100); +Fork.forkB("v", 20); + +leftToRight(10)(forkA, forkB); + +drawObject(forkA, forkB); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/activity.3} +\end{multicols} + +\subsection{Branch} + +A branch is created by the macro: + +\begin{verbatim} +Branch.name; +\end{verbatim} + +Here is an example: + +\begin{multicols}{2} +\begin{verbatim} +Branch.testA; + +drawObject(testA); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/activity.4} +\end{multicols} + + +\subsection{Types of Links} + +In activity diagrams, transitions between activities are needed. They are typeset +as in the example below. In section \ref{composite-states} such a transition +is showed. This type of link is also used for state machine diagrams. + +\begin{verbatim} +link(transition)( pointA -- pointB ); +\end{verbatim} + +\section{State Diagrams} + +The constructor of a state allows for aggregated sub-states: + +\begin{verbatim} +State.name(state-name)(substates-list); +\end{verbatim} + +The parameter {\code state-name} is a string or a list of comma-separated strings representing +the state's name or description. The {\code substates-list} parameter is used to specify +the substates of this state as a comma-separated list of objects; this list may be void. + +An example of a simple state: + +\begin{multicols}{2} +\begin{verbatim} +State.s("Take order")(); +drawObject(s); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/state.1} +\end{multicols} + + +\subsection{Composite States} +\label{composite-states} + +A composite state is defined by enumerating at the end of its constructor the inner +states. Interestingly enough, the composite state takes care of drawing the sub-states it +contains. The transitions must be drawn after the composite state, as seen in the +next example: + +\begin{multicols}{2} +\begin{verbatim} +Begin.b; +End.e; +State.c("Component")(); +State.composite("Composite")(b, e, c); + +b.midx = e.midx = c.midx; +c.top = b.bottom - 20; +e.top = c.bottom - 20; + +composite.info.drawNameLine := 1; +drawObject(composite); + +link(transition)(b.s -- c.n); +link(transition)(c.s -- e.n); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/state.2} +\end{multicols} + +\subsection{Internal Transitions} + +Internal transitions can be specified by using the macro: +\begin{verbatim} +stateTransitions.name(list-transitions); +\end{verbatim} + +Identifier {\code name} gives the state object whose internal transitions are being set, +and parameter {\code list-transitions} is a comma-separated string list. + + +An example is given below: + +\begin{multicols}{2} +\begin{verbatim} +State.s("An interesting state", + "which is worth mentioning")(); +stateTransitions.s( + "OnEntry / Open eyes", + "OnExit / Sleep well"); +s.info.drawNameLine := 1; + +drawObject(s); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/state.3} +\end{multicols} + +\subsection{Special States} + +Similarly to the usage of {\code Begin} and {\code End} macros, one can define history states, +exit/entry point states and terminate pseudo-states, by using the following constructors. + +\begin{verbatim} +History.nameA; +ExitPoint.nameB; +EntryPoint.nameC; +Terminate.nameD; +\end{verbatim} + +\section{Drawing Paths} + +The {\code link} macro is powerful enough to draw relations following arbitrary paths: + +\begin{multicols}{2} +\begin{verbatim} +path cool; +cool := A.e .. A.e+(20,10) .. + B.s+(20,-40) .. B.s+(-10,-30) + -- B.s; +link(inheritance)(cool); + +link(aggregationUni) + (A.n ..(30,30)..B.w); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/paths.1} +\end{multicols} + +Amusing as it may be, this feature gets old soon. When typesetting UML diagrams in good style, rectangular paths are usually preferred. +It is for this kind of paths that MetaUML offers extensive support, by means of ``syntactic sugar'' constructs which +are not only self-documenting, but reduce the amount of typing and thinking required. + +\subsection{Manhattan Paths} + +The ``Manhattan'' path macros generate a path between two points consisting of one +horizontal and one vertical segment. The macro {\code pathManhattanX} generates first a +horizontal segment, while the macro {\code pathManhattanY} generates first a +vertical segment. In MetaUML it also matters the direction of a path, so you +can choose to reverse it by using {\code rpathManhattanX} and {\code rpathManhattanY} +(note the prefix ``{\code r}''): + +\begin{verbatim} +pathManhattanX(A, B) +pathManhattanY(A, B) + +rpathManhattanX(A, B) +rpathManhattanY(A, B) +\end{verbatim} + +\pagebreak +Here is an example: + +\begin{multicols}{2} +\begin{verbatim} +Class.A("A")()(); +Class.B("B")()(); + +B.sw = A.ne + (10,10); +drawObjects(A, B); + +link(aggregationUni) + (rpathManhattanX(A.e, B.s)); +link(inheritance) + (pathManhattanY(A.n, B.w)); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/paths.2} +\end{multicols} + +\subsection{Stair Step Paths} + +These path macros generate stair-like paths between two points. +The ``stair'' can ``rise'' first in the direction of $Ox$ axis ({\code pathStepX}) +or in the direction of $Oy$ axis ({\code pathStepY}). How much should a step +rise is given by an additional parameter, {\code delta}. Again, the macros +prefixed with ``{\code r}'' reverse the direction of the path given by their +unprefixed counterparts. + +\begin{verbatim} +pathStepX(A, B, delta) +pathStepY(A, B, delta) + +rpathStepX(A, B, delta) +rpathStepY(A, B, delta) +\end{verbatim} + +Here is an example: + +\begin{multicols}{2} +\begin{verbatim} +stepX:=60; +link(aggregationUni) + (pathStepX(A.e, B.e, stepX)); + +stepY:=20; +link(inheritance) + (pathStepY(B.n, A.n, stepY)); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/paths.3} +\end{multicols} + +\subsection{Horizontal and Vertical Paths} + +There are times when drawing horizontal or vertical links is required, +even when the objects are not properly aligned. To this aim, the following macros +are useful: + +\begin{verbatim} +pathHorizontal(pA, untilX) +pathVertical(pA, untilY) + +rpathHorizontal(pA, untilX) +rpathVertical(pA, untilY) +\end{verbatim} + +A path created by {\code pathHorizonal} starts from the point {\code pA} +and continues horizontally until coordinate {\code untilX} is reached. The macro +{\code pathVertical} constructs the path dually, working vertically. +The prefix ``{\code r}'' reverses the direction of the path. + +Usage example: + +\begin{multicols}{2} +\begin{verbatim} +untilX := B.left; +link(association) + (pathHorizontal(A.e, untilX)); + +untilY:= C.bottom; +link(association) + (pathVertical(A.n, untilY)); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/paths.4} +\end{multicols} + +\subsection{Direct Paths} + +A direct path can be created with {\code directPath}. The call {\code directPath(A, B)} +is equivalent to {\code A -{}- B}. + +\subsection{Paths between Objects} + +Using the constructs presented above, links between diagram objects are drawn easily like this: + +\begin{verbatim} +link(transition)(directPath(objA.nw, objB.se)); +\end{verbatim} + +There are times however when this direct approach may yield unsatisfactory visual results, +especially when the object's corners is round. To tackle these situations, MetaUML provides the macro +{\code pathCut}, whose aim is to limit a given path exactly to the region outside the actual +borders of the objects it connects. The macro's synopsis is: + +\begin{verbatim} +pathCut(thePath)(objectA, objectB) +\end{verbatim} + +Here, {\code thePath} is a given MetaPost path and {\code objectA} and {\code objectB} +are two MetaUML objects. By contract, each MetaUML object of type, say, {\code X} +defines a macro {\code X\_border} which returns the path that surrounds it. Because +of that, {\code pathCut} can make the appropriate modifications to {\code thePath}. + +The following code demonstrates the benefits of the {\code pathCut} macro: + +\begin{multicols}{2} +\begin{verbatim} +z = A.se + (30, -10); +link(transition) + (pathCut(A, B)(A.c--z--B.c)); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/paths.5} +\end{multicols} + +\subsubsection{Direct Paths between Centers} + +At times is quicker to just draw direct paths between the center of two objects, +minding of course the object margins. The macro which does this is {\code clink}: + +\begin{verbatim} +clink(how-to-draw-information)(objA, objB); +\end{verbatim} + +The parameter {\code how-to-draw-information} is the same as for the macro {\code link}; +{\code objA} and {\code objB} are two MetaUML objects. + +Below is an example which involves the inheritance relation: + +\begin{multicols}{2} +\begin{verbatim} +clink(inheritance)(A, B); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/paths.6} +\end{multicols} + +\section{Arranging Diagram Items} +\label{section:positioning} + +Using equations involving cardinal points, such as {\code A.nw = B.ne + (10,0)}, is +good enough for achieving the desired results. However, programs are best to +be written for human audience, rather than for compilers. It does become a bit +tiresome to think all the time of cardinal points and figure out the +direction of positive or negative offsets. Because of that, MetaUML offers +syntactic sugar which allows for an easier understanding of the intent behind +the positioning code. + +Suppose that we have three classes, {\code A}, {\code B}, {\code C} and their base class +{\code Base}. We want the base class to be at the top, and the derived classes to be +on a line below. This code will do: + +\begin{verbatim} +A.ne = B.nw + (20,0); +B.ne = C.nw + (20,0); +Base.s = B.n + (0,-20); +\end{verbatim} + +Unfortunately, writing code such as this makes it hard for fellow programmers to visualize +its intent upon reading it. And ``fellow programmers`` include the author, five minutes later. + +Perhaps the next version of the code will drive home the point. The outcome is +the same as before, but the layout is stated in a more human-friendly way. You might even +infer by yourself that the numeric argument represents the distance between the objects. + +\begin{multicols}{2} +\begin{verbatim} +leftToRight(20)(A, B, C); +topToBottom(20)(Base, B); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/positioning.2} +\end{multicols} + +Below there are examples which show how these macros can be used. Suppose that we have the +following definitions for objects {\code X}, {\code Y}, and {\code Z}; also, let's assume +that {\code spacing} is a numeric variable set to {\code 5}. + +\begin{verbatim} +Picture.X("a"); +Picture.Y("..."); +Picture.Z("Cyan"); +\end{verbatim} + +\begin{tabular}{||l|c||} +\hline +{\code leftToRight.top(spacing)(X, Y, Z);} & \includegraphics{fig/positioning.3} \\ +\hline +{\code leftToRight.midy(spacing)(X, Y, Z);} & \includegraphics{fig/positioning.4} \\ +\hline +{\code leftToRight.bottom(spacing)(X, Y, Z);} & \includegraphics{fig/positioning.5} \\ +\hline +{\code topToBottom.left(spacing)(X, Y, Z);} & \includegraphics{fig/positioning.6} \\ +\hline +{\code topToBottom.midx(spacing)(X, Y, Z);} & \includegraphics{fig/positioning.7} \\ +\hline +{\code topToBottom.right(spacing)(X, Y, Z);} & \includegraphics{fig/positioning.8} \\ +\hline +\end{tabular} \\ + +To make things even easier, the following equivalent contructs are also allowed: + +\begin{verbatim} +leftToRight.midy(spacing)(X, Y, Z); +leftToRight(spacing)(X, Y, Z); +\end{verbatim} + +\begin{verbatim} +topToBottom.midx(spacing)(X, Y, Z); +topToBottom(spacing)(X, Y, Z); +\end{verbatim} + +If you want to specify that some objects have a given property equal, while the distance between them is given elsewhere, you can use the macro {\code same}. +This macro accepts a variable number of parameters, but at least two. The following table gives the interpretation of the macro for a simple example. + +\begin{tabular}{||l|l||} +\hline +{\code same.top(X, Y, Z);} & {\code X.top = Y.top = Z.top;} \\ +\hline +{\code same.midy(X, Y, Z);} & {\code X.midy = Y.midy = Z.midy;} \\ +\hline +{\code same.bottom(X, Y, Z);} & {\code X.bottom = Y.bottom = Z.bottom;} \\ +\hline +{\code same.left(X, Y, Z);} & {\code X.left = Y.left = Z.left;} \\ +\hline +{\code same.midx(X, Y, Z);} & {\code X.midx = Y.midx = Z.midx;} \\ +\hline +{\code same.right(X, Y, Z);} & {\code X.right = Y.right = Z.right;} \\ +\hline +\end{tabular} \\ + +Relative positions of two points can be declared more easily using the macros {\code below}, {\code above}, {\code atright}, {\code atleft}. +Let us assume that {\code A} and {\code B} are two points (objects of type {\code pair} in MetaPost). The following constructs are equivalent: + +\begin{tabular}{||l|l||} +\hline +{\code B = A + (5,0);} & {\code B = atright(A, 5);} \\ +{\code B = A - (5,0);} & {\code B = atleft(A, 5);} \\ +{\code B = A + (0,5);} & {\code B = above(A, 5);} \\ +{\code B = A - (0,5);} & {\code B = below(A, 5);} \\ +\hline +\end{tabular} + + +\section{The MetaUML Infrastructure} +\label{section:infrastructure} + +MetaPost is a macro language based on equation solving. Using it may seem quite +tricky at first for a programmer accustomed to modern object-oriented languages. +However, the great power of MetaPost consists in its versatility. Indeed, it is possible to write +a system which mimics quite well object-oriented behavior. Along this line, METAOBJ +\cite{metaobj} is a library worth mentioning: it provides a high-level objects +infrastructure along with a battery of predefined objects. + +Surprisingly enough, MetaUML does not use METAOBJ. Instead, it uses a custom written, +lightweight object-oriented infrastructure, provisionally called ``{\code util}''. +METAOBJ's facilities, although impressive, were perceived by me as being a bit too much +for what was initially intented as a quick way of getting some UML diagrams layed out. +Inspired by METAOBJ, ``{\code util}'' was designed to fulfill with minimal effort +the specific tasks needed to confortably position, allign or group visual objects +which include text. + +Another library having some object-oriented traits is the {\code boxes} +library, which comes with the standard MetaPost distribution. Early versions of +MetaUML did use {\code boxes} as an infrastructure, but this approach had to be abandoned eventually. +The main reason was that it was difficult to achieve good visual results when stacking texts +(more on that further on). For all it's worth, it did not fit well with the way in which MetaUML's +layout mechanism was shaping up at the time. + +\subsection{Motivation} + +Suppose that we want to typeset two texts with their bottom lines aligned, using {\code boxit}: + +\begin{multicols}{2} +\begin{verbatim} +boxit.a ("yummy"); +boxit.b ("cool"); + +a.nw = (0,0); b.sw = a.se + (10,0); + +drawboxed (a, b); % or drawunboxed(a,b) +draw a.sw -- b.se dashed evenly + withpen pencircle scaled 1.1; +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/boxes_vs_util.1} +\end{multicols} + +Note that, despite supposedly having their bottom lines alligned, +``yummy'' {\it looks} slightly higher than ``cool''. This would be unacceptable +in a UML class diagram, when roles are placed at the ends of a horizontal association. +Regardless of the default spacing being smaller in the {\code util} library, +the very same unfortunate misalignment effect rears its ugly head: + +\begin{multicols}{2} +\begin{verbatim} +Picture.a("yummy"); +Picture.b("cool"); +% comment next line for unboxed +a.info.boxed := b.info.boxed := 1; + +b.sw = a.se + (10,0); + +drawObjects(a, b); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/boxes_vs_util.2} +\end{multicols} + +However, the strong point of {\code util} is that we have a recourse to this problem: + +\begin{multicols}{2} +\begin{verbatim} +iPict.ignoreNegativeBase := 1; + +Picture.a("yummy"); +Picture.b("cool"); +% the rest the same as above +drawObjects(a, b); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/boxes_vs_util.3} +\end{multicols} + +\subsection{The Picture Macro} + +We have seen previously the line {\code iPict.ignoreNegativeBase := 1}. +Who is {\code iPict} and what is it doing in our program? MetaUML +aims at separating the ``business logic'' (what to draw) from the +``interface'' (how to draw). In order to achieve this, it records the ``how to draw'' +information within the so-called {\code Info} structures. The object {\code iPict} +is an instance of {\code PictureInfo} structure, which has the following properties +(or attributes): +\begin{verbatim} +left, right, top, bottom +ignoreNegativeBase +boxed, borderColor +\end{verbatim} + +The first four attributes specify how much space should be left around the +actual item to be drawn. The marvelous effect of {\code ignoreNegativeBase} +has just been shown (off), while the last two attributes control whether the border +should be drawn (when {\code boxed=1}) and if drawn, in which color. + +There's one more thing: the font to typeset the text in. This is specified +in a {\code FontInfo} structure which has two attributes: the font name +and the font scale. This information is kept within the {\code PictureInfo} structure +as a contained attribute {\code iFont}. Both {\code FontInfo} and {\code PictureInfo} +have ``copy constructors'' which can be used to make copies. We have already +the effect of these copy constructors at work, when we used: + +\begin{verbatim} +Picture.a("yummy"); +a.info.boxed := 1; +\end{verbatim} + +A copy of the default info for a picture, {\code iPict}, has been made within +the object {\code a} and can be accessed as {\code a.info}. Having a copy of the +info in each object may seem like an overkill, but it allows for a fine grained +control of the drawing mode of each individual object. This feature comes in very +handy when working with a large number of settings, as it is the case for MetaUML. + +Let us imagine for a moment that we have two types of text to write: one with a small font +and a small margin and one with a big font and a big margin. We could in theory +configure each individual object or set back and forth global parameters, but +this is far for convenient. It is preferable to have two sets of settings and specify +them explicitly when they are needed. The following code could be placed somewhere +in a configuration file and loaded before any {\code beginfig} macro: +\begin{verbatim} +PictureInfoCopy.iBig(iPict); +iBig.left := iBig.right := 20; +iBig.top := 10; +iBig.bottom := 1; +iBig.boxed := 1; +iBig.ignoreNegativeBase := 1; +iBig.iFont.name := defaultfont; +iBig.iFont.scale := 3; + +PictureInfoCopy.iSmall(iPict); +iSmall.boxed := 1; +iSmall.borderColor := green; +\end{verbatim} + +Below is an usage example of these definitions. Note the name of the macro: {\code EPicture}. +The prefix comes form ``explicit'' and it's used to acknowledge that the +``how to draw'' information is given explicitly --- as a parameter, +rather than defaulted to what's recorded in {\code iPict}, as with the {\code Picture} macro. +Having predefined configurations yields short, convenient code. + +\begin{multicols}{2} +\begin{verbatim} +EPicture.a(iBig)("yummy"); +EPicture.b(iSmall)("cool"); +% you can still modify a.info, b.info + +b.sw = a.se + (10,0); + +drawObjects(a, b); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/picture_info.1} +\end{multicols} + +\subsubsection{Fixed Sizes} + +By default, the size of a {\code Picture} object is set by its contents. However, +it is possible to specify fixed dimensions both the width and the height, independently. +This can be done by setting the {\code info}'s attributes {\code fixedWidth} and {\code fixedHeight} to values +greater than 0. If any of these attributes is left to its default value, {\code -1}, then for the corresponding +axis the dimension is set according to the dimension of the content. Nevertheless, the fixed dimensions are enforced, even though the contained object would have needed additional space. + +\begin{multicols}{2} +\begin{verbatim} +PictureInfoCopy.myFixed(iPict); +myFixed.ignoreNegativeBase := 1; +myFixed.fixedWidth := 15; +myFixed.fixedHeight := 20; +myFixed.boxed := 1; + +EPicture.a(myFixed)("a"); +EPicture.b(myFixed)(".-."); +EPicture.c(myFixed)("toolong"); + +leftToRight.bottom(10)(a, b, c); + +drawObjects(a, b, c); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/picture_info.2} +\end{multicols} + +\subsubsection{Content alignment} + +When fixed dimensions are used, one most likely would prefer a centered alignement of the contents in the +{\code Picture} box. This option can be expressed independently for each of the axes, +by setting the {\code info}'s attributes {\code valign} and {\code halign} to descriptive string values. +For horizontal alignement, {\code halign} can be set to {\code "left"} or {\code "center"}, and for +vertical alignement, {\code valign} can be set to {\code "bottom} or {\code "center"}. The default +values for these attributes are {\code "left"} and {\code "bottom"}, respectively. + +The next example uses horizontal centered alignement and a bottom alignement with a {\code 4.5} base offset, for +vertical alignement. This vertical alignement gives a better visual result than the centered one, at +least for the situations in which there are texts to be placed horizontally. + +\begin{multicols}{2} +\begin{verbatim} +PictureInfoCopy.myFixed(iPict); +myFixed.ignoreNegativeBase := 1; +myFixed.bottom := 4.5; +myFixed.valign := "bottom"; +myFixed.halign := "center"; +myFixed.fixedWidth := 25; +myFixed.fixedHeight := 15; +myFixed.boxed := 1; + +EPicture.a(myFixed)("a"); +EPicture.b(myFixed)("yum"); +EPicture.c(myFixed)("b"); + +leftToRight.bottom(10)(a, b, c); + +drawObjects(a, b, c); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/picture_info.3} +\end{multicols} + +\subsection{Stacking Objects} + +It is possible to stack objects, much in the style of {\code setboxjoin} +from {\code boxes} library. + +\begin{multicols}{2} +\begin{verbatim} +Picture.a0("yummy"); +Picture.a1("cool"); +Picture.a2("fool"); + +setObjectJoin(pa.sw = pb.nw); +joinObjects(scantokens listArray(a)(3)); + +drawObjects(scantokens listArray(a)(3)); +% or drawObjects (a0, a1, a2); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/object_stack.1} +\end{multicols} + +The {\code listArray} macro provides here a shortcut for writing +{\code a0, a1, a2}. This macro is particularly useful for generic +code which does not know beforehand the number of elements to be drawn. +Having to write the {\code scantokens} keyword is admittedly a nuisance, but +this is required. + + +\subsection{The Group Macro} + +It is possible to group objects in MetaUML. This feature is the cornerstone +of MetaUML, allowing for the easy development of complex objects, such as +composite stats in state machine diagrams. + +Similarly to the macro {\code Picture}, the structure {\code GroupInfo} +is used for specifying group properties; its default instantiation is +{\code iGroup}. Furthermore, the macro {\code EGroup} explicitely sets the +layout information. + +Here is an example: + +\begin{multicols}{2} +\begin{verbatim} +iGroup.left:=20; +iGroup.right:=15; +iGroup.boxed:=1; +iPicture.boxed:=1; + +Picture.a("yummy"); +Picture.b("cool"); +Picture.c("fool"); + +b.nw = a.nw + (20,20); % A +c.nw = a.nw + (15, 40); % B + +Group.g(a, b, c); +g.nw = (10,10); % C + +drawObject(g); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/group.1} +\end{multicols} + +After some objects are grouped, they can only be drawn +by invoking the {\code drawObject} macro on the group that aggregates them, and not individually. +Conveniently, once the relative positioning of objects within a group is set (line A and B), the whole +group can be ``moved'' do the desired position (line C), and all the contained objects will move along. + +\subsection{The PictureStack Macro} + +The {\code PictureStack} macro is a syntactic sugar for a set of pictures, +stacked according to predefined equations and grouped together. + +\begin{multicols}{2} +\begin{verbatim} +iStack.boxed := 1; +iStack.iPict.boxed := 1; +PictureStack.myStack("foo", + "bar: int" infont "tyxtt", + "nicely-centered" infont defaultfont, + "nice")("vcenter"); + +drawObject(myStack); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/picture_stack.1} +\end{multicols} + +Note the last parameter of the macro {\code PictureStack}, here {\code vcenter}. +It is used to generate appropriate equations based on a descriptive name. +The spacing between individual picture objects is set by the field +{\code iStack.spacing}. Currently, the following alignment names are +defined: {\code vleft}, {\code vright}, {\code vcenter}, +{\code vleftbase}, {\code vrightbase}, {\code vcenterbase}. All these +names refer to vertical alignment (the prefix ``{\code v}''); alignment can +be at left, right or centered. The variants having the suffix ``{\code base}'' align +the pictures so that {\code iStack.spacing} refer to the distance between the +bottom lines of the pictures. The unsuffixed variants use {\code iStack.spacing} as +the distance between one's bottom line and the next's top line. + +The ``{\code base}'' alignment is particularly useful for stacking text, since it +offers better visual appearance when {\code iPict.ignoreNegativeBase} is set to {\code 1}. + +\section{Components Design} + +Each MetaUML component (e.g. {\code Picture}, {\code PictureStack}, {\code Class}) is +designed according to an established pattern. This section gives more insight +on this. + +In order to draw a component, MetaUML categorizes the required information as follows: +\begin{itemize} +\item what to draw, or what are the elements of a component. +\item how to draw, or how are the elements positioned in relation to each other within the component +\item where to draw +\end{itemize} + +For example, in order to draw a picture object we must know, respectively: +\begin{itemize} +\item what is the text or the native picture that needs to be drawn +\item what are the margins that should be left around the contents +\item where is the picture to be drawn +\end{itemize} + +Why do we bother with these questions? Why don't we just simply draw the picture +component as soon as it was created and get it over with? +That is, why doesn't the following code just work? + +\begin{verbatim} +Picture.pict("foo"); +\end{verbatim} + +Well, although we have the answer to question 1 (what to draw), +we still need to have question 3 answered. The code below becomes thus a +necessity (actually, you are not forced to specify the positioning of an object, +because its draw method positions it to {\code (0,0)} by default): + +\begin{verbatim} +% question 1: what to draw +Picture.pict("foo"); + +% question 3: where to draw +pict.nw = (10,10); + +% now we can draw +drawObject(pict); +\end{verbatim} + +How about question 2, how to draw? By default, this problem is addressed behind the +scenes by the component. This means, for the Picture object, that a native picture is created +from the given string, and around that picture certain margins are placed, by means of MetaPost equations. +(The margins also come in handy when stacking Picture objects, so that the result doesn't look too cluttered.) +If these equations were defined within the Picture constructor, then an +usability problem would have appeared, because it wouldn't have been possible to modify the margins, +as in the code below: + +\begin{verbatim} +% question 1: what to draw +Picture.pict("foo"); + +% question 2: how to draw +pict.info.left := 10; +pict.info.boxed := 1; + +% question 3: where to draw +pict.nw = (0,0); + +% now we can draw +drawObject(pict); +\end{verbatim} + +To allow for this type of code, the equations that define the layout of the {\code Picture} object (here, what the margins are) +must be defined somewhere after the constructor. This is done by a macro called {\code Picture\_layout}. +This macro defines all the equations which link the ``what to draw'' information to the ``how to draw'' +information (which in our case is taken from the {\code info} member, a copy of {\code iPict}). +Nevertheless, notice that {\code Picture\_layouts} is not explicitly invoked. To the user's +great relief, this is taken care of automatically within the {\code Picture\_draw} macro. + +There are times however, when explicitly invoking a macro like {\code Picture\_layout} +becomes a necessity. This is because, by contract, it is only after the {\code layout} +macro is invoked that the final dimensions (width, height) of an object are +definitely and permanently known. Imagine that we have a component whose job is to +surround in a red-filled rectangle some other objects. This component +needs to know what the dimensions of the contained objects are, in order to be able to set +its own dimensions. At drawing time, the contained objects must not have been drawn already, +because the red rectangle of the container would overwrite them. +Therefore, the whole pseudo-code would be: +\begin{verbatim} +Create objects o1, o2, ... ok; +Create container c(o1, o2, ..., ok); +Optional: modify info-s for o1, o2, ... ok; +Optional: modify info for c; + +layout c, requiring layout of o1, o2, ... ok; +establish where to draw c; +draw red rectangle defined by c; +draw components o1, o2, ...ok within c +\end{verbatim} + +A natural conclusion is that an object must not be laid out more than once, because otherwise +inconsistent or superfluous equations would arise. To enforce this, by contract, +any object must keep record of whether its layout method has already been invoked, +and if the answer is affirmative, subsequent invocations of the layout macro would +do nothing. It is very important to mention that after the {\code layout} macro is +invoked over an object, modifying the {\code info} member of that object has +no subsequent effect, since the layout equations are declared and interpreted only once. + +\subsection{Notes on the Implementation of Links} + +MetaUML considers edges in diagram graphs as links. A link is composed of a path and the +heads (possible none, one or two). For example, since an association has no heads, it suffices +to draw along the path with a solid pen; however, an unidirectional aggregation has, in addition +to a solid path, two heads: one is an arrow and the other is a diamond. + +The general algorithm for drawing a link is: + +\begin{verbatim} +0. Reserve space for heads +1. Draw the path (except for the heads) +2. Draw head 1 +3. Draw head 2 +\end{verbatim} + +Each of the UML link types define how the drawing should be done, in each of the +cases (1, 2 and 3). Consider the link type of unidirectional composition. +Its ``class'' is declared as: + +\begin{verbatim} +vardef CompositionUniInfo@# = + LinkInfo@#; + + @#widthA = defaultRelationHeadWidth; + @#heightA = defaultRelationHeadHeight; + @#drawMethodA = "drawArrow"; + + @#widthB = defaultRelationHeadWidth; + @#heightB = defaultRelationHeadHeight; + @#drawMethodB = "drawDiamondBlack"; + + @#drawMethod = "drawLine"; +enddef; +\end{verbatim} + +Using this definition, the actual description is created like this: + +\begin{verbatim} +CompositionUniInfo.compositionUni; +\end{verbatim} + +As shown previously, is is the macro {\code link} which +performs the actual drawing, using the link description information +which is given as parameter (generally called {\code iLink}). +For example, we can use: + +\begin{verbatim} +link(aggregationUni)((0,0)--(40,0)); +\end{verbatim} + +%\begin{figure} +%\centering +%\includegraphics{fig/how-links-work.1} +%\caption{An example of a picture stack.} +%\label{fig:hlw} +%\end{figure} + +Let us see now the inner workings of macro {\code link}. Its definition is: + +\begin{verbatim} +vardef link(text iLink)(expr myPath)= + LinkStructure.ls(myPath, + iLink.widthA, iLink.widthB); + drawLinkStructure(ls)(iLink); +enddef; +\end{verbatim} + +\begin{figure} +\centering +\begin{tabular}{l|l} +$AB$ & the path specified by the user \\ +$|AA'|$ & {\code iLink.widthA}\\ +$|BB'|$ & {\code iLink.widthB} +\end{tabular} +\includegraphics{fig/how-links-work.2} +\caption{Details on how a link is drawn by MetaUML.} +\label{fig:hlw2} +\end{figure} + +First, space is reserved for heads, by ``shortening'' the given path {\code myPath} +by {\code iLink.widthA} at the beginning and by {\code iLink.widthB} at the end. +After that, the shortened path is drawn with the ``method'' +given by {\code iLink.drawMethod} and the heads with the ``methods'' +{\code iLink.drawMethodA} and {\code iLink.drawMethodB}, +respectively (figure \ref{fig:hlw2}). + +\subsection{Object Definitions: Easier {\code generic\_declare}} + +In MetaPost, if somebody wants to define something resembling a class in an object-oriented language, +named, say, {\code Person}, he would do something like this: + +\begin{verbatim} +vardef Person@#(expr _name, _age)= + % @# prefix can be seen as `this` pointer + string @#name; + numeric @#age; + + @#name := _name; + @#age := _age; +enddef; +\end{verbatim} + +This allows for the creation of instances (or objects) of class {\code Person} by using +declarations like: + +\begin{verbatim} +Person.personA; +Person.personB; +\end{verbatim} + + However, if one also wants to able able to create indexed arrays of persons, such as +{\code Person.student0}, {\code Person.student1} etc., the definition of class +{\code Person} must read: + +\begin{verbatim} +vardef Person@#(expr _name, _age)= + _n_ := str @#; + generic_declare(string) _n.name; + generic_declare(numeric) _n.age; + + @#name := _name; + @#age := _age; +enddef; +\end{verbatim} + +This construction is rather inelegant. MetaUML offers alternative macros to achieve +the same effect, uncluttering the code by removing the need for the unaesthetic {\code \_n\_} and +{\code \_n}. + +\begin{verbatim} +vardef Person@#(expr _name, _age)= + attributes(@#); + var(string) name; + var(numeric) age; + + @#name := _name; + @#age := _age; +enddef; +\end{verbatim} + +\section{Customization in MetaUML: Examples} +\label{section:customization} + +We have seen that in MetaUML the ``how to draw'' information is memorized into the so-called +``{\code Info}'' structures. For example, the default way in which a {\code Picture} object is +to be drawn is recorded into an instance of {\code PictureInfo}, named {\code iPict}. In this section we +present a case study involving the customization of {\code Class} objects. The customization of +any other MetaUML objects works similarly. Here we cannot possibly present all the customization +options for all kinds of MetaUML objects: this would take too long. Nevertheless, an interested reader can refer +to the top of the appropriate MetaUML library file, where {\code Info} structures are defined. +For example, class diagram related definitions are in {\code metauml\_class.mp}, activity diagram +definitions are in {\code metauml\_activity.mp} etc. + +\subsection{Global settings} + +Let us assume that we do not particularly like the default foreground color of all classes, and wish +to change it so something yellowish. In this scenario, one would most likely want to change +the appropriate field in {\code iClass}: + +\begin{verbatim} +iClass.foreColor := (.9, .9, 0); +\end{verbatim} + +After this, we can obtain the following result: + +\begin{multicols}{2} +\begin{verbatim} +Class.A("A")()(); +Class.B("B")()(); +Class.C("C")()(); + +B.w = A.e + (20,0); +C.n = .5[A.se, B.sw] + (0, -10); + +drawObjects(A, B, C); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/class_customization.1} +\end{multicols} + +\subsection{Individual settings} + +To modify the settings of one particular {\code Class} objects, another strategy is more appropriate. How about having class +{\code C} stand out with a light blue foreground color, a bigger font size for the class name and a blue border? + +\begin{multicols}{2} +\begin{verbatim} +iPict.foreColor := (.9, .9, 0); + +Class.A("A")()(); +Class.B("B")()(); +Class.C("C")()(); +C.info.foreColor := (.9, .7, .7); +C.info.borderColor := green; +C.info.iName.iFont.scale := 2; + +% positioning code ommited +drawObjects(A, B, C); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/class_customization.2} +\end{multicols} + +As an aside, each {\code Class} object has an {\code info} member which is created as +a copy of {\code iClass}; the actual drawing is performed using this copied +information. Because of that, the {\code info} member can be safely modified after the object +has been created, obtaining the expected results and not influencing other objects. + +Another thing worth mentioning is that the {\code ClassInfo} structure contains +the {\code iName} member, which is an instance of {\code PictureInfo}. In our example we +do not want to modify the spacings around the {\code Picture} object, +but the characteristics of the font its contents is typeset into. To do that, +we modify the {\code iName.iFont} member, which by default is a copy of {\code iFont} +(an instance of {\code FontInfo}, defined in {\code util\_picture.mp}). +If, for example, we want to change the font the class name is rendered into, we would set +the attribute {\code iName.iFont.name} to a string representing a font name +on our system (as used with the MetaPost {\code infont} operator). + +\subsection{Predefined settings} + +This usage scenario is perhaps more interesting. Suppose that we have two +types of classes which we want to draw differently. Making the setting adjustments +for each individual class object would soon become a nuisance. MetaUML's solution consists in the +ability of using predefined ``how to draw'' {\code Info} objects. Let us create such objects: + +\begin{verbatim} +ClassInfoCopy.iHome(iClass); +iHome.foreColor := (0, .9, .9); + +ClassInfo.iRemote; +iRemote.foreColor := (.9, .9, 0); +iRemote.borderColor := green; +\end{verbatim} + +Object {\code iHome} is a copy of {\code iClass} (as it might have been set at +the time of the macro call). Object {\code iRemote} is created just as {\code iClass} +is originally created. We can now use these {\code Info} objects to easily set the +``how to draw'' information for classes. The result is depicted below, +please note the ``{\code E}'' prefix in {\code EClass}: + +\begin{multicols}{2} +\begin{verbatim} +EClass.A(iHome)("UserHome")()(); +EClass.B(iRemote)("UserRemote")()(); +EClass.C(iHome)("CartHome")()(); +EClass.D(iRemote)("CartRemote")()(); +\end{verbatim} +\columnbreak +\hspace{1cm}\includegraphics{fig/class_customization.3} +\end{multicols} + +\subsection{Extreme customization} + +When another font (or font size) is used, it may become necessary to change the space between the +baselines of attributes and methods. Figure below is the result of the (unlikely) code: + +\begin{multicols}{2} +\begin{verbatim} +Class.A("Foo") + ("a: int", "b: int") + ("foo()", "bar()", "gar()"); + +A.info.iName.iFont.name := metauml_defaultFontBold; +A.info.iName.iFont.scale := 1.2; + +A.info.iAttributeStack.iPict.iFont.scale := 0.8; +A.info.iAttributeStack.top := 10; +A.info.iAttributeStack.spacing := 11; + +A.info.iMethodStack.iPict.iFont.scale := 2; +A.info.iMethodStack.spacing := 17; +A.info.iMethodStack.bottom := 10; + +drawObject(A); +\end{verbatim} +\columnbreak +\hspace{4cm}\includegraphics{fig/class_customization.4} +\end{multicols} + +\begin{verbatim} +\end{verbatim} + +Both {\code iAttributeStack} and {\code iMethodStack} are instances of +{\code PictureStackInfo}, which is used to control the display of {\code PictureStack} objects. +%We can also customize the size and colors of the ``locks'' by setting {\code A.info.iLock}. + +As font names, you can choose from the globally defined {\code metauml\_defaultFont}, {\code metauml\_defaultFontOblique}, {\code metauml\_defaultFontBold}, {\code metauml\_defaultFontBoldOblique}, or any other name of a font that is available on your system. + +\section{Alternatives to MetaUML} + +No software package is perfect, and for this MetaUML is a prime example. Here is a list of packages that may also be used to create UML diagrams for LaTeX work: + +\begin{itemize} +\item uml.sty \cite{umlsty} +\item pst-uml \cite{pstumlsty} +\item umldoc \cite{umldoc} +\item TiKZ-UML \cite{tikzuml} +\end{itemize} + +Do not ignore the possibility of creating your diagrams using a GUI program, and then exporting them into a LaTex-friendly open format such as SVG \cite{svglatex}. + +\pagebreak +\input{test-suite} + +\pagebreak +\section{References} +\printbibliography[heading=none] + +\end{document} diff --git a/Master/texmf-dist/doc/metapost/metauml/manual/test-suite.tex b/Master/texmf-dist/doc/metapost/metauml/manual/test-suite.tex new file mode 100644 index 00000000000..b0aa9a66856 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/metauml/manual/test-suite.tex @@ -0,0 +1,82 @@ +% Part of the MetaUML manual +% Copyright (c) 2005 Ovidiu Gheorghies +% +% Permission is granted to copy, distribute and/or modify this document +% under the terms of the GNU Free Documentation License, Version 1.2 +% or any later version published by the Free Software Foundation; +% with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +% A copy of the license is included in the section entitled "GNU +% Free Documentation License". + +\newcommand{\metaumltest}[2]{Test #2 --- \\ \includegraphics{fig/test_#1.#2} \\ } +\newcommand{\metaumltests}[2]{\multido{\iA=1+1}{#2}{\metaumltest{#1}{\iA}}} + +\section{Test Suite} + +\subsection{Low-level} + \metaumltests{lowlevel}{2} + +\subsection{Fonts} + \metaumltests{font}{3} + +\subsection{Util library} + \subsubsection{Picture tests} + \metaumltests{picture}{10} + + \subsubsection{Picture tests - TeX rendering} + \metaumltests{picture_tex_rendering}{1} + + \subsubsection{Group tests} + \metaumltests{group}{2} + + \subsubsection{PictureStack tests} + \metaumltests{picture_stack}{7} + + \subsubsection{Positioning tests} + \metaumltests{positioning}{6} + +\subsection{Class diagram} + \subsubsection{Class tests} + \metaumltests{class}{16} + \subsubsection{Class feature types tests} + \metaumltests{class_feature_types}{5} + \subsubsection{Class template tests} + \metaumltests{class_templates}{3} + + \subsubsection{Qualified Association tests} + \metaumltests{class_qual_assoc}{2} + +\subsection{Package diagram} +\subsubsection{Package tests} + \metaumltests{package}{2} + +\subsection{Component diagram} +\subsubsection{Component tests} + \metaumltests{component}{1} + +\subsection{Paths} + \metaumltests{paths}{3} + +\subsection{Behavioral diagrams} + \subsubsection{Activity tests} + \metaumltests{activity}{2} + + \subsubsection{State Machine tests} + \metaumltests{state}{5} + + \subsubsection{Usecase tests} + \metaumltests{usecase}{9} + +\subsection{Miscelaneous} + \subsubsection{Notes} + \metaumltests{note}{2} + \subsubsection{Objects (Class Instances)} + \metaumltests{instance}{1} + +\subsection{User requests} + Test 1 --- \\ \includegraphics[scale=.2]{fig/test_lars_issues.1} \\ + \metaumltest{lars_issues}{2} + +\subsection{Skins} + \metaumltests{skins}{1} + \metaumltests{skins_global_defaults}{1} |