c33c8a9bf558ee8888dc45f8b9e76781532e0382
[javainspect.git] / src / main / java / eu / svjatoslav / inspector / java / RenderJavaInspect.java
1 /*
2  * JavaInspect - Utility to visualize java software
3  * Copyright (C) 2013-2015, 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 import java.io.FileNotFoundException;
16
17 public class RenderJavaInspect {
18
19     private static void fullProjectExample() {
20         // Create graph
21         final ClassGraph graph = new ClassGraph();
22
23         // Recursively scan current directory for Java source code and attempt
24         // to detect class names from there to be added to the graph.
25         graph.addProject(".");
26
27         // do not show single classes with no relationships on the graph
28         graph.hideOrphanedClasses();
29
30         // Produce SVG image titled "JavaInspect full project.png" to the
31         // user Desktop directory.
32         graph.generateGraph("JavaInspect full project");
33     }
34
35     private static void handpickClassesExample() {
36         /*
37          * This example demonstrates generating of class graph from hand picked
38                  * classes and visualizing GraphViz itself.
39                  */
40
41         // Create graph
42         final ClassGraph graph = new ClassGraph();
43
44         // Add some random object to the graph. GraphViz will detect Class from
45         // the object.
46         graph.add(graph);
47
48         // Also add some random class to the graph.
49         graph.add(Utils.class);
50
51         // Keep intermediary GraphViz DOT file for reference.
52         graph.setKeepDotFile(true);
53
54         // Produce SVG image titled "JavaInspect.svg" to the user Desktop
55         // directory
56         graph.generateGraph("JavaInspect");
57     }
58
59     public static void main(final String[] args) throws FileNotFoundException {
60
61         handpickClassesExample();
62
63         fullProjectExample();
64
65     }
66 }