Changed license to LGPLv3.
[javainspect.git] / src / test / java / eu / svjatoslav / inspector / java / structure / example / RenderJavaInspect.java
1 /*
2  * JavaInspect - Utility to visualize java software
3  * Copyright (C) 2013-2014, 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.structure.example;
11
12 import java.io.FileNotFoundException;
13
14 import eu.svjatoslav.inspector.java.structure.ClassGraph;
15 import eu.svjatoslav.inspector.java.structure.Utils;
16
17 public class RenderJavaInspect {
18
19         private static void fullProjectExample() {
20                 final ClassGraph graph = new ClassGraph();
21
22                 // Recursively scan current directory for Java source code and attempt
23                 // to detect class names from there to be added to the graph.
24                 graph.addProject(".");
25
26                 // Blacklist example classes from being shown on the graph
27                 graph.getFilter().blacklistClassPattern(
28                                 "eu.svjatoslav.inspector.java.structure.example.*");
29
30                 // do not show single classes with no relationships on the graph
31                 graph.hideOrphanedClasses();
32
33                 // Produce bitmap image titled "JavaInspect full project.png" to the
34                 // user Desktop directory.
35                 graph.generateGraph("JavaInspect full project");
36         }
37
38         private static void handpickClassesExample() {
39                 /*
40                  * This example demonstrates generating of class graph from hand picked
41                  * classes.
42                  */
43
44                 // Create graph
45                 final ClassGraph graph = new ClassGraph();
46
47                 // While classes and objects can be immediately passed to ClassGraph
48                 // constructor as arguments, it is also possible to add then one by one
49                 // as in the following example.
50
51                 // Add some object to the graph.
52                 graph.addObject(graph);
53
54                 // Add some class to the graph.
55                 graph.addClass(Utils.class);
56
57                 // Produce bitmap image titled "JavaInspect.png" to the user Desktop
58                 // directory and keep intermediary GraphViz DOT file for reference.
59                 graph.generateGraph("JavaInspect", true);
60         }
61
62         public static void main(final String[] args) throws FileNotFoundException {
63
64                 handpickClassesExample();
65
66                 fullProjectExample();
67
68         }
69 }