From: Svjatoslav Agejenko Date: Fri, 13 Sep 2013 21:11:17 +0000 (+0300) Subject: improved project documentation X-Git-Tag: javainspect-1.2~7 X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=javainspect.git;a=commitdiff_plain;h=16ba5341215d24fdcfa07072d52cf87e5a4375ed improved project documentation --- diff --git a/doc/JavaInspect full project.png b/doc/JavaInspect full project.png new file mode 100644 index 0000000..2fb9b51 Binary files /dev/null and b/doc/JavaInspect full project.png differ diff --git a/doc/JavaInspect.dot b/doc/JavaInspect.dot index fc58358..660c81c 100644 --- a/doc/JavaInspect.dot +++ b/doc/JavaInspect.dot @@ -1,186 +1,138 @@ digraph Java { graph [rankdir=LR, overlap = false, concentrate=true]; -// Class: eu.svjatoslav.javainspect.structure.ClassDescriptor - class_eu_svjatoslav_javainspect_structure_ClassDescriptor[label=< +// Class: eu.svjatoslav.inspector.java.structure.Filter + class_eu_svjatoslav_inspector_java_structure_Filter[label=<
// class descriptor header - + // fields: - // methods - - // distinctiveReferenceColor - - // interfaceColor - - // superClass - - // dump - - // MAX_REFERECNES_COUNT - - // nameToFieldMap - - // superClassColor - - // isInterface - - // referenceCount - - // isEnum - - // interfaces - - // fullyQualifiedName - - // isArray - + // blacklistClassPatterns + + // whitelistClassPatterns + // methods: - // getClassName - - // getDot - - // isVisible - - // indexFields - - // areReferencesShown - - // enlistFieldReferences - - // enlistFields - - // getEmbeddedDot - - // enlistImplementedInterfaces - - // getGraphId - - // enlistMethodReferences - - // enlistMethods - - // enlistSuperClass - - // generateDotHeader - - // getBackgroundColor - - // getBorderWidth - - // getPackageName - - // getAllFields - - // getColor - - // getDistinctiveColor - - // setDistinctiveColor - - // registerReference - + // blacklistClassPattern + + // isClassShown + + // whitelistClassPattern +
eu.svjatoslav.javainspect.structure
ClassDescriptor
eu.svjatoslav.inspector.java.structure
Filter
Listmethods
StringdistinctiveReferenceColor
StringinterfaceColor
ClassDescriptorsuperClass
Graphdump
intMAX_REFERECNES_COUNT
MapnameToFieldMap
StringsuperClassColor
booleanisInterface
intreferenceCount
booleanisEnum
Listinterfaces
StringfullyQualifiedName
booleanisArray
ListblacklistClassPatterns
ListwhitelistClassPatterns
StringgetClassName
StringgetDot
booleanisVisible
voidindexFields
booleanareReferencesShown
voidenlistFieldReferences
voidenlistFields
StringgetEmbeddedDot
voidenlistImplementedInterfaces
StringgetGraphId
voidenlistMethodReferences
voidenlistMethods
voidenlistSuperClass
voidgenerateDotHeader
StringgetBackgroundColor
StringgetBorderWidth
StringgetPackageName
ListgetAllFields
StringgetColor
StringgetDistinctiveColor
voidsetDistinctiveColor
voidregisterReference
voidblacklistClassPattern
booleanisClassShown
voidwhitelistClassPattern
>, shape="none"]; // field references to other classes - class_eu_svjatoslav_javainspect_structure_ClassDescriptor:methods -> class_eu_svjatoslav_javainspect_structure_MethodDescriptor[label="methods", color="antiquewhite4", style="bold"]; - class_eu_svjatoslav_javainspect_structure_ClassDescriptor:dump -> class_eu_svjatoslav_javainspect_structure_Graph[label="dump", color="blueviolet", style="bold"]; - class_eu_svjatoslav_javainspect_structure_ClassDescriptor:nameToFieldMap -> class_eu_svjatoslav_javainspect_structure_FieldDescriptor[label="nameToFieldMap", color="brown4", style="bold"]; // method references to other classes - class_eu_svjatoslav_javainspect_structure_ClassDescriptor:getAllFields -> class_eu_svjatoslav_javainspect_structure_FieldDescriptor[label="getAllFields", color="brown4", style="dotted, bold"]; - // interfaces implemented by class: eu.svjatoslav.javainspect.structure.ClassDescriptor - class_eu_svjatoslav_javainspect_structure_GraphElement -> class_eu_svjatoslav_javainspect_structure_ClassDescriptor[style="dotted, tapered", color="olivedrab2", penwidth=20, dir="forward"]; - -// Class: eu.svjatoslav.javainspect.structure.MethodDescriptor - class_eu_svjatoslav_javainspect_structure_MethodDescriptor[label=< +// Class: eu.svjatoslav.inspector.java.structure.FieldDescriptor + class_eu_svjatoslav_inspector_java_structure_FieldDescriptor[label=<
// class descriptor header - + // fields: // name // parent + // type + // typeArguments - // returnType - // methods: // getDot - // isVisible - // getEmbeddedDot // getGraphId - // getMethodLabel - + // getOutsideVisibleReferencesCount + + // isVisible +
eu.svjatoslav.javainspect.structure
MethodDescriptor
eu.svjatoslav.inspector.java.structure
FieldDescriptor
Stringname
ClassDescriptorparent
ClassDescriptortype
ListtypeArguments
ClassDescriptorreturnType
StringgetDot
booleanisVisible
StringgetEmbeddedDot
StringgetGraphId
StringgetMethodLabel
intgetOutsideVisibleReferencesCount
booleanisVisible
>, shape="none"]; // field references to other classes // method references to other classes - // interfaces implemented by class: eu.svjatoslav.javainspect.structure.MethodDescriptor - class_eu_svjatoslav_javainspect_structure_GraphElement -> class_eu_svjatoslav_javainspect_structure_MethodDescriptor[style="dotted, tapered", color="olivedrab2", penwidth=20, dir="forward"]; + // interfaces implemented by class: eu.svjatoslav.inspector.java.structure.FieldDescriptor + class_eu_svjatoslav_inspector_java_structure_GraphElement -> class_eu_svjatoslav_inspector_java_structure_FieldDescriptor[style="dotted, tapered", color="olivedrab2", penwidth=20, dir="forward"]; -// Class: eu.svjatoslav.javainspect.structure.Graph - class_eu_svjatoslav_javainspect_structure_Graph[label=< +// Class: eu.svjatoslav.inspector.java.structure.MethodDescriptor + class_eu_svjatoslav_inspector_java_structure_MethodDescriptor[label=<
// class descriptor header - + // fields: - // nameToClassMap - + // name + + // parent + + // returnType + + // typeArguments + // methods: - // addClass - - // addObject - - // generateGraph - - // generateGraph - + // compareTo + + // compareTo + + // getDot + + // getEmbeddedDot + + // getGraphId + + // getMethodLabel + + // getOutsideVisibleReferencesCount + + // isVisible +
eu.svjatoslav.javainspect.structure
Graph
eu.svjatoslav.inspector.java.structure
MethodDescriptor
MapnameToClassMap
Stringname
ClassDescriptorparent
ClassDescriptorreturnType
ListtypeArguments
ClassDescriptoraddClass
ClassDescriptoraddObject
voidgenerateGraph
voidgenerateGraph
intcompareTo
intcompareTo
StringgetDot
StringgetEmbeddedDot
StringgetGraphId
StringgetMethodLabel
intgetOutsideVisibleReferencesCount
booleanisVisible
>, shape="none"]; // field references to other classes // method references to other classes -// Class: eu.svjatoslav.javainspect.structure.Utils - class_eu_svjatoslav_javainspect_structure_Utils[label=< + // interfaces implemented by class: eu.svjatoslav.inspector.java.structure.MethodDescriptor + class_eu_svjatoslav_inspector_java_structure_GraphElement -> class_eu_svjatoslav_inspector_java_structure_MethodDescriptor[style="dotted, tapered", color="olivedrab2", penwidth=20, dir="forward"]; + +// Class: eu.svjatoslav.inspector.java.structure.Utils + class_eu_svjatoslav_inspector_java_structure_Utils[label=<
// class descriptor header - + // fields: + // darkColors + + // enumMethods + + // lastChosenDarkColor + + // lastChosenLightColor + // lightColors // systemDataTypes - // lastChosenLightColor - - // lastChosenDarkColor - // systemMethods - // enumMethods - - // darkColors - // systemPackages // methods: + // getNextDarkColor + + // getNextLightColor + // initDarkColors // initEnumMethods @@ -193,74 +145,172 @@ graph [rankdir=LR, overlap = false, concentrate=true]; // initSystemPackages - // isSystemMethod - - // getNextDarkColor - - // getNextLightColor - + // isEnumMethod + // isSystemDataType + // isSystemMethod + // isSystemPackage - // isEnumMethod -
eu.svjatoslav.javainspect.structure
Utils
eu.svjatoslav.inspector.java.structure
Utils
ListdarkColors
ListenumMethods
intlastChosenDarkColor
intlastChosenLightColor
ListlightColors
ListsystemDataTypes
intlastChosenLightColor
intlastChosenDarkColor
ListsystemMethods
ListenumMethods
ListdarkColors
ListsystemPackages
StringgetNextDarkColor
StringgetNextLightColor
voidinitDarkColors
voidinitSystemMethods
voidinitSystemPackages
booleanisSystemMethod
StringgetNextDarkColor
StringgetNextLightColor
booleanisEnumMethod
booleanisSystemDataType
booleanisSystemMethod
booleanisSystemPackage
booleanisEnumMethod
>, shape="none"]; // field references to other classes // method references to other classes -// Class: eu.svjatoslav.javainspect.structure.GraphElement - class_eu_svjatoslav_javainspect_structure_GraphElement[label=< +// Class: eu.svjatoslav.inspector.java.structure.GraphElement + class_eu_svjatoslav_inspector_java_structure_GraphElement[label=<
// class descriptor header - + // methods: // getDot - // isVisible - // getEmbeddedDot // getGraphId + // isVisible +
eu.svjatoslav.javainspect.structure
GraphElement
eu.svjatoslav.inspector.java.structure
GraphElement
StringgetDot
booleanisVisible
StringgetEmbeddedDot
StringgetGraphId
booleanisVisible
>, shape="none"]; // method references to other classes -// Class: eu.svjatoslav.javainspect.structure.FieldDescriptor - class_eu_svjatoslav_javainspect_structure_FieldDescriptor[label=< +// Class: eu.svjatoslav.inspector.java.structure.ClassGraph + class_eu_svjatoslav_inspector_java_structure_ClassGraph[label=<
// class descriptor header - + // fields: - // name - - // parent - - // typeArguments - - // type - + // filter + + // nameToClassMap + + + // methods: + // addClass + + // addObject + + // addProject + + // generateGraph + + // generateGraph + + // hideOrphanedClasses + + // render + +
eu.svjatoslav.javainspect.structure
FieldDescriptor
eu.svjatoslav.inspector.java.structure
ClassGraph
Stringname
ClassDescriptorparent
ListtypeArguments
ClassDescriptortype
Filterfilter
MapnameToClassMap
ClassDescriptoraddClass
ClassDescriptoraddObject
voidaddProject
voidgenerateGraph
voidgenerateGraph
voidhideOrphanedClasses
voidrender
>, shape="none"]; + + // field references to other classes + class_eu_svjatoslav_inspector_java_structure_ClassGraph:filter -> class_eu_svjatoslav_inspector_java_structure_Filter[label="filter", color="antiquewhite4", style="bold"]; + + // method references to other classes + +// Class: eu.svjatoslav.inspector.java.structure.ClassDescriptor + class_eu_svjatoslav_inspector_java_structure_ClassDescriptor[label=< + + // class descriptor header + + + // fields: + // MAX_REFERECNES_COUNT + + // classGraph + + // distinctiveReferenceColor + + // fullyQualifiedName + + // incomingReferencesCount + + // interfaceColor + + // interfaces + + // isArray + + // isEnum + + // isInterface + + // isShown + + // methods + + // nameToFieldMap + + // superClass + + // superClassColor + // methods: + // areReferencesShown + + // enlistFieldReferences + + // enlistFields + + // enlistImplementedInterfaces + + // enlistMethodReferences + + // enlistMethods + + // enlistSuperClass + + // generateDotHeader + + // getAllFields + + // getBackgroundColor + + // getBorderWidth + + // getClassName + + // getColor + + // getDistinctiveColor + // getDot - // isVisible - // getEmbeddedDot // getGraphId + // getPackageName + + // getParentClassesName + + // hide + + // hideClassIfNoReferences + + // indexFields + + // isVisible + + // registerReference + + // setDistinctiveColor +
eu.svjatoslav.inspector.java.structure
ClassDescriptor
intMAX_REFERECNES_COUNT
ClassGraphclassGraph
StringdistinctiveReferenceColor
StringfullyQualifiedName
intincomingReferencesCount
StringinterfaceColor
Listinterfaces
booleanisArray
booleanisEnum
booleanisInterface
booleanisShown
SortedSetmethods
MapnameToFieldMap
ClassDescriptorsuperClass
StringsuperClassColor
booleanareReferencesShown
voidenlistFieldReferences
voidenlistFields
voidenlistImplementedInterfaces
voidenlistMethodReferences
voidenlistMethods
voidenlistSuperClass
voidgenerateDotHeader
ListgetAllFields
StringgetBackgroundColor
StringgetBorderWidth
StringgetClassName
StringgetColor
StringgetDistinctiveColor
StringgetDot
booleanisVisible
StringgetEmbeddedDot
StringgetGraphId
StringgetPackageName
StringgetParentClassesName
voidhide
booleanhideClassIfNoReferences
voidindexFields
booleanisVisible
voidregisterReference
voidsetDistinctiveColor
>, shape="none"]; // field references to other classes + class_eu_svjatoslav_inspector_java_structure_ClassDescriptor:classGraph -> class_eu_svjatoslav_inspector_java_structure_ClassGraph[label="classGraph", color="blueviolet", style="bold"]; + class_eu_svjatoslav_inspector_java_structure_ClassDescriptor:methods -> class_eu_svjatoslav_inspector_java_structure_MethodDescriptor[label="methods", color="brown4", style="bold"]; + class_eu_svjatoslav_inspector_java_structure_ClassDescriptor:nameToFieldMap -> class_eu_svjatoslav_inspector_java_structure_FieldDescriptor[label="nameToFieldMap", color="chartreuse4", style="bold"]; // method references to other classes + class_eu_svjatoslav_inspector_java_structure_ClassDescriptor:getAllFields -> class_eu_svjatoslav_inspector_java_structure_FieldDescriptor[label="getAllFields", color="chartreuse4", style="dotted, bold"]; - // interfaces implemented by class: eu.svjatoslav.javainspect.structure.FieldDescriptor - class_eu_svjatoslav_javainspect_structure_GraphElement -> class_eu_svjatoslav_javainspect_structure_FieldDescriptor[style="dotted, tapered", color="olivedrab2", penwidth=20, dir="forward"]; + // interfaces implemented by class: eu.svjatoslav.inspector.java.structure.ClassDescriptor + class_eu_svjatoslav_inspector_java_structure_GraphElement -> class_eu_svjatoslav_inspector_java_structure_ClassDescriptor[style="dotted, tapered", color="olivedrab2", penwidth=20, dir="forward"]; } diff --git a/doc/JavaInspect.png b/doc/JavaInspect.png index 057976b..c4f94b1 100644 Binary files a/doc/JavaInspect.png and b/doc/JavaInspect.png differ diff --git a/doc/index.html b/doc/index.html index 096c1e0..b826e7a 100644 --- a/doc/index.html +++ b/doc/index.html @@ -70,25 +70,31 @@ This software is distributed under -

