Top Description Fields Constructors Methods
io.github.classgraph

pack-priv final Class GraphvizDotfileGenerator

extends Object
Class Inheritance
Imports
java.util.BitSet, .HashSet, .Set, nonapi.io.github.classgraph.scanspec.ScanSpec, nonapi.io.github.classgraph.utils.CollectionUtils

Builds a class graph visualization in Graphviz .dot file format.

Field Summary

Modifier and TypeField and Description
private static final String
ANNOTATION_COLOR

The color for annotations.

private static final String
INTERFACE_COLOR

The color for interfaces.

private static final BitSet
IS_UNICODE_WHITESPACE

Which characters are Unicode whitespace.

private static final int
PARAM_WRAP_WIDTH

The wrap width for method parameters.

private static final String
STANDARD_CLASS_COLOR

The color for standard classes.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static String

Returns:

the string
generateGraphVizDotFile
(final ClassInfoList
the class info list
classInfoList
,
final float
the size X
sizeX
,
final float
the size Y
sizeY
,
final boolean
whether to show fields
showFields
,
final boolean
whether to show field type dependency edges
showFieldTypeDependencyEdges
,
final boolean
whether to show methods
showMethods
,
final boolean
whether to show method type dependency edges
showMethodTypeDependencyEdges
,
final boolean
whether to show annotations
showAnnotations
,
final boolean
whether to use simple names for classes
useSimpleNames
,
final ScanSpec
the scan spec
scanSpec
)

Generates a .dot file which can be fed into GraphViz for layout and visualization of the class graph.

pack-priv static String

Returns:

the GraphViz file contents.
generateGraphVizDotFileFromInterClassDependencies
(final ClassInfoList
The list of nodes whose dependencies should be plotted in the graph.
classInfoList
,
final float
The GraphViz layout width in inches.
sizeX
,
final float
The GraphViz layout width in inches.
sizeY
,
final boolean
If true, include any dependency nodes in the graph that are not themselves in classInfoList.
includeExternalClasses
)

Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph.

private static void
htmlEncode(final CharSequence
The string to escape to make HTML-safe.
unsafeStr
,
final boolean
If true, turn '\n' into a break element in the output.
turnNewlineIntoBreak
,
final StringBuilder
the buf
buf
)

Encode HTML-unsafe characters as HTML entities.

private static void
htmlEncode(final CharSequence
The string to escape to make HTML-safe.
unsafeStr
,
final StringBuilder
the buf
buf
)

Encode HTML-unsafe characters as HTML entities.

private static boolean

Returns:

true if the character is Unicode whitespace
isUnicodeWhitespace
(final char
the character
c
)

Checks if a character is Unicode whitespace.

private static void
labelClassNodeHTML(final ClassInfo
the class info
ci
,
final String
the shape to use
shape
,
final String
the box background color
boxBgColor
,
final boolean
whether to show fields
showFields
,
final boolean
whether to show methods
showMethods
,
final boolean
whether to use simple names for classes in type signatures
useSimpleNames
,
final ScanSpec
the scan spec
scanSpec
,
final StringBuilder
the buf
buf
)

Produce HTML label for class node.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ANNOTATION_COLORback to summary
private static final String ANNOTATION_COLOR

The color for annotations.

INTERFACE_COLORback to summary
private static final String INTERFACE_COLOR

The color for interfaces.

IS_UNICODE_WHITESPACEback to summary
private static final BitSet IS_UNICODE_WHITESPACE

Which characters are Unicode whitespace.

PARAM_WRAP_WIDTHback to summary
private static final int PARAM_WRAP_WIDTH

The wrap width for method parameters.

STANDARD_CLASS_COLORback to summary
private static final String STANDARD_CLASS_COLOR

The color for standard classes.

Constructor Detail

GraphvizDotfileGeneratorback to summary
private GraphvizDotfileGenerator()

Constructor.

Method Detail

generateGraphVizDotFileback to summary
pack-priv static String generateGraphVizDotFile(final ClassInfoList classInfoList, final float sizeX, final float sizeY, final boolean showFields, final boolean showFieldTypeDependencyEdges, final boolean showMethods, final boolean showMethodTypeDependencyEdges, final boolean showAnnotations, final boolean useSimpleNames, final 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:ClassInfoList

the class info list

sizeX:float

the size X

sizeY:float

the size Y

showFields:boolean

whether to show fields

showFieldTypeDependencyEdges:boolean

whether to show field type dependency edges

showMethods:boolean

whether to show methods

showMethodTypeDependencyEdges:boolean

whether to show method type dependency edges

showAnnotations:boolean

whether to show annotations

useSimpleNames:boolean

whether to use simple names for classes

scanSpec:ScanSpec

the scan spec

Returns:String

the string

generateGraphVizDotFileFromInterClassDependenciesback to summary
pack-priv static String generateGraphVizDotFileFromInterClassDependencies(final ClassInfoList classInfoList, final float sizeX, final float sizeY, final 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 called ClassGraph#enableInterClassDependencies() before scanning to use this method.

Parameters
classInfoList:ClassInfoList

The list of nodes whose dependencies should be plotted in the graph.

sizeX:float

The GraphViz layout width in inches.

sizeY:float

The GraphViz layout width in inches.

includeExternalClasses:boolean

If true, include any dependency nodes in the graph that are not themselves in classInfoList.

Returns:String

the GraphViz file contents.

Exceptions
IllegalArgumentException:
if this ClassInfoList is empty or ClassGraph#enableInterClassDependencies() was not called before scanning (since there would be nothing to graph).
htmlEncodeback to summary
private static void htmlEncode(final CharSequence unsafeStr, final boolean turnNewlineIntoBreak, final StringBuilder buf)

Encode HTML-unsafe characters as HTML entities.

Parameters
unsafeStr:CharSequence

The string to escape to make HTML-safe.

turnNewlineIntoBreak:boolean

If true, turn '\n' into a break element in the output.

buf:StringBuilder

the buf

htmlEncodeback to summary
private static void htmlEncode(final CharSequence unsafeStr, final StringBuilder buf)

Encode HTML-unsafe characters as HTML entities.

Parameters
unsafeStr:CharSequence

The string to escape to make HTML-safe.

buf:StringBuilder

the buf

isUnicodeWhitespaceback to summary
private static boolean isUnicodeWhitespace(final char c)

Checks if a character is Unicode whitespace.

Parameters
c:char

the character

Returns:boolean

true if the character is Unicode whitespace

labelClassNodeHTMLback to summary
private static void labelClassNodeHTML(final ClassInfo ci, final String shape, final String boxBgColor, final boolean showFields, final boolean showMethods, final boolean useSimpleNames, final ScanSpec scanSpec, final StringBuilder buf)

Produce HTML label for class node.

Parameters
ci:ClassInfo

the class info

shape:String

the shape to use

boxBgColor:String

the box background color

showFields:boolean

whether to show fields

showMethods:boolean

whether to show methods

useSimpleNames:boolean

whether to use simple names for classes in type signatures

scanSpec:ScanSpec

the scan spec

buf:StringBuilder

the buf