Skip to content

Commit

Permalink
refactor: prepare jaws implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudroques committed Nov 27, 2024
1 parent cec0358 commit bde8a5b
Show file tree
Hide file tree
Showing 159 changed files with 288 additions and 256 deletions.
6 changes: 3 additions & 3 deletions src/net/atmp/CucaDiagram.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private void eventuallyBuildPhantomGroups() {
int countChildren = quark.countChildren();
if (countChildren > 0) {
// final Display display = Display.getWithNewlines(quark.getQualifiedName());
final Display display = Display.getWithNewlines(quark.getName());
final Display display = Display.getWithNewlines(legacyReplaceBackslashNByNewline(), quark.getName());
final Entity result = this.createGroup(quark, GroupType.PACKAGE);
result.setDisplay(display);
}
Expand Down Expand Up @@ -810,7 +810,7 @@ final public Entity createLeaf(Quark<Entity> quark, CucaDiagram diagram, LeafTyp
else if (Objects.requireNonNull(entityType) == LeafType.JSON)
bodier = new BodierJSon();
else
bodier = BodyFactory.createLeaf(entityType, hideVisibilityModifier);
bodier = BodyFactory.createLeaf(getSkinParam(), entityType, hideVisibilityModifier);

final Entity result = new Entity(quark, this, bodier, entityType, diagram.rawLayout);
bodier.setLeaf(result);
Expand All @@ -822,7 +822,7 @@ public Entity createGroup(Quark<Entity> quark, GroupType groupType) {
if (quark.getData() != null)
return quark.getData();

final Bodier bodier = BodyFactory.createGroup();
final Bodier bodier = BodyFactory.createGroup(getSkinParam());
final Entity result = new Entity(quark, this, bodier, groupType, this.rawLayout);

return result;
Expand Down
1 change: 0 additions & 1 deletion src/net/sourceforge/plantuml/AbstractPSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,5 +264,4 @@ public Set<ParserPass> getRequiredPass() {
public void startingPass(ParserPass pass) {
}


}
7 changes: 6 additions & 1 deletion src/net/sourceforge/plantuml/TitledDiagram.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public Pragma getPragma() {
public TitledDiagram(UmlSource source, UmlDiagramType type, Map<String, String> orig) {
super(source);
this.type = type;
this.skinParam = SkinParam.create(type);
this.skinParam = SkinParam.create(type, getPragma());
if (orig != null)
this.skinParam.copyAllFrom(orig);

Expand Down Expand Up @@ -262,5 +262,10 @@ public void exportDiagramGraphic(UGraphic ug, FileFormatOption fileFormatOption)
final TextBlock textBlock = getTextMainBlock(fileFormatOption);
textBlock.drawU(ug);
}

final public boolean legacyReplaceBackslashNByNewline() {
return skinParam.legacyReplaceBackslashNByNewline();
}


}
4 changes: 2 additions & 2 deletions src/net/sourceforge/plantuml/abel/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,9 @@ public TextBlock getStateHeader(ISkinParam skinParam) {
Display display = null;
for (CharSequence s : details)
if (display == null)
display = Display.getWithNewlines(s.toString());
display = Display.getWithNewlines(skinParam.legacyReplaceBackslashNByNewline(), s.toString());
else
display = display.addAll(Display.getWithNewlines(s.toString()));
display = display.addAll(Display.getWithNewlines(skinParam.legacyReplaceBackslashNByNewline(), s.toString()));

final HorizontalAlignment horizontalAlignment = style.getHorizontalAlignment();
return display.create(fontConfiguration, horizontalAlignment, skinParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void endif() {
public Entity getStart() {
final Quark<Entity> quark = quarkInContext(true, "start");
if (quark.getData() == null)
reallyCreateLeaf(quark, Display.getWithNewlines("start"), LeafType.CIRCLE_START, null);
reallyCreateLeaf(quark, Display.getWithNewlines(legacyReplaceBackslashNByNewline(), "start"), LeafType.CIRCLE_START, null);

return quark.getData();
}
Expand All @@ -89,7 +89,7 @@ public Entity getEnd(String suppId) {
final String tmp = suppId == null ? "end" : "end$" + suppId;
final Quark<Entity> quark = quarkInContext(true, tmp);
if (quark.getData() == null)
reallyCreateLeaf(quark, Display.getWithNewlines("end"), LeafType.CIRCLE_END, null);
reallyCreateLeaf(quark, Display.getWithNewlines(legacyReplaceBackslashNByNewline(), "end"), LeafType.CIRCLE_END, null);

return quark.getData();
}
Expand Down Expand Up @@ -142,7 +142,7 @@ public Entity createInnerActivity() {
final String idShort = "##" + this.getUniqueSequence("");

final Quark<Entity> quark = quarkInContext(true, idShort);
gotoGroup(quark, Display.getWithNewlines(quark.getName()), GroupType.INNER_ACTIVITY);
gotoGroup(quark, Display.getWithNewlines(legacyReplaceBackslashNByNewline(), quark.getName()), GroupType.INNER_ACTIVITY);
final Entity g = getCurrentGroup();

lastEntityConsulted = null;
Expand All @@ -161,7 +161,7 @@ public void concurrentActivity(String name) {
throw new IllegalStateException("type=" + getCurrentGroup().getGroupType());

final Quark<Entity> idNewLong = quarkInContext(true, idShort);
gotoGroup(idNewLong, Display.getWithNewlines("code"), GroupType.CONCURRENT_ACTIVITY);
gotoGroup(idNewLong, Display.getWithNewlines(legacyReplaceBackslashNByNewline(), "code"), GroupType.CONCURRENT_ACTIVITY);
lastEntityConsulted = null;
lastEntityBrancheConsulted = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocatio

final Entity branch = diagram.getCurrentContext().getBranch();

final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(arg.get("BRACKET", 0)), lenght);
final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.get("BRACKET", 0)), lenght);
Link link = new Link(diagram, diagram.getSkinParam().getCurrentStyleBuilder(), entity1,
branch, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), linkArg.withQuantifier(null, ifLabel)
.withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocatio
if (arg.get("STEREOTYPE2", 0) != null)
entity2.setStereotype(Stereotype.build(arg.get("STEREOTYPE2", 0)));

final Display linkLabel = Display.getWithNewlines(arg.get("BRACKET", 0));
final Display linkLabel = Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.get("BRACKET", 0));

final String arrowBody1 = CommandLinkClass.notNull(arg.get("ARROW_BODY1", 0));
final String arrowBody2 = CommandLinkClass.notNull(arg.get("ARROW_BODY2", 0));
Expand Down Expand Up @@ -215,7 +215,7 @@ static Entity getEntity(ActivityDiagram diagram, RegexResult arg, final boolean
final LeafType type = getTypeIfExisting(diagram, ident);
Entity result = ident.getData();
if (result == null)
result = diagram.reallyCreateLeaf(ident, Display.getWithNewlines(idShort), type, null);
result = diagram.reallyCreateLeaf(ident, Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), idShort), type, null);

if (partition != null)
diagram.endGroup();
Expand All @@ -227,23 +227,23 @@ static Entity getEntity(ActivityDiagram diagram, RegexResult arg, final boolean
final Quark<Entity> quark = diagram.quarkInContext(true, diagram.cleanId(bar));
Entity result = quark.getData();
if (result == null)
result = diagram.reallyCreateLeaf(quark, Display.getWithNewlines(bar), LeafType.SYNCHRO_BAR, null);
result = diagram.reallyCreateLeaf(quark, Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), bar), LeafType.SYNCHRO_BAR, null);
return result;
}
final RegexPartialMatch quoted = arg.get("QUOTED" + suf);
if (quoted.get(0) != null) {
final String quotedString = quoted.get(1) == null ? quoted.get(0) : quoted.get(1);
if (partition != null) {
final Quark<Entity> quark = diagram.quarkInContext(true, diagram.cleanId(partition));
diagram.gotoGroup(quark, Display.getWithNewlines(partition), GroupType.PACKAGE);
diagram.gotoGroup(quark, Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), partition), GroupType.PACKAGE);
}

