Debian Codegraph @

texmf-dist/doc/metapost/metauml/manual/fig/test_picture_stack.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 input metauml;
19
20 string theFont;
21 theFont := "tyxtt";
22
23 util_log_thresholdlevel := 100;
24
25 beginfig(1);
26 PictureStackInfoCopy.stackWay(iStack);
27
28 EPictureStack.emptyStack(stackWay)()("vcenter");
29 emptyStack.nw=(10,10);
30 drawObject(emptyStack);
31 endfig;
32
33 beginfig(2);
34 PictureStack.myStack("foo")("vcenter");
35 myStack.nw = (0,0);
36 PictureStack_draw.myStack;
37 endfig;
38
39 beginfig(3);
40 PictureStack.myStackB("foo", "bar")("vcenter");
41 myStackB.nw = (0,0);
42 PictureStack_draw.myStackB;
43 endfig;
44
45 beginfig(4);
46 % 1
47 PictureStack.stack("item A", "item B long", "C")("vcenter");
48 stack.info.boxed := 1;
49 stack.info.iPict.boxed := 1; % this does nothing, it's too late
50
51 stack.nw = (0,0);
52 drawObject(stack);
53
54 % 2
55 PictureStack.stackb("item A", "item B long", "C")("vcenter");
56 stackb.info.boxed := 1;
57 stackb.pict[0].info.boxed := 1;
58 stackb.pict[2].info.boxed := 1;
59
60 stackb.nw = (100,0);
61 drawObject(stackb);
62
63 % 3
64 PictureStackInfoCopy.myInfo(iStack);
65 myInfo.boxed := 1;
66 myInfo.iPict.boxed := 1;
67 EPictureStack.stackc(myInfo)("item A", "item B long", "C")("vcenter");
68
69 stackc.nw = (200,0);
70 drawObject(stackc);
71 endfig;
72
73 beginfig(5);
74 vardef joinCallback= enddef;
75 PictureStack.custom("A.A", "B__________B", "C-----C")
76 ("joinCallback");
77
78 drawObject(custom);
79 endfig;
80
81 beginfig(6);
82 save custom;
83
84 pickup pencircle scaled 4pt;
85 drawdot origin;
86
87 vardef joinCallbackA=
88 setObjectJoin(pa.bottom = pb.top + index*10; pa.left = pb.left);
89 setObjectJoinFirst(pa.nw = (30,0));
90 enddef;
91
92 PictureStack.customA("go", "further", "and further", "and further still")
93 ("joinCallbackA");
94
95 vardef joinCallbackB=
96 setObjectJoin(pb.bottom = customA.pict[index].bottom; pb.midx = pa.midx);
97 setObjectJoinFirst(pa.bottom = customA.pict[index].bottom);
98 enddef;
99
100 PictureStack.customB(".", "..", "...", "....")
101 ("joinCallbackB");
102
103 drawObjects(customA, customB);
104 endfig;
105
106 beginfig(7);
107 save stackX;
108 save stylePA, stylePB;
109 save stylePictureStack;
110
111 PictureInfoCopy.stylePA(iPict);
112 stylePA.borderColor := green;
113 stylePA.boxed := 1;
114
115 PictureInfoCopy.stylePB(iPict);
116 stylePB.borderColor := red;
117 stylePB.boxed := 1;
118
119 PictureStackInfoCopy.stylePictureStack(iStack);
120
121 def styleSupplier(expr i)= if i mod 2 = 0: stylePA else: stylePB fi enddef;
122
123 stylePictureStack.childStyleSupplier := "styleSupplier";
124
125 EPictureStack.stackX(stylePictureStack)("a","b","c","d","e")("vcenter");
126
127 drawObjects(stackX);
128 endfig;
129
130 end