88import org .springframework .boot .autoconfigure .SpringBootApplication ;
99
1010import java .io .IOException ;
11+ import java .util .*;
1112
1213@ SpringBootApplication
1314public class DemoApplication implements ApplicationRunner {
@@ -32,20 +33,69 @@ public void run(ApplicationArguments args) throws Exception {
3233
3334 printUser ();
3435
36+ printListGraph ();
37+ }
38+
39+ private void printListGraph () {
40+
41+ Random random = new Random ();
42+ List <Integer > list = new ArrayList <>(128 );
43+ for (int i = 0 ; i < 128 ; i ++) {
44+ list .add (i , random .nextInt (128 ));
45+ }
46+
47+ try {
48+ System .out .println (" ===> GraphLayout.parseInstance(list).toImage(\" list.png\" )" );
49+ GraphLayout .parseInstance (list ).toImage ("list.png" );
50+ } catch (IOException e ) {
51+ throw new RuntimeException (e );
52+ }
53+
54+ Map <String , Integer > map = new HashMap (256 );
55+ for (int i = 0 ; i < 128 ; i ++) {
56+ map .put ("K" + i , i );
57+ }
58+
59+ try {
60+ System .out .println (" ===> GraphLayout.parseInstance(map).toImage(\" map.png\" ))" );
61+ GraphLayout .parseInstance (map ).toImage ("map.png" );
62+ } catch (IOException e ) {
63+ throw new RuntimeException (e );
64+ }
65+
3566 }
3667
3768 private void printUser () {
69+
70+ System .out .println (" ===> ClassLayout.parseInstance(user).toPrintable()" );
3871 User user = new User (true , (byte ) 65 ,12345 , 8888 , 12345678L , 9999999L , "a" );
3972 System .out .println (ClassLayout .parseInstance (user ).toPrintable ());
4073
74+ System .out .println (" ===> GraphLayout.parseInstance(user).toPrintable()" );
4175 System .out .println (GraphLayout .parseInstance (user ).toPrintable ());
76+
77+ System .out .println (" ===> GraphLayout.parseInstance(user).toFootprint()" );
4278 System .out .println (GraphLayout .parseInstance (user ).toFootprint ());
4379
4480// try {
4581// GraphLayout.parseInstance(user).toImage("user.png");
4682// } catch (IOException e) {
4783// e.printStackTrace();
4884// }
85+
86+ User user1 = new User (false , (byte ) 66 ,12346 , 5555 , 12345679L , 888888L , "b" );
87+ Klass klass = new Klass ("Klass1" , Arrays .asList (user ,user1 ));
88+
89+ System .out .println (" ===> ClassLayout.parseInstance(klass).toPrintable()" );
90+ System .out .println (ClassLayout .parseInstance (klass ).toPrintable ());
91+
92+ System .out .println (" ===> GraphLayout.parseInstance(klass).toImage(\" klass.png\" )" );
93+ try {
94+ GraphLayout .parseInstance (klass ,user ,user1 ).toImage ("klass.png" );
95+ } catch (IOException e ) {
96+ throw new RuntimeException (e );
97+ }
98+
4999 }
50100
51101 private void printObject () {
@@ -83,4 +133,14 @@ public User(boolean b1, byte b2, int a, Integer b, long c, Long d, String s) {
83133 private String s ;
84134 }
85135
136+ public static class Klass {
137+ private String klassName ;
138+ private List <User > users ;
139+
140+ public Klass (String klassName , List <User > users ) {
141+ this .klassName = klassName ;
142+ this .users = users ;
143+ }
144+ }
145+
86146}
0 commit comments