Skip to content

Commit

Permalink
chore: jaws refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudroques committed Nov 21, 2024
1 parent 27c22a9 commit 837f440
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 41 deletions.
5 changes: 2 additions & 3 deletions src/net/sourceforge/plantuml/dot/CucaDiagramTxtMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -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<String> disp = BackSlash.getWithNewlines(att.toString());
final List<String> disp = Display.getWithNewlines3(att.toString());
ug.getCharArea().drawStringsLRSimple(disp, 1, y);
y += StringUtils.getHeight(disp);
}
Expand Down Expand Up @@ -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<String> disp = BackSlash.getWithNewlines(att.toString());
final List<String> disp = Display.getWithNewlines3(att.toString());
ug.getCharArea().drawStringsLRUnicode(disp, 1, y);
y += StringUtils.getHeight(disp);
}
Expand Down
30 changes: 30 additions & 0 deletions src/net/sourceforge/plantuml/klimt/creole/Display.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,36 @@ public static Display getWithNewlines2(String s) throws NoSuchColorException {
return result;
}

public static List<String> getWithNewlines3(CharSequence s) {
if (s == null)
return null;

final List<String> 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;
Expand Down
36 changes: 0 additions & 36 deletions src/net/sourceforge/plantuml/text/BackSlash.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> getWithNewlines(CharSequence s) {
if (s == null)
return null;

final List<String> 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);
Expand Down
2 changes: 1 addition & 1 deletion src/net/sourceforge/plantuml/url/Url.java
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/net/sourceforge/plantuml/utils/BlocLines.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static BlocLines fromArray(String[] array) {

public static BlocLines getWithNewlines(String s) {
final List<StringLocated> 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);
Expand Down

0 comments on commit 837f440

Please sign in to comment.