Class GraphvizDotfileGenerator

java.lang.Object
io.github.classgraph.GraphvizDotfileGenerator

final class GraphvizDotfileGenerator extends Object
Builds a class graph visualization in Graphviz .dot file format.
  • Field Details

    • STANDARD_CLASS_COLOR

      private static final String STANDARD_CLASS_COLOR
      The color for standard classes.
      See Also:
    • INTERFACE_COLOR

      private static final String INTERFACE_COLOR
      The color for interfaces.
      See Also:
    • ANNOTATION_COLOR

      private static final String ANNOTATION_COLOR
      The color for annotations.
      See Also:
    • PARAM_WRAP_WIDTH

      private static final int PARAM_WRAP_WIDTH
      The wrap width for method parameters.
      See Also:
    • IS_UNICODE_WHITESPACE

      private static final BitSet 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

      private static void htmlEncode(CharSequence unsafeStr, 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, String shape, String boxBgColor, boolean showFields, boolean showMethods, boolean useSimpleNames, ScanSpec scanSpec, StringBuilder buf)
      Produce HTML label for class node.
      Parameters:
      ci - the class info
      shape - the shape to use
      boxBgColor - the box background color
      showFields - whether to show fields
      showMethods - whether to show methods
      useSimpleNames - whether to use simple names for classes in type signatures
      scanSpec - the scan spec
      buf - 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 list
      sizeX - the size X
      sizeY - the size Y
      showFields - whether to show fields
      showFieldTypeDependencyEdges - whether to show field type dependency edges
      showMethods - whether to show methods
      showMethodTypeDependencyEdges - whether to show method type dependency edges
      showAnnotations - whether to show annotations
      useSimpleNames - whether to use simple names for classes
      scanSpec - 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 called ClassGraph.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 this ClassInfoList is empty or ClassGraph.enableInterClassDependencies() was not called before scanning (since there would be nothing to graph).