Usage example

+

Usage example 1

- Following example produces graph for JavaInspect itself: +
+
+		/*
+		 * This example demonstrates generating of class graph from hand picked
+		 * classes.
+		 */
 
-	
+		// Create graph
+		final ClassGraph graph = new ClassGraph();
 
-
-// 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 then one by one
+		// as in the following example.
 
-// Add some object to the graph.
-graph.addObject(graph);
+		// Add some object to the graph.
+		graph.addObject(graph);
 
-// Add some class to the graph.
-graph.addClass(Utils.class);
+		// Add some class to the graph.
+		graph.addClass(Utils.class);
 
-// Produce bitmap image titled "JavaInspect.png" to the user Desktop
-// directory.
-graph.generateGraph("JavaInspect", true);
+		// Produce bitmap image titled "JavaInspect.png" to the user Desktop
+		// directory and keep intermediary GraphViz DOT file for reference.
+		graph.generateGraph("JavaInspect", true);
 
 
 
@@ -99,6 +105,33 @@ Result:
 
+

Usage example 2

+ +
+
+		// Recursively scan current directory for Java source code and attempt
+		// to detect class names from there to be added to the graph.
+		graph.addProject(".");
+
+		// Blacklist example classes from being shown on the graph
+		graph.getFilter().blacklistClassPattern(
+				"eu.svjatoslav.inspector.java.structure.example.*");
+
+		// do not show single classes with no relationships on the graph
+		graph.hideOrphanedClasses();
+
+		// Produce bitmap image titled "JavaInspect full project.png" to the
+		// user Desktop directory.
+		graph.generateGraph("JavaInspect full project");
+
+
+
+Result:
+    Generated PNG image: JavaInspect full project.png
+
+
+ +

