X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Feu%2Fsvjatoslav%2Finspector%2Fjava%2Fstructure%2Fexample%2FRenderJavaInspect.java;h=1f388837c1044d4edde2308a09b340891fdd9a3f;hb=9720b6ec40d9b10e5a2df8fad848b82f36451c1b;hp=560c1726dd1a0c7bdc2c9afc584146e34eb07c93;hpb=92162fc60b34f64b1f2570e943ab2cef6db8e54d;p=javainspect.git diff --git a/src/test/java/eu/svjatoslav/inspector/java/structure/example/RenderJavaInspect.java b/src/test/java/eu/svjatoslav/inspector/java/structure/example/RenderJavaInspect.java old mode 100644 new mode 100755 index 560c172..1f38883 --- a/src/test/java/eu/svjatoslav/inspector/java/structure/example/RenderJavaInspect.java +++ b/src/test/java/eu/svjatoslav/inspector/java/structure/example/RenderJavaInspect.java @@ -1,69 +1,69 @@ /* * JavaInspect - Utility to visualize java software - * Copyright (C) 2013, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * 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 2 of the GNU General Public License - * as published by the Free Software Foundation. + * 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.structure.example; -import java.io.FileNotFoundException; - import eu.svjatoslav.inspector.java.structure.ClassGraph; import eu.svjatoslav.inspector.java.structure.Utils; +import java.io.FileNotFoundException; + public class RenderJavaInspect { - public static void main(final String[] args) throws FileNotFoundException { + private static void fullProjectExample() { + // Create graph + final ClassGraph graph = new ClassGraph(); - handpickClassesExample(); + // Recursively scan current directory for Java source code and attempt + // to detect class names from there to be added to the graph. + graph.addProject("."); - fullProjectExample(); + // Blacklist example classes from being shown on the graph + graph.blacklistClassPattern("eu.svjatoslav.inspector.java.structure.example.*"); - } + // do not show single classes with no relationships on the graph + graph.hideOrphanedClasses(); - private static void fullProjectExample() { - final ClassGraph graph = new ClassGraph(); + // Produce bitmap image titled "JavaInspect full project.png" to the + // user Desktop directory. + graph.generateGraph("JavaInspect full project"); + } - // Recursively scan current directory for Java source code and attempt - // to detect class names from there to be added to the graph. - graph.addProject("."); + private static void handpickClassesExample() { + /* + * This example demonstrates generating of class graph from hand picked + * classes and visualizing GraphViz itself. + */ - // Blacklist example classes from being shown on the graph - graph.getFilter().blacklistClassPattern( - "eu.svjatoslav.inspector.java.structure.example.*"); + // Create graph + final ClassGraph graph = new ClassGraph(); - // do not show single classes with no relationships on the graph - graph.hideOrphanedClasses(); + // Add some random object to the graph. GraphViz will detect Class from + // the object. + graph.add(graph); - // Produce bitmap image titled "JavaInspect full project.png" to the - // user Desktop directory. - graph.generateGraph("JavaInspect full project"); - } + // Also add some random class to the graph. + graph.add(Utils.class); - private static void handpickClassesExample() { - /* - * This example demonstrates generating of class graph from hand picked - * classes. - */ + // Keep intermediary GraphViz DOT file for reference. + graph.setKeepDotFile(true); - // Create graph - final ClassGraph graph = new ClassGraph(); + // Produce bitmap image titled "JavaInspect.png" to the user Desktop + // directory + graph.generateGraph("JavaInspect"); + } - // While classes and objects can be immediately passed to ClassGraph - // constructor as arguments, it is also possible to add then one by one - // as in the following example. + public static void main(final String[] args) throws FileNotFoundException { - // Add some object to the graph. - graph.addObject(graph); + handpickClassesExample(); - // Add some class to the graph. - graph.addClass(Utils.class); + fullProjectExample(); - // Produce bitmap image titled "JavaInspect.png" to the user Desktop - // directory and keep intermediary GraphViz DOT file for reference. - graph.generateGraph("JavaInspect", true); - } + } }