final Quark<Entity> quark = diagram.quarkInContext(true, diagram.cleanId(quotedString));

final LeafType type = getTypeIfExisting(diagram, quark);
Entity result = quark.getData();
if (result == null)
result = diagram.reallyCreateLeaf(quark, Display.getWithNewlines(quoted.get(0)), type, null);
result = diagram.reallyCreateLeaf(quark, Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), quoted.get(0)), type, null);
if (partition != null)
diagram.endGroup();

Expand All @@ -258,7 +258,7 @@ static Entity getEntity(ActivityDiagram diagram, RegexResult arg, final boolean
final Quark<Entity> identInvisible = diagram.quarkInContext(true, diagram.cleanId(quoteInvisibleString));
Entity result = identInvisible.getData();
if (result == null)
result = diagram.reallyCreateLeaf(identInvisible, Display.getWithNewlines(identInvisible.getName()),
result = diagram.reallyCreateLeaf(identInvisible, Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), identInvisible.getName()),
LeafType.ACTIVITY, null);
if (partition != null)
diagram.endGroup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ protected CommandExecutionResult executeNow(final ActivityDiagram diagram, BlocL
}
if (partition != null) {
final Quark<Entity> idNewLong = diagram.quarkInContext(true, diagram.cleanId(partition));
diagram.gotoGroup(idNewLong, Display.getWithNewlines(partition), GroupType.PACKAGE);
diagram.gotoGroup(idNewLong, Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), partition), GroupType.PACKAGE);
}
final Quark<Entity> ident = diagram.quarkInContext(true, diagram.cleanId(idShort));

