Debian Codegraph @

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

raw
1 % Part of the MetaUML manual.
2 % Copyright (C) 2005 Ovidiu Gheorghies
3 %
4 % This program is free software; you can redistribute it and/or
5 % modify it under the terms of the GNU General Public License
6 % as published by the Free Software Foundation; either version 2
7 % of the License, or (at your option) any later version.
8 %
9 % This program is distributed in the hope that it will be useful,
10 % but WITHOUT ANY WARRANTY; without even the implied warranty of
11 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 % GNU General Public License for more details.
13 %
14 % You should have received a copy of the GNU General Public License
15 % along with this program; if not, write to the Free Software
16 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 % for f in `find . | grep '.*\.[1-9]'`; do echo $f; done
19
20 input metauml;
21
22 beginfig(1);
23 Begin.b;
24 State.on("On")();
25 State.off("Off")();
26 End.e;
27
28 setObjectJoin(pb.w = pa.e + (20,0));
29 joinObjects(b, on, off, e);
30 drawObjects(b, on, off, e);
31
32 clink(transition)(b, on);
33 clink(transition)(on, off);
34 clink(transition)(off, e);
35 endfig;
36
37 beginfig(2);
38 save b, reading, processing, e, exit;
39
40 Begin.b;
41 State.reading("Commands read")();
42 State.processing("Processing commands")();
43 End.e;
44 setObjectJoin(pb.n = pa.s + (0, -20));
45 joinObjects(b, reading, processing, e);
46
47 State.composite("Work")(b, reading, processing, e);
48 drawObject(composite);
49
50 clink(transition)(b, reading);
51 clink(transition)(reading, processing);
52 clink(transition)(processing, e);
53
54 ExitPoint.exit;
55 exit.c=(composite.right, reading.midy);
56 drawObject(exit);
57 item(iAssoc)("error")(obj.nw = exit.s);
58
59 clink(transition)(reading, exit);
60
61 State.error("Prepare error report")();
62 State.result("Display result")();
63 End.theEnd;
64
65 error.midx = result.midx = theEnd.midx = composite.right + 90;
66 error.midy = exit.midy;
67 result.midy = processing.midy;
68 theEnd.midy = e.midy;
69 drawObjects(error, result, theEnd);
70
71 clink(transition)(exit, error);
72 clink(transition)(error, result);
73 clink(transition)(result, theEnd);
74
75 link(transition)(rpathHorizontal(result.w, composite.right));
76 endfig;
77
78 end