From 837f4407ff11786ef054219b97af46007e135456 Mon Sep 17 00:00:00 2001 From: PlantUML Date: Thu, 21 Nov 2024 16:31:40 +0000 Subject: [PATCH] chore: jaws refactoring --- .../plantuml/dot/CucaDiagramTxtMaker.java | 5 ++- .../plantuml/klimt/creole/Display.java | 30 ++++++++++++++++ .../sourceforge/plantuml/text/BackSlash.java | 36 ------------------- src/net/sourceforge/plantuml/url/Url.java | 2 +- .../sourceforge/plantuml/utils/BlocLines.java | 2 +- 5 files changed, 34 insertions(+), 41 deletions(-) diff --git a/src/net/sourceforge/plantuml/dot/CucaDiagramTxtMaker.java b/src/net/sourceforge/plantuml/dot/CucaDiagramTxtMaker.java index 7a823d750e8..d43e1814bbd 100644 --- a/src/net/sourceforge/plantuml/dot/CucaDiagramTxtMaker.java +++ b/src/net/sourceforge/plantuml/dot/CucaDiagramTxtMaker.java @@ -66,7 +66,6 @@ import net.sourceforge.plantuml.posimo.Path; import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SecurityUtils; -import net.sourceforge.plantuml.text.BackSlash; public final class CucaDiagramTxtMaker { // ::remove file when __CORE__ @@ -161,7 +160,7 @@ private void drawClassSimple(final Entity ent, UGraphicTxt ug) { ug.getCharArea().drawHLine('-', y, 1, w - 1); y++; for (CharSequence att : ent.getBodier().getRawBody()) { - final List disp = BackSlash.getWithNewlines(att.toString()); + final List disp = Display.getWithNewlines3(att.toString()); ug.getCharArea().drawStringsLRSimple(disp, 1, y); y += StringUtils.getHeight(disp); } @@ -192,7 +191,7 @@ private void drawClassUnicode(final Entity ent, UGraphicTxt ug) { ug.getCharArea().drawChar('\u2524', w - 1, y); y++; for (CharSequence att : ent.getBodier().getRawBody()) { - final List disp = BackSlash.getWithNewlines(att.toString()); + final List disp = Display.getWithNewlines3(att.toString()); ug.getCharArea().drawStringsLRUnicode(disp, 1, y); y += StringUtils.getHeight(disp); } diff --git a/src/net/sourceforge/plantuml/klimt/creole/Display.java b/src/net/sourceforge/plantuml/klimt/creole/Display.java index 7d9db77488f..73826115f80 100644 --- a/src/net/sourceforge/plantuml/klimt/creole/Display.java +++ b/src/net/sourceforge/plantuml/klimt/creole/Display.java @@ -210,6 +210,36 @@ public static Display getWithNewlines2(String s) throws NoSuchColorException { return result; } + public static List getWithNewlines3(CharSequence s) { + if (s == null) + return null; + + final List result = new ArrayList<>(); + final StringBuilder current = new StringBuilder(); + for (int i = 0; i < s.length(); i++) { + final char c = s.charAt(i); + if (c == '\\' && i < s.length() - 1) { + final char c2 = s.charAt(i + 1); + i++; + if (c2 == 'n') { + result.add(current.toString()); + current.setLength(0); + } else if (c2 == 't') { + current.append('\t'); + } else if (c2 == '\\') { + current.append(c2); + } + } else { + current.append(c); + } + } + result.add(current.toString()); + return Collections.unmodifiableList(result); + } + + + + public static Display getWithNewlines(String s) { if (s == null) return NULL; diff --git a/src/net/sourceforge/plantuml/text/BackSlash.java b/src/net/sourceforge/plantuml/text/BackSlash.java index 82da8bca83f..4a7e2c962d0 100644 --- a/src/net/sourceforge/plantuml/text/BackSlash.java +++ b/src/net/sourceforge/plantuml/text/BackSlash.java @@ -60,46 +60,10 @@ public static char hiddenNewLine() { return Jaws.BLOCK_E1_NEWLINE; } - @JawsStrange - public static String manageNewLine(String string) { - return string; - } - - public static List getWithNewlines(CharSequence s) { - if (s == null) - return null; - - final List result = new ArrayList<>(); - final StringBuilder current = new StringBuilder(); - for (int i = 0; i < s.length(); i++) { - final char c = s.charAt(i); - if (c == '\\' && i < s.length() - 1) { - final char c2 = s.charAt(i + 1); - i++; - if (c2 == 'n') { - result.add(current.toString()); - current.setLength(0); - } else if (c2 == 't') { - current.append('\t'); - } else if (c2 == '\\') { - current.append(c2); - } - } else { - current.append(c); - } - } - result.add(current.toString()); - return Collections.unmodifiableList(result); - } - public static String translateBackSlashes(CharSequence s) { if (s == null) return null; - // final String tmps = s.toString(); - // if (tmps.indexOf('\\') == -1) { - // return tmps; - // } final StringBuilder result = new StringBuilder(); for (int i = 0; i < s.length(); i++) { final char c = s.charAt(i); diff --git a/src/net/sourceforge/plantuml/url/Url.java b/src/net/sourceforge/plantuml/url/Url.java index e660af652e3..1b12cd8bd3e 100644 --- a/src/net/sourceforge/plantuml/url/Url.java +++ b/src/net/sourceforge/plantuml/url/Url.java @@ -55,7 +55,7 @@ public Url(String url, String tooltip, String label) { if (tooltip == null) this.tooltip = url; else - this.tooltip = BackSlash.manageNewLine(tooltip); + this.tooltip = tooltip; // this.tooltip = url; // ::done diff --git a/src/net/sourceforge/plantuml/utils/BlocLines.java b/src/net/sourceforge/plantuml/utils/BlocLines.java index 62600f60b95..ac916e3324c 100644 --- a/src/net/sourceforge/plantuml/utils/BlocLines.java +++ b/src/net/sourceforge/plantuml/utils/BlocLines.java @@ -126,7 +126,7 @@ public static BlocLines fromArray(String[] array) { public static BlocLines getWithNewlines(String s) { final List result = new ArrayList<>(); - for (String cs : BackSlash.getWithNewlines(s)) + for (String cs : Display.getWithNewlines3(s)) result.add(new StringLocated(cs, null)); return new BlocLines(result);