Reorganized project.
[javainspect.git] / src / main / java / eu / svjatoslav / inspector / java / RenderJavaInspect.java
diff --git a/src/main/java/eu/svjatoslav/inspector/java/RenderJavaInspect.java b/src/main/java/eu/svjatoslav/inspector/java/RenderJavaInspect.java
new file mode 100755 (executable)
index 0000000..c33c8a9
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * JavaInspect - Utility to visualize java software
+ * Copyright (C) 2013-2015, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 3 of the GNU Lesser General Public License
+ * or later as published by the Free Software Foundation.
+ */
+
+package eu.svjatoslav.inspector.java;
+
+import eu.svjatoslav.inspector.java.structure.ClassGraph;
+import eu.svjatoslav.inspector.java.structure.Utils;
+
+import java.io.FileNotFoundException;
+
+public class RenderJavaInspect {
+
+    private static void fullProjectExample() {
+        // Create graph
+        final ClassGraph graph = new ClassGraph();
+
+        // Recursively scan current directory for Java source code and attempt
+        // to detect class names from there to be added to the graph.
+        graph.addProject(".");
+
+        // do not show single classes with no relationships on the graph
+        graph.hideOrphanedClasses();
+
+        // Produce SVG image titled "JavaInspect full project.png" to the
+        // user Desktop directory.
+        graph.generateGraph("JavaInspect full project");
+    }
+
+    private static void handpickClassesExample() {
+        /*
+         * This example demonstrates generating of class graph from hand picked
+                * classes and visualizing GraphViz itself.
+                */
+
+        // Create graph
+        final ClassGraph graph = new ClassGraph();
+
+        // Add some random object to the graph. GraphViz will detect Class from
+        // the object.
+        graph.add(graph);
+
+        // Also add some random class to the graph.
+        graph.add(Utils.class);
+
+        // Keep intermediary GraphViz DOT file for reference.
+        graph.setKeepDotFile(true);
+
+        // Produce SVG image titled "JavaInspect.svg" to the user Desktop
+        // directory
+        graph.generateGraph("JavaInspect");
+    }
+
+    public static void main(final String[] args) throws FileNotFoundException {
+
+        handpickClassesExample();
+
+        fullProjectExample();
+
+    }
+}