Debian Codegraph @

src/smetana/core/Z.java

raw symbols SCIP
1 /* ========================================================================
2 * PlantUML : a free UML diagram generator
3 * ========================================================================
4 *
5 * Project Info: http://plantuml.com
6 *
7 * If you like this project or if you find it useful, you can support us at:
8 *
9 * http://plantuml.com/patreon (only 1$ per month!)
10 * http://plantuml.com/paypal
11 *
12 * This file is part of Smetana.
13 * Smetana is a partial translation of Graphviz/Dot sources from C to Java.
14 *
15 * (C) Copyright 2009-2020, Arnaud Roques
16 *
17 * This translation is distributed under the same Licence as the original C program.
18 *
19 * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
20 * LICENSE ("AGREEMENT"). [Eclipse Public License - v 1.0]
21 *
22 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
23 * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
24 *
25 * You may obtain a copy of the License at
26 *
27 * http://www.eclipse.org/legal/epl-v10.html
28 *
29 * Unless required by applicable law or agreed to in writing, software
30 * distributed under the License is distributed on an "AS IS" BASIS,
31 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32 * See the License for the specific language governing permissions and
33 * limitations under the License.
34 *
35 */
36
37 package smetana.core;
38
39 import static smetana.core.JUtils.function;
40 import gen.lib.cdt.dttree__c;
41 import gen.lib.cgraph.attr__c;
42 import gen.lib.cgraph.edge__c;
43 import gen.lib.cgraph.graph__c;
44 import gen.lib.cgraph.id__c;
45 import gen.lib.cgraph.mem__c;
46 import gen.lib.cgraph.node__c;
47 import gen.lib.cgraph.utils__c;
48 import gen.lib.common.arrows__c;
49 import gen.lib.common.shapes__c;
50 import gen.lib.dotgen.dotsplines__c;
51 import gen.lib.label.xlabels__c;
52 import h.ST_Agdesc_s;
53 import h.ST_Agedge_s;
54 import h.ST_Agiddisc_s;
55 import h.ST_Agmemdisc_s;
56 import h.ST_Agnode_s;
57 import h.ST_Agraph_s;
58 import h.ST_Agsubnode_s;
59 import h.ST_Agsym_s;
60 import h.ST_Agtag_s;
61 import h.ST_HDict_t;
62 import h.ST_Pedge_t;
63 import h.ST_arrowname_t;
64 import h.ST_arrowtype_t;
65 import h.ST_boxf;
66 import h.ST_deque_t;
67 import h.ST_dt_s;
68 import h.ST_dtdisc_s;
69 import h.ST_dtmethod_s;
70 import h.ST_elist;
71 import h.ST_nlist_t;
72 import h.ST_pointf;
73 import h.ST_pointnlink_t;
74 import h.ST_polygon_t;
75 import h.ST_port;
76 import h.ST_refstr_t;
77 import h.ST_shape_desc;
78 import h.ST_shape_functions;
79 import h.ST_splineInfo;
80 import h.ST_textfont_t;
81 import h.ST_tna_t;
82 import h.ST_triangle_t;
83
84 import java.util.HashMap;
85 import java.util.LinkedList;
86 import java.util.Map;
87
88 public class Z {
89
90 private static final ThreadLocal<LinkedList<Z>> instances2 = new ThreadLocal<LinkedList<Z>>();
91
92 public final Map<Integer, CString> all = new HashMap<Integer, CString>();
93
94 public final ST_dtmethod_s _Dttree = new ST_dtmethod_s();
95 public final ST_dtmethod_s Dttree = _Dttree;
96
97 public final ST_dtmethod_s _Dtobag = new ST_dtmethod_s();
98 public final ST_dtmethod_s Dtobag = _Dtobag;
99
100 public final ST_dtdisc_s AgDataDictDisc = new ST_dtdisc_s();
101
102 public final ST_Agdesc_s ProtoDesc = new ST_Agdesc_s();
103
104 public ST_Agraph_s ProtoGraph;
105
106 public final ST_Agtag_s Tag = new ST_Agtag_s();
107
108 public final ST_dtdisc_s Ag_mainedge_seq_disc = new ST_dtdisc_s();
109
110 public final ST_dtdisc_s Ag_subedge_seq_disc = new ST_dtdisc_s();
111
112 public final ST_dtdisc_s Ag_subedge_id_disc = new ST_dtdisc_s();
113
114 public final ST_dtdisc_s Ag_subgraph_id_disc = new ST_dtdisc_s();
115
116 public final ST_Agiddisc_s AgIdDisc = new ST_Agiddisc_s();
117
118 public final ST_Agmemdisc_s AgMemDisc = new ST_Agmemdisc_s();
119
120 public final ST_dtdisc_s Ag_subnode_id_disc = new ST_dtdisc_s();
121
122 public final ST_dtdisc_s Ag_subnode_seq_disc = new ST_dtdisc_s();
123
124 public int HTML_BIT;
125
126 public int CNT_BITS;
127
128 public final ST_dtdisc_s Refstrdisc = new ST_dtdisc_s();
129
130 public final ST_dtdisc_s Hdisc = new ST_dtdisc_s();
131
132 public ST_dt_s Refdict_default;
133
134 public ST_Agraph_s Ag_dictop_G;
135
136 public final ST_arrowname_t Arrowsynonyms[] = new ST_arrowname_t[] { new ST_arrowname_t() };
137
138 public final ST_arrowname_t Arrownames[] = new ST_arrowname_t[] { new ST_arrowname_t(), new ST_arrowname_t(), new ST_arrowname_t() };
139
140 public final ST_arrowname_t Arrowmods[] = new ST_arrowname_t[] { new ST_arrowname_t() };
141
142 public final ST_arrowtype_t Arrowtypes[] = new ST_arrowtype_t[] { new ST_arrowtype_t(), new ST_arrowtype_t(), new ST_arrowtype_t(), new ST_arrowtype_t(), new ST_arrowtype_t(), new ST_arrowtype_t(), new ST_arrowtype_t(), new ST_arrowtype_t(), new ST_arrowtype_t() };
143
144 public __ptr__ Show_boxes;
145
146 public int CL_type;
147
148 public boolean Concentrate;
149
150 public int MaxIter;
151
152 public int State;
153
154 public int EdgeLabelsDone;
155
156 public double Initial_dist;
157
158 public ST_Agsym_s G_activepencolor, G_activefillcolor, G_selectedpencolor, G_selectedfillcolor, G_visitedpencolor,
159 G_visitedfillcolor, G_deletedpencolor, G_deletedfillcolor, G_ordering, G_peripheries, G_penwidth,
160 G_gradientangle, G_margin;
161
162 public ST_Agsym_s N_height, N_width, N_shape, N_color, N_fillcolor, N_activepencolor, N_activefillcolor,
163 N_selectedpencolor, N_selectedfillcolor, N_visitedpencolor, N_visitedfillcolor, N_deletedpencolor,
164 N_deletedfillcolor, N_fontsize, N_fontname, N_fontcolor, N_margin, N_label, N_xlabel, N_nojustify, N_style,
165 N_showboxes, N_sides, N_peripheries, N_ordering, N_orientation, N_skew, N_distortion, N_fixed,
166 N_imagescale, N_layer, N_group, N_comment, N_vertices, N_z, N_penwidth, N_gradientangle;
167
168 public ST_Agsym_s E_weight, E_minlen, E_color, E_fillcolor, E_activepencolor, E_activefillcolor, E_selectedpencolor,
169 E_selectedfillcolor, E_visitedpencolor, E_visitedfillcolor, E_deletedpencolor, E_deletedfillcolor,
170 E_fontsize, E_fontname, E_fontcolor, E_label, E_xlabel, E_dir, E_style, E_decorate, E_showboxes, E_arrowsz,
171 E_constr, E_layer, E_comment, E_label_float, E_samehead, E_sametail, E_arrowhead, E_arrowtail, E_headlabel,
172 E_taillabel, E_labelfontsize, E_labelfontname, E_labelfontcolor, E_labeldistance, E_labelangle, E_tailclip,
173 E_headclip, E_penwidth;
174
175 public int N_nodes, N_edges;
176
177 public int Minrank, Maxrank;
178
179 public int S_i;
180
181 public int Search_size;
182
183 public final ST_nlist_t Tree_node = new ST_nlist_t();
184
185 public final ST_elist Tree_edge = new ST_elist();
186
187 public ST_Agedge_s Enter;
188
189 public int Low, Lim, Slack;
190
191 public int Rankdir;
192
193 public boolean Flip;
194
195 public final ST_pointf Offset = new ST_pointf();
196
197 public int nedges, nboxes;
198
199 public int routeinit;
200
201 public ST_pointf.Array ps;
202
203 public int maxpn;
204
205 public ST_pointf.Array polypoints;
206
207 public int polypointn;
208
209 public ST_Pedge_t.Array edges;
210
211 public int edgen;
212
213 public final ST_boxf[] boxes = ST_boxf.malloc(1000);
214
215 public int MinQuit;
216
217 public double Convergence;
218
219 public ST_Agraph_s Root;
220
221 public int GlobalMinRank, GlobalMaxRank;
222
223 public boolean ReMincross;
224
225 public ST_Agedge_s.ArrayOfStar TE_list;
226
227 public __ptr__ TI_list;
228
229 public ST_Agnode_s Last_node_decomp;
230 public ST_Agnode_s Last_node_rank;
231
232 public char Cmark;
233
234 public int trin, tril;
235
236 public ST_triangle_t.Array tris;
237
238 public int pnln, pnll;
239
240 public ST_pointnlink_t pnls[];
241 public ST_pointnlink_t pnlps[];
242
243 public final ST_port Center = new ST_port();
244
245 public final ST_polygon_t p_ellipse = new ST_polygon_t();
246
247 public final ST_polygon_t p_box = new ST_polygon_t();
248
249 public final ST_shape_functions poly_fns = new ST_shape_functions();
250
251 public ST_tna_t.Array tnas;
252 public int tnan;
253
254 public final ST_shape_desc Shapes[] = { __Shapes__("box", poly_fns, p_box),
255 __Shapes__("ellipse", poly_fns, p_ellipse), __Shapes__(null, null, null) };
256
257 public final ST_dtdisc_s Ag_mainedge_id_disc = new ST_dtdisc_s();
258
259 public final ST_deque_t dq = new ST_deque_t();
260
261 public final ST_Agdesc_s Agdirected = new ST_Agdesc_s();
262
263 public final ST_splineInfo sinfo = new ST_splineInfo();
264
265 public ST_Agnode_s lastn; /* last node argument */
266 public ST_polygon_t poly;
267 public int last, outp, sides;
268 public final ST_pointf O = new ST_pointf(); /* point (0,0) */
269 public ST_pointf.Array vertex;
270 public double xsize, ysize, scalex, scaley, box_URx, box_URy;
271
272 public final ST_textfont_t tf = new ST_textfont_t();
273
274 public ST_pointf.Array pointfs;
275 public ST_pointf.Array pointfs2;
276 public int numpts;
277 public int numpts2;
278
279 public __ptr__ Count;
280 public int C;
281
282 public int ctr = 1;
283
284 public final ST_Agsubnode_s template = new ST_Agsubnode_s();
285 public final ST_Agnode_s dummy = new ST_Agnode_s();
286
287 public ST_Agraph_s G_ns;
288 public ST_Agraph_s G_decomp;
289
290 public int opl;
291
292 public int opn_route;
293 public int opn_shortest;
294
295 public ST_pointf.Array ops_route;
296 public ST_pointf.Array ops_shortest;
297
298 public static Z z() {
299 return instances2.get().peekFirst();
300 }
301
302 public static void open() {
303 LinkedList<Z> list = instances2.get();
304 if (list == null) {
305 list = new LinkedList<Z>();
306 instances2.set(list);
307 }
308 list.addFirst(new Z());
309 }
310
311 public static void close() {
312 instances2.get().removeFirst();
313 }
314
315 private ST_shape_desc __Shapes__(String s, ST_shape_functions shape_functions, ST_polygon_t polygon) {
316 ST_shape_desc result = new ST_shape_desc();
317 result.setPtr("name", s == null ? null : new CString(s));
318 result.setPtr("fns", shape_functions);
319 result.setPtr("polygon", polygon);
320 return result;
321 }
322
323 private final static __struct__ createArrowtypes(int type, double lenfact, CFunction function) {
324 final ST_arrowtype_t result = new ST_arrowtype_t();
325 result.type = type;
326 result.lenfact = lenfact;
327 result.gen = function;
328 return result;
329 }
330
331 private final static __struct__ create_arrowname_t(String name, int type) {
332 final ST_arrowname_t result = new ST_arrowname_t();
333 result.name = name == null ? null : new CString(name);
334 result.type = type;
335 return result;
336 }
337
338 private Z() {
339
340 _Dttree.searchf = function(dttree__c.class, "dttree");
341 _Dttree.type = 0000004;
342
343 _Dtobag.searchf = function(dttree__c.class, "dttree");
344 _Dtobag.type = 0000010;
345
346 AgDataDictDisc.key = OFFSET.create(ST_Agsym_s.class, "name").toInt();
347 AgDataDictDisc.size = -1;
348 AgDataDictDisc.link = OFFSET.create(ST_Agsym_s.class, "link").toInt();
349 AgDataDictDisc.makef = null;
350 AgDataDictDisc.freef = function(attr__c.class, "freesym");
351 AgDataDictDisc.comparf = null;
352 AgDataDictDisc.hashf = null;
353
354 ProtoDesc.directed = 1;
355 ProtoDesc.strict = 0;
356 ProtoDesc.no_loop = 1;
357 ProtoDesc.maingraph = 0;
358 ProtoDesc.flatlock = 1;
359 ProtoDesc.no_write = 1;
360
361 Ag_mainedge_seq_disc.key = 0;
362 Ag_mainedge_seq_disc.size = 0;
363 Ag_mainedge_seq_disc.link = OFFSET.create(ST_Agedge_s.class, "seq_link").toInt(); // seq_link is the third
364 // field in Agedge_t
365 Ag_mainedge_seq_disc.makef = null;
366 Ag_mainedge_seq_disc.freef = null;
367 Ag_mainedge_seq_disc.comparf = function(edge__c.class, "agedgeseqcmpf");
368 Ag_mainedge_seq_disc.hashf = null;
369 Ag_mainedge_seq_disc.memoryf = function(utils__c.class, "agdictobjmem");
370 Ag_mainedge_seq_disc.eventf = null;
371
372 Ag_subedge_seq_disc.key = 0;
373 Ag_subedge_seq_disc.size = 0;
374 Ag_subedge_seq_disc.link = -1;
375 Ag_subedge_seq_disc.makef = null;
376 Ag_subedge_seq_disc.freef = null;
377 Ag_subedge_seq_disc.comparf = function(edge__c.class, "agedgeseqcmpf");
378 Ag_subedge_seq_disc.hashf = null;
379 Ag_subedge_seq_disc.memoryf = function(utils__c.class, "agdictobjmem");
380 Ag_subedge_seq_disc.eventf = null;
381
382 Ag_subedge_id_disc.key = 0;
383 Ag_subedge_id_disc.size = 0;
384 Ag_subedge_id_disc.link = -1;
385 Ag_subedge_id_disc.makef = null;
386 Ag_subedge_id_disc.freef = null;
387 Ag_subedge_id_disc.comparf = function(edge__c.class, "agedgeidcmpf");
388 Ag_subedge_id_disc.hashf = null;
389 Ag_subedge_id_disc.memoryf = function(utils__c.class, "agdictobjmem");
390 Ag_subedge_id_disc.eventf = null;
391
392 Ag_subgraph_id_disc.key = 0;
393 Ag_subgraph_id_disc.size = 0;
394 Ag_subgraph_id_disc.link = OFFSET.create(ST_Agraph_s.class, "link").toInt(); // link is the third field in
395 // Agraph_t
396 Ag_subgraph_id_disc.makef = null;
397 Ag_subgraph_id_disc.freef = null;
398 Ag_subgraph_id_disc.comparf = function(graph__c.class, "agraphidcmpf");
399 Ag_subgraph_id_disc.hashf = null;
400 Ag_subgraph_id_disc.memoryf = function(utils__c.class, "agdictobjmem");
401 Ag_subgraph_id_disc.eventf = null;
402
403 AgIdDisc.open = function(id__c.class, "idopen");
404 AgIdDisc.map = function(id__c.class, "idmap");
405 AgIdDisc.alloc = function(id__c.class, "idalloc");
406 AgIdDisc.free = function(id__c.class, "idfree");
407 AgIdDisc.print = function(id__c.class, "idprint");
408 AgIdDisc.close = function(id__c.class, "idclose");
409 AgIdDisc.idregister = function(id__c.class, "idregister");
410
411 AgMemDisc.open = function(mem__c.class, "memopen");
412 AgMemDisc.alloc = function(mem__c.class, "memalloc");
413 AgMemDisc.resize = function(mem__c.class, "memresize");
414 AgMemDisc.free = function(mem__c.class, "memfree");
415 AgMemDisc.close = null;
416
417 Ag_subnode_id_disc.key = 0;
418 Ag_subnode_id_disc.size = 0;
419 Ag_subnode_id_disc.link = OFFSET.create(ST_Agsubnode_s.class, "id_link").toInt(); // id_link is the second
420 // field in Agsubnode_t
421 Ag_subnode_id_disc.makef = null;
422 Ag_subnode_id_disc.freef = null;
423 Ag_subnode_id_disc.comparf = function(node__c.class, "agsubnodeidcmpf");
424 Ag_subnode_id_disc.hashf = null;
425 Ag_subnode_id_disc.memoryf = function(utils__c.class, "agdictobjmem");
426 Ag_subnode_id_disc.eventf = null;
427
428 Ag_subnode_seq_disc.key = 0;
429 Ag_subnode_seq_disc.size = 0;
430 Ag_subnode_seq_disc.link = OFFSET.create(ST_Agsubnode_s.class, "seq_link").toInt(); // link is the first
431 // field in
432 // Agsubnode_t
433 Ag_subnode_seq_disc.makef = null;
434 Ag_subnode_seq_disc.freef = function(node__c.class, "free_subnode");
435 Ag_subnode_seq_disc.comparf = function(node__c.class, "agsubnodeseqcmpf");
436 Ag_subnode_seq_disc.hashf = null;
437 Ag_subnode_seq_disc.memoryf = function(utils__c.class, "agdictobjmem");
438 Ag_subnode_seq_disc.eventf = null;
439
440 Refstrdisc.key = OFFSET.create(ST_refstr_t.class, "s").toInt(); // *s is the third field in refstr_t
441 Refstrdisc.size = -1;
442 Refstrdisc.link = 0;
443 Refstrdisc.makef = null;
444 Refstrdisc.freef = function(utils__c.class, "agdictobjfree");
445 Refstrdisc.comparf = null;
446 Refstrdisc.hashf = null;
447 Refstrdisc.memoryf = function(utils__c.class, "agdictobjmem");
448 Refstrdisc.eventf = null;
449
450 Hdisc.key = OFFSET.create(ST_HDict_t.class, "key").toInt();
451 Hdisc.size = 4;
452 Hdisc.link = -1;
453 Hdisc.makef = null;
454 Hdisc.freef = null;
455 Hdisc.comparf = function(xlabels__c.class, "icompare");
456 Hdisc.hashf = null;
457 Hdisc.memoryf = null;
458 Hdisc.eventf = null;
459
460 Arrowsynonyms[0].___(create_arrowname_t(null, 0));
461
462 Arrownames[0].___(create_arrowname_t("normal", 1));
463 Arrownames[1].___(create_arrowname_t("none", 8));
464 Arrownames[2].___(create_arrowname_t(null, 0));
465
466 Arrowmods[0].___(create_arrowname_t(null, 0));
467
468 Arrowtypes[0].___(createArrowtypes(1, 1.0, function(arrows__c.class, "arrow_type_normal")));
469 Arrowtypes[1].___(createArrowtypes(2, 1.0, function(arrows__c.class, "arrow_type_crow")));
470 Arrowtypes[2].___(createArrowtypes(3, 0.5, function(arrows__c.class, "arrow_type_tee")));
471 Arrowtypes[3].___(createArrowtypes(4, 1.0, function(arrows__c.class, "arrow_type_box")));
472 Arrowtypes[4].___(createArrowtypes(5, 1.2, function(arrows__c.class, "arrow_type_diamond")));
473 Arrowtypes[5].___(createArrowtypes(6, 0.8, function(arrows__c.class, "arrow_type_dot")));
474 Arrowtypes[6].___(createArrowtypes(7, 1.0, function(arrows__c.class, "arrow_type_curve")));
475 Arrowtypes[7].___(createArrowtypes(8, 0.5, function(arrows__c.class, "arrow_type_gap")));
476 Arrowtypes[8].___(createArrowtypes(0, 0.0, null));
477
478 Center.p.x = 0;
479 Center.p.y = 0;
480 Center.theta = -1;
481 Center.bp = null;
482 Center.defined = 0;
483 Center.constrained = 0;
484 Center.clip = 1;
485 Center.dyna = 0;
486 Center.order = 0;
487 Center.side = 0;
488
489 p_ellipse.setInt("regular", 0);
490 p_ellipse.setInt("peripheries", 1);
491 p_ellipse.setInt("sides", 1);
492 p_ellipse.setDouble("orientation", 0.);
493 p_ellipse.setDouble("distortion", 0.);
494 p_ellipse.setDouble("skew", 0.);
495
496 p_box.setInt("regular", 0);
497 p_box.setInt("peripheries", 1);
498 p_box.setInt("sides", 4);
499 p_box.setDouble("orientation", 0.);
500 p_box.setDouble("distortion", 0.);
501 p_box.setDouble("skew", 0.);
502
503 poly_fns.setPtr("initfn", function(shapes__c.class, "poly_init"));
504 poly_fns.setPtr("freefn", function(shapes__c.class, "poly_free"));
505 poly_fns.setPtr("portfn", function(shapes__c.class, "poly_port"));
506 poly_fns.setPtr("insidefn", function(shapes__c.class, "poly_inside"));
507 poly_fns.setPtr("pboxfn", function(shapes__c.class, "poly_path"));
508 poly_fns.setPtr("codefn", function(shapes__c.class, "poly_gencode"));
509
510 Ag_mainedge_id_disc.key = 0;
511 Ag_mainedge_id_disc.size = 0;
512 Ag_mainedge_id_disc.link = OFFSET.create(ST_Agedge_s.class, "id_link").toInt(); // id_link is the second
513 // field in Agedge_t
514 Ag_mainedge_id_disc.makef = null;
515 Ag_mainedge_id_disc.freef = null;
516 Ag_mainedge_id_disc.comparf = function(edge__c.class, "agedgeidcmpf");
517 Ag_mainedge_id_disc.hashf = null;
518 Ag_mainedge_id_disc.memoryf = function(utils__c.class, "agdictobjmem");
519 Ag_mainedge_id_disc.eventf = null;
520
521 Agdirected.directed = 1;
522 Agdirected.strict = 0;
523 Agdirected.no_loop = 0;
524 Agdirected.maingraph = 1;
525
526 sinfo.setPtr("swapEnds", function(dotsplines__c.class, "swap_ends_p"));
527 sinfo.setPtr("splineMerge", function(dotsplines__c.class, "spline_merge"));
528
529 }
530
531 }