Package io.github.classgraph
Class GraphvizDotfileGenerator
java.lang.Object
io.github.classgraph.GraphvizDotfileGenerator
Builds a class graph visualization in Graphviz .dot file format.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
The color for annotations.private static final String
The color for interfaces.private static final BitSet
Which characters are Unicode whitespace.private static final int
The wrap width for method parameters.private static final String
The color for standard classes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static String
generateGraphVizDotFile
(ClassInfoList classInfoList, float sizeX, float sizeY, boolean showFields, boolean showFieldTypeDependencyEdges, boolean showMethods, boolean showMethodTypeDependencyEdges, boolean showAnnotations, boolean useSimpleNames, ScanSpec scanSpec) Generates a .dot file which can be fed into GraphViz for layout and visualization of the class graph.(package private) static String
generateGraphVizDotFileFromInterClassDependencies
(ClassInfoList classInfoList, float sizeX, float sizeY, boolean includeExternalClasses) Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph.private static void
htmlEncode
(CharSequence unsafeStr, boolean turnNewlineIntoBreak, StringBuilder buf) Encode HTML-unsafe characters as HTML entities.private static void
htmlEncode
(CharSequence unsafeStr, StringBuilder buf) Encode HTML-unsafe characters as HTML entities.private static boolean
isUnicodeWhitespace
(char c) Checks if a character is Unicode whitespace.private static void
labelClassNodeHTML
(ClassInfo ci, String shape, String boxBgColor, boolean showFields, boolean showMethods, boolean useSimpleNames, ScanSpec scanSpec, StringBuilder buf) Produce HTML label for class node.
-
Field Details
-
STANDARD_CLASS_COLOR
The color for standard classes.- See Also:
-
INTERFACE_COLOR
The color for interfaces.- See Also:
-
ANNOTATION_COLOR
The color for annotations.- See Also:
-
PARAM_WRAP_WIDTH
private static final int PARAM_WRAP_WIDTHThe wrap width for method parameters.- See Also:
-
IS_UNICODE_WHITESPACE
Which characters are Unicode whitespace.
-
-
Constructor Details
-
GraphvizDotfileGenerator
private GraphvizDotfileGenerator()Constructor.
-
-
Method Details
-
isUnicodeWhitespace
private static boolean isUnicodeWhitespace(char c) Checks if a character is Unicode whitespace.- Parameters:
c
- the character- Returns:
- true if the character is Unicode whitespace
-
htmlEncode
private static void htmlEncode(CharSequence unsafeStr, boolean turnNewlineIntoBreak, StringBuilder buf) Encode HTML-unsafe characters as HTML entities.- Parameters:
unsafeStr
- The string to escape to make HTML-safe.turnNewlineIntoBreak
- If true, turn '\n' into a break element in the output.buf
- the buf
-
htmlEncode
Encode HTML-unsafe characters as HTML entities.- Parameters:
unsafeStr
- The string to escape to make HTML-safe.buf
- the buf
-
labelClassNodeHTML
private static void labelClassNodeHTML(ClassInfo ci, String shape, String boxBgColor, boolean showFields, boolean showMethods, boolean useSimpleNames, ScanSpec scanSpec, StringBuilder buf) Produce HTML label for class node.- Parameters:
ci
- the class infoshape
- the shape to useboxBgColor
- the box background colorshowFields
- whether to show fieldsshowMethods
- whether to show methodsuseSimpleNames
- whether to use simple names for classes in type signaturesscanSpec
- the scan specbuf
- the buf
-
generateGraphVizDotFile
static String generateGraphVizDotFile(ClassInfoList classInfoList, float sizeX, float sizeY, boolean showFields, boolean showFieldTypeDependencyEdges, boolean showMethods, boolean showMethodTypeDependencyEdges, boolean showAnnotations, boolean useSimpleNames, ScanSpec scanSpec) Generates a .dot file which can be fed into GraphViz for layout and visualization of the class graph. The sizeX and sizeY parameters are the image output size to use (in inches) when GraphViz is asked to render the .dot file.- Parameters:
classInfoList
- the class info listsizeX
- the size XsizeY
- the size YshowFields
- whether to show fieldsshowFieldTypeDependencyEdges
- whether to show field type dependency edgesshowMethods
- whether to show methodsshowMethodTypeDependencyEdges
- whether to show method type dependency edgesshowAnnotations
- whether to show annotationsuseSimpleNames
- whether to use simple names for classesscanSpec
- the scan spec- Returns:
- the string
-
generateGraphVizDotFileFromInterClassDependencies
static String generateGraphVizDotFileFromInterClassDependencies(ClassInfoList classInfoList, float sizeX, float sizeY, boolean includeExternalClasses) Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph. The returned graph shows inter-class dependencies only. The sizeX and sizeY parameters are the image output size to use (in inches) when GraphViz is asked to render the .dot file. You must have calledClassGraph.enableInterClassDependencies()
before scanning to use this method.- Parameters:
classInfoList
- The list of nodes whose dependencies should be plotted in the graph.sizeX
- The GraphViz layout width in inches.sizeY
- The GraphViz layout width in inches.includeExternalClasses
- If true, include any dependency nodes in the graph that are not themselves in classInfoList.- Returns:
- the GraphViz file contents.
- Throws:
IllegalArgumentException
- if thisClassInfoList
is empty orClassGraph.enableInterClassDependencies()
was not called before scanning (since there would be nothing to graph).
-