Package io.github.classgraph
Class GraphvizDotfileGenerator
- java.lang.Object
-
- io.github.classgraph.GraphvizDotfileGenerator
-
final class GraphvizDotfileGenerator extends java.lang.Object
Builds a class graph visualization in Graphviz .dot file format.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ANNOTATION_COLOR
The color for annotations.private static java.lang.String
INTERFACE_COLOR
The color for interfaces.private static java.util.BitSet
IS_UNICODE_WHITESPACE
Which characters are Unicode whitespace.private static int
PARAM_WRAP_WIDTH
The wrap width for method parameters.private static java.lang.String
STANDARD_CLASS_COLOR
The color for standard classes.
-
Constructor Summary
Constructors Modifier Constructor Description private
GraphvizDotfileGenerator()
Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static java.lang.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 java.lang.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(java.lang.CharSequence unsafeStr, boolean turnNewlineIntoBreak, java.lang.StringBuilder buf)
Encode HTML-unsafe characters as HTML entities.private static void
htmlEncode(java.lang.CharSequence unsafeStr, java.lang.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, java.lang.String shape, java.lang.String boxBgColor, boolean showFields, boolean showMethods, boolean useSimpleNames, ScanSpec scanSpec, java.lang.StringBuilder buf)
Produce HTML label for class node.
-
-
-
Field Detail
-
STANDARD_CLASS_COLOR
private static final java.lang.String STANDARD_CLASS_COLOR
The color for standard classes.- See Also:
- Constant Field Values
-
INTERFACE_COLOR
private static final java.lang.String INTERFACE_COLOR
The color for interfaces.- See Also:
- Constant Field Values
-
ANNOTATION_COLOR
private static final java.lang.String ANNOTATION_COLOR
The color for annotations.- See Also:
- Constant Field Values
-
PARAM_WRAP_WIDTH
private static final int PARAM_WRAP_WIDTH
The wrap width for method parameters.- See Also:
- Constant Field Values
-
IS_UNICODE_WHITESPACE
private static final java.util.BitSet IS_UNICODE_WHITESPACE
Which characters are Unicode whitespace.
-
-
Method Detail
-
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(java.lang.CharSequence unsafeStr, boolean turnNewlineIntoBreak, java.lang.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
private static void htmlEncode(java.lang.CharSequence unsafeStr, java.lang.StringBuilder buf)
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, java.lang.String shape, java.lang.String boxBgColor, boolean showFields, boolean showMethods, boolean useSimpleNames, ScanSpec scanSpec, java.lang.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 java.lang.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 java.lang.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:
java.lang.IllegalArgumentException
- if thisClassInfoList
is empty orClassGraph.enableInterClassDependencies()
was not called before scanning (since there would be nothing to graph).
-
-