Skip to content

Commit

Permalink
🚧 refactor: prepare jaws deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudroques committed Dec 2, 2024
1 parent 0632bbe commit 408d086
Show file tree
Hide file tree
Showing 161 changed files with 337 additions and 256 deletions.
1 change: 1 addition & 0 deletions CONVENTIONAL_COMMIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Each Gitmoji corresponds to a specific type of change:
| 🔒 | Fixing security issues | `fix` |
| 🌱 | Adding or updating a seed file | `chore` |
| 🔥 | Removing code or files | `chore` |
| 🚧 | Work in progress (WIP) | `chore` |

#### Guidelines for Using Gitmoji
- Place the corresponding emoji at the beginning of the **description** in the commit message header.
Expand Down
2 changes: 1 addition & 1 deletion 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(legacyReplaceBackslashNByNewline(), quark.getName());
final Display display = Display.getWithNewlines(getPragma(), quark.getName());
final Entity result = this.createGroup(quark, GroupType.PACKAGE);
result.setDisplay(display);
}
Expand Down
33 changes: 32 additions & 1 deletion src/net/atmp/ImageBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import net.sourceforge.plantuml.klimt.color.ColorMapper;
import net.sourceforge.plantuml.klimt.color.HColor;
import net.sourceforge.plantuml.klimt.color.HColorGradient;
import net.sourceforge.plantuml.klimt.color.HColorSet;
import net.sourceforge.plantuml.klimt.color.HColorSimple;
import net.sourceforge.plantuml.klimt.color.HColors;
import net.sourceforge.plantuml.klimt.drawing.LimitFinder;
Expand All @@ -78,11 +79,14 @@
import net.sourceforge.plantuml.klimt.drawing.tikz.UGraphicTikz;
import net.sourceforge.plantuml.klimt.drawing.txt.UGraphicTxt;
import net.sourceforge.plantuml.klimt.drawing.visio.UGraphicVdx;
import net.sourceforge.plantuml.klimt.font.FontConfiguration;
import net.sourceforge.plantuml.klimt.font.StringBounder;
import net.sourceforge.plantuml.klimt.font.UFont;
import net.sourceforge.plantuml.klimt.geom.XDimension2D;
import net.sourceforge.plantuml.klimt.shape.TextBlock;
import net.sourceforge.plantuml.klimt.shape.UDrawable;
import net.sourceforge.plantuml.klimt.shape.URectangle;
import net.sourceforge.plantuml.klimt.shape.UText;
import net.sourceforge.plantuml.skin.ColorParam;
import net.sourceforge.plantuml.skin.CornerParam;
import net.sourceforge.plantuml.skin.LineParam;
Expand Down Expand Up @@ -116,6 +120,7 @@ public class ImageBuilder {
private TitledDiagram titledDiagram;
private boolean randomPixel;
private String warningOrError;
private boolean warningN;

public static ImageBuilder imageBuilder(FileFormatOption fileFormatOption) {
return new ImageBuilder(fileFormatOption);
Expand Down Expand Up @@ -215,6 +220,7 @@ public ImageBuilder styled(TitledDiagram diagram) {
seed = diagram.seed();
titledDiagram = diagram;
warningOrError = diagram.getWarningOrError();
warningN = diagram.getPragma().isBackslashNWarning();
return this;
}

Expand All @@ -240,14 +246,21 @@ public byte[] writeByteArray() throws IOException {

private ImageData writeImageInternal(OutputStream os) throws IOException {
XDimension2D dim = getFinalDimension();
if (warningN)
dim = dim.delta(0, 60);
final Scale scale = titledDiagram == null ? null : titledDiagram.getScale();
final double scaleFactor = (scale == null ? 1 : scale.getScale(dim.getWidth(), dim.getHeight())) * getDpi()
/ 96.0;
if (scaleFactor <= 0)
throw new IllegalStateException("Bad scaleFactor");
WasmLog.log("...image drawing...");
UGraphic ug = createUGraphic(dim, scaleFactor,
titledDiagram == null ? new Pragma() : titledDiagram.getPragma());
titledDiagram == null ? Pragma.createEmpty() : titledDiagram.getPragma());
if (warningN) {
drawWarning(ug.apply(new UTranslate(margin.getLeft(), 5)), dim.getWidth());
ug = ug.apply(UTranslate.dy(60));
}

maybeDrawBorder(ug, dim);
if (randomPixel)
drawRandomPoint(ug);
Expand All @@ -268,6 +281,24 @@ private ImageData writeImageInternal(OutputStream os) throws IOException {
return createImageData(dim);
}

private void drawWarning(UGraphic ug, double width) {

final HColorSet set = HColorSet.instance();

final HColor back = set.getColorOrWhite("ffcccc");
final HColor border = set.getColorOrWhite("ff9999");
ug = ug.apply(back.bg()).apply(border);
final URectangle rect = URectangle.build(width - margin.getLeft() - margin.getRight(), 50).rounded(5);
ug.apply(UStroke.withThickness(3)).draw(rect);

ug = ug.apply(HColors.BLACK);

final FontConfiguration fc = FontConfiguration.blackBlueTrue(UFont.monospaced(10));
final String text = "Warning: you are using \\n!";
ug.apply(new UTranslate(10, 25)).draw(UText.build(text, fc));

}

private void maybeDrawBorder(UGraphic ug, XDimension2D dim) {
if (skinParam == null)
return;
Expand Down
11 changes: 4 additions & 7 deletions src/net/sourceforge/plantuml/TitledDiagram.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,10 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram,

private final SkinParam skinParam;

public Pragma getPragma() {
return skinParam.getPragma();
}

public TitledDiagram(UmlSource source, UmlDiagramType type, Map<String, String> orig) {
super(source);
this.type = type;
this.skinParam = SkinParam.create(type, new Pragma());
this.skinParam = SkinParam.create(type, Pragma.createEmpty());
if (orig != null)
this.skinParam.copyAllFrom(orig);

Expand Down Expand Up @@ -261,9 +257,10 @@ public void exportDiagramGraphic(UGraphic ug, FileFormatOption fileFormatOption)
textBlock.drawU(ug);
}

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



}
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(skinParam.legacyReplaceBackslashNByNewline(), s.toString());
display = Display.getWithNewlines(skinParam.getPragma(), s.toString());
else
display = display.addAll(Display.getWithNewlines(skinParam.legacyReplaceBackslashNByNewline(), s.toString()));
display = display.addAll(Display.getWithNewlines(skinParam.getPragma(), 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(legacyReplaceBackslashNByNewline(), "start"), LeafType.CIRCLE_START, null);
reallyCreateLeaf(quark, Display.getWithNewlines(getPragma(), "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(legacyReplaceBackslashNByNewline(), "end"), LeafType.CIRCLE_END, null);
reallyCreateLeaf(quark, Display.getWithNewlines(getPragma(), "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(legacyReplaceBackslashNByNewline(), quark.getName()), GroupType.INNER_ACTIVITY);
gotoGroup(quark, Display.getWithNewlines(getPragma(), 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(legacyReplaceBackslashNByNewline(), "code"), GroupType.CONCURRENT_ACTIVITY);
gotoGroup(idNewLong, Display.getWithNewlines(getPragma(), "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(diagram.legacyReplaceBackslashNByNewline(), arg.get("BRACKET", 0)), lenght);
final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), arg.get("BRACKET", 0));
final Display linkLabel = Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), idShort), type, null);
result = diagram.reallyCreateLeaf(ident, Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), bar), LeafType.SYNCHRO_BAR, null);
result = diagram.reallyCreateLeaf(quark, Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), partition), GroupType.PACKAGE);
diagram.gotoGroup(quark, Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), quoted.get(0)), type, null);
result = diagram.reallyCreateLeaf(quark, Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), identInvisible.getName()),
result = diagram.reallyCreateLeaf(identInvisible, Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), partition), GroupType.PACKAGE);
diagram.gotoGroup(idNewLong, Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), displayString), LeafType.ACTIVITY, null);
entity2 = diagram.reallyCreateLeaf(ident, Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), line0.get("BRACKET", 0));
final Display linkLabel = Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), quark.getName()), GroupType.PACKAGE);
diagram.gotoGroup(quark, Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), arg.get("LABEL", 0));
final Display display = Display.getWithNewlines2(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), arg.get("LABEL", 0)), BoxStyle.PLAIN, null, Colors.empty(),
return diagram.addActivity(Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), label));
diagram.setLabelNextArrow(Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), arg.get("LABEL", 0));
final Display label = Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), label));
return in.withDisplay(Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), test));
return diagram.switchCase(Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), test), when, color);
return diagram.elseIf(incoming, Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), test), when, color);
return diagram.elseIf(incoming, Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), arg.get("WHEN", 0));
final Display when = Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), test), Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.get("WHEN", 0)), color, url, stereotype);
diagram.startIf(Display.getWithNewlines(diagram.getPragma(), test), Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), test), Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.get("WHEN", 0)), color, null, null);
diagram.startIf(Display.getWithNewlines(diagram.getPragma(), test), Display.getWithNewlines(diagram.getPragma(), 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(diagram.legacyReplaceBackslashNByNewline(), arg.get("TEST", 0)), Display.getWithNewlines(diagram.legacyReplaceBackslashNByNewline(), arg.get("WHEN", 0)), null,
diagram.startIf(Display.getWithNewlines(diagram.getPragma(), arg.get("TEST", 0)), Display.getWithNewlines(diagram.getPragma(), arg.get("WHEN", 0)), null,
null, null);

return CommandExecutionResult.ok();
Expand Down
Loading

0 comments on commit 408d086

Please sign in to comment.