Entity entity2 = ident.getData();
if (entity2 == null)
entity2 = diagram.reallyCreateLeaf(ident, Display.getWithNewlines(displayString), LeafType.ACTIVITY, null);
entity2 = diagram.reallyCreateLeaf(ident, Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), displayString), LeafType.ACTIVITY, null);

diagram.setLastEntityConsulted(entity2);

Expand All @@ -210,7 +210,7 @@ protected CommandExecutionResult executeNow(final ActivityDiagram diagram, BlocL

final int lenght = arrow.length() - 1;

final Display linkLabel = Display.getWithNewlines(line0.get("BRACKET", 0));
final Display linkLabel = Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), line0.get("BRACKET", 0));

LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
if (arrow.contains("."))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocatio
throws NoSuchColorException {
final Quark<Entity> quark = diagram.quarkInContext(true, diagram.cleanId(arg.get("NAME", 0)));

diagram.gotoGroup(quark, Display.getWithNewlines(quark.getName()), GroupType.PACKAGE);
diagram.gotoGroup(quark, Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), quark.getName()), GroupType.PACKAGE);
final Entity p = diagram.getCurrentGroup();

final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocati
if (style == BoxStyle.PLAIN)
style = BoxStyle.fromString(arg.get("STYLE", 0));

final Display display = Display.getWithNewlines2(arg.get("LABEL", 0));
final Display display = Display.getWithNewlines2(diagram.legacyReplaceBackslashNByNewline(), arg.get("LABEL", 0));
return diagram.addActivity(display, style, url, colors, stereotype);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static IRegex getRegexConcat() {

@Override
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg, ParserPass currentPass) {
return diagram.addActivity(Display.getWithNewlines(arg.get("LABEL", 0)), BoxStyle.PLAIN, null, Colors.empty(),
return diagram.addActivity(Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.get("LABEL", 0)), BoxStyle.PLAIN, null, Colors.empty(),
null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocati
}
final String label = arg.get("LABEL", 0);
if (label != null && label.length() > 0)
diagram.setLabelNextArrow(Display.getWithNewlines(label));
diagram.setLabelNextArrow(Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), label));

return CommandExecutionResult.ok();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocati
if (stereo != null)
stereotype = Stereotype.build(stereo);

final Display label = Display.getWithNewlines(arg.get("LABEL", 0));
final Display label = Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.get("LABEL", 0));

final LinkRendering in = getBackRendering(diagram, arg, "INCOMING");
final LinkRendering out = getBackRendering(diagram, arg, "OUTCOMING");
Expand All @@ -121,7 +121,7 @@ static public LinkRendering getBackRendering(ActivityDiagram3 diagram, RegexResu
else
in = LinkRendering.create(incomingColor);
final String label = arg.get(name, 0);
return in.withDisplay(Display.getWithNewlines(label));
return in.withDisplay(Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), label));
}

static private Rainbow getRainbow(String key, ActivityDiagram3 diagram, RegexResult arg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocati
test = null;
}

return diagram.switchCase(Display.getWithNewlines(test));
return diagram.switchCase(Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), test));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocati
final LinkRendering incoming = CommandBackward3.getBackRendering(diagram, arg, "INCOMING");
final LinkRendering when = CommandBackward3.getBackRendering(diagram, arg, "WHEN");

