summaryrefslogtreecommitdiff
path: root/src/smetana/core/JUtils.java
blob: d3ae213753f17067b07fe4933bbc0107beb90e11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
/* ========================================================================
 * PlantUML : a free UML diagram generator
 * ========================================================================
 *
 * Project Info:  http://plantuml.com
 * 
 * If you like this project or if you find it useful, you can support us at:
 * 
 * http://plantuml.com/patreon (only 1$ per month!)
 * http://plantuml.com/paypal
 * 
 * This file is part of Smetana.
 * Smetana is a partial translation of Graphviz/Dot sources from C to Java.
 *
 * (C) Copyright 2009-2020, Arnaud Roques
 *
 * This translation is distributed under the same Licence as the original C program.
 * 
 * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
 * LICENSE ("AGREEMENT"). [Eclipse Public License - v 1.0]
 * 
 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
 * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
 * 
 * You may obtain a copy of the License at
 * 
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package smetana.core;

import h.Agcbstack_s;
import h.Agdstate_s;
import h.Agiodisc_s;
import h.GVCOMMON_t;
import h.LeafList_t;
import h.ST_Agattr_s;
import h.ST_Agcbstack_s;
import h.ST_Agclos_s;
import h.ST_Agdatadict_s;
import h.ST_Agdesc_s;
import h.ST_Agdisc_s;
import h.ST_Agdstate_s;
import h.ST_Agedge_s;
import h.ST_Agedgeinfo_t;
import h.ST_Agedgepair_s;
import h.ST_Agiddisc_s;
import h.ST_Agiodisc_s;
import h.ST_Agmemdisc_s;
import h.ST_Agnode_s;
import h.ST_Agnodeinfo_t;
import h.ST_Agobj_s;
import h.ST_Agraph_s;
import h.ST_Agraphinfo_t;
import h.ST_Agrec_s;
import h.ST_Agsubnode_s;
import h.ST_Agsym_s;
import h.ST_GVCOMMON_t;
import h.ST_GVC_s;
import h.ST_HDict_t;
import h.ST_IMapEntry_t;
import h.ST_LeafList_t;
import h.ST_Node_t___;
import h.ST_Pedge_t;
import h.ST_Ppoly_t;
import h.ST_RTree;
import h.ST_XLabels_t;
import h.ST_arrowtype_t;
import h.ST_aspect_t;
import h.ST_bezier;
import h.ST_boxf;
import h.ST_cinfo_t;
import h.ST_dt_s;
import h.ST_dtdata_s;
import h.ST_dtdisc_s;
import h.ST_dthold_s;
import h.ST_dtlink_s;
import h.ST_dtmethod_s;
import h.ST_elist;
import h.ST_fontinfo;
import h.ST_label_params_t;
import h.ST_layout_t;
import h.ST_nlist_t;
import h.ST_nodequeue;
import h.ST_object_t;
import h.ST_pack_info;
import h.ST_path;
import h.ST_pathend_t;
import h.ST_pointf;
import h.ST_pointnlink_t;
import h.ST_polygon_t;
import h.ST_port;
import h.ST_rank_t;
import h.ST_refstr_t;
import h.ST_shape_desc;
import h.ST_shape_functions;
import h.ST_splineInfo;
import h.ST_spline_info_t;
import h.ST_splines;
import h.ST_tedge_t;
import h.ST_textfont_t;
import h.ST_textlabel_t;
import h.ST_textspan_t;
import h.ST_tna_t;
import h.ST_triangle_t;
import h.ST_xlabel_t;
import h.ST_dthold_s;
import h.layout_t;
import h.rank_t;
import h.tedge_t;

import java.util.LinkedHashSet;
import java.util.Set;

import smetana.core.amiga.StarArrayOfInteger;
import smetana.core.amiga.StarStruct;

// http://docs.oracle.com/javase/specs/jls/se5.0/html/expressions.html#15.7.4
// http://www.jbox.dk/sanos/source/lib/string.c.html

public class JUtils {

	public static int USHRT_MAX = 65535;

	public static size_t sizeof(Class cl) {
		return new size_t_struct(cl);
	}

	public static size_t sizeof(String name, int sz) {
		if (name.equals("char*")) {
			return new size_t_array_of_charstars(sz);
		}
		throw new UnsupportedOperationException();
	}

	public static size_t size_t_array_of_integer(int nb) {
		return new size_t_array_of_integer(nb);
	}

	public static int strcmp(CString s1, CString s2) {
		return s1.compareTo(s2);
	}

	public static int strncmp(CString s1, CString s2, int n) {
		return s1.compareTo(s2, n);
	}

	public static CString strstr(CString s1, CString s2) {
		throw new UnsupportedOperationException("s1=" + s1 + " s2=" + s2);
	}

	public static void strncpy(CString destination, CString source, int nb) {
		destination.copyFrom(source, nb);
	}

	public static CString strchr(CString str, char c) {
		return str.strchr(c);
	}

	public static int strtol(CString str, CString[] endptr, int base) {
		if (base != 10) {
			throw new IllegalArgumentException();
		}
		CString end = str;
		int result = Integer.parseInt(end.getContent());
		endptr[0] = end.plus(("" + result).length());
		return result;
	}

	public static double strtod(CString str, CString[] endptr) {
		final double result = Double.parseDouble(str.getContent());
		return result;
	}

	public static double atof(CString str) {
		return Double.parseDouble(str.getContent());
	}

	public static int memcmp(__ptr__ s1, __ptr__ s2, int sz) {
		throw new UnsupportedOperationException("s1=" + s1 + " s2=" + s2 + " sz=" + sz);
	}

	public static void memset(__ptr__ obj, int value, size_t nbytes) {
		if (value != 0) {
			throw new UnsupportedOperationException();
		}
	}

	public static int strlen(CString s) {
		return s.length();
	}

	public static double abs(double x) {
		return Math.abs(x);
	}

	public static double cos(double x) {
		return Math.cos(x);
	}

	public static double sin(double x) {
		return Math.sin(x);
	}

	public static double sqrt(double x) {
		return Math.sqrt(x);
	}

	public static double atan2(double a, double b) {
		return Math.atan2(a, b);
	}

	public static double pow(double a, double b) {
		return Math.pow(a, b);
	}

	public static boolean isdigit(char c) {
		return Character.isDigit(c);
	}

	public static int atoi(CString s) {
		return Integer.parseInt(s.getContent());
	}

	public static char tolower(char c) {
		return Character.toLowerCase(c);
	}

	public static CFunction function(Class codingClass, String name) {
		return CFunctionImpl.create(codingClass, name);
	}

	public static int enumAsInt(Class enumClass, String name) {
		CEnumInterpretor interpretor = new CEnumInterpretor(enumClass);
		final int result = interpretor.valueOf(name);
		JUtils.LOG("result for " + name + " is " + result);
		return result;
	}

	public static CString getenv(CString var) {
		return null;
	}

	public static void LOG(String s) {
		// System.err.println(s);
	}

	public static void LOG2(String s) {
		// System.err.println(s);
	}

	public static boolean EQ(Object o1, Object o2) {
		final boolean result = EQ_(o1, o2);
		if (o1 instanceof UnsupportedStarStruct && o2 instanceof UnsupportedStarStruct) {
			UnsupportedStarStruct ooo1 = (UnsupportedStarStruct) o1;
			UnsupportedStarStruct ooo2 = (UnsupportedStarStruct) o2;
			if ((ooo1.UID == ooo2.UID) != result) {
				// throw new UnsupportedOperationException();
			}
		}
		return result;
	}

	private static boolean EQ_(Object o1, Object o2) {
		if (o1 == o2) {
			return true;
		}
		if (o1 == null && o2 != null) {
			return false;
		}
		if (o2 == null && o1 != null) {
			return false;
		}
		// if (o1 instanceof AreaArray && o2 instanceof AreaArray) {
		// return ((AreaArray) o1).isSameThan((AreaArray) o2);
		// }
		if (o1 instanceof ST_pointnlink_t && o2 instanceof ST_pointnlink_t) {
			return ((ST_pointnlink_t) o1).isSameThan((ST_pointnlink_t) o2);
		}
		if (o1 instanceof ST_object_t && o2 instanceof ST_object_t) {
			return ((ST_object_t) o1).isSameThan((ST_object_t) o2);
		}
		if (o1 instanceof StarStruct && o2 instanceof StarStruct) {
			// System.err.println("o1="+o1.getClass());
			// System.err.println("o2="+o2.getClass());
			return ((StarStruct) o1).isSameThan((StarStruct) o2);
		}
		if (o1 instanceof CString && o2 instanceof CString) {
			return ((CString) o1).isSameThan((CString) o2);
		}
		if (o1 instanceof ST_Agnode_s.ArrayOfStar && o2 instanceof ST_Agnode_s.ArrayOfStar) {
			return ((ST_Agnode_s.ArrayOfStar) o1).isSameThan2((ST_Agnode_s.ArrayOfStar) o2);
		}
		// if (o1 instanceof StarStar && o2 instanceof StarArrayOfPtr) {
		// __ptr__ o1b = ((StarStar) o1).getPtr();
		// __ptr__ o2b = ((StarArrayOfPtr) o2).getPtr();
		// if (((StarStruct) o1b).getRealClass() != ((StarStruct) o2b).getRealClass()) {
		// throw new UnsupportedOperationException();
		// }
		// return EQ(o1b, o2b);
		// }
		System.err.println("o1=" + o1.getClass() + " " + o1);
		System.err.println("o2=" + o2.getClass() + " " + o2);
		throw new UnsupportedOperationException();
	}

	public static boolean NEQ(Object o1, Object o2) {
		return EQ(o1, o2) == false;
	}

	public static void qsort(__ptr__ array, int nb, CFunction compare) {
		if (nb <= 1) {
			return;
		}
		JUtils.LOG("array=" + array);
		JUtils.LOG("nb=" + nb);
		JUtils.LOG("compare=" + compare);
		boolean change;
		do {
			change = false;
			for (int i = 0; i < nb - 1; i++) {
				__ptr__ element1 = array.plus(i);
				__ptr__ element2 = array.plus(i + 1);
				Integer cmp = (Integer) compare.exe(element1, element2);
				JUtils.LOG("cmp=" + cmp);
				if (cmp.intValue() > 0) {
					change = true;
					if (array instanceof StarArrayOfInteger) {
						((StarArrayOfInteger) array).swap(i, i + 1);
						// } else if (array instanceof STStarArrayOfPointer) {
						// ((STStarArrayOfPointer) array).swap(i, i + 1);
					} else if (array instanceof ST_Agnode_s.ArrayOfStar) {
						((ST_Agnode_s.ArrayOfStar) array).swap(i, i + 1);
					} else if (array instanceof ST_Agedge_s.ArrayOfStar) {
						((ST_Agedge_s.ArrayOfStar) array).swap(i, i + 1);
					} else {
						throw new UnsupportedOperationException();
						// ((StarStar) array).swap(i, i + 1);
					}
				}
			}
		} while (change);
		for (int i = 0; i < nb - 1; i++) {
			__ptr__ element1 = array.plus(i);
			__ptr__ element2 = array.plus(i + 1);
			JUtils.LOG("element1=" + element1);
			JUtils.LOG("element2=" + element2);
			Integer cmp = (Integer) compare.exe(element1, element2);
			JUtils.LOG("cmp=" + cmp);
			if (cmp.intValue() > 0) {
				throw new IllegalStateException();
			}
		}
	}

	static public int setjmp(jmp_buf jmp) {
		// if (jmp.hasBeenCalled()) {
		// throw new UnsupportedOperationException();
		// }
		jmp.saveCallingEnvironment();
		return 0;
	}

	// DEBUG

	public static void printDebugEdge(ST_Agedge_s e) {
		System.err.println("*********** PRINT EDGE ********** ");
		final ST_Agedgeinfo_t data = (ST_Agedgeinfo_t) Macro.AGDATA(e).castTo(ST_Agedgeinfo_t.class);
		final ST_splines splines = (ST_splines) data.spl;
		// ST_boxf bb = (ST_boxf) splines.bb;
		final ST_bezier list = splines.list.getPtr();
		System.err.println("splines.size=" + splines.size);
		//System.err.println("bb.LL=" + pointftoString(bb.LL));
		//System.err.println("bb.UR=" + pointftoString(bb.UR));
		printDebugBezier((ST_bezier) splines.list.getPtr());

	}

	private static String pointftoString(ST_pointf point) {
		final StringBuilder sb = new StringBuilder();
		sb.append("(");
		sb.append(point.x);
		sb.append(" ; ");
		sb.append(point.y);
		sb.append(")");
		return sb.toString();
	}

	private static void printDebugBezier(ST_bezier bezier) {
		System.err.println("bezier.size=" + bezier.size);
		System.err.println("bezier.sflag=" + bezier.sflag);
		System.err.println("splines.eflag=" + bezier.eflag);
		System.err.println("bezier.sp=" + pointftoString(bezier.sp));
		System.err.println("bezier.ep=" + pointftoString(bezier.ep));
		for (int i = 0; i < bezier.size; i++) {
			final ST_pointf pt = bezier.list.get(i);
			System.err.println("pt=" + pointftoString(pt));
		}
	}

	public static <C extends __ptr__> __struct__<C> from(Class<C> theClass) {
		if (theClass == ST_dtmethod_s.class) {
			return new ST_dtmethod_s();
		}
		if (theClass == ST_dtdisc_s.class) {
			return new ST_dtdisc_s();
		}
		if (theClass == ST_Agdesc_s.class) {
			return new ST_Agdesc_s();
		}
		// if (theClass == Agtag_s.class) {
		// return new ST_Agtag_s();
		// }
		if (theClass == ST_Agiddisc_s.class) {
			return new ST_Agiddisc_s();
		}
		if (theClass == ST_Agmemdisc_s.class) {
			return new ST_Agmemdisc_s();
		}
		if (theClass == ST_nlist_t.class) {
			return new ST_nlist_t();
		}
		if (theClass == ST_arrowtype_t.class) {
			return new ST_arrowtype_t();
		}
		if (theClass == ST_elist.class) {
			return new ST_elist();
		}
		if (theClass == ST_pointf.class) {
			return new ST_pointf();
		}
		if (theClass == ST_boxf.class) {
			return new ST_boxf();
		}
		if (theClass == ST_port.class) {
			return new ST_port();
		}
		if (theClass == ST_polygon_t.class) {
			return new ST_polygon_t();
		}
		if (theClass == ST_shape_functions.class) {
			return new ST_shape_functions();
		}
		if (theClass == ST_shape_desc.class) {
			return new ST_shape_desc();
		}
		// if (theClass == deque_t.class) {
		// return new ST_deque_t();
		// }
		// if (theClass == pointnlink_t.class) {
		// return new ST_pointnlink_t();
		// }
		if (theClass == ST_Ppoly_t.class) {
			return new ST_Ppoly_t();
		}
		if (theClass == ST_splineInfo.class) {
			return new ST_splineInfo();
		}
		if (theClass == ST_textfont_t.class) {
			return new ST_textfont_t();
		}
		//
		// if (UmlDiagram.SMETANA_BETA) {
		if (theClass == ST_Agsubnode_s.class) {
			return new ST_Agsubnode_s();
		}
		if (theClass == ST_dtlink_s.class) {
			return new ST_dtlink_s();
		}
		if (theClass == ST_refstr_t.class) {
			return new ST_refstr_t();
		}
		if (theClass == ST_refstr_t.class) {
			return new ST_refstr_t();
		}
		if (theClass == ST_Agsym_s.class) {
			return new ST_Agsym_s();
		}
		if (theClass == ST_Agedge_s.class) {
			return new ST_Agedge_s();
		}
		if (theClass == ST_Agobj_s.class) {
			return new ST_Agobj_s();
		}
		if (theClass == ST_Agrec_s.class) {
			return new ST_Agrec_s();
		}
		if (theClass == ST_Agraph_s.class) {
			return new ST_Agraph_s();
		}
		if (theClass == ST_Agclos_s.class) {
			return new ST_Agclos_s();
		}
		if (theClass == ST_Agdisc_s.class) {
			return new ST_Agdisc_s();
		}
		if (theClass == Agdstate_s.class) {
			return new ST_Agdstate_s();
		}
		if (theClass == Agiodisc_s.class) {
			return new ST_Agiodisc_s();
		}
		if (theClass == ST_dt_s.class) {
			return new ST_dt_s();
		}
		if (theClass == ST_dtdata_s.class) {
			return new ST_dtdata_s();
		}
		if (theClass == ST_Agdatadict_s.class) {
			return new ST_Agdatadict_s();
		}
		if (theClass == ST_Agattr_s.class) {
			return new ST_Agattr_s();
		}
		if (theClass == Agcbstack_s.class) {
			return new ST_Agcbstack_s();
		}
		if (theClass == ST_Agnode_s.class) {
			return new ST_Agnode_s();
		}
		if (theClass == ST_Agedgepair_s.class) {
			return new ST_Agedgepair_s();
		}
		if (theClass == ST_Agraphinfo_t.class) {
			return new ST_Agraphinfo_t();
		}
		if (theClass == ST_GVC_s.class) {
			return new ST_GVC_s();
		}
		if (theClass == GVCOMMON_t.class) {
			return new ST_GVCOMMON_t();
		}
		// if (theClass == ST_gvlayout_engine_s.class) {
		// return new ST_gvlayout_engine_s();
		// }
		// if (theClass == gvlayout_features_t.class) {
		// return new ST_gvlayout_features_t();
		// }
		// if (theClass == gvplugin_active_layout_t.class) {
		// return new ST_gvplugin_active_layout_t();
		// }
		// if (theClass == gvplugin_installed_t.class) {
		// return new ST_gvplugin_installed_t();
		// }
		if (theClass == layout_t.class) {
			return new ST_layout_t();
		}
		if (theClass == ST_Agnodeinfo_t.class) {
			return new ST_Agnodeinfo_t();
		}
		if (theClass == ST_textlabel_t.class) {
			return new ST_textlabel_t();
		}
		if (theClass == ST_textspan_t.class) {
			return new ST_textspan_t();
		}
		if (theClass == rank_t.class) {
			return new ST_rank_t();
		}
		// if (theClass == adjmatrix_t.class) {
		// return new ST_adjmatrix_t();
		// }
		if (theClass == ST_Agedgeinfo_t.class) {
			return new ST_Agedgeinfo_t();
		}
		if (theClass == ST_splines.class) {
			return new ST_splines();
		}
		if (theClass == ST_bezier.class) {
			return new ST_bezier();
		}
		if (theClass == ST_dthold_s.class) {
			return new ST_dthold_s();
		}
		//
		if (theClass == ST_pack_info.class) {
			return new ST_pack_info();
		}
		if (theClass == ST_aspect_t.class) {
			return new ST_aspect_t();
		}
		if (theClass == ST_fontinfo.class) {
			return new ST_fontinfo();
		}
		if (theClass == ST_IMapEntry_t.class) {
			return new ST_IMapEntry_t();
		}
		// if (theClass == point.class) {
		// return new ST_point();
		// }
		if (theClass == ST_nodequeue.class) {
			return new ST_nodequeue();
		}
		if (theClass == ST_spline_info_t.class) {
			return new ST_spline_info_t();
		}
		if (theClass == ST_path.class) {
			return new ST_path();
		}
		if (theClass == ST_pathend_t.class) {
			return new ST_pathend_t();
		}
		// if (theClass == inside_t.class) {
		// return new ST_inside_t();
		// }
		if (theClass == ST_triangle_t.class) {
			return new ST_triangle_t();
		}
		if (theClass == tedge_t.class) {
			return new ST_tedge_t();
		}
		if (theClass == ST_Pedge_t.class) {
			return new ST_Pedge_t();
		}
		if (theClass == ST_tna_t.class) {
			return new ST_tna_t();
		}
		if (theClass == ST_label_params_t.class) {
			return new ST_label_params_t();
		}
		if (theClass == ST_object_t.class) {
			return new ST_object_t();
		}
		if (theClass == ST_xlabel_t.class) {
			return new ST_xlabel_t();
		}
		if (theClass == ST_XLabels_t.class) {
			return new ST_XLabels_t();
		}
		if (theClass == ST_HDict_t.class) {
			return new ST_HDict_t();
		}
		if (theClass == ST_RTree.class) {
			return new ST_RTree();
		}
		if (theClass == ST_Node_t___.class) {
			return new ST_Node_t___();
		}
		if (theClass == ST_cinfo_t.class) {
			return new ST_cinfo_t();
		}
		// }
		notFound(theClass);
		throw new UnsupportedOperationException();
	}

	public static StarStruct create(Class theClass, StarStruct parent) {
		if (theClass == ST_dtmethod_s.class) {
			throw new IllegalArgumentException(theClass.toString());
		}
		if (theClass == ST_dtdisc_s.class) {
			return new ST_dtdisc_s(parent);
		}
		if (theClass == ST_Agdesc_s.class) {
			return new ST_Agdesc_s(parent);
		}
		if (theClass == ST_nlist_t.class) {
			return new ST_nlist_t(parent);
		}
		if (theClass == ST_elist.class) {
			return new ST_elist(parent);
		}
		if (theClass == ST_pointf.class) {
			return new ST_pointf(parent);
		}
		if (theClass == ST_boxf.class) {
			return new ST_boxf(parent);
		}
		if (theClass == ST_port.class) {
			return new ST_port(parent);
		}
		if (theClass == ST_polygon_t.class) {
			return new ST_polygon_t(parent);
		}
		if (theClass == ST_shape_functions.class) {
			return new ST_shape_functions(parent);
		}
		if (theClass == ST_shape_desc.class) {
			return new ST_shape_desc(parent);
		}
		// if (theClass == deque_t.class) {
		// return new ST_deque_t(parent);
		// }
		// if (theClass == pointnlink_t.class) {
		// return new ST_pointnlink_t(parent);
		// }
		if (theClass == ST_Ppoly_t.class) {
			return new ST_Ppoly_t(parent);
		}
		if (theClass == ST_splineInfo.class) {
			return new ST_splineInfo(parent);
		}
		if (theClass == ST_textfont_t.class) {
			return new ST_textfont_t(parent);
		}
		//
		// if (UmlDiagram.SMETANA_BETA) {
		if (theClass == ST_Agsubnode_s.class) {
			return new ST_Agsubnode_s(parent);
		}
		if (theClass == ST_dtlink_s.class) {
			return new ST_dtlink_s(parent);
		}
		if (theClass == ST_refstr_t.class) {
			return new ST_refstr_t();
		}
		if (theClass == ST_refstr_t.class) {
			return new ST_refstr_t();
		}
		if (theClass == ST_Agsym_s.class) {
			return new ST_Agsym_s(parent);
		}
		if (theClass == ST_Agedge_s.class) {
			return new ST_Agedge_s(parent);
		}
		if (theClass == ST_Agobj_s.class) {
			return new ST_Agobj_s(parent);
		}
		if (theClass == ST_Agrec_s.class) {
			return new ST_Agrec_s(parent);
		}
		if (theClass == ST_Agraph_s.class) {
			return new ST_Agraph_s(parent);
		}
		if (theClass == ST_Agclos_s.class) {
			return new ST_Agclos_s(parent);
		}
		if (theClass == ST_Agdisc_s.class) {
			return new ST_Agdisc_s(parent);
		}
		if (theClass == Agdstate_s.class) {
			return new ST_Agdstate_s(parent);
		}
		if (theClass == ST_dt_s.class) {
			return new ST_dt_s(parent);
		}
		if (theClass == ST_dtdata_s.class) {
			return new ST_dtdata_s(parent);
		}
		if (theClass == ST_Agdatadict_s.class) {
			return new ST_Agdatadict_s(parent);
		}
		if (theClass == ST_Agattr_s.class) {
			return new ST_Agattr_s(parent);
		}
		if (theClass == Agcbstack_s.class) {
			return new ST_Agcbstack_s(parent);
		}
		if (theClass == ST_Agnode_s.class) {
			return new ST_Agnode_s(parent);
		}
		if (theClass == ST_Agedgepair_s.class) {
			return new ST_Agedgepair_s(parent);
		}
		if (theClass == ST_Agraphinfo_t.class) {
			return new ST_Agraphinfo_t(parent);
		}
		if (theClass == ST_GVC_s.class) {
			return new ST_GVC_s(parent);
		}
		if (theClass == GVCOMMON_t.class) {
			return new ST_GVCOMMON_t(parent);
		}
		// if (theClass == ST_gvlayout_engine_s.class) {
		// throw new UnsupportedOperationException();
		// // return new ST_gvlayout_engine_s(parent);
		// }
		// if (theClass == gvlayout_features_t.class) {
		// throw new UnsupportedOperationException();
		// // return new ST_gvlayout_features_t(parent);
		// }
		// if (theClass == gvplugin_active_layout_t.class) {
		// throw new UnsupportedOperationException();
		// // return new ST_gvplugin_active_layout_t(parent);
		// }
		// if (theClass == gvplugin_installed_t.class) {
		// return new ST_gvplugin_installed_t(parent);
		// }
		if (theClass == layout_t.class) {
			return new ST_layout_t(parent);
		}
		if (theClass == ST_Agnodeinfo_t.class) {
			return new ST_Agnodeinfo_t(parent);
		}
		if (theClass == ST_textlabel_t.class) {
			return new ST_textlabel_t(parent);
		}
		if (theClass == ST_textspan_t.class) {
			return new ST_textspan_t(parent);
		}
		if (theClass == rank_t.class) {
			return new ST_rank_t(parent);
		}
		// if (theClass == adjmatrix_t.class) {
		// return new ST_adjmatrix_t(parent);
		// }
		if (theClass == ST_Agedgeinfo_t.class) {
			return new ST_Agedgeinfo_t(parent);
		}
		if (theClass == ST_splines.class) {
			return new ST_splines(parent);
		}
		if (theClass == ST_bezier.class) {
			return new ST_bezier(parent);
		}
		if (theClass == ST_dthold_s.class) {
			return new ST_dthold_s(parent);
		}
		//
		if (theClass == ST_pack_info.class) {
			return new ST_pack_info(parent);
		}
		if (theClass == ST_aspect_t.class) {
			return new ST_aspect_t(parent);
		}
		if (theClass == ST_fontinfo.class) {
			return new ST_fontinfo(parent);
		}
		if (theClass == ST_IMapEntry_t.class) {
			return new ST_IMapEntry_t(parent);
		}
		// if (theClass == point.class) {
		// return new ST_point(parent);
		// }
		if (theClass == ST_nodequeue.class) {
			return new ST_nodequeue(parent);
		}
		if (theClass == ST_spline_info_t.class) {
			return new ST_spline_info_t(parent);
		}
		if (theClass == ST_path.class) {
			return new ST_path(parent);
		}
		if (theClass == ST_pathend_t.class) {
			return new ST_pathend_t(parent);
		}
		// if (theClass == inside_t.class) {
		// return new ST_inside_t(parent);
		// }
		if (theClass == ST_triangle_t.class) {
			return new ST_triangle_t(parent);
		}
		if (theClass == tedge_t.class) {
			return new ST_tedge_t(parent);
		}
		if (theClass == ST_Pedge_t.class) {
			return new ST_Pedge_t(parent);
		}
		if (theClass == ST_tna_t.class) {
			return new ST_tna_t(parent);
		}
		if (theClass == ST_label_params_t.class) {
			return new ST_label_params_t(parent);
		}
		if (theClass == ST_object_t.class) {
			return new ST_object_t(parent);
		}
		if (theClass == ST_xlabel_t.class) {
			return new ST_xlabel_t(parent);
		}
		if (theClass == ST_XLabels_t.class) {
			return new ST_XLabels_t(parent);
		}
		if (theClass == ST_HDict_t.class) {
			return new ST_HDict_t(parent);
		}
		if (theClass == ST_RTree.class) {
			return new ST_RTree(parent);
		}
		if (theClass == ST_Node_t___.class) {
			return new ST_Node_t___(parent);
		}
		if (theClass == ST_cinfo_t.class) {
			return new ST_cinfo_t(parent);
		}
		// }
		notFound(theClass);
		throw new UnsupportedOperationException();
	}

	private static final Set<String> todo = new LinkedHashSet<String>();

	private static void notFound(Class theClass) {
		todo.add(theClass.getName());
		System.err.println("todo=" + todo);
	}

}