Embedding JavaInspect in your project

@@ -112,7 +145,7 @@ Declare JavaInspect as dependency:
         <dependency>
             <groupId>eu.svjatoslav</groupId>
             <artifactId>javainspect</artifactId>
-            <version>1.1</version>
+            <version>1.2</version>
         </dependency>
  
     </dependencies>
diff --git a/src/main/java/eu/svjatoslav/inspector/java/methods/package-info.java b/src/main/java/eu/svjatoslav/inspector/java/methods/package-info.java
new file mode 100644
index 0000000..81febf5
--- /dev/null
+++ b/src/main/java/eu/svjatoslav/inspector/java/methods/package-info.java
@@ -0,0 +1,13 @@
+package eu.svjatoslav.inspector.java.methods;
+
+/**
+ * This package contains quickly hacked together Java language parser.
+ * Goal is to start visualizing method call references and other things
+ * which are not easily readable at runtime via reflection.
+ * 
+ * Work in progress...
+ * 
+ * Currently in is useful just for detecting class names and packages.
+ * 
+ */
+
diff --git a/src/main/java/eu/svjatoslav/inspector/java/structure/ClassDescriptor.java b/src/main/java/eu/svjatoslav/inspector/java/structure/ClassDescriptor.java
index 55ef66c..c0be547 100644
--- a/src/main/java/eu/svjatoslav/inspector/java/structure/ClassDescriptor.java
+++ b/src/main/java/eu/svjatoslav/inspector/java/structure/ClassDescriptor.java
@@ -12,9 +12,11 @@ package eu.svjatoslav.inspector.java.structure;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
 
 /**
  * Describes single class instance
@@ -25,9 +27,9 @@ public class ClassDescriptor implements GraphElement {
 
 	public final String fullyQualifiedName;
 
-	Map nameToFieldMap = new HashMap();
+	Map nameToFieldMap = new TreeMap();
 
-	public List methods = new ArrayList();
+	public SortedSet methods = new TreeSet();
 
 	/**
 	 * Incoming arrows will have this color.
@@ -297,7 +299,7 @@ public class ClassDescriptor implements GraphElement {
 	public String getGraphId() {
 		final String result = "class_"
 				+ fullyQualifiedName.replace('.', '_').replace(";", "")
-						.replace("[L", "").replace('$', '_');
+				.replace("[L", "").replace('$', '_');
 		return result;
 	}
 
@@ -362,11 +364,11 @@ public class ClassDescriptor implements GraphElement {
 
 		for (final MethodDescriptor methodDescriptor : methods)
 			outgoingVisibleReferencesCount += methodDescriptor
-					.getOutsideVisibleReferencesCount();
+			.getOutsideVisibleReferencesCount();
 
 		for (final FieldDescriptor fieldDescriptor : nameToFieldMap.values())
 			outgoingVisibleReferencesCount += fieldDescriptor
-					.getOutsideVisibleReferencesCount();
+			.getOutsideVisibleReferencesCount();
 
 		final int totalReferencesCount = outgoingVisibleReferencesCount
 				+ incomingReferencesCount;
@@ -407,7 +409,7 @@ public class ClassDescriptor implements GraphElement {
 		if (Utils.isSystemPackage(fullyQualifiedName))
 			return false;
 
-		if (!classGraph.filter.isClassShown(fullyQualifiedName))
+		if (!classGraph.getFilter().isClassShown(fullyQualifiedName))
 			return false;
 
 		return isShown;
diff --git a/src/main/java/eu/svjatoslav/inspector/java/structure/ClassGraph.java b/src/main/java/eu/svjatoslav/inspector/java/structure/ClassGraph.java
index 6155876..7bae6f3 100644
--- a/src/main/java/eu/svjatoslav/inspector/java/structure/ClassGraph.java
+++ b/src/main/java/eu/svjatoslav/inspector/java/structure/ClassGraph.java
@@ -35,19 +35,33 @@ public class ClassGraph {
 	 */
 	Map nameToClassMap = new HashMap();
 
