From f1ac2f8f772637e622e4c5d4d69a8b9a69e2e931 Mon Sep 17 00:00:00 2001 From: Jim Bethancourt Date: Sun, 7 Jun 2026 14:47:44 -0500 Subject: [PATCH 1/2] #164 Use Vizdom instead of D3 for DOT graph rendering Use Vizdom instead of D3 for DOT graph rendering. Resulting graph is much less chaotic and will likely be easier to follow. Vizdom can also handle rendering much larger graphs quickly. --- .../mavenreport/RefactorFirstMavenReport.java | 12 +++-- .../hjug/refactorfirst/report/HtmlReport.java | 45 ++++++++----------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/refactor-first-maven-plugin/src/main/java/org/hjug/mavenreport/RefactorFirstMavenReport.java b/refactor-first-maven-plugin/src/main/java/org/hjug/mavenreport/RefactorFirstMavenReport.java index 8c7ecc1..aaf3983 100644 --- a/refactor-first-maven-plugin/src/main/java/org/hjug/mavenreport/RefactorFirstMavenReport.java +++ b/refactor-first-maven-plugin/src/main/java/org/hjug/mavenreport/RefactorFirstMavenReport.java @@ -101,10 +101,8 @@ private void printHead(Sink mainSink) { renderJsDeclaration(mainSink, "https://cdnjs.cloudflare.com/ajax/libs/sigma.js/2.4.0/sigma.min.js"); renderJsDeclaration(mainSink, "https://cdnjs.cloudflare.com/ajax/libs/graphology/0.25.4/graphology.umd.min.js"); - // may only need graphlib-dot - renderJsDeclaration(mainSink, "https://cdnjs.cloudflare.com/ajax/libs/graphlib/2.1.8/graphlib.min.js"); - renderJsDeclaration(mainSink, "https://cdn.jsdelivr.net/npm/graphlib-dot@0.6.4/dist/graphlib-dot.min.js"); renderJsDeclaration(mainSink, "https://cdn.jsdelivr.net/npm/3d-force-graph"); + renderModuleDeclaration(mainSink, "https://cdn.jsdelivr.net/npm/@vizdom/vizdom-ts-web@0.1.19/vizdom_ts.min.js"); mainSink.head_(); } @@ -120,6 +118,14 @@ private void renderJsDeclaration(Sink mainSink, String scriptUrl) { mainSink.unknown("script", new Object[] {HtmlMarkup.TAG_TYPE_END}, null); } + private void renderModuleDeclaration(Sink mainSink, String scriptUrl) { + SinkEventAttributeSet githubButtonJS = new SinkEventAttributeSet(); + githubButtonJS.addAttribute(SinkEventAttributes.TYPE, "module"); + githubButtonJS.addAttribute(SinkEventAttributes.SRC, scriptUrl); + mainSink.unknown("script", new Object[] {HtmlMarkup.TAG_TYPE_START}, githubButtonJS); + mainSink.unknown("script", new Object[] {HtmlMarkup.TAG_TYPE_END}, null); + } + private void renderStyle(Sink mainSink) { SinkEventAttributeSet githubButtonJS = new SinkEventAttributeSet(); githubButtonJS.addAttribute(SinkEventAttributes.SRC, HtmlReport.POPUP_STYLE); diff --git a/report/src/main/java/org/hjug/refactorfirst/report/HtmlReport.java b/report/src/main/java/org/hjug/refactorfirst/report/HtmlReport.java index f985d3b..bd46d22 100644 --- a/report/src/main/java/org/hjug/refactorfirst/report/HtmlReport.java +++ b/report/src/main/java/org/hjug/refactorfirst/report/HtmlReport.java @@ -14,7 +14,7 @@ @Slf4j public class HtmlReport extends SimpleHtmlReport { - int d3Threshold = 700; + int dotGraphThreshold = 4000; // use Files.readString(Path.of(file)) // Created by generative AI and modified slightly @@ -279,10 +279,9 @@ public class HtmlReport extends SimpleHtmlReport { + " "; // Created by generative AI and modified - public static final String POPUP_STYLE = "