X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Finspector%2Fjava%2Fstructure%2FClassGraph.java;h=bf34841ea459d9d89c7bf9e4af4e25a5492563c2;hb=8886bb51f2caf11b8e778bacb4c8ea18ac7f1027;hp=7bae6f3179536676f42138ed3c3855d2af115e8f;hpb=16ba5341215d24fdcfa07072d52cf87e5a4375ed;p=javainspect.git
diff --git a/src/main/java/eu/svjatoslav/inspector/java/structure/ClassGraph.java b/src/main/java/eu/svjatoslav/inspector/java/structure/ClassGraph.java
old mode 100644
new mode 100755
index 7bae6f3..bf34841
--- a/src/main/java/eu/svjatoslav/inspector/java/structure/ClassGraph.java
+++ b/src/main/java/eu/svjatoslav/inspector/java/structure/ClassGraph.java
@@ -1,10 +1,10 @@
/*
* JavaInspect - Utility to visualize java software
- * Copyright (C) 2013, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
+ * Copyright (C) 2013-2014, 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;
@@ -22,10 +22,7 @@ import eu.svjatoslav.inspector.java.methods.ProjectScanner;
public class ClassGraph {
public static void render(final String graphName, final Class... classes) {
- final ClassGraph classGraph = new ClassGraph();
-
- for (final Class clazz : classes)
- classGraph.addClass(clazz);
+ final ClassGraph classGraph = new ClassGraph(classes);
classGraph.generateGraph(graphName);
}
@@ -54,7 +51,7 @@ public class ClassGraph {
* objects that shall be added to graph
*/
public ClassGraph(final Object... objects) {
- for (Object object : objects)
+ for (final Object object : objects)
addClass(object.getClass());
}
@@ -115,7 +112,7 @@ public class ClassGraph {
* 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.
@@ -127,8 +124,31 @@ public class ClassGraph {
final String desktopPath = CommonPathResolver.getDesktopDirectory()
.getAbsolutePath() + "/";
- final String dotFilePath = desktopPath + resultFileName + ".dot";
- final String imageFilePath = desktopPath + resultFileName + ".png";
+ generateGraph(desktopPath, resultFileName, keepDotFile);
+ }
+
+ /**
+ * @param targetDirectory
+ * target directory name
+ *
+ * @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(String targetDirectory,
+ final String resultFileName, final boolean keepDotFile) {
+
+ if (!targetDirectory.endsWith("/"))
+ targetDirectory += "/";
+
+ final String dotFilePath = targetDirectory + resultFileName + ".dot";
+ final String imageFilePath = targetDirectory + resultFileName + ".png";
System.out.println("Dot file path:" + dotFilePath);
@@ -155,6 +175,7 @@ public class ClassGraph {
} catch (final IOException e) {
System.err.println(e);
}
+
}
private String getDot() {
@@ -173,6 +194,10 @@ public class ClassGraph {
return resultStr;
}
+ public Filter getFilter() {
+ return filter;
+ }
+
/**
* Hide orphaned class that have no references
*/
@@ -183,11 +208,7 @@ public class ClassGraph {
}
- public Filter getFilter() {
- return filter;
- }
-
- public void setFilter(Filter filter) {
+ public void setFilter(final Filter filter) {
this.filter = filter;
}