Debian Codegraph @

src/smetana/core/Macro.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 h.ST_Agedge_s;
40 import h.ST_Agedgeinfo_t;
41 import h.ST_Agnode_s;
42 import h.ST_Agnodeinfo_t;
43 import h.ST_Agobj_s;
44 import h.ST_Agraph_s;
45 import h.ST_Agraphinfo_t;
46 import h.ST_Agrec_s;
47 import h.ST_Agtag_s;
48 import h.ST_GVC_s;
49 import h.ST_Pedge_t;
50 import h.ST_bezier;
51 import h.ST_boxf;
52 import h.ST_elist;
53 import h.ST_layout_t;
54 import h.ST_nlist_t;
55 import h.ST_pointf;
56 import h.ST_port;
57 import h.ST_rank_t;
58 import h.ST_shape_desc;
59 import h.ST_splines;
60 import h.ST_textlabel_t;
61 import h.ST_textspan_t;
62
63 import java.util.regex.Matcher;
64 import java.util.regex.Pattern;
65
66 public class Macro {
67
68 public static <O> O F(O result, Object... dummy) {
69 return result;
70 }
71
72 public static int ASINT(boolean v) {
73 return v ? 1 : 0;
74 }
75
76 public static boolean N(boolean v) {
77 return v == false;
78 }
79
80 public static boolean N(int i) {
81 return i == 0;
82 }
83
84 public static boolean N(char c) {
85 return c == 0;
86 }
87
88 public static boolean N(Object o) {
89 if (o instanceof Boolean) {
90 throw new IllegalArgumentException();
91 }
92 if (o instanceof Integer) {
93 throw new IllegalArgumentException();
94 }
95 return o == null;
96 }
97
98 public static boolean NOT(boolean v) {
99 return v == false;
100 }
101
102 public static int NOTI(boolean v) {
103 return v ? 0 : 1;
104 }
105
106 public static boolean NOT(int i) {
107 return i == 0;
108 }
109
110 public static boolean NOT(char c) {
111 return c == 0;
112 }
113
114 public static boolean NOT(Object o) {
115 return o == null;
116 }
117
118 public static void TRACE(String functionName) {
119 // System.err.println(functionName);
120 }
121
122 public static __ptr__ UNSUPPORTED(String comment) {
123 throw new UnsupportedOperationException(comment);
124 }
125
126 public static int UNSUPPORTED_INT(String comment) {
127 throw new UnsupportedOperationException(comment);
128 }
129
130 // Graphviz
131
132 // #define AGRAPH 0 /* can't exceed 2 bits. see Agtag_t. */
133 // #define AGNODE 1
134 // #define AGOUTEDGE 2
135 // #define AGINEDGE 3 /* (1 << 1) indicates an edge tag. */
136 // #define AGEDGE AGOUTEDGE /* synonym in object kind args */
137 public final static int AGRAPH = 0;
138 public final static int AGNODE = 1;
139 public final static int AGOUTEDGE = 2;
140 public final static int AGINEDGE = 3;
141 public final static int AGEDGE = AGOUTEDGE;
142
143 // #define AGTAG(obj) (((Agobj_t*)(obj))->tag)
144 public static ST_Agtag_s AGTAG(__ptr__ obj) {
145 return (ST_Agtag_s) ((ST_Agobj_s) obj.castTo(ST_Agobj_s.class)).tag;
146 }
147
148 // #define AGTYPE(obj) (AGTAG(obj).objtype)
149 public static int AGTYPE(__ptr__ obj) {
150 return AGTAG(obj).objtype;
151 }
152
153 public static void AGTYPE(__ptr__ obj, int v) {
154 AGTAG(obj).objtype = v;
155 }
156
157 // #define AGID(obj) (AGTAG(obj).id)
158 public static int AGID(__ptr__ obj) {
159 return AGTAG(obj).id;
160 }
161
162 public static void AGID(__ptr__ obj, int v) {
163 AGTAG(obj).id = v;
164 }
165
166 // #define AGSEQ(obj) (AGTAG(obj).seq)
167 public static int AGSEQ(__ptr__ obj) {
168 return AGTAG(obj).seq;
169 }
170
171 public static void AGSEQ(__ptr__ obj, int v) {
172 AGTAG(obj).seq = v;
173 }
174
175 // #define AGATTRWF(obj) (AGTAG(obj).attrwf)
176 // #define AGDATA(obj) (((Agobj_t*)(obj))->data)
177 public static ST_Agrec_s AGDATA(__ptr__ obj) {
178 return ((ST_Agobj_s) obj.castTo(ST_Agobj_s.class)).data;
179 }
180
181 public static void AGDATA(__ptr__ obj, __ptr__ v) {
182 obj.castTo(ST_Agobj_s.class).setPtr("data", v);
183 }
184
185 // #define AGIN2OUT(e) ((e)-1)
186 public static __ptr__ AGIN2OUT(__ptr__ e) {
187 return e.plus(-1);
188 }
189
190 // #define AGOUT2IN(e) ((e)+1)
191 public static __ptr__ AGOUT2IN(__ptr__ e) {
192 return e.plus(1);
193 }
194
195 // #define AGOPP(e) ((AGTYPE(e)==AGINEDGE)?AGIN2OUT(e):AGOUT2IN(e))
196 public static ST_Agedge_s AGOPP(ST_Agedge_s e) {
197 return (ST_Agedge_s) (AGTYPE(e) == AGINEDGE ? AGIN2OUT(e) : AGOUT2IN(e));
198 }
199
200 // #define AGMKOUT(e) (AGTYPE(e) == AGOUTEDGE? (e): AGIN2OUT(e))
201 public static ST_Agedge_s AGMKOUT(__ptr__ e) {
202 return (ST_Agedge_s) (AGTYPE(e) == AGOUTEDGE ? (e) : AGIN2OUT(e));
203 }
204
205 // #define AGMKIN(e) (AGTYPE(e) == AGINEDGE? (e): AGOUT2IN(e))
206 public static ST_Agedge_s AGMKIN(__ptr__ e) {
207 return (ST_Agedge_s) (AGTYPE(e) == AGINEDGE ? (e) : AGOUT2IN(e));
208 }
209
210 // #define AGTAIL(e) (AGMKIN(e)->node)
211 public static ST_Agnode_s AGTAIL(__ptr__ e) {
212 return (ST_Agnode_s) AGMKIN(e).node;
213 }
214
215 public static ST_Agnode_s agtail(__ptr__ e) {
216 return (ST_Agnode_s) AGMKIN(e).node;
217 }
218
219 public static void agtail(ST_Agedge_s e, __ptr__ v) {
220 AGMKIN(e).setPtr("node", v);
221 }
222
223 // #define AGHEAD(e) (AGMKOUT(e)->node)
224 public static ST_Agnode_s AGHEAD(__ptr__ e) {
225 return (ST_Agnode_s) AGMKOUT(e).node;
226 }
227
228 private static ST_Agnode_s aghead(ST_Agedge_s e) {
229 return (ST_Agnode_s) AGMKOUT(e).node;
230 }
231
232 public static void aghead(ST_Agedge_s e, __ptr__ v) {
233 AGMKOUT(e).setPtr("node", v);
234 }
235
236 // #define agtail(e) AGTAIL(e)
237 // #define aghead(e) AGHEAD(e)
238 // #define agopp(e) AGOPP(e)
239 // #define ageqedge(e,f) (AGMKOUT(e) == AGMKOUT(f))
240
241 // #define AGHEADPOINTER(g) ((Agnoderef_t*)(g->n_seq->data->hh._head))
242 // #define AGRIGHTPOINTER(rep) ((Agnoderef_t*)((rep)->seq_link.right?((void*)((rep)->seq_link.right) -
243 // offsetof(Agsubnode_t,seq_link)):0))
244 // #define AGLEFTPOINTER(rep) ((Agnoderef_t*)((rep)->seq_link.hl._left?((void*)((rep)->seq_link.hl._left) -
245 // offsetof(Agsubnode_t,seq_link)):0))
246 //
247 // #define FIRSTNREF(g) (agflatten(g,1), AGHEADPOINTER(g))
248 //
249 // #define NEXTNREF(g,rep) (AGRIGHTPOINTER(rep) == AGHEADPOINTER(g)?0:AGRIGHTPOINTER(rep))
250 //
251 // #define PREVNREF(g,rep) (((rep)==AGHEADPOINTER(g))?0:(AGLEFTPOINTER(rep)))
252 //
253 // #define LASTNREF(g) (agflatten(g,1), AGHEADPOINTER(g)?AGLEFTPOINTER(AGHEADPOINTER(g)):0)
254 // #define NODEOF(rep) ((rep)->node)
255 //
256 // #define FIRSTOUTREF(g,sn) (agflatten(g,1), (sn)->out_seq)
257 // #define LASTOUTREF(g,sn) (agflatten(g,1), (Agedgeref_t*)dtlast(sn->out_seq))
258 // #define FIRSTINREF(g,sn) (agflatten(g,1), (sn)->in_seq)
259 // #define NEXTEREF(g,rep) ((rep)->right)
260 // #define PREVEREF(g,rep) ((rep)->hl._left)
261 // /* this is expedient but a bit slimey because it "knows" that dict entries of both nodes
262 // and edges are embedded in main graph objects but allocated separately in subgraphs */
263 // #define AGSNMAIN(sn) ((sn)==(&((sn)->node->mainsub)))
264 // #define EDGEOF(sn,rep) (AGSNMAIN(sn)?((Agedge_t*)((unsigned char*)(rep) - offsetof(Agedge_t,seq_link))) :
265 // ((Dthold_t*)(rep))->obj)
266
267 // #define LENGTH(e) (ND_rank(aghead(e)) - ND_rank(agtail(e)))
268 public static int LENGTH(ST_Agedge_s e) {
269 return ND_rank(aghead(e)) - ND_rank(agtail(e));
270 }
271
272 // #define SLACK(e) (LENGTH(e) - ED_minlen(e))
273 public static int SLACK(ST_Agedge_s e) {
274 return LENGTH(e) - ED_minlen(e);
275 }
276
277 // #define SEQ(a,b,c) (((a) <= (b)) && ((b) <= (c)))
278 public static boolean SEQ(int a, int b, int c) {
279 return (((a) <= (b)) && ((b) <= (c)));
280 }
281
282 // #define TREE_EDGE(e) (ED_tree_index(e) >= 0)
283 public static boolean TREE_EDGE(ST_Agedge_s e) {
284 return ED_tree_index(e) >= 0;
285 }
286
287 // #define GD_parent(g) (((Agraphinfo_t*)AGDATA(g))->parent)
288 public static __ptr__ GD_parent(ST_Agraph_s g) {
289 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).parent;
290 }
291
292 public static void GD_parent(ST_Agraph_s g, __ptr__ v) {
293 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setPtr("parent", v);
294 }
295
296 // #define GD_level(g) (((Agraphinfo_t*)AGDATA(g))->level)
297 // #define GD_drawing(g) (((Agraphinfo_t*)AGDATA(g))->drawing)
298 public static ST_layout_t GD_drawing(ST_Agraph_s g) {
299 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).drawing;
300 }
301
302 public static void GD_drawing(ST_Agraph_s g, __ptr__ v) {
303 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setPtr("drawing", v);
304 }
305
306 // #define GD_bb(g) (((Agraphinfo_t*)AGDATA(g))->bb)
307 public static ST_boxf GD_bb(__ptr__ g) {
308 return (ST_boxf) ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).bb;
309 }
310
311 // #define GD_gvc(g) (((Agraphinfo_t*)AGDATA(g))->gvc)
312 public static ST_GVC_s GD_gvc(ST_Agraph_s g) {
313 return (ST_GVC_s) ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).gvc;
314 }
315
316 public static void GD_gvc(ST_Agraph_s g, ST_GVC_s v) {
317 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setPtr("gvc", v);
318 }
319
320 // #define GD_cleanup(g) (((Agraphinfo_t*)AGDATA(g))->cleanup)
321 public static __ptr__ GD_cleanup(ST_Agraph_s g) {
322 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).cleanup;
323 }
324
325 // #define GD_dist(g) (((Agraphinfo_t*)AGDATA(g))->dist)
326 // #define GD_alg(g) (((Agraphinfo_t*)AGDATA(g))->alg)
327 // #define GD_border(g) (((Agraphinfo_t*)AGDATA(g))->border)
328 public static ST_pointf[] GD_border(ST_Agraph_s g) {
329 return ((ST_Agraphinfo_t) AGDATA(g).castTo(ST_Agraphinfo_t.class)).border;
330 }
331
332 // #define GD_cl_cnt(g) (((Agraphinfo_t*)AGDATA(g))->cl_nt)
333 // #define GD_clust(g) (((Agraphinfo_t*)AGDATA(g))->clust)
334 public static ST_Agraph_s.Array GD_clust(ST_Agraph_s g) {
335 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).clust;
336 }
337
338 public static void GD_clust(ST_Agraph_s g, __ptr__ v) {
339 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setPtr("clust", v);
340 }
341
342 // #define GD_dotroot(g) (((Agraphinfo_t*)AGDATA(g))->dotroot)
343 public static ST_Agraph_s GD_dotroot(ST_Agraph_s g) {
344 return (ST_Agraph_s) ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).dotroot;
345 }
346
347 public static void GD_dotroot(ST_Agraph_s g, __ptr__ v) {
348 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setPtr("dotroot", v);
349 }
350
351 // #define GD_comp(g) (((Agraphinfo_t*)AGDATA(g))->comp)
352 public static ST_nlist_t GD_comp(ST_Agraph_s g) {
353 return (ST_nlist_t) ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).comp;
354 }
355
356 // #define GD_exact_ranksep(g) (((Agraphinfo_t*)AGDATA(g))->exact_ranksep)
357 public static int GD_exact_ranksep(ST_Agraph_s g) {
358 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).exact_ranksep;
359 }
360
361 public static void GD_exact_ranksep(ST_Agraph_s g, int v) {
362 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("exact_ranksep", v);
363 }
364
365 // #define GD_expanded(g) (((Agraphinfo_t*)AGDATA(g))->expanded)
366 public static boolean GD_expanded(ST_Agraph_s g) {
367 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).expanded;
368 }
369
370 public static void GD_expanded(ST_Agraph_s g, boolean v) {
371 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).expanded = v;
372 }
373
374 // #define GD_flags(g) (((Agraphinfo_t*)AGDATA(g))->flags)
375 public static int GD_flags(ST_Agraph_s g) {
376 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).flags;
377 }
378
379 public static void GD_flags(ST_Agraph_s g, int v) {
380 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("flags", v);
381 }
382
383 // #define GD_gui_state(g) (((Agraphinfo_t*)AGDATA(g))->gui_state)
384 // #define GD_charset(g) (((Agraphinfo_t*)AGDATA(g))->charset)
385 public static int GD_charset(ST_Agraph_s g) {
386 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).charset;
387 }
388
389 public static void GD_charset(ST_Agraph_s g, int v) {
390 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("charset", v);
391 }
392
393 // #define GD_has_labels(g) (((Agraphinfo_t*)AGDATA(g))->has_labels)
394 public static int GD_has_labels(__ptr__ g) {
395 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).has_labels;
396 }
397
398 public static void GD_has_labels(__ptr__ g, int v) {
399 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("has_labels", v);
400 }
401
402 // #define GD_has_images(g) (((Agraphinfo_t*)AGDATA(g))->has_images)
403 // #define GD_has_flat_edges(g) (((Agraphinfo_t*)AGDATA(g))->has_flat_edges)
404 public static int GD_has_flat_edges(ST_Agraph_s g) {
405 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).has_flat_edges;
406 }
407
408 public static void GD_has_flat_edges(ST_Agraph_s g, boolean v) {
409 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).has_flat_edges = v?1:0;
410 }
411
412 // #define GD_has_sourcerank(g) (((Agraphinfo_t*)AGDATA(g))->has_sourcerank)
413 // #define GD_has_sinkrank(g) (((Agraphinfo_t*)AGDATA(g))->has_sinkrank)
414 // #define GD_ht1(g) (((Agraphinfo_t*)AGDATA(g))->ht1)
415 public static double GD_ht1(ST_Agraph_s g) {
416 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).ht1;
417 }
418
419 public static void GD_ht1(ST_Agraph_s g, double v) {
420 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setDouble("ht1", v);
421 }
422
423 // #define GD_ht2(g) (((Agraphinfo_t*)AGDATA(g))->ht2)
424 public static double GD_ht2(ST_Agraph_s g) {
425 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).ht2;
426 }
427
428 public static void GD_ht2(ST_Agraph_s g, double v) {
429 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setDouble("ht2", v);
430 }
431
432 // #define GD_inleaf(g) (((Agraphinfo_t*)AGDATA(g))->inleaf)
433 // #define GD_installed(g) (((Agraphinfo_t*)AGDATA(g))->installed)
434 public static int GD_installed(ST_Agraph_s g) {
435 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).installed;
436 }
437
438 public static void GD_installed(ST_Agraph_s g, int v) {
439 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("installed", v);
440 }
441
442 // #define GD_label(g) (((Agraphinfo_t*)AGDATA(g))->label)
443 public static ST_textlabel_t GD_label(__ptr__ g) {
444 return (ST_textlabel_t) ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).label;
445 }
446
447 public static void GD_label(__ptr__ g, __ptr__ v) {
448 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setPtr("label", v);
449 }
450
451 // #define GD_leader(g) (((Agraphinfo_t*)AGDATA(g))->leader)
452 public static ST_Agnode_s GD_leader(ST_Agraph_s g) {
453 return (ST_Agnode_s) ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).leader;
454 }
455
456 public static void GD_leader(ST_Agraph_s g, __ptr__ v) {
457 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setPtr("leader", v);
458 }
459
460 // #define GD_rankdir2(g) (((Agraphinfo_t*)AGDATA(g))->rankdir)
461 public static int GD_rankdir2(ST_Agraph_s g) {
462 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).rankdir;
463 }
464
465 public static void GD_rankdir2(ST_Agraph_s g, int v) {
466 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("rankdir", v);
467 }
468
469 // #define GD_rankdir(g) (((Agraphinfo_t*)AGDATA(g))->rankdir & 0x3)
470 public static int GD_rankdir(ST_Agraph_s g) {
471 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).rankdir & 0x3;
472 }
473
474 // #define GD_flip(g) (GD_rankdir(g) & 1)
475 public static int GD_flip(ST_Agraph_s g) {
476 return GD_rankdir(g) & 1;
477 }
478
479 // #define GD_realrankdir(g) ((((Agraphinfo_t*)AGDATA(g))->rankdir) >> 2)
480 // #define GD_realflip(g) (GD_realrankdir(g) & 1)
481 // #define GD_ln(g) (((Agraphinfo_t*)AGDATA(g))->ln)
482 public static ST_Agnode_s GD_ln(ST_Agraph_s g) {
483 return (ST_Agnode_s) ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).ln;
484 }
485
486 public static void GD_ln(ST_Agraph_s g, __ptr__ v) {
487 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setPtr("ln", v);
488 }
489
490 // #define GD_maxrank(g) (((Agraphinfo_t*)AGDATA(g))->maxrank)
491 public static int GD_maxrank(ST_Agraph_s g) {
492 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).maxrank;
493 }
494
495 public static void GD_maxrank(ST_Agraph_s g, int v) {
496 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("maxrank", v);
497 }
498
499 // #define GD_maxset(g) (((Agraphinfo_t*)AGDATA(g))->maxset)
500 public static __ptr__ GD_maxset(ST_Agraph_s g) {
501 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).maxset;
502 }
503
504 // #define GD_minrank(g) (((Agraphinfo_t*)AGDATA(g))->minrank)
505 public static int GD_minrank(ST_Agraph_s g) {
506 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).minrank;
507 }
508
509 public static void GD_minrank(ST_Agraph_s g, int v) {
510 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("minrank", v);
511 }
512
513 // #define GD_minset(g) (((Agraphinfo_t*)AGDATA(g))->minset)
514 public static __ptr__ GD_minset(ST_Agraph_s g) {
515 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).minset;
516 }
517
518 // #define GD_minrep(g) (((Agraphinfo_t*)AGDATA(g))->minrep)
519 // #define GD_maxrep(g) (((Agraphinfo_t*)AGDATA(g))->maxrep)
520 // #define GD_move(g) (((Agraphinfo_t*)AGDATA(g))->move)
521 // #define GD_n_cluster(g) (((Agraphinfo_t*)AGDATA(g))->n_cluster)
522 public static int GD_n_cluster(ST_Agraph_s g) {
523 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).n_cluster;
524 }
525
526 public static void GD_n_cluster(ST_Agraph_s g, int v) {
527 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("n_cluster", v);
528 }
529
530 // #define GD_n_nodes(g) (((Agraphinfo_t*)AGDATA(g))->n_nodes)
531 public static int GD_n_nodes(ST_Agraph_s g) {
532 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).n_nodes;
533 }
534
535 public static void GD_n_nodes(ST_Agraph_s g, int v) {
536 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("n_nodes", v);
537 }
538
539 // #define GD_ndim(g) (((Agraphinfo_t*)AGDATA(g))->ndim)
540 // #define GD_odim(g) (((Agraphinfo_t*)AGDATA(g))->odim)
541 // #define GD_neato_nlist(g) (((Agraphinfo_t*)AGDATA(g))->neato_nlist)
542 // #define GD_nlist(g) (((Agraphinfo_t*)AGDATA(g))->nlist)
543 public static ST_Agnode_s GD_nlist(ST_Agraph_s g) {
544 return (ST_Agnode_s) ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).nlist;
545 }
546
547 public static void GD_nlist(ST_Agraph_s g, __ptr__ v) {
548 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setPtr("nlist", v);
549 }
550
551 // #define GD_nodesep(g) (((Agraphinfo_t*)AGDATA(g))->nodesep)
552 public static int GD_nodesep(ST_Agraph_s g) {
553 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).nodesep;
554 }
555
556 public static void GD_nodesep(ST_Agraph_s g, int v) {
557 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("nodesep", v);
558 }
559
560 // #define GD_outleaf(g) (((Agraphinfo_t*)AGDATA(g))->outleaf)
561 // #define GD_rank(g) (((Agraphinfo_t*)AGDATA(g))->rank)
562 public static ST_rank_t.Array2 GD_rank(ST_Agraph_s g) {
563 return (ST_rank_t.Array2) ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).rank;
564 }
565
566 public static void GD_rank(ST_Agraph_s g, ST_rank_t.Array2 v) {
567 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setPtr("rank", v);
568 }
569
570 // #define GD_rankleader(g) (((Agraphinfo_t*)AGDATA(g))->rankleader)
571 public static ST_Agnode_s.Array GD_rankleader(ST_Agraph_s g) {
572 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).rankleader;
573 }
574
575 public static void GD_rankleader(ST_Agraph_s g, __ptr__ v) {
576 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setPtr("rankleader", v);
577 }
578
579 // #define GD_ranksep(g) (((Agraphinfo_t*)AGDATA(g))->ranksep)
580 public static int GD_ranksep(ST_Agraph_s g) {
581 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).ranksep;
582 }
583
584 public static void GD_ranksep(ST_Agraph_s g, int v) {
585 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("ranksep", v);
586 }
587
588 // #define GD_rn(g) (((Agraphinfo_t*)AGDATA(g))->rn)
589 public static ST_Agnode_s GD_rn(ST_Agraph_s g) {
590 return (ST_Agnode_s) ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).rn;
591 }
592
593 public static void GD_rn(ST_Agraph_s g, __ptr__ v) {
594 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setPtr("rn", v);
595 }
596
597 // #define GD_set_type(g) (((Agraphinfo_t*)AGDATA(g))->set_type)
598 public static int GD_set_type(ST_Agraph_s g) {
599 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).set_type;
600 }
601
602 public static void GD_set_type(ST_Agraph_s g, int v) {
603 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("set_type", v);
604 }
605
606 // #define GD_label_pos(g) (((Agraphinfo_t*)AGDATA(g))->label_pos)
607 public static int GD_label_pos(ST_Agraph_s g) {
608 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).label_pos;
609 }
610
611 public static void GD_label_pos(ST_Agraph_s g, int v) {
612 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("label_pos", v);
613 }
614
615 // #define GD_showboxes(g) (((Agraphinfo_t*)AGDATA(g))->showboxes)
616 public static int GD_showboxes(ST_Agraph_s g) {
617 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).showboxes;
618 }
619
620 public static void GD_showboxes(ST_Agraph_s g, int v) {
621 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("showboxes", v);
622 }
623
624 // #define GD_fontnames(g) (((Agraphinfo_t*)AGDATA(g))->fontnames)
625 public static int GD_fontnames(ST_Agraph_s g) {
626 return ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).fontnames;
627 }
628
629 public static void GD_fontnames(ST_Agraph_s g, int v) {
630 ((ST_Agraphinfo_t)AGDATA(g).castTo(ST_Agraphinfo_t.class)).setInt("fontnames", v);
631 }
632
633 // #define GD_spring(g) (((Agraphinfo_t*)AGDATA(g))->spring)
634 // #define GD_sum_t(g) (((Agraphinfo_t*)AGDATA(g))->sum_t)
635 // #define GD_t(g) (((Agraphinfo_t*)AGDATA(g))->t)
636
637 // #define ND_id(n) (((Agnodeinfo_t*)AGDATA(n))->id)
638 public static int ND_id(ST_Agnode_s n) {
639 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).id;
640 }
641
642 // #define ND_alg(n) (((Agnodeinfo_t*)AGDATA(n))->alg)
643 public static __ptr__ ND_alg(ST_Agnode_s n) {
644 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).alg;
645 }
646
647 public static void ND_alg(ST_Agnode_s n, __ptr__ value) {
648 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setPtr("alg", value);
649 }
650
651 // #define ND_UF_parent(n) (((Agnodeinfo_t*)AGDATA(n))->UF_parent)
652 public static ST_Agnode_s ND_UF_parent(__ptr__ n) {
653 return (ST_Agnode_s) ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).UF_parent;
654 }
655
656 public static void ND_UF_parent(__ptr__ n, __ptr__ v) {
657 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setPtr("UF_parent", v);
658 }
659
660 // #define ND_set(n) (((Agnodeinfo_t*)AGDATA(n))->set)
661 // #define ND_UF_size(n) (((Agnodeinfo_t*)AGDATA(n))->UF_size)
662 public static int ND_UF_size(ST_Agnode_s n) {
663 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).UF_size;
664 }
665
666 public static void ND_UF_size(ST_Agnode_s n, int v) {
667 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setInt("UF_size", v);
668 }
669
670 // #define ND_bb(n) (((Agnodeinfo_t*)AGDATA(n))->bb)
671 // #define ND_clust(n) (((Agnodeinfo_t*)AGDATA(n))->clust)
672 public static ST_Agraph_s ND_clust(__ptr__ n) {
673 return (ST_Agraph_s) ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).clust;
674 }
675
676 public static void ND_clust(ST_Agnode_s n, __ptr__ v) {
677 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setPtr("clust", v);
678 }
679
680 // #define ND_coord(n) (((Agnodeinfo_t*)AGDATA(n))->coord)
681 public static ST_pointf ND_coord(__ptr__ n) {
682 return (ST_pointf) ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).coord;
683 }
684
685 // #define ND_dist(n) (((Agnodeinfo_t*)AGDATA(n))->dist)
686
687 // #define ND_flat_in(n) (((Agnodeinfo_t*)AGDATA(n))->flat_in)
688 public static ST_elist ND_flat_in(ST_Agnode_s n) {
689 return (ST_elist) ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).flat_in;
690 }
691
692 // #define ND_flat_out(n) (((Agnodeinfo_t*)AGDATA(n))->flat_out)
693 public static ST_elist ND_flat_out(ST_Agnode_s n) {
694 return (ST_elist) ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).flat_out;
695 }
696
697 // #define ND_gui_state(n) (((Agnodeinfo_t*)AGDATA(n))->gui_state)
698 // #define ND_has_port(n) (((Agnodeinfo_t*)AGDATA(n))->has_port)
699 public static boolean ND_has_port(ST_Agnode_s n) {
700 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).has_port;
701 }
702
703 // #define ND_rep(n) (((Agnodeinfo_t*)AGDATA(n))->rep)
704 // #define ND_heapindex(n) (((Agnodeinfo_t*)AGDATA(n))->heapindex)
705 // #define ND_height(n) (((Agnodeinfo_t*)AGDATA(n))->height)
706 public static double ND_height(__ptr__ n) {
707 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).height;
708 }
709
710 public static void ND_height(ST_Agnode_s n, double v) {
711 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setDouble("height", v);
712 }
713
714 // #define ND_hops(n) (((Agnodeinfo_t*)AGDATA(n))->hops)
715 // #define ND_ht(n) (((Agnodeinfo_t*)AGDATA(n))->ht)
716 public static double ND_ht(__ptr__ n) {
717 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).ht;
718 }
719
720 public static void ND_ht(ST_Agnode_s n, double v) {
721 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setDouble("ht", v);
722 }
723
724 // #define ND_in(n) (((Agnodeinfo_t*)AGDATA(n))->in)
725 public static ST_elist ND_in(ST_Agnode_s n) {
726 return ((ST_Agnodeinfo_t) AGDATA(n).castTo(ST_Agnodeinfo_t.class)).in;
727 }
728
729 public static void ND_in(__ptr__ n, __struct__<ST_elist> v) {
730 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setStruct("in", v);
731 }
732
733 // #define ND_inleaf(n) (((Agnodeinfo_t*)AGDATA(n))->inleaf)
734 public static __ptr__ ND_inleaf(ST_Agnode_s n) {
735 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).inleaf;
736 }
737
738 // #define ND_label(n) (((Agnodeinfo_t*)AGDATA(n))->label)
739 public static ST_textlabel_t ND_label(ST_Agnode_s n) {
740 return (ST_textlabel_t) ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).label;
741 }
742
743 public static void ND_label(ST_Agnode_s n, __ptr__ v) {
744 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setPtr("label", v);
745 }
746
747 // #define ND_xlabel(n) (((Agnodeinfo_t*)AGDATA(n))->xlabel)
748 public static ST_textlabel_t ND_xlabel(ST_Agnode_s n) {
749 return (ST_textlabel_t) ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).xlabel;
750 }
751
752 // #define ND_lim(n) (((Agnodeinfo_t*)AGDATA(n))->lim)
753 public static int ND_lim(ST_Agnode_s n) {
754 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).lim;
755 }
756
757 public static void ND_lim(ST_Agnode_s n, int v) {
758 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setInt("lim", v);
759 }
760
761 // #define ND_low(n) (((Agnodeinfo_t*)AGDATA(n))->low)
762 public static int ND_low(ST_Agnode_s n) {
763 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).low;
764 }
765
766 public static void ND_low(ST_Agnode_s n, int v) {
767 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setInt("low", v);
768 }
769
770 // #define ND_lw(n) (((Agnodeinfo_t*)AGDATA(n))->lw)
771 public static double ND_lw(__ptr__ n) {
772 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).lw;
773 }
774
775 public static void ND_lw(ST_Agnode_s n, double v) {
776 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setDouble("lw", v);
777 }
778
779 // #define ND_mark(n) (((Agnodeinfo_t*)AGDATA(n))->mark)
780 public static int ND_mark(__ptr__ n) {
781 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).mark;
782 }
783
784 public static void ND_mark(__ptr__ n, int v) {
785 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setInt("mark", v);
786 }
787
788 public static void ND_mark(__ptr__ n, boolean v) {
789 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).mark = v?1:0;
790 }
791
792 // #define ND_mval(n) (((Agnodeinfo_t*)AGDATA(n))->mval)
793 public static double ND_mval(__ptr__ n) {
794 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).mval;
795 }
796
797 public static void ND_mval(ST_Agnode_s n, double v) {
798 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setDouble("mval", v);
799 }
800
801 // #define ND_n_cluster(n) (((Agnodeinfo_t*)AGDATA(n))->n_cluster)
802 // #define ND_next(n) (((Agnodeinfo_t*)AGDATA(n))->next)
803 public static ST_Agnode_s ND_next(ST_Agnode_s n) {
804 return (ST_Agnode_s) ((ST_Agnodeinfo_t) AGDATA(n).castTo(ST_Agnodeinfo_t.class)).next;
805 }
806
807 public static void ND_next(__ptr__ n, __ptr__ v) {
808 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setPtr("next", v);
809 }
810
811 // #define ND_node_type(n) (((Agnodeinfo_t*)AGDATA(n))->node_type)
812 public static int ND_node_type(ST_Agnode_s n) {
813 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).node_type;
814 }
815
816 public static void ND_node_type(ST_Agnode_s n, int v) {
817 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setInt("node_type", v);
818 }
819
820 // #define ND_onstack(n) (((Agnodeinfo_t*)AGDATA(n))->onstack)
821 public static boolean ND_onstack(ST_Agnode_s n) {
822 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).onstack!=0;
823 }
824
825 public static void ND_onstack(ST_Agnode_s n, int v) {
826 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setInt("onstack", v);
827 }
828
829 public static void ND_onstack(ST_Agnode_s n, boolean v) {
830 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).onstack = v?1:0;
831 }
832
833 // #define ND_order(n) (((Agnodeinfo_t*)AGDATA(n))->order)
834 public static int ND_order(__ptr__ n) {
835 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).order;
836 }
837
838 public static void ND_order(__ptr__ n, int v) {
839 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setInt("order", v);
840 }
841
842 // #define ND_other(n) (((Agnodeinfo_t*)AGDATA(n))->other)
843 public static ST_elist ND_other(ST_Agnode_s n) {
844 return (ST_elist) ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).other;
845 }
846
847 // #define ND_out(n) (((Agnodeinfo_t*)AGDATA(n))->out)
848 public static ST_elist ND_out(__ptr__ n) {
849 return ((ST_Agnodeinfo_t) AGDATA(n).castTo(ST_Agnodeinfo_t.class)).out;
850 }
851
852 public static void ND_out(__ptr__ n, __struct__<ST_elist> v) {
853 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setStruct("out", v);
854 }
855
856 // #define ND_outleaf(n) (((Agnodeinfo_t*)AGDATA(n))->outleaf)
857 public static __ptr__ ND_outleaf(ST_Agnode_s n) {
858 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).outleaf;
859 }
860
861 // #define ND_par(n) (((Agnodeinfo_t*)AGDATA(n))->par)
862 public static ST_Agedge_s ND_par(ST_Agnode_s n) {
863 return (ST_Agedge_s) ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).par;
864 }
865
866 public static void ND_par(ST_Agnode_s n, __ptr__ v) {
867 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setPtr("par", v);
868 }
869
870 // #define ND_pinned(n) (((Agnodeinfo_t*)AGDATA(n))->pinned)
871 // #define ND_pos(n) (((Agnodeinfo_t*)AGDATA(n))->pos)
872 // #define ND_prev(n) (((Agnodeinfo_t*)AGDATA(n))->prev)
873 public static __ptr__ ND_prev(ST_Agnode_s n) {
874 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).prev;
875 }
876
877 public static void ND_prev(ST_Agnode_s n, __ptr__ v) {
878 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setPtr("prev", v);
879 }
880
881 // #define ND_priority(n) (((Agnodeinfo_t*)AGDATA(n))->priority)
882 public static int ND_priority(ST_Agnode_s n) {
883 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).priority;
884 }
885
886 public static void ND_priority(ST_Agnode_s n, int v) {
887 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setInt("priority", v);
888 }
889
890 // #define ND_rank(n) (((Agnodeinfo_t*)AGDATA(n))->rank)
891 public static int ND_rank(__ptr__ n) {
892 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).rank;
893 }
894
895 public static void ND_rank(__ptr__ n, int v) {
896 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setInt("rank", v);
897 }
898
899 // #define ND_ranktype(n) (((Agnodeinfo_t*)AGDATA(n))->ranktype)
900 public static int ND_ranktype(ST_Agnode_s n) {
901 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).ranktype;
902 }
903
904 public static void ND_ranktype(ST_Agnode_s n, int v) {
905 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setInt("ranktype", v);
906 }
907
908 // #define ND_rw(n) (((Agnodeinfo_t*)AGDATA(n))->rw)
909 public static double ND_rw(__ptr__ n) {
910 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).rw;
911 }
912
913 public static void ND_rw(ST_Agnode_s n, double v) {
914 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setDouble("rw", v);
915 }
916
917 // #define ND_save_in(n) (((Agnodeinfo_t*)AGDATA(n))->save_in)
918 public static ST_elist ND_save_in(ST_Agnode_s n) {
919 return (ST_elist) ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).save_in;
920 }
921
922 public static void ND_save_in(ST_Agnode_s n, __struct__<ST_elist> v) {
923 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setStruct("save_in", v);
924 }
925
926 // #define ND_save_out(n) (((Agnodeinfo_t*)AGDATA(n))->save_out)
927 public static ST_elist ND_save_out(ST_Agnode_s n) {
928 return (ST_elist) ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).save_out;
929 }
930
931 public static void ND_save_out(ST_Agnode_s n, __struct__<ST_elist> v) {
932 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setStruct("save_out", v);
933 }
934
935 // #define ND_shape(n) (((Agnodeinfo_t*)AGDATA(n))->shape)
936 public static ST_shape_desc ND_shape(ST_Agnode_s n) {
937 return ((ST_Agnodeinfo_t) AGDATA(n).castTo(ST_Agnodeinfo_t.class)).shape;
938 }
939
940 public static void ND_shape(ST_Agnode_s n, __ptr__ v) {
941 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setPtr("shape", v);
942 }
943
944 // #define ND_shape_info(n) (((Agnodeinfo_t*)AGDATA(n))->shape_info)
945 public static __ptr__ ND_shape_info(__ptr__ n) {
946 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).shape_info;
947 }
948
949 // #define ND_showboxes(n) (((Agnodeinfo_t*)AGDATA(n))->showboxes)
950 public static int ND_showboxes(ST_Agnode_s n) {
951 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).showboxes;
952 }
953
954 public static void ND_showboxes(ST_Agnode_s n, int v) {
955 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setInt("showboxes", v);
956 }
957
958 // #define ND_state(n) (((Agnodeinfo_t*)AGDATA(n))->state)
959 // #define ND_clustnode(n) (((Agnodeinfo_t*)AGDATA(n))->clustnode)
960 // #define ND_tree_in(n) (((Agnodeinfo_t*)AGDATA(n))->tree_in)
961 public static ST_elist ND_tree_in(ST_Agnode_s n) {
962 return (ST_elist) ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).tree_in;
963 }
964
965 // #define ND_tree_out(n) (((Agnodeinfo_t*)AGDATA(n))->tree_out)
966 public static ST_elist ND_tree_out(ST_Agnode_s n) {
967 return (ST_elist) ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).tree_out;
968 }
969
970 // #define ND_weight_class(n) (((Agnodeinfo_t*)AGDATA(n))->weight_class)
971 public static int ND_weight_class(ST_Agnode_s n) {
972 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).weight_class;
973 }
974
975 public static void ND_weight_class(ST_Agnode_s n, int v) {
976 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setInt("weight_class", v);
977 }
978
979 // #define ND_width(n) (((Agnodeinfo_t*)AGDATA(n))->width)
980 public static double ND_width(__ptr__ n) {
981 return ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).width;
982 }
983
984 public static void ND_width(ST_Agnode_s n, double v) {
985 ((ST_Agnodeinfo_t)AGDATA(n).castTo(ST_Agnodeinfo_t.class)).setDouble("width", v);
986 }
987
988 // #define ND_xsize(n) (ND_lw(n)+ND_rw(n))
989 // #define ND_ysize(n) (ND_ht(n))
990
991 // #define ED_alg(e) (((Agedgeinfo_t*)AGDATA(e))->alg)
992 // #define ED_conc_opp_flag(e) (((Agedgeinfo_t*)AGDATA(e))->conc_opp_flag)
993 public static boolean ED_conc_opp_flag(ST_Agedge_s e) {
994 return ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).conc_opp_flag;
995 }
996
997 public static void ED_conc_opp_flag(ST_Agedge_s e, boolean v) {
998 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setInt("conc_opp_flag", v ? 1 : 0);
999 }
1000
1001 // #define ED_count(e) (((Agedgeinfo_t*)AGDATA(e))->count)
1002 public static int ED_count(__ptr__ e) {
1003 return ((ST_Agedgeinfo_t) AGDATA(e).castTo(ST_Agedgeinfo_t.class)).count;
1004 }
1005
1006 public static void ED_count(__ptr__ e, int v) {
1007 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setInt("count", v);
1008 }
1009
1010 // #define ED_cutvalue(e) (((Agedgeinfo_t*)AGDATA(e))->cutvalue)
1011 public static int ED_cutvalue(ST_Agedge_s e) {
1012 return ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).cutvalue;
1013 }
1014
1015 public static void ED_cutvalue(ST_Agedge_s e, int v) {
1016 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setInt("cutvalue", v);
1017 }
1018
1019 // #define ED_edge_type(e) (((Agedgeinfo_t*)AGDATA(e))->edge_type)
1020 // #define ED_adjacent(e) (((Agedgeinfo_t*)AGDATA(e))->adjacent)
1021 public static int ED_adjacent(__ptr__ e) {
1022 return ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).adjacent;
1023 }
1024
1025 public static void ED_adjacent(ST_Agedge_s e, int v) {
1026 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setInt("adjacent", v);
1027 }
1028
1029 // #define ED_factor(e) (((Agedgeinfo_t*)AGDATA(e))->factor)
1030 // #define ED_gui_state(e) (((Agedgeinfo_t*)AGDATA(e))->gui_state)
1031 // #define ED_head_label(e) (((Agedgeinfo_t*)AGDATA(e))->head_label)
1032 public static ST_textlabel_t ED_head_label(ST_Agedge_s e) {
1033 return (ST_textlabel_t) ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).head_label;
1034 }
1035
1036 public static void ED_head_label(ST_Agedge_s e, __ptr__ v) {
1037 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setPtr("head_label", v);
1038 }
1039
1040 // #define ED_head_port(e) (((Agedgeinfo_t*)AGDATA(e))->head_port)
1041 public static ST_port ED_head_port(__ptr__ e) {
1042 return (ST_port) ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).head_port;
1043 }
1044
1045 public static void ED_head_port(ST_Agedge_s e, ST_port v) {
1046 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setStruct("head_port", v);
1047 }
1048
1049 // #define ED_label(e) (((Agedgeinfo_t*)AGDATA(e))->label)
1050 public static ST_textlabel_t ED_label(__ptr__ e) {
1051 return (ST_textlabel_t) ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).label;
1052 }
1053
1054 public static void ED_label(ST_Agedge_s e, __ptr__ v) {
1055 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setPtr("label", v);
1056 }
1057
1058 // #define ED_xlabel(e) (((Agedgeinfo_t*)AGDATA(e))->xlabel)
1059 public static ST_textlabel_t ED_xlabel(ST_Agedge_s e) {
1060 return (ST_textlabel_t) ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).xlabel;
1061 }
1062
1063 // #define ED_label_ontop(e) (((Agedgeinfo_t*)AGDATA(e))->label_ontop)
1064 public static boolean ED_label_ontop(ST_Agedge_s e) {
1065 return ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).label_ontop;
1066 }
1067
1068 public static void ED_label_ontop(ST_Agedge_s e, boolean v) {
1069 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).label_ontop = v;
1070 }
1071
1072 // #define ED_minlen(e) (((Agedgeinfo_t*)AGDATA(e))->minlen)
1073 public static int ED_minlen(ST_Agedge_s e) {
1074 return ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).minlen;
1075 }
1076
1077 public static void ED_minlen(ST_Agedge_s e, int v) {
1078 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setInt("minlen", v);
1079 }
1080
1081 // #define ED_path(e) (((Agedgeinfo_t*)AGDATA(e))->path)
1082 // #define ED_showboxes(e) (((Agedgeinfo_t*)AGDATA(e))->showboxes)
1083 public static int ED_showboxes(ST_Agedge_s e) {
1084 return ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).showboxes;
1085 }
1086
1087 public static void ED_showboxes(ST_Agedge_s e, int v) {
1088 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setInt("showboxes", v);
1089 }
1090
1091 // #define ED_spl(e) (((Agedgeinfo_t*)AGDATA(e))->spl)
1092 public static ST_splines ED_spl(ST_Agedge_s e) {
1093 return ((ST_Agedgeinfo_t) AGDATA(e).castTo(ST_Agedgeinfo_t.class)).spl;
1094 }
1095
1096 public static void ED_spl(ST_Agedge_s e, ST_splines v) {
1097 ((ST_Agedgeinfo_t) AGDATA(e).castTo(ST_Agedgeinfo_t.class)).spl = v;
1098 }
1099
1100 // #define ED_tail_label(e) (((Agedgeinfo_t*)AGDATA(e))->tail_label)
1101 public static ST_textlabel_t ED_tail_label(ST_Agedge_s e) {
1102 return (ST_textlabel_t) ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).tail_label;
1103 }
1104
1105 public static void ED_tail_label(ST_Agedge_s e, __ptr__ v) {
1106 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setPtr("tail_label", v);
1107 }
1108
1109 // #define ED_tail_port(e) (((Agedgeinfo_t*)AGDATA(e))->tail_port)
1110 public static ST_port ED_tail_port(__ptr__ e) {
1111 return (ST_port) ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).tail_port;
1112 }
1113
1114 public static void ED_tail_port(ST_Agedge_s e, ST_port v) {
1115 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setStruct("tail_port", v);
1116 }
1117
1118 // #define ED_to_orig(e) (((Agedgeinfo_t*)AGDATA(e))->to_orig)
1119 public static ST_Agedge_s ED_to_orig(__ptr__ e) {
1120 return (ST_Agedge_s) ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).to_orig;
1121 }
1122
1123 public static void ED_to_orig(ST_Agedge_s e, __ptr__ v) {
1124 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setPtr("to_orig", v);
1125 }
1126
1127 // #define ED_to_virt(e) (((Agedgeinfo_t*)AGDATA(e))->to_virt)
1128 public static ST_Agedge_s ED_to_virt(ST_Agedge_s e) {
1129 return (ST_Agedge_s) ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).to_virt;
1130 }
1131
1132 public static void ED_to_virt(ST_Agedge_s e, __ptr__ v) {
1133 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setPtr("to_virt", v);
1134 }
1135
1136 // #define ED_tree_index(e) (((Agedgeinfo_t*)AGDATA(e))->tree_index)
1137 public static int ED_tree_index(__ptr__ e) {
1138 return ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).tree_index;
1139 }
1140
1141 public static void ED_tree_index(__ptr__ e, int v) {
1142 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setInt("tree_index", v);
1143 }
1144
1145 // #define ED_xpenalty(e) (((Agedgeinfo_t*)AGDATA(e))->xpenalty)
1146 public static int ED_xpenalty(__ptr__ e) {
1147 return ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).xpenalty;
1148 }
1149
1150 public static void ED_xpenalty(ST_Agedge_s e, int v) {
1151 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setInt("xpenalty", v);
1152 }
1153
1154 // #define ED_dist(e) (((Agedgeinfo_t*)AGDATA(e))->dist)
1155 public static double ED_dist(ST_Agedge_s e) {
1156 return ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).dist;
1157 }
1158
1159 public static void ED_dist(ST_Agedge_s e, double v) {
1160 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setDouble("dist", v);
1161 }
1162
1163 // #define ED_weight(e) (((Agedgeinfo_t*)AGDATA(e))->weight)
1164 public static int ED_weight(ST_Agedge_s e) {
1165 return ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).weight;
1166 }
1167
1168 public static void ED_weight(ST_Agedge_s e, int v) {
1169 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setInt("weight", v);
1170 }
1171
1172 //
1173 // #define ED_alg(e) (((Agedgeinfo_t*)AGDATA(e))->alg)
1174 // #define ED_conc_opp_flag(e) (((Agedgeinfo_t*)AGDATA(e))->conc_opp_flag)
1175 // #define ED_count(e) (((Agedgeinfo_t*)AGDATA(e))->count)
1176 // #define ED_cutvalue(e) (((Agedgeinfo_t*)AGDATA(e))->cutvalue)
1177 // #define ED_edge_type(e) (((Agedgeinfo_t*)AGDATA(e))->edge_type)
1178 public static int ED_edge_type(ST_Agedge_s e) {
1179 return ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).edge_type;
1180 }
1181
1182 public static void ED_edge_type(ST_Agedge_s e, int v) {
1183 ((ST_Agedgeinfo_t)AGDATA(e).castTo(ST_Agedgeinfo_t.class)).setInt("edge_type", v);
1184 }
1185
1186 // #define ED_adjacent(e) (((Agedgeinfo_t*)AGDATA(e))->adjacent)
1187 // #define ED_factor(e) (((Agedgeinfo_t*)AGDATA(e))->factor)
1188 // #define ED_gui_state(e) (((Agedgeinfo_t*)AGDATA(e))->gui_state)
1189 // #define ED_head_label(e) (((Agedgeinfo_t*)AGDATA(e))->head_label)
1190 // #define ED_head_port(e) (((Agedgeinfo_t*)AGDATA(e))->head_port)
1191 // #define ED_label(e) (((Agedgeinfo_t*)AGDATA(e))->label)
1192 // #define ED_xlabel(e) (((Agedgeinfo_t*)AGDATA(e))->xlabel)
1193 // #define ED_label_ontop(e) (((Agedgeinfo_t*)AGDATA(e))->label_ontop)
1194 // #define ED_minlen(e) (((Agedgeinfo_t*)AGDATA(e))->minlen)
1195 // #define ED_path(e) (((Agedgeinfo_t*)AGDATA(e))->path)
1196 // #define ED_showboxes(e) (((Agedgeinfo_t*)AGDATA(e))->showboxes)
1197 // #define ED_spl(e) (((Agedgeinfo_t*)AGDATA(e))->spl)
1198 // #define ED_tail_label(e) (((Agedgeinfo_t*)AGDATA(e))->tail_label)
1199 // #define ED_tail_port(e) (((Agedgeinfo_t*)AGDATA(e))->tail_port)
1200 // #define ED_to_orig(e) (((Agedgeinfo_t*)AGDATA(e))->to_orig)
1201 // #define ED_to_virt(e) (((Agedgeinfo_t*)AGDATA(e))->to_virt)
1202 // #define ED_tree_index(e) (((Agedgeinfo_t*)AGDATA(e))->tree_index)
1203 // #define ED_xpenalty(e) (((Agedgeinfo_t*)AGDATA(e))->xpenalty)
1204 // #define ED_dist(e) (((Agedgeinfo_t*)AGDATA(e))->dist)
1205 // #define ED_weight(e) (((Agedgeinfo_t*)AGDATA(e))->weight)
1206
1207 // #define elist_fastapp(item,L) do {L.list[L.size++] = item; L.list[L.size] = NULL;} while(0)
1208
1209 // #define ALLOC(size,ptr,type) (ptr? (type*)realloc(ptr,(size)*sizeof(type)):(type*)malloc((size)*sizeof(type)))
1210
1211 public static ST_Agedge_s.ArrayOfStar ALLOC_allocated_ST_Agedge_s(ST_Agedge_s.ArrayOfStar old, int size) {
1212 return old != null ? old.reallocJ(size) : new ST_Agedge_s.ArrayOfStar(size);
1213 }
1214
1215 public static ST_Agnode_s.ArrayOfStar ALLOC_allocated_ST_Agnode_s(ST_Agnode_s.ArrayOfStar old, int size) {
1216 return old != null ? old.reallocJ(size) : new ST_Agnode_s.ArrayOfStar(size);
1217 }
1218
1219 public static ST_pointf.Array ALLOC_allocated_ST_pointf(ST_pointf.Array old, int size) {
1220 return old != null ? old.reallocJ(size) : new ST_pointf.Array(size);
1221 }
1222
1223 public static ST_Pedge_t.Array ALLOC_allocated_ST_Pedge_t(ST_Pedge_t.Array old, int size) {
1224 return old != null ? old.reallocJ(size) : new ST_Pedge_t.Array(size);
1225 }
1226
1227 public static __ptr__ ALLOC_INT(int size, __ptr__ ptr) {
1228 return (__ptr__) (ptr != null ? JUtils.size_t_array_of_integer(size).realloc(ptr) : JUtils
1229 .size_t_array_of_integer(size).malloc());
1230 }
1231
1232 // #define RALLOC(size,ptr,type) ((type*)realloc(ptr,(size)*sizeof(type)))
1233 public static __ptr__ RALLOC(int nb, __ptr__ ptr, Class type) {
1234 throw new UnsupportedOperationException();
1235 }
1236
1237 public static ST_Agnode_s.ArrayOfStar ALLOC_Agnode_s(int nb, ST_Agnode_s.ArrayOfStar old) {
1238 if (old == null) {
1239 return new ST_Agnode_s.ArrayOfStar(nb);
1240 }
1241 return old.reallocJ(nb);
1242 }
1243
1244 public static ST_bezier.Array2 ALLOC_ST_bezier(int nb, ST_bezier.Array2 old) {
1245 if (old == null) {
1246 return new ST_bezier.Array2(nb);
1247 }
1248 return old.reallocJ(nb);
1249 }
1250
1251 public static ST_rank_t.Array2 ALLOC_ST_rank_t(int nb, ST_rank_t.Array2 old) {
1252 if (old == null) {
1253 return new ST_rank_t.Array2(nb);
1254 }
1255 return old.reallocJ(nb);
1256 }
1257
1258 // #define elist_append(item,L) do {L.list = ALLOC(L.size + 2,L.list,edge_t*); L.list[L.size++] = item;
1259 // L.list[L.size] = NULL;} while(0)
1260 public static void elist_append(__ptr__ item, ST_elist L) {
1261 // L.setPtr("list", ALLOC_empty(L.size + 2, L.getPtr("list"), Agedge_s.class));
1262 L.realloc(L.size + 2);
1263 L.setInList(L.size, item);
1264 L.size = 1 + L.size;
1265 L.setInList(L.size, null);
1266 }
1267
1268 // #define alloc_elist(n,L) do {L.size = 0; L.list = N_NEW(n + 1,edge_t*); } while (0)
1269 public static void alloc_elist(int n, ST_elist L) {
1270 L.size = 0;
1271 L.mallocEmpty(n + 1);
1272 // L.setPtr("list", (__ptr__) JUtils.sizeof_starstar_empty(cl, n + 1).malloc());
1273 }
1274
1275 // #define free_list(L) do {if (L.list) free(L.list);} while (0)
1276 public static void free_list(ST_elist L) {
1277 if (L.listNotNull())
1278 L.free();
1279 // Memory.free(L.getPtr("list"));
1280 }
1281
1282 public static double ABS(double a) {
1283 return Math.abs(a);
1284 }
1285
1286 public static int ABS(int a) {
1287 return Math.abs(a);
1288 }
1289
1290 public static double MAX(double a, double b) {
1291 return Math.max(a, b);
1292 }
1293
1294 public static int MAX(int a, int b) {
1295 return Math.max(a, b);
1296 }
1297
1298 public static double MIN(double a, double b) {
1299 return Math.min(a, b);
1300 }
1301
1302 public static int MIN(int a, int b) {
1303 return Math.min(a, b);
1304 }
1305
1306 // #define BETWEEN(a,b,c) (((a) <= (b)) && ((b) <= (c)))
1307 public static boolean BETWEEN(double a, double b, double c) {
1308 return (((a) <= (b)) && ((b) <= (c)));
1309 }
1310
1311 public static boolean BETWEEN(int a, int b, int c) {
1312 return (((a) <= (b)) && ((b) <= (c)));
1313 }
1314
1315 // #define ROUND(f) ((f>=0)?(int)(f + .5):(int)(f - .5))
1316 public static int ROUND(double f) {
1317 return ((f >= 0) ? (int) (f + .5) : (int) (f - .5));
1318 }
1319
1320 // #define MAKEFWDEDGE(new, old) { \
1321 // edge_t *newp; \
1322 // Agedgeinfo_t *info; \
1323 // newp = new; \
1324 // info = (Agedgeinfo_t*)newp->base.data; \
1325 // *info = *(Agedgeinfo_t*)old->base.data; \
1326 // *newp = *old; \
1327 // newp->base.data = (Agrec_t*)info; \
1328 // AGTAIL(newp) = AGHEAD(old); \
1329 // AGHEAD(newp) = AGTAIL(old); \
1330 // ED_tail_port(newp) = ED_head_port(old); \
1331 // ED_head_port(newp) = ED_tail_port(old); \
1332 // ED_edge_type(newp) = VIRTUAL; \
1333 // ED_to_orig(newp) = old; \
1334
1335 public static void MAKEFWDEDGE(ST_Agedge_s new_, ST_Agedge_s old) {
1336 ST_Agedge_s newp;
1337 ST_Agedgeinfo_t info;
1338 newp = (ST_Agedge_s) new_.getPtr();
1339 info = (ST_Agedgeinfo_t) newp.base.data.castTo(ST_Agedgeinfo_t.class);
1340 info.copyDataFrom(old.base.data.castTo(ST_Agedgeinfo_t.class).getStruct());
1341 newp.copyDataFrom((__ptr__)old);
1342 newp.base.setPtr("data", info);
1343 agtail(newp, AGHEAD(old));
1344 aghead(newp, AGTAIL(old));
1345 ED_tail_port(newp, ED_head_port(old));
1346 ED_head_port(newp, ED_tail_port(old));
1347 ED_edge_type(newp, VIRTUAL);
1348 ED_to_orig(newp, old);
1349 }
1350
1351 // #define VIRTUAL 1 /* virtual nodes in long edge chains */
1352 public static final int VIRTUAL = 1;
1353
1354 // #define ZALLOC(size,ptr,type,osize) (ptr?
1355 // (type*)zrealloc(ptr,size,sizeof(type),osize):(type*)zmalloc((size)*sizeof(type)))
1356
1357 public static ST_textspan_t.Array ZALLOC_ST_textspan_t(ST_textspan_t.Array old, int size) {
1358 return old != null ? old.reallocJ(size) : new ST_textspan_t.Array(size);
1359 }
1360
1361 public static ST_Agraph_s.Array ZALLOC_ST_Agraph_s(ST_Agraph_s.Array old, int size) {
1362 return old != null ? old.reallocJ(size) : new ST_Agraph_s.Array(size);
1363 }
1364
1365 public static final int MAXSHORT = 0x7fff;
1366
1367 public static final int INT_MAX = Integer.MAX_VALUE;
1368 // #define INT_MIN (-INT_MAX - 1)
1369 public static final int INT_MIN = Integer.MIN_VALUE;
1370 static {
1371 if (INT_MIN != -INT_MAX - 1) {
1372 throw new IllegalStateException();
1373 }
1374 }
1375
1376 public static final double HUGE_VAL = Double.POSITIVE_INFINITY;
1377
1378 public static double fabs(double x) {
1379 return Math.abs(x);
1380 }
1381
1382 public static double hypot(double x, double y) {
1383 double t;
1384 x = Math.abs(x);
1385 y = Math.abs(y);
1386 t = Math.min(x, y);
1387 x = Math.max(x, y);
1388 t = t / x;
1389 return x * Math.sqrt(1 + t * t);
1390 }
1391
1392 // #define SQR(a) ((a) * (a))
1393 public static double SQR(double a) {
1394 return a * a;
1395 }
1396
1397 // #define MILLIPOINT .001
1398 // #define MICROPOINT .000001
1399 public static double MILLIPOINT = .001;
1400 public static double MICROPOINT = .000001;
1401
1402 // #define APPROXEQPT(p,q,tol) (DIST2((p),(q)) < SQR(tol))
1403 public static boolean APPROXEQPT(ST_pointf p, ST_pointf q, double tol) {
1404 return (DIST2((p), (q)) < SQR(tol));
1405 }
1406
1407 // #define LEN2(a,b) (SQR(a) + SQR(b))
1408 public static double LEN2(double a, double b) {
1409 return (SQR(a) + SQR(b));
1410 }
1411
1412 // #define LEN(a,b) (sqrt(LEN2((a),(b))))
1413 public static double LEN(double a, double b) {
1414 return (Math.sqrt(LEN2((a), (b))));
1415 }
1416
1417 //
1418 // #define DIST2(p,q) (LEN2(((p).x - (q).x),((p).y - (q).y)))
1419 public static double DIST2(ST_pointf p, ST_pointf q) {
1420 return (LEN2(((p).x - (q).x), ((p).y - (q).y)));
1421 }
1422
1423 // #define DIST(p,q) (sqrt(DIST2((p),(q))))
1424
1425 // #define INSIDE(p,b) (BETWEEN((b).LL.x,(p).x,(b).UR.x) && BETWEEN((b).LL.y,(p).y,(b).UR.y))
1426 public static boolean INSIDE(ST_pointf p, ST_boxf b) {
1427 return (BETWEEN(b.LL.x, p.x, b.UR.x) && BETWEEN(b.LL.y, p.y, b.UR.y));
1428 }
1429
1430 public static final double M_PI = Math.PI;
1431 // #define SQRT2 1.41421356237309504880
1432 public static final double SQRT2 = Math.sqrt(2);
1433
1434 // #define RADIANS(deg) ((deg)/180.0 * M_PI)
1435 public static double RADIANS(double deg) {
1436 return ((deg) / 180.0 * M_PI);
1437 }
1438
1439 // #define DISTSQ(a, b) ( \
1440 // (((a).x - (b).x) * ((a).x - (b).x)) + (((a).y - (b).y) * ((a).y - (b).y)) \
1441 // )
1442
1443 public static double DISTSQ(ST_pointf a, ST_pointf b) {
1444 return (((a).x - (b).x) * ((a).x - (b).x))
1445 + (((a).y - (b).y) * ((a).y - (b).y));
1446 }
1447
1448 public static void hackInitDimensionFromLabel(ST_pointf size, String label) {
1449 if (label.matches("_dim_\\d+_\\d+_")) {
1450 Pattern p = Pattern.compile("_dim_(\\d+)_(\\d+)_");
1451 Matcher m = p.matcher(label);
1452 if (m.matches() == false) {
1453 throw new IllegalStateException();
1454 }
1455 int ww = Integer.parseInt(m.group(1));
1456 int hh = Integer.parseInt(m.group(2));
1457 size.setDouble("x", ww);
1458 size.setDouble("y", hh);
1459 JUtils.LOG2("Hacking dimension to width=" + ww + " height=" + hh);
1460 }
1461 }
1462
1463 public static CString createHackInitDimensionFromLabel(int width, int height) {
1464 return new CString("_dim_" + width + "_" + height + "_");
1465 }
1466 }