2424import java .awt .image .BufferedImage ;
2525import java .io .*;
2626
27+ import static guru .nidi .graphviz .attribute .Attributes .attr ;
2728import static guru .nidi .graphviz .attribute .Label .Justification .LEFT ;
2829import static guru .nidi .graphviz .attribute .Rank .RankDir .LEFT_TO_RIGHT ;
2930import static guru .nidi .graphviz .attribute .Records .rec ;
@@ -48,12 +49,16 @@ void ex1() throws IOException {
4849 //## basic
4950 Graph g = graph ("example1" ).directed ()
5051 .graphAttr ().with (Rank .dir (LEFT_TO_RIGHT ))
52+ .nodeAttr ().with (Font .name ("arial" ))
53+ .linkAttr ().with ("class" , "link-class" )
5154 .with (
5255 node ("a" ).with (Color .RED ).link (node ("b" )),
53- node ("b" ).link (to (node ("c" )).with (Style .DASHED ))
56+ node ("b" ).link (
57+ to (node ("c" )).with (attr ("weight" , 5 ), Style .DASHED )
58+ )
5459 );
5560 Graphviz .fromGraph (g ).height (100 ).render (Format .PNG ).toFile (new File ("example/ex1.png" ));
56- //## end
61+ //##
5762 }
5863
5964 @ Test
@@ -62,7 +67,7 @@ void ex1m() throws IOException {
6267 MutableGraph g = mutGraph ("example1" ).setDirected (true ).add (
6368 mutNode ("a" ).add (Color .RED ).addLink (mutNode ("b" )));
6469 Graphviz .fromGraph (g ).width (200 ).render (Format .PNG ).toFile (new File ("example/ex1m.png" ));
65- //## end
70+ //##
6671 }
6772
6873 @ Test
@@ -74,7 +79,7 @@ void ex1i() throws IOException {
7479 mutNode ("a" ).addLink (mutNode ("b" ));
7580 });
7681 Graphviz .fromGraph (g ).width (200 ).render (Format .PNG ).toFile (new File ("example/ex1i.png" ));
77- //## end
82+ //##
7883 }
7984
8085 @ Test
@@ -100,7 +105,7 @@ void ex2() throws IOException {
100105 init .link (mkString ));
101106
102107 Graphviz .fromGraph (g ).width (900 ).render (Format .PNG ).toFile (new File ("example/ex2.png" ));
103- //## end
108+ //##
104109 }
105110
106111 @ Test
@@ -127,7 +132,7 @@ void ex3() throws IOException {
127132 node2 .link (between (port ("p" ), node6 .port (NORTH_WEST ))),
128133 node4 .link (between (port ("p" ), node7 .port (SOUTH_WEST ))));
129134 Graphviz .fromGraph (g ).width (900 ).render (Format .PNG ).toFile (new File ("example/ex3.png" ));
130- //## end
135+ //##
131136 }
132137
133138 @ Test
@@ -146,7 +151,7 @@ void ex4() throws IOException {
146151 Style .lineWidth (4 ).and (Style .FILLED )));
147152 Graphviz .fromGraph (g ).width (700 ).render (Format .PNG ).toFile (new File ("example/ex4-2.png" ));
148153 }
149- //## end
154+ //##
150155 }
151156
152157 @ Test
@@ -163,7 +168,7 @@ void ex5() throws IOException {
163168 String dot = viz .render (Format .DOT ).toString ();
164169 String json = viz .engine (Engine .NEATO ).render (Format .JSON ).toString ();
165170 BufferedImage image = viz .render (Format .PNG ).toImage ();
166- //## end
171+ //##
167172 end ();
168173 init ();
169174 }
@@ -176,7 +181,7 @@ void ex7() throws IOException {
176181 Graphviz g = Graphviz .fromGraph (graph ()
177182 .with (node (Label .html ("<table border='0'><tr><td><img src='graphviz.png' /></td></tr></table>" ))));
178183 g .basedir (new File ("example" )).render (Format .PNG ).toFile (new File ("example/ex7.png" ));
179- //## img
184+ //##
180185 }
181186
182187 @ Test
@@ -185,7 +190,7 @@ void ex8() throws IOException {
185190 Graphviz g = Graphviz .fromGraph (graph ()
186191 .with (node (" " ).with (Size .std ().margin (.8 , .7 ), Image .of ("graphviz.png" ))));
187192 g .basedir (new File ("example" )).render (Format .PNG ).toFile (new File ("example/ex8.png" ));
188- //## image
193+ //##
189194 }
190195
191196 @ Test
@@ -199,7 +204,7 @@ void ex9() throws IOException {
199204 SvgElementFinder .use (svg , finder -> {
200205 finder .findNode ("unicorn" ).setAttribute ("class" , "pink" );
201206 })));
202- g .basedir ( new File ( "example" )). render (Format .PNG ).toFile (new File ("example/ex9.png" ));
203- //## image
207+ g .render (Format .PNG ).toFile (new File ("example/ex9.png" ));
208+ //##
204209 }
205210}
0 commit comments