c4e3717d907519d3b64c79293146d09529810394
[javainspect.git] / src / main / java / eu / svjatoslav / inspector / java / RenderJavaInspect.java
1 /*
2  * JavaInspect - Utility to visualize java software
3  * Copyright (C) 2013-2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of version 3 of the GNU Lesser General Public License
7  * or later as published by the Free Software Foundation.
8  */
9
10 package eu.svjatoslav.inspector.java;
11
12 import eu.svjatoslav.inspector.java.structure.ClassGraph;
13 import eu.svjatoslav.inspector.java.structure.Utils;
14
15 public class RenderJavaInspect {
16
17     private static void fullProjectExample() {
18         // Create graph
19         final ClassGraph graph = new ClassGraph();
20
21         // Recursively scan current directory for Java source code and attempt
22         // to detect class names from there to be added to the graph.
23         graph.addProject(".");
24
25         // do not show single classes with no relationships on the graph
26         graph.hideOrphanedClasses();
27
28         // Produce SVG image titled "JavaInspect full project.png" to the
29         // user Desktop directory.
30         graph.generateGraph("JavaInspect full project");
31     }
32
33     private static void handpickClassesExample() {
34         /*
35          * This example demonstrates generating of class graph from hand picked
36          * classes and visualizing GraphViz itself.
37          */
38
39         // Create graph
40         final ClassGraph graph = new ClassGraph();
41
42         // Add some random object to the graph. GraphViz will detect Class from
43         // the object.
44         graph.add(graph);
45
46         // Also add some random class to the graph.
47         graph.add(Utils.class);
48
49         // Keep intermediary GraphViz DOT file for reference.
50         graph.setKeepDotFile(true);
51
52         // Produce SVG image titled "JavaInspect.svg" to the user Desktop
53         // directory
54         graph.generateGraph("JavaInspect");
55     }
56
57     public static void main(final String[] args) {
58
59         handpickClassesExample();
60
61         fullProjectExample();
62
63     }
64 }