ruby-graphviz 0.9.7 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +2 -0
- data/ChangeLog.rdoc +9 -0
- data/README.rdoc +11 -0
- data/bin/gem2gv +166 -0
- data/bin/ruby2gv +76 -33
- data/examples/HTML-Labels.rb +8 -1
- data/examples/dot/hello_test.rb +1 -1
- data/examples/maketest.bat +94 -0
- data/examples/maketest.sh +10 -0
- data/examples/sample01.rb +1 -1
- data/examples/sample28.rb +12 -0
- data/examples/sample29.rb +8 -0
- data/examples/sample30.rb +12 -0
- data/examples/sdlshapes/README +2 -0
- data/examples/sdlshapes/sdl.ps +655 -0
- data/examples/sdlshapes/sdlshapes.dot +78 -0
- data/examples/testxml.rb +1 -1
- data/lib/graphviz.rb +43 -18
- data/lib/graphviz/attrs.rb +5 -4
- data/lib/graphviz/constants.rb +184 -151
- data/lib/graphviz/edge.rb +2 -2
- data/lib/graphviz/node.rb +10 -4
- data/lib/graphviz/parser.rb +15 -0
- data/lib/graphviz/types.rb +21 -0
- data/lib/graphviz/types/esc_string.rb +29 -0
- data/lib/graphviz/types/html_string.rb +16 -0
- data/lib/graphviz/xml.rb +1 -1
- data/test/test_init.rb +46 -0
- metadata +15 -2
@@ -0,0 +1,94 @@
|
|
1
|
+
@echo "arrowhead.rb"
|
2
|
+
@ruby arrowhead.rb
|
3
|
+
@echo "HTML-Labels.rb"
|
4
|
+
@ruby HTML-Labels.rb
|
5
|
+
@echo "p2p.rb"
|
6
|
+
@ruby p2p.rb
|
7
|
+
|
8
|
+
@echo "sample01.rb"
|
9
|
+
@ruby sample01.rb
|
10
|
+
@echo "sample02.rb"
|
11
|
+
@ruby sample02.rb
|
12
|
+
@echo "sample03.rb"
|
13
|
+
@ruby sample03.rb
|
14
|
+
@echo "sample04.rb"
|
15
|
+
@ruby sample04.rb
|
16
|
+
@echo "sample05.rb"
|
17
|
+
@ruby sample05.rb
|
18
|
+
@echo "sample06.rb"
|
19
|
+
@ruby sample06.rb
|
20
|
+
@echo "sample07.rb"
|
21
|
+
@ruby sample07.rb
|
22
|
+
@echo "sample08.rb"
|
23
|
+
@ruby sample08.rb
|
24
|
+
@echo "sample09.rb"
|
25
|
+
@ruby sample09.rb
|
26
|
+
@echo "sample10.rb"
|
27
|
+
@ruby sample10.rb
|
28
|
+
@echo "sample11.rb"
|
29
|
+
@ruby sample11.rb
|
30
|
+
@echo "sample12.rb"
|
31
|
+
@ruby sample12.rb
|
32
|
+
@echo "sample13.rb"
|
33
|
+
@ruby sample13.rb
|
34
|
+
@echo "sample14.rb"
|
35
|
+
@ruby sample14.rb
|
36
|
+
@echo "sample15.rb"
|
37
|
+
@ruby sample15.rb
|
38
|
+
@echo "sample16.rb"
|
39
|
+
@ruby sample16.rb
|
40
|
+
@echo "sample17.rb"
|
41
|
+
@ruby sample17.rb
|
42
|
+
@echo "sample18.rb"
|
43
|
+
@ruby sample18.rb
|
44
|
+
@echo "sample19.rb"
|
45
|
+
@ruby sample19.rb
|
46
|
+
@echo "sample20.rb"
|
47
|
+
@ruby sample20.rb
|
48
|
+
@echo "sample21.rb"
|
49
|
+
@ruby sample21.rb
|
50
|
+
@echo "sample22.rb"
|
51
|
+
@ruby sample22.rb
|
52
|
+
@echo "sample23.rb"
|
53
|
+
@ruby sample23.rb
|
54
|
+
@echo "sample24.rb"
|
55
|
+
@ruby sample24.rb
|
56
|
+
@echo "sample25.rb"
|
57
|
+
@ruby sample25.rb
|
58
|
+
@echo "sample26.rb"
|
59
|
+
@ruby sample26.rb
|
60
|
+
@echo "sample27.rb"
|
61
|
+
@ruby sample27.rb
|
62
|
+
@echo "sample28.rb"
|
63
|
+
@ruby sample28.rb
|
64
|
+
@echo "sample29.rb"
|
65
|
+
@ruby sample29.rb
|
66
|
+
@echo "sample30.rb"
|
67
|
+
@ruby sample30.rb
|
68
|
+
|
69
|
+
|
70
|
+
@echo "shapes.rb"
|
71
|
+
@ruby shapes.rb
|
72
|
+
@echo "testorder.rb"
|
73
|
+
@ruby testorder.rb
|
74
|
+
@echo "testxml.rb"
|
75
|
+
@ruby testxml.rb
|
76
|
+
|
77
|
+
@cd dot
|
78
|
+
@pwd
|
79
|
+
@echo "dot/hello_test.rb"
|
80
|
+
@ruby hello_test.rb
|
81
|
+
@cd ..
|
82
|
+
|
83
|
+
@cd graphviz.org
|
84
|
+
@echo "graphviz.org/cluster.rb"
|
85
|
+
@ruby cluster.rb
|
86
|
+
@echo "graphviz.org/hello_world.rb"
|
87
|
+
@ruby hello_world.rb
|
88
|
+
@echo "graphviz.org/lion_share.rb"
|
89
|
+
@ruby lion_share.rb
|
90
|
+
@echo "graphviz.org/process.rb"
|
91
|
+
@ruby process.rb
|
92
|
+
@echo "graphviz.org/TrafficLights.rb"
|
93
|
+
@ruby TrafficLights.rb
|
94
|
+
@cd ..
|
data/examples/maketest.sh
CHANGED
@@ -57,6 +57,16 @@ echo "sample24.rb"
|
|
57
57
|
ruby sample24.rb
|
58
58
|
echo "sample25.rb"
|
59
59
|
ruby sample25.rb
|
60
|
+
echo "sample26.rb"
|
61
|
+
ruby sample26.rb
|
62
|
+
echo "sample27.rb"
|
63
|
+
ruby sample27.rb
|
64
|
+
echo "sample28.rb"
|
65
|
+
ruby sample28.rb
|
66
|
+
echo "sample29.rb"
|
67
|
+
ruby sample29.rb
|
68
|
+
echo "sample30.rb"
|
69
|
+
ruby sample30.rb
|
60
70
|
|
61
71
|
echo "shapes.rb"
|
62
72
|
ruby shapes.rb
|
data/examples/sample01.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
puts GraphViz.new(:G){ |g|
|
7
|
+
g[:ratio => "auto", :label => "I love the world!"]
|
8
|
+
|
9
|
+
g.hello( :label => "Hello", :color => "blue" ) # You can do this
|
10
|
+
g.none[ :label => "World", :color => "green" ] # or that
|
11
|
+
(g.hello - g.none)[:style => :bold, :label => " I say"]
|
12
|
+
}.save( :png => "#{$0}.png" )
|
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz.new(:G){ |g|
|
7
|
+
g.add_node("\"Hello.\"\nHow are you ?", :href => "http://www.website.com", :tooltip => "\"Hello.\"\nHow are you ?", :shape => "ellipse", :color => "#FF0000")
|
8
|
+
}.save( :svg => "#{$0}.svg" )
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz.new(:g){ |g|
|
7
|
+
g[:center] = true
|
8
|
+
a = g.add_node("A", :shape => "sdl_procedure_start", :peripheries => 0 )
|
9
|
+
b = g.add_node("B", :shape => "sdl_save", :peripheries => 0)
|
10
|
+
c = g.add_node("n", :shape => "box", :label => "\\G::\\N\\r")
|
11
|
+
a << b << c
|
12
|
+
}.save( :ps => "#{$0}.ps", :extlib => "sdlshapes/sdl.ps" )
|
@@ -0,0 +1,655 @@
|
|
1
|
+
%! SDL shapes for Graphviz/dot in PostScript output mode
|
2
|
+
|
3
|
+
% FILE
|
4
|
+
% sdl.ps - SDL shapes for Graphviz/dot in PostScript output mode
|
5
|
+
%
|
6
|
+
% USE
|
7
|
+
% All procedures expect to be passed a rectangular bounding box in the
|
8
|
+
% order [upper right, lower right, lower left, upper left, upper right].
|
9
|
+
% All procedures expect to be used with "peripheries = 0".
|
10
|
+
%
|
11
|
+
% BUGS
|
12
|
+
% The following shapes are currently not implemented:
|
13
|
+
% - frame/system/block/process/procedure/service/procedure, and types thereof
|
14
|
+
% - macro inlet/outlet/call
|
15
|
+
% - exception handler/handle/raise
|
16
|
+
% - decision (suggest use diamond)
|
17
|
+
% - alternative (suggest use triangle)
|
18
|
+
% - internal input/output (suggest stop using historical relics!)
|
19
|
+
%
|
20
|
+
% COPYRIGHT AND PERMISSION NOTICE
|
21
|
+
% Copyright (C) 2005 Cambridge Silicon Radio Ltd.; all rights reserved.
|
22
|
+
%
|
23
|
+
% Permission is hereby granted, free of charge, to any person obtaining
|
24
|
+
% a copy of this software and associated documentation files (the
|
25
|
+
% "Software"), to deal in the Software without restriction, including
|
26
|
+
% without limitation the rights to use, copy, modify, merge, publish,
|
27
|
+
% distribute, sublicense, and/or sell copies of the Software, and to
|
28
|
+
% permit persons to whom the Software is furnished to do so, subject to
|
29
|
+
% the following conditions:
|
30
|
+
%
|
31
|
+
% The above copyright notice and this permission notice shall be
|
32
|
+
% included in all copies or substantial portions of the Software.
|
33
|
+
%
|
34
|
+
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
35
|
+
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
36
|
+
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
37
|
+
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
38
|
+
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
39
|
+
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
40
|
+
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
41
|
+
%
|
42
|
+
% Except as contained in this notice, the name of a copyright holder
|
43
|
+
% shall not be used in advertising or otherwise to promote the sale, use
|
44
|
+
% or other dealings in the Software without prior written authorization
|
45
|
+
% of the copyright holder.
|
46
|
+
%
|
47
|
+
% REVISION
|
48
|
+
% #4
|
49
|
+
|
50
|
+
/xdef {exch def} bind def
|
51
|
+
|
52
|
+
% SDL task
|
53
|
+
|
54
|
+
/sdl_task {
|
55
|
+
3 1 roll % put filled flag at end
|
56
|
+
4 ne { stop } if % sanity-check number of sides
|
57
|
+
aload pop
|
58
|
+
newpath
|
59
|
+
moveto
|
60
|
+
lineto
|
61
|
+
lineto
|
62
|
+
lineto
|
63
|
+
pop pop
|
64
|
+
closepath
|
65
|
+
{ fill } { stroke } ifelse
|
66
|
+
} bind def
|
67
|
+
|
68
|
+
% SDL input from right
|
69
|
+
% The indent has lines at 45 degrees
|
70
|
+
% There should be a few spaces at the end of this shape's label
|
71
|
+
|
72
|
+
/sdl_input_from_right {
|
73
|
+
9 dict begin
|
74
|
+
3 1 roll % put filled flag at end
|
75
|
+
4 ne { stop } if % sanity-check number of sides
|
76
|
+
aload pop
|
77
|
+
/ury xdef /urx xdef
|
78
|
+
/lry xdef /lrx xdef
|
79
|
+
/lly xdef /llx xdef
|
80
|
+
/uly xdef /ulx xdef
|
81
|
+
/h2 ury lry sub 2 div def
|
82
|
+
newpath
|
83
|
+
moveto
|
84
|
+
urx h2 sub ury h2 sub lineto
|
85
|
+
lrx lry lineto
|
86
|
+
llx lly lineto
|
87
|
+
ulx uly lineto
|
88
|
+
closepath
|
89
|
+
{ fill } { stroke } ifelse
|
90
|
+
end
|
91
|
+
} bind def
|
92
|
+
|
93
|
+
% SDL input from left
|
94
|
+
% Similar to SDL input from right
|
95
|
+
% There should be a few spaces at the start of this shape's label
|
96
|
+
|
97
|
+
/sdl_input_from_left {
|
98
|
+
9 dict begin
|
99
|
+
3 1 roll % put filled flag at end
|
100
|
+
4 ne { stop } if % sanity-check number of sides
|
101
|
+
aload pop
|
102
|
+
/ury xdef /urx xdef
|
103
|
+
/lry xdef /lrx xdef
|
104
|
+
/lly xdef /llx xdef
|
105
|
+
/uly xdef /ulx xdef
|
106
|
+
/h2 uly lly sub 2 div def
|
107
|
+
newpath
|
108
|
+
moveto
|
109
|
+
lrx lry lineto
|
110
|
+
llx lly lineto
|
111
|
+
ulx h2 add ury h2 sub lineto
|
112
|
+
ulx uly lineto
|
113
|
+
closepath
|
114
|
+
{ fill } { stroke } ifelse
|
115
|
+
end
|
116
|
+
} bind def
|
117
|
+
|
118
|
+
% SDL priority input from right
|
119
|
+
% Similar to SDL input from right
|
120
|
+
% The chevrons are displaced by an eighth of the shape height
|
121
|
+
% The filled version is indistinguishable from a non-priority SDL input
|
122
|
+
|
123
|
+
/sdl_priority_input_from_right {
|
124
|
+
9 dict begin
|
125
|
+
3 1 roll % put filled flag at end
|
126
|
+
4 ne { stop } if % sanity-check number of sides
|
127
|
+
aload pop
|
128
|
+
/ury xdef /urx xdef
|
129
|
+
/lry xdef /lrx xdef
|
130
|
+
/lly xdef /llx xdef
|
131
|
+
/uly xdef /ulx xdef
|
132
|
+
/h2 ury lry sub 2 div def
|
133
|
+
newpath
|
134
|
+
moveto
|
135
|
+
urx h2 sub ury h2 sub lineto
|
136
|
+
lrx lry lineto
|
137
|
+
llx lly lineto
|
138
|
+
ulx uly lineto
|
139
|
+
closepath
|
140
|
+
{ fill } { stroke
|
141
|
+
urx h2 4 div sub ury moveto
|
142
|
+
urx h2 sub h2 4 div sub ury h2 sub lineto
|
143
|
+
lrx h2 4 div sub lry lineto
|
144
|
+
stroke } ifelse
|
145
|
+
end
|
146
|
+
} bind def
|
147
|
+
|
148
|
+
% SDL priority input from left
|
149
|
+
% Similar to SDL priority input from right
|
150
|
+
|
151
|
+
/sdl_priority_input_from_left {
|
152
|
+
9 dict begin
|
153
|
+
3 1 roll % put filled flag at end
|
154
|
+
4 ne { stop } if % sanity-check number of sides
|
155
|
+
aload pop
|
156
|
+
/ury xdef /urx xdef
|
157
|
+
/lry xdef /lrx xdef
|
158
|
+
/lly xdef /llx xdef
|
159
|
+
/uly xdef /ulx xdef
|
160
|
+
/h2 uly lly sub 2 div def
|
161
|
+
newpath
|
162
|
+
moveto
|
163
|
+
lrx lry lineto
|
164
|
+
llx lly lineto
|
165
|
+
ulx h2 add uly h2 sub lineto
|
166
|
+
ulx uly lineto
|
167
|
+
closepath
|
168
|
+
{ fill } { stroke
|
169
|
+
llx h2 4 div add lly moveto
|
170
|
+
ulx h2 add h2 4 div add uly h2 sub lineto
|
171
|
+
ulx h2 4 div add uly lineto
|
172
|
+
stroke } ifelse
|
173
|
+
end
|
174
|
+
} bind def
|
175
|
+
|
176
|
+
% SDL start
|
177
|
+
% The left and right sides are semicircles
|
178
|
+
% This should be used with "label = " ""
|
179
|
+
|
180
|
+
/sdl_start {
|
181
|
+
9 dict begin
|
182
|
+
3 1 roll % put filled flag at end
|
183
|
+
4 ne { stop } if % sanity-check number of sides
|
184
|
+
aload pop
|
185
|
+
/ury xdef /urx xdef
|
186
|
+
/lry xdef /lrx xdef
|
187
|
+
/lly xdef /llx xdef
|
188
|
+
/uly xdef /ulx xdef
|
189
|
+
pop pop
|
190
|
+
/r ury lry sub 2 div def
|
191
|
+
newpath
|
192
|
+
urx r sub ury r sub r 90 -90 arcn
|
193
|
+
ulx r add uly r sub r -90 90 arcn
|
194
|
+
closepath
|
195
|
+
{ fill } { stroke } ifelse
|
196
|
+
end
|
197
|
+
} bind def
|
198
|
+
|
199
|
+
% SDL procedure start
|
200
|
+
% Similar to SDL start
|
201
|
+
% The filled version is indistinguishable from an SDL start
|
202
|
+
% This should be used with "label = " ""
|
203
|
+
|
204
|
+
/sdl_procedure_start {
|
205
|
+
9 dict begin
|
206
|
+
3 1 roll % put filled flag at end
|
207
|
+
4 ne { stop } if % sanity-check number of sides
|
208
|
+
aload pop
|
209
|
+
/ury xdef /urx xdef
|
210
|
+
/lry xdef /lrx xdef
|
211
|
+
/lly xdef /llx xdef
|
212
|
+
/uly xdef /ulx xdef
|
213
|
+
pop pop
|
214
|
+
/r ury lry sub 2 div def
|
215
|
+
newpath
|
216
|
+
urx r sub ury r sub r 90 -90 arcn
|
217
|
+
ulx r add uly r sub r -90 90 arcn
|
218
|
+
closepath
|
219
|
+
{ fill } { stroke
|
220
|
+
lrx r sub lry moveto
|
221
|
+
0 r 2 mul rlineto
|
222
|
+
llx r add lly moveto
|
223
|
+
0 r 2 mul rlineto
|
224
|
+
stroke } ifelse
|
225
|
+
end
|
226
|
+
} bind def
|
227
|
+
|
228
|
+
% SDL state/nextstate
|
229
|
+
% The left and right sides are arcs
|
230
|
+
|
231
|
+
/sdl_state {
|
232
|
+
12 dict begin
|
233
|
+
3 1 roll % put filled flag at end
|
234
|
+
4 ne { stop } if % sanity-check number of sides
|
235
|
+
aload pop
|
236
|
+
/ury xdef /urx xdef
|
237
|
+
/lry xdef /lrx xdef
|
238
|
+
/lly xdef /llx xdef
|
239
|
+
/uly xdef /ulx xdef
|
240
|
+
pop pop
|
241
|
+
/h2 ury lry sub 2 div def
|
242
|
+
/w2 h2 1.5 mul def % was urx ulx sub 2 div def but this made curvature width-dependent
|
243
|
+
/r w2 def
|
244
|
+
/th h2 r dup mul h2 dup mul sub sqrt atan def
|
245
|
+
newpath
|
246
|
+
urx w2 sub ury h2 sub r th th neg arcn
|
247
|
+
ulx w2 add uly h2 sub r -180 th add -180 th sub arcn
|
248
|
+
closepath
|
249
|
+
{ fill } { stroke } ifelse
|
250
|
+
end
|
251
|
+
} bind def
|
252
|
+
|
253
|
+
% SDL output to right
|
254
|
+
% The outdent has lines at 45 degrees
|
255
|
+
% There should be a few spaces at the end of this shape's label
|
256
|
+
|
257
|
+
/sdl_output_to_right {
|
258
|
+
9 dict begin
|
259
|
+
3 1 roll % put filled flag at end
|
260
|
+
4 ne { stop } if % sanity-check number of sides
|
261
|
+
aload pop
|
262
|
+
/ury xdef /urx xdef
|
263
|
+
/lry xdef /lrx xdef
|
264
|
+
/lly xdef /llx xdef
|
265
|
+
/uly xdef /ulx xdef
|
266
|
+
/h2 ury lry sub 2 div def
|
267
|
+
newpath
|
268
|
+
exch h2 sub exch moveto
|
269
|
+
urx ury h2 sub lineto
|
270
|
+
lrx h2 sub lry lineto
|
271
|
+
llx lly lineto
|
272
|
+
ulx uly lineto
|
273
|
+
closepath
|
274
|
+
{ fill } { stroke } ifelse
|
275
|
+
end
|
276
|
+
} bind def
|
277
|
+
|
278
|
+
% SDL output to left
|
279
|
+
% Similar to SDL output to right
|
280
|
+
% There should be a few spaces at the start of this shape's label
|
281
|
+
|
282
|
+
/sdl_output_to_left {
|
283
|
+
9 dict begin
|
284
|
+
3 1 roll % put filled flag at end
|
285
|
+
4 ne { stop } if % sanity-check number of sides
|
286
|
+
aload pop
|
287
|
+
/ury xdef /urx xdef
|
288
|
+
/lry xdef /lrx xdef
|
289
|
+
/lly xdef /llx xdef
|
290
|
+
/uly xdef /ulx xdef
|
291
|
+
/h2 ury lry sub 2 div def
|
292
|
+
newpath
|
293
|
+
moveto
|
294
|
+
lrx lry lineto
|
295
|
+
llx h2 add lly lineto
|
296
|
+
ulx ury h2 sub lineto
|
297
|
+
ulx h2 add uly lineto
|
298
|
+
closepath
|
299
|
+
{ fill } { stroke } ifelse
|
300
|
+
end
|
301
|
+
} bind def
|
302
|
+
|
303
|
+
% SDL continuous signal/enabling condition
|
304
|
+
% The chevrons have lines at 45 degrees
|
305
|
+
% There should be a few spaces at the start and end of this shape's label
|
306
|
+
|
307
|
+
/sdl_condition {
|
308
|
+
9 dict begin
|
309
|
+
3 1 roll % put filled flag at end
|
310
|
+
4 ne { stop } if % sanity-check number of sides
|
311
|
+
aload pop
|
312
|
+
/ury xdef /urx xdef
|
313
|
+
/lry xdef /lrx xdef
|
314
|
+
/lly xdef /llx xdef
|
315
|
+
/uly xdef /ulx xdef
|
316
|
+
/h2 ury lry sub 2 div def
|
317
|
+
newpath
|
318
|
+
exch h2 sub exch moveto
|
319
|
+
urx ury h2 sub lineto
|
320
|
+
lrx h2 sub lry lineto
|
321
|
+
dup llx h2 add lly 3 -1 roll { lineto } { moveto } ifelse
|
322
|
+
ulx uly h2 sub lineto
|
323
|
+
ulx h2 add uly lineto
|
324
|
+
{ fill } { stroke } ifelse
|
325
|
+
end
|
326
|
+
} bind def
|
327
|
+
|
328
|
+
% SDL save
|
329
|
+
% The left and right edges are at about 60 degrees
|
330
|
+
% There should be a few spaces at the start and end of this shape's label
|
331
|
+
|
332
|
+
/sdl_save {
|
333
|
+
9 dict begin
|
334
|
+
3 1 roll % put filled flag at end
|
335
|
+
4 ne { stop } if % sanity-check number of sides
|
336
|
+
aload pop
|
337
|
+
/ury xdef /urx xdef
|
338
|
+
/lry xdef /lrx xdef
|
339
|
+
/lly xdef /llx xdef
|
340
|
+
/uly xdef /ulx xdef
|
341
|
+
/h3 ury lry sub 3 div def
|
342
|
+
newpath
|
343
|
+
moveto
|
344
|
+
lrx h3 sub lry lineto
|
345
|
+
llx lly lineto
|
346
|
+
ulx h3 add uly lineto
|
347
|
+
closepath
|
348
|
+
{ fill } { stroke } ifelse
|
349
|
+
end
|
350
|
+
} bind def
|
351
|
+
|
352
|
+
% SDL stop
|
353
|
+
% The width of the bounding box is ignored; the lines are set at 45 degrees
|
354
|
+
% This shape cannot be filled
|
355
|
+
% This should be used with "label = """ and "arrowhead = none, headclip = false"
|
356
|
+
|
357
|
+
/sdl_stop {
|
358
|
+
7 dict begin
|
359
|
+
{ stop } if % make sure not asked to fill this
|
360
|
+
4 ne { stop } if % sanity-check number of sides
|
361
|
+
aload pop
|
362
|
+
pop pop
|
363
|
+
/lry xdef /lrx xdef
|
364
|
+
/lly xdef /llx xdef
|
365
|
+
/uly xdef pop
|
366
|
+
/h2 uly lly sub 2 div def
|
367
|
+
/mx llx lrx add 2 div def
|
368
|
+
newpath
|
369
|
+
mx h2 add exch moveto pop
|
370
|
+
mx h2 sub lly lineto
|
371
|
+
mx h2 sub uly moveto
|
372
|
+
mx h2 add lry lineto
|
373
|
+
closepath
|
374
|
+
stroke
|
375
|
+
end
|
376
|
+
} bind def
|
377
|
+
|
378
|
+
% SDL return
|
379
|
+
% The width of the bounding box is ignored; the lines are set at 45 degrees
|
380
|
+
% The filled version is indistinguishable from an SDL connection
|
381
|
+
|
382
|
+
/sdl_return {
|
383
|
+
9 dict begin
|
384
|
+
3 1 roll % put filled flag at end
|
385
|
+
4 ne { stop } if % sanity-check number of sides
|
386
|
+
aload pop
|
387
|
+
/ury xdef pop
|
388
|
+
/lry xdef /lrx xdef
|
389
|
+
/lly xdef /llx xdef
|
390
|
+
/uly xdef pop
|
391
|
+
pop pop
|
392
|
+
/h2 uly lly sub 2 div 2 sqrt div def
|
393
|
+
/mx llx lrx add 2 div def
|
394
|
+
/my lry ury add 2 div def
|
395
|
+
newpath
|
396
|
+
mx my uly lly sub 2 div 0 360 arc
|
397
|
+
{ fill } { stroke
|
398
|
+
mx h2 add my h2 add moveto
|
399
|
+
mx h2 sub my h2 sub lineto
|
400
|
+
mx h2 sub my h2 add moveto
|
401
|
+
mx h2 add my h2 sub lineto
|
402
|
+
stroke } ifelse
|
403
|
+
end
|
404
|
+
} bind def
|
405
|
+
|
406
|
+
% SDL create
|
407
|
+
% The extra lines are displaced by an eighth of the shape height
|
408
|
+
% The filled version is indistinguishable from an SDL task
|
409
|
+
|
410
|
+
/sdl_create {
|
411
|
+
9 dict begin
|
412
|
+
3 1 roll % put filled flag at end
|
413
|
+
4 ne { stop } if % sanity-check number of sides
|
414
|
+
aload pop
|
415
|
+
/ury xdef /urx xdef
|
416
|
+
/lry xdef /lrx xdef
|
417
|
+
/lly xdef /llx xdef
|
418
|
+
/uly xdef /ulx xdef
|
419
|
+
/h8 ury lry sub 8 div def
|
420
|
+
newpath
|
421
|
+
moveto
|
422
|
+
lrx lry lineto
|
423
|
+
llx lly lineto
|
424
|
+
ulx uly lineto
|
425
|
+
closepath
|
426
|
+
{ fill } { stroke
|
427
|
+
ulx uly h8 sub moveto
|
428
|
+
urx ury h8 sub lineto
|
429
|
+
llx lly h8 add moveto
|
430
|
+
lrx lry h8 add lineto
|
431
|
+
stroke } ifelse
|
432
|
+
end
|
433
|
+
} bind def
|
434
|
+
|
435
|
+
% SDL call
|
436
|
+
% The extra lines are displaced by an eighth of the shape height
|
437
|
+
% The filled version is indistinguishable from an SDL task
|
438
|
+
% There should be a few spaces at the start and end of this shape's label
|
439
|
+
|
440
|
+
/sdl_call {
|
441
|
+
9 dict begin
|
442
|
+
3 1 roll % put filled flag at end
|
443
|
+
4 ne { stop } if % sanity-check number of sides
|
444
|
+
aload pop
|
445
|
+
/ury xdef /urx xdef
|
446
|
+
/lry xdef /lrx xdef
|
447
|
+
/lly xdef /llx xdef
|
448
|
+
/uly xdef /ulx xdef
|
449
|
+
/h8 ury lry sub 8 div def
|
450
|
+
newpath
|
451
|
+
moveto
|
452
|
+
lrx lry lineto
|
453
|
+
llx lly lineto
|
454
|
+
ulx uly lineto
|
455
|
+
closepath
|
456
|
+
{ fill } { stroke
|
457
|
+
urx h8 sub ury moveto
|
458
|
+
lrx h8 sub lry lineto
|
459
|
+
llx h8 add lly moveto
|
460
|
+
ulx h8 add uly lineto
|
461
|
+
stroke } ifelse
|
462
|
+
end
|
463
|
+
} bind def
|
464
|
+
|
465
|
+
% SDL text symbol
|
466
|
+
% The corner has a size of twice the H height
|
467
|
+
|
468
|
+
/sdl_text {
|
469
|
+
10 dict begin
|
470
|
+
3 1 roll % put filled flag at end
|
471
|
+
4 ne { stop } if % sanity-check number of sides
|
472
|
+
aload pop
|
473
|
+
/ury xdef /urx xdef
|
474
|
+
/lry xdef /lrx xdef
|
475
|
+
/lly xdef /llx xdef
|
476
|
+
/uly xdef /ulx xdef
|
477
|
+
/h8 ury lry sub 8 div def
|
478
|
+
newpath
|
479
|
+
moveto
|
480
|
+
/d (H) true charpath flattenpath pathbbox exch pop exch sub exch pop 2 mul def
|
481
|
+
newpath
|
482
|
+
urx ury d sub moveto
|
483
|
+
lrx lry lineto
|
484
|
+
llx lly lineto
|
485
|
+
ulx uly lineto
|
486
|
+
urx d sub ury lineto
|
487
|
+
closepath
|
488
|
+
{ fill } { stroke } ifelse
|
489
|
+
urx ury d sub moveto
|
490
|
+
d neg 0 rlineto
|
491
|
+
0 d rlineto
|
492
|
+
stroke
|
493
|
+
end
|
494
|
+
} bind def
|
495
|
+
|
496
|
+
% SDL text extension from left
|
497
|
+
% This should be used with "rank = same"
|
498
|
+
|
499
|
+
/sdl_text_extension_from_left {
|
500
|
+
3 1 roll % put filled flag at end
|
501
|
+
4 ne { stop } if % sanity-check number of sides
|
502
|
+
aload pop
|
503
|
+
pop pop
|
504
|
+
moveto
|
505
|
+
lineto
|
506
|
+
lineto
|
507
|
+
lineto
|
508
|
+
{ fill } { stroke } ifelse
|
509
|
+
} bind def
|
510
|
+
|
511
|
+
% SDL text extension from right
|
512
|
+
% This should be used with "rank = same"
|
513
|
+
|
514
|
+
/sdl_text_extension_from_right {
|
515
|
+
3 1 roll % put filled flag at end
|
516
|
+
4 ne { stop } if % sanity-check number of sides
|
517
|
+
aload pop
|
518
|
+
pop pop
|
519
|
+
8 4 roll
|
520
|
+
moveto
|
521
|
+
lineto
|
522
|
+
lineto
|
523
|
+
lineto
|
524
|
+
{ fill } { stroke } ifelse
|
525
|
+
} bind def
|
526
|
+
|
527
|
+
% SDL comment from left
|
528
|
+
% This should be used with "style = dashed" and "rank = same"
|
529
|
+
|
530
|
+
/sdl_comment_from_left { sdl_text_extension_from_left } bind def
|
531
|
+
|
532
|
+
% SDL comment from right
|
533
|
+
% This should be used with "style = dashed" and "rank = same"
|
534
|
+
|
535
|
+
/sdl_comment_from_right { sdl_text_extension_from_right } bind def
|
536
|
+
|
537
|
+
% SDL connector
|
538
|
+
% The width of the bounding box is ignored
|
539
|
+
|
540
|
+
/sdl_connector {
|
541
|
+
7 dict begin
|
542
|
+
3 1 roll % put filled flag at end
|
543
|
+
4 ne { stop } if % sanity-check number of sides
|
544
|
+
aload pop
|
545
|
+
pop pop
|
546
|
+
/lry xdef /lrx xdef
|
547
|
+
/lly xdef /llx xdef
|
548
|
+
/uly xdef pop
|
549
|
+
pop pop
|
550
|
+
/h2 uly lly sub 2 div def
|
551
|
+
/mx llx lrx add 2 div def
|
552
|
+
newpath
|
553
|
+
mx uly h2 sub h2 0 360 arc
|
554
|
+
{ fill } { stroke } ifelse
|
555
|
+
end
|
556
|
+
} bind def
|
557
|
+
|
558
|
+
% SDL set (extension)
|
559
|
+
% The hourglass has a size of twice the H height
|
560
|
+
% There should be a few spaces at the start of this shape's label
|
561
|
+
|
562
|
+
/sdl_set {
|
563
|
+
10 dict begin
|
564
|
+
3 1 roll % put filled flag at end
|
565
|
+
4 ne { stop } if % sanity-check number of sides
|
566
|
+
aload pop
|
567
|
+
/ury xdef /urx xdef
|
568
|
+
/lry xdef /lrx xdef
|
569
|
+
/lly xdef /llx xdef
|
570
|
+
/uly xdef /ulx xdef
|
571
|
+
/my uly lly add 2 div def
|
572
|
+
newpath
|
573
|
+
moveto
|
574
|
+
/d (H) true charpath flattenpath pathbbox exch pop exch sub exch pop def
|
575
|
+
newpath
|
576
|
+
llx d add my d add moveto
|
577
|
+
ulx d add uly lineto
|
578
|
+
urx ury lineto
|
579
|
+
lrx lry lineto
|
580
|
+
llx d add lly lineto
|
581
|
+
llx d add my d sub lineto
|
582
|
+
dup { closepath fill } { stroke } ifelse
|
583
|
+
llx my d sub moveto
|
584
|
+
d 2 mul dup rlineto
|
585
|
+
d 2 mul neg 0 rlineto
|
586
|
+
d 2 mul dup neg rlineto
|
587
|
+
closepath
|
588
|
+
{ fill } { stroke } ifelse
|
589
|
+
end
|
590
|
+
} bind def
|
591
|
+
|
592
|
+
% SDL reset (extension)
|
593
|
+
% The cross has a size of twice the H height
|
594
|
+
% There should be a few spaces at the start of this shape's label
|
595
|
+
|
596
|
+
/sdl_reset {
|
597
|
+
10 dict begin
|
598
|
+
3 1 roll % put filled flag at end
|
599
|
+
4 ne { stop } if % sanity-check number of sides
|
600
|
+
aload pop
|
601
|
+
/ury xdef /urx xdef
|
602
|
+
/lry xdef /lrx xdef
|
603
|
+
/lly xdef /llx xdef
|
604
|
+
/uly xdef /ulx xdef
|
605
|
+
/my uly lly add 2 div def
|
606
|
+
newpath
|
607
|
+
moveto
|
608
|
+
/d (H) true charpath flattenpath pathbbox exch pop exch sub exch pop def
|
609
|
+
newpath
|
610
|
+
urx ury moveto
|
611
|
+
lrx lry lineto
|
612
|
+
llx d add lly lineto
|
613
|
+
ulx d add uly lineto
|
614
|
+
closepath
|
615
|
+
{ fill } { stroke } ifelse
|
616
|
+
llx my d sub moveto
|
617
|
+
d 2 mul dup rlineto
|
618
|
+
llx d 2 mul add my d sub moveto
|
619
|
+
d 2 mul dup neg exch rlineto
|
620
|
+
stroke
|
621
|
+
end
|
622
|
+
} bind def
|
623
|
+
|
624
|
+
% SDL export (extension)
|
625
|
+
% The store has a width of twice the H height
|
626
|
+
% There should be a few spaces at the start of this shape's label
|
627
|
+
|
628
|
+
/sdl_export {
|
629
|
+
10 dict begin
|
630
|
+
3 1 roll % put filled flag at end
|
631
|
+
4 ne { stop } if % sanity-check number of sides
|
632
|
+
aload pop
|
633
|
+
/ury xdef /urx xdef
|
634
|
+
/lry xdef /lrx xdef
|
635
|
+
/lly xdef /llx xdef
|
636
|
+
/uly xdef /ulx xdef
|
637
|
+
/my uly lly add 2 div def
|
638
|
+
newpath
|
639
|
+
moveto
|
640
|
+
/d (H) true charpath flattenpath pathbbox exch pop exch sub exch pop def
|
641
|
+
newpath
|
642
|
+
llx d add my d 2 div add moveto
|
643
|
+
ulx d add uly lineto
|
644
|
+
urx ury lineto
|
645
|
+
lrx lry lineto
|
646
|
+
llx d add lly lineto
|
647
|
+
llx d add my d 2 div sub lineto
|
648
|
+
{ closepath fill } { stroke } ifelse
|
649
|
+
llx my d 2 div sub moveto
|
650
|
+
d 2 mul 0 rlineto
|
651
|
+
llx my d 2 div add moveto
|
652
|
+
d 2 mul 0 rlineto
|
653
|
+
stroke
|
654
|
+
end
|
655
|
+
} bind def
|