1414@ Slf4j
1515public class HtmlReport extends SimpleHtmlReport {
1616
17- int d3Threshold = 700 ;
17+ int dotGraphThreshold = 4000 ;
1818
1919 // use Files.readString(Path.of(file))
2020 // Created by generative AI and modified slightly
@@ -279,10 +279,9 @@ public class HtmlReport extends SimpleHtmlReport {
279279 + " </script>" ;
280280
281281 // Created by generative AI and modified
282- public static final String POPUP_STYLE = "<style>\n " + " /* Popup container */ \n "
282+ public static final String POPUP_STYLE = "<style>\n "
283283 + " main {\n " + " max-width: 100vw;/*3840px;*/\n "
284284 + " width: 100vw; /* or 100vw for viewport width */\n "
285- + " /*background-color: lightblue; *//* just for visibility */\n "
286285 + " padding: 0px 0px; /* 0px top & bottom, 40px left & right */\n "
287286 + " }\n "
288287 + "\n "
@@ -301,6 +300,7 @@ public class HtmlReport extends SimpleHtmlReport {
301300 + " width: 100%;\n "
302301 + " height: 100%;\n "
303302 + " }"
303+ + " /* Popup container */\n "
304304 + " .popup {\n "
305305 + " position: fixed;\n "
306306 + " display: none;\n "
@@ -388,24 +388,14 @@ public String printHead() {
388388 "<script async defer src=\" https://buttons.github.io/buttons.js\" ></script>\n "
389389 // google chart import
390390 + "<script type=\" text/javascript\" src=\" https://www.gstatic.com/charts/loader.js\" ></script>\n "
391- // d3 dot graph imports
392- // + "<script src=\"https://d3js.org/d3.v5.min.js\"></script>\n"
393- // + "<script
394- // src=\"https://cdnjs.cloudflare.com/ajax/libs/d3-graphviz/3.0.5/d3-graphviz.min.js\"></script>\n"
395- // + "<script
396- // src=\"https://unpkg.com/@hpcc-js/wasm@0.3.11/dist/index.min.js\"></script>\n"
397-
398- // + "<script
399- // src=\"https://cdn.jsdelivr.net/npm/@hpcc-js/wasm-graphviz@1.7.0/dist/index.min.js\"></script>\n"
391+ // graphing imports - sigma, graphology, vizdom
400392 + "<script src=\" https://cdn.jsdelivr.net/npm/svg-pan-zoom@3.6.1/dist/svg-pan-zoom.min.js\" ></script>"
401-
402- // sigma graph imports - sigma, graphology, graphlib, and graphlib-dot
403393 + "<script src=\" https://cdnjs.cloudflare.com/ajax/libs/sigma.js/2.4.0/sigma.min.js\" ></script>\n "
404394 + "<script src=\" https://cdnjs.cloudflare.com/ajax/libs/graphology/0.25.4/graphology.umd.min.js\" ></script>\n "
405- // may only need graphlib-dot
406- + "<script src=\" https://cdnjs.cloudflare.com/ajax/libs/graphlib/2.1.8/graphlib.min.js\" ></script>\n "
407395 + "<script src=\" https://cdn.jsdelivr.net/npm/graphlib-dot@0.6.4/dist/graphlib-dot.min.js\" ></script>\n "
408396 + "<script src=\" https://cdn.jsdelivr.net/npm/3d-force-graph\" ></script>\n "
397+ + "<script type=\" module\" src=\" https://cdn.jsdelivr.net/npm/@vizdom/vizdom-ts-web@0.1.19/vizdom_ts.min.js\" ></script>\n "
398+ // Make the output look decent. Don't use in RefactorFirstMavenReport.
409399 + "<link rel=\" stylesheet\" href=\" https://unpkg.com/mvp.css\" >\n " ;
410400 }
411401
@@ -489,7 +479,7 @@ public String renderClassGraphVisuals() {
489479 int relationshipCount = classGraph .edgeSet ().size ();
490480 stringBuilder .append ("<div align=\" center\" >Number of classes: " + classCount + " Number of relationships: "
491481 + relationshipCount + "<br></div>" );
492- if (classCount + relationshipCount < d3Threshold ) {
482+ if (classCount + relationshipCount < dotGraphThreshold ) {
493483 stringBuilder .append (generateDotImage (classGraphName ));
494484 } else {
495485 // revisit and add DOT SVG popup button
@@ -519,15 +509,18 @@ private StringBuilder generateGraphButtons(String graphName, String dot) {
519509 private static String generateDotImage (String graphName ) {
520510 // revisit and add D3 popup button as well
521511 return "<div id=\" " + graphName
522- + "\" style=\" width: 95%; margin: auto; border: thin solid black\" ></div>\n "
512+ + "\" style=\" width: 95%; height: 70vh; margin: auto; border: thin solid black\" ></div>\n "
523513 + "<script type=\" module\" >\n "
524- + "import { Graphviz } from \" https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/index.js\" ;\n "
525- + " if (Graphviz) {\n "
526- + " const graphviz = await Graphviz.load();\n "
527- + " let svg = graphviz.layout("
528- + graphName + "_dot, \" svg\" , \" dot\" );\n "
529- + " // Set desired width and height\n "
530- + "\n "
514+ + "import init, { DotParser } from \" https://esm.run/@vizdom/vizdom-ts-web\" ;\n "
515+ + " if(DotParser) {\n "
516+ + " // Wait for the WASM binary to be compiled and the 'wasm' object to be populated\n "
517+ + " await init();\n "
518+ + " // Create a new Dot Parser\n "
519+ + " const parser = new DotParser();\n "
520+ + " const dotGraph = parser.parse("
521+ + graphName + "_dot);\n " + " const directedGraph = dotGraph.to_directed();\n "
522+ + " const positioned = directedGraph.layout();\n "
523+ + " let svg = positioned.to_svg().to_string();\n "
531524 + " // Modify the SVG string to include width and height attributes\n "
532525 + " svg = svg.replace('<svg ', `<svg class=\" fullscreen-svg\" `);\n "
533526 + "\n "
@@ -637,7 +630,7 @@ public String renderCycleVisuals(RankedCycle cycle) {
637630 StringBuilder stringBuilder = new StringBuilder ();
638631 stringBuilder .append (generateGraphButtons (cycleName , dot ));
639632
640- if (cycle .getCycleNodes ().size () + cycle .getEdgeSet ().size () < d3Threshold ) {
633+ if (cycle .getCycleNodes ().size () + cycle .getEdgeSet ().size () < dotGraphThreshold ) {
641634 stringBuilder .append (generateDotImage (cycleName ));
642635 } else {
643636 // revisit and add DOT SVG popup button
0 commit comments