return diagram.elseIf(incoming, Display.getWithNewlines(test), when, color);
return diagram.elseIf(incoming, Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), test), when, color);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocati
final LinkRendering incoming = CommandBackward3.getBackRendering(diagram, arg, "INCOMING");
final LinkRendering when = CommandBackward3.getBackRendering(diagram, arg, "WHEN");

return diagram.elseIf(incoming, Display.getWithNewlines(test), when, color);
return diagram.elseIf(incoming, Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), test), when, color);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocati
// if (getSystem().getLastEntityConsulted() == null) {
// return CommandExecutionResult.error("No if for this endif");
// }
final Display when = Display.getWithNewlines(arg.get("WHEN", 0));
final Display when = Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.get("WHEN", 0));
return diagram.else2(LinkRendering.none().withDisplay(when));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocati
}
final Stereotype stereotype = Stereotype.build(arg.get("STEREO", 0));

diagram.startIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color, url, stereotype);
diagram.startIf(Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), test), Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.get("WHEN", 0)), color, url, stereotype);

return CommandExecutionResult.ok();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocati
if (test.length() == 0)
test = null;

diagram.startIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color, null, null);
diagram.startIf(Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), test), Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.get("WHEN", 0)), color, null, null);

return CommandExecutionResult.ok();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static IRegex getRegexConcat() {
@Override
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg, ParserPass currentPass) {

diagram.startIf(Display.getWithNewlines(arg.get("TEST", 0)), Display.getWithNewlines(arg.get("WHEN", 0)), null,
diagram.startIf(Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.get("TEST", 0)), Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.get("WHEN", 0)), null,
null, null);

return CommandExecutionResult.ok();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static IRegex getRegexConcat() {
@Override
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg, ParserPass currentPass) {
// diagram.setColorNextArrow(color);
diagram.setLabelNextArrow(Display.getWithNewlines("NOLINK"));
diagram.setLabelNextArrow(Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), "NOLINK"));
return CommandExecutionResult.ok();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static IRegex getRegexConcat() {
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg,
ParserPass currentPass) throws NoSuchColorException {
final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
final Display note = Display.getWithNewlines(arg.get("NOTE", 0));
final Display note = Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.get("NOTE", 0));
final NotePosition position = NotePosition.defaultLeft(arg.get("POSITION", 0));
final NoteType type = NoteType.defaultType(arg.get("TYPE", 0));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocati
// final HColor titleColor = HColors.BLUE;// stylePartition.value(PName.FontColor).asColor(diagram.getSkinParam().getIHtmlColorSet());
// final double roundCorner = stylePartition.value(PName.RoundCorner).asDouble();

diagram.startGroup(Display.getWithNewlines(partitionTitle), backColor, symbol, stylePartition);
diagram.startGroup(Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), partitionTitle), backColor, symbol, stylePartition);

return CommandExecutionResult.ok();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocati
throws NoSuchColorException {
final String s = arg.get("COLOR", 0);
final HColor color = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s);
final Display label = Display.getWithNewlines(arg.get("LABEL", 0));
final Display label = Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.get("LABEL", 0));
final BoxStyle boxStyle;
final String styleString = arg.get("STYLE", 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ static IRegex getRegexConcat() {
@Override
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg, ParserPass currentPass)
throws NoSuchColorException {
final Display test = Display.getWithNewlines(arg.getLazzy("TEST", 0));
final Display yes = Display.getWithNewlines(arg.getLazzy("WHEN", 0));
final Display out = Display.getWithNewlines(arg.getLazzy("OUT", 0));
final Display test = Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.getLazzy("TEST", 0));
final Display yes = Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.getLazzy("WHEN", 0));
final Display out = Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.getLazzy("OUT", 0));

final String colorString = arg.get("COLOR", 0);
final Rainbow rainbow;
Expand All @@ -117,7 +117,7 @@ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocati
diagram.getSkinParam().colorArrowSeparationSpace());
}

final Display linkLabel = Display.getWithNewlines(arg.get("LABEL", 0));
final Display linkLabel = Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.get("LABEL", 0));
return diagram.repeatWhile(test, yes, out, linkLabel, rainbow);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines
// 0));

final String test = line0.get("TEST1", 0);
Display testDisplay = Display.getWithNewlines(test);
Display testDisplay = Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), test);
for (StringLocated s : lines.subExtract(1, 1)) {
testDisplay = testDisplay.add(s.getString());
}
Expand Down
Loading

0 comments on commit bde8a5b

Please sign in to comment.