From 7525c42e636be80e34c890337859bf5f243ed0e8 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Tue, 3 Mar 2015 22:29:52 +0200 Subject: [PATCH] updated example code --- doc/index.org | 33 +++++++++++-------- .../structure/example/RenderJavaInspect.java | 9 +++-- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/doc/index.org b/doc/index.org index 873b0dd..0e768ad 100644 --- a/doc/index.org +++ b/doc/index.org @@ -85,25 +85,32 @@ Control code in general does the following: ** example 1 This example demonstrates generating of class graph from hand picked -classes. +classes and visualizing GraphViz itself. #+BEGIN_SRC java - // Create graph - final ClassGraph graph = new ClassGraph(); - // While classes and objects can be immediately passed to ClassGraph - // constructor as arguments, it is also possible to add them one by - // one as in the following example. +// Create graph +final ClassGraph graph = new ClassGraph(); - // Add some object to the graph. - graph.addObject(graph); +// Add some random object to the graph. GraphViz will detect Class from +// the object. +graph.add(graph); - // Add some class to the graph. - graph.addClass(Utils.class); +// Also add some random class to the graph. +graph.add(Utils.class); + +// Keep intermediary GraphViz DOT file for reference. +graph.setKeepDotFile(true); + +// Produce bitmap image titled "JavaInspect.png" to the user Desktop +// directory +graph.generateGraph("JavaInspect"); + +#+END_SRC + +Note: if needed, this code can be very compactly written too: +#+BEGIN_SRC java - // Produce bitmap image titled "JavaInspect.png" to the user Desktop - // directory and keep intermediary GraphViz DOT file for reference. - graph.generateGraph("JavaInspect", true); #+END_SRC 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 index 181ac09..2f535b1 100755 --- a/src/test/java/eu/svjatoslav/inspector/java/structure/example/RenderJavaInspect.java +++ b/src/test/java/eu/svjatoslav/inspector/java/structure/example/RenderJavaInspect.java @@ -47,12 +47,15 @@ public class RenderJavaInspect { // the object. graph.add(graph); - // Add some random class to the graph. + // Also add some random class to the graph. graph.add(Utils.class); + // Keep intermediary GraphViz DOT file for reference. + graph.setKeepDotFile(true); + // Produce bitmap image titled "JavaInspect.png" to the user Desktop - // directory and keep intermediary GraphViz DOT file for reference. - graph.setKeepDotFile(true).generateGraph("JavaInspect"); + // directory + graph.generateGraph("JavaInspect"); } public static void main(final String[] args) throws FileNotFoundException { -- 2.20.1