-	public Filter filter = new Filter();
+	private Filter filter = new Filter();
 
 	public ClassGraph() {
 	}
 
-	public ClassGraph(final Class clazz) {
-		addClass(clazz);
+	/**
+	 * @param classes
+	 *            classes that shall be added to graph
+	 */
+	public ClassGraph(final Class... classes) {
+		for (final Class clazz : classes)
+			addClass(clazz);
 	}
 
-	public ClassGraph(final Object root) {
-		addClass(root.getClass());
+	/**
+	 * @param objects
+	 *            objects that shall be added to graph
+	 */
+	public ClassGraph(final Object... objects) {
+		for (Object object : objects)
+			addClass(object.getClass());
 	}
 
+	/**
+	 * @param clazz
+	 *            class that shall be added to graph
+	 */
 	public ClassDescriptor addClass(final Class clazz) {
 
 		if (clazz == null)
@@ -61,10 +75,19 @@ public class ClassGraph {
 		return new ClassDescriptor(clazz, this);
 	}
 
+	/**
+	 * @param object
+	 *            object that shall be added to graph
+	 */
 	public ClassDescriptor addObject(final Object object) {
 		return addClass(object.getClass());
 	}
 
+	/**
+	 * @param path
+	 *            path to recursively scan for java source code could be
+	 *            relative to current project or absolute
+	 */
 	public void addProject(final String path) {
 		final ProjectScanner projectScanner = new ProjectScanner(new File(path));
 		for (final Clazz clazz : projectScanner.getAllClasses())
@@ -78,17 +101,34 @@ public class ClassGraph {
 			}
 	}
 
-	public void generateGraph(final String graphName) {
-		generateGraph(graphName, false);
+	/**
+	 * @param resultFileName
+	 *            file name for the generated graph. Existing file with the same
+	 *            name will be overwritten.
+	 */
+	public void generateGraph(final String resultFileName) {
+		generateGraph(resultFileName, false);
 	}
 
-	public void generateGraph(final String graphName, final boolean keepDotFile) {
+	/**
+	 * @param resultFileName
+	 *            file name for the generated graph. File extension will be
+	 *            added automatically. Existing file with the same name will be
+	 *            overwritten.
+	 * 
+	 * @param keepDotFile
+	 *            if set to true then intermediary GraphViz DOT
+	 *            file will be kept.
+	 */
+
+	public void generateGraph(final String resultFileName,
+			final boolean keepDotFile) {
 
 		final String desktopPath = CommonPathResolver.getDesktopDirectory()
 				.getAbsolutePath() + "/";
 
-		final String dotFilePath = desktopPath + graphName + ".dot";
-		final String imageFilePath = desktopPath + graphName + ".png";
+		final String dotFilePath = desktopPath + resultFileName + ".dot";
+		final String imageFilePath = desktopPath + resultFileName + ".png";
 
 		System.out.println("Dot file path:" + dotFilePath);
 
@@ -101,8 +141,8 @@ public class ClassGraph {
 			// execute GraphViz to visualize graph
 			try {
 				Runtime.getRuntime()
-						.exec(new String[] { "dot", "-Tpng", dotFilePath, "-o",
-								imageFilePath }).waitFor();
+				.exec(new String[] { "dot", "-Tpng", dotFilePath, "-o",
+						imageFilePath }).waitFor();
 			} catch (final InterruptedException e) {
 			} finally {
 			}
@@ -133,11 +173,22 @@ public class ClassGraph {
 		return resultStr;
 	}
 
-	public void hideClassesWithoutReferences() {
+	/**
+	 * Hide orphaned class that have no references
+	 */
+	public void hideOrphanedClasses() {
 
 		for (final ClassDescriptor classDescriptor : nameToClassMap.values())
 			classDescriptor.hideClassIfNoReferences();
 
 	}
 
+	public Filter getFilter() {
+		return filter;
+	}
+
+	public void setFilter(Filter filter) {
+		this.filter = filter;
+	}
+
 }
diff --git a/src/main/java/eu/svjatoslav/inspector/java/structure/FieldDescriptor.java b/src/main/java/eu/svjatoslav/inspector/java/structure/FieldDescriptor.java
index e4611aa..42ecfcf 100644
--- a/src/main/java/eu/svjatoslav/inspector/java/structure/FieldDescriptor.java
+++ b/src/main/java/eu/svjatoslav/inspector/java/structure/FieldDescriptor.java
@@ -17,6 +17,10 @@ import java.util.List;
 
 public class FieldDescriptor implements GraphElement {
 
+	/**
+	 * This class corresponds to single field within a java class.
+	 */
+
 	public String name;
 	public ClassDescriptor type;
 	private ClassDescriptor parent;
diff --git a/src/main/java/eu/svjatoslav/inspector/java/structure/Filter.java b/src/main/java/eu/svjatoslav/inspector/java/structure/Filter.java
index 72590f3..0dba93e 100644
--- a/src/main/java/eu/svjatoslav/inspector/java/structure/Filter.java
+++ b/src/main/java/eu/svjatoslav/inspector/java/structure/Filter.java
@@ -7,21 +7,35 @@ import eu.svjatoslav.commons.string.WildCardMatcher;
 
 public class Filter {
 
-	private static final List blacklistedClasses = new ArrayList();
-
-	private static final List whitelistedClasses = new ArrayList();
+	/**
+	 * This class implements filter of classes that will be included or excluded
+	 * from resulting graph.
+	 * 
+	 * Filtering is done by lists of whitelist and blacklist patterns using
+	 * wildcards.
+	 * 
+	 * Filtering logic is such that if at least single whitelist entry is
+	 * defined then every class that is not whitelisted is automatically
+	 * excluded from graph.
+	 * 
+	 * Otherwise every class in included in graph that is not blacklisted.
+	 */
+
+	private static final List blacklistClassPatterns = new ArrayList();
+
+	private static final List whitelistClassPatterns = new ArrayList();
 
 	public void blacklistClassPattern(final String pattern) {
-		blacklistedClasses.add(pattern);
+		blacklistClassPatterns.add(pattern);
 	}
 
 	public boolean isClassShown(final String className) {
-		for (final String pattern : blacklistedClasses)
+		for (final String pattern : blacklistClassPatterns)
 			if (WildCardMatcher.match(className, pattern))
 				return false;
 
-		if (!whitelistedClasses.isEmpty()) {
-			for (final String pattern : whitelistedClasses)
+		if (!whitelistClassPatterns.isEmpty()) {
+			for (final String pattern : whitelistClassPatterns)
 				if (WildCardMatcher.match(className, pattern))
 					return true;
 			return false;
@@ -31,7 +45,7 @@ public class Filter {
 	}
 
 	public void whitelistClassPattern(final String pattern) {
-		whitelistedClasses.add(pattern);
+		whitelistClassPatterns.add(pattern);
 	}
 
 }
diff --git a/src/main/java/eu/svjatoslav/inspector/java/structure/MethodDescriptor.java b/src/main/java/eu/svjatoslav/inspector/java/structure/MethodDescriptor.java
index c3aeaf9..5e03b6b 100644
--- a/src/main/java/eu/svjatoslav/inspector/java/structure/MethodDescriptor.java
+++ b/src/main/java/eu/svjatoslav/inspector/java/structure/MethodDescriptor.java
@@ -15,7 +15,12 @@ import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.List;
 
-public class MethodDescriptor implements GraphElement {
+public class MethodDescriptor implements GraphElement,
+Comparable {
+
+	/**
+	 * This class corresponds to single method within a java class.
+	 */
 
 	public String name;
 	public ClassDescriptor returnType;
@@ -149,4 +154,14 @@ public class MethodDescriptor implements GraphElement {
 		return true;
 	}
 
+	@Override
+	public int compareTo(MethodDescriptor o) {
+
+		int nameComparisonResult = name.compareTo(o.name);
+		if (nameComparisonResult != 0)
+			return nameComparisonResult;
+
+		return toString().compareTo(o.toString());
+	}
+
 }
diff --git a/src/main/java/eu/svjatoslav/inspector/java/structure/example/RenderJavaInspect.java b/src/main/java/eu/svjatoslav/inspector/java/structure/example/RenderJavaInspect.java
index f993e22..560c172 100644
--- a/src/main/java/eu/svjatoslav/inspector/java/structure/example/RenderJavaInspect.java
+++ b/src/main/java/eu/svjatoslav/inspector/java/structure/example/RenderJavaInspect.java
@@ -18,9 +18,44 @@ public class RenderJavaInspect {
 
 	public static void main(final String[] args) throws FileNotFoundException {
 
+		handpickClassesExample();
+
+		fullProjectExample();
+
+	}
+
+	private static void fullProjectExample() {
+		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(".");
+
+		// Blacklist example classes from being shown on the graph
+		graph.getFilter().blacklistClassPattern(
+				"eu.svjatoslav.inspector.java.structure.example.*");
+
+		// do not show single classes with no relationships on the graph
+		graph.hideOrphanedClasses();
+
+		// Produce bitmap 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.
+		 */
+
 		// 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 then one by one
+		// as in the following example.
+
 		// Add some object to the graph.
 		graph.addObject(graph);
 
@@ -28,7 +63,7 @@ public class RenderJavaInspect {
 		graph.addClass(Utils.class);
 
 		// Produce bitmap image titled "JavaInspect.png" to the user Desktop
-		// directory.
+		// directory and keep intermediary GraphViz DOT file for reference.
 		graph.generateGraph("JavaInspect", true);
 	}
 }
diff --git a/src/main/java/eu/svjatoslav/inspector/xml/xsd/Main.java b/src/main/java/eu/svjatoslav/inspector/xml/xsd/Main.java
deleted file mode 100644
index 41e7de6..0000000
--- a/src/main/java/eu/svjatoslav/inspector/xml/xsd/Main.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package eu.svjatoslav.inspector.xml.xsd;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.xml.sax.SAXException;
-
-public class Main {
-
-	public static void main(final String[] args) throws SAXException,
-			IOException, ParserConfigurationException {
-
-		final XSD xsd = new XSD();
-
-		xsd.parse(new FileInputStream("/home/n0/Desktop/MeterSchema.xsd"));
-
-		System.out.println(xsd);
-
-	}
-
-}
diff --git a/src/main/java/eu/svjatoslav/inspector/xml/xsd/XSD.java b/src/main/java/eu/svjatoslav/inspector/xml/xsd/XSD.java
deleted file mode 100644
index 2b60bf4..0000000
--- a/src/main/java/eu/svjatoslav/inspector/xml/xsd/XSD.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package eu.svjatoslav.inspector.xml.xsd;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.xml.sax.SAXException;
-
-import eu.svjatoslav.commons.data.xml.XmlElement;
-import eu.svjatoslav.commons.data.xml.XmlHelper;
-
-public class XSD {
-
-	private static final String XMLNS_PREFIX = "xmlns:";
-	Map namespaces = new HashMap();
-
-	private void detectNamespaces(final XmlElement xsdSchema) {
-		for (final String attributeName : xsdSchema.getAttributeNames())
-
-			if (attributeName.startsWith(XMLNS_PREFIX)) {
-				final String nameSpaceName = attributeName
-						.substring(XMLNS_PREFIX.length());
-				namespaces.put(nameSpaceName,
-						xsdSchema.getAttributeValue(attributeName));
-			}
-	}
-
-	public void parse(final InputStream inputStream) throws SAXException,
-			IOException, ParserConfigurationException {
-
-		final XmlElement xsdSchema = XmlHelper.parseXml(inputStream);
-
-		detectNamespaces(xsdSchema);
-
-		System.out.println(xsdSchema.toString());
-	}
-
-	@Override
-	public String toString() {
-		final StringBuffer result = new StringBuffer();
-
-		result.append("namespaces:\n");
-
-		for (final Map.Entry entry : namespaces.entrySet())
-			result.append("    " + entry.getKey() + " = " + entry.getValue()
-					+ "\n");
-
-		return result.toString();
-	}
-
-}