1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-05 21:17:52 +00:00
Arnaud Roques 2023-09-11 19:39:02 +02:00
parent 04a071c4a4
commit 41ba2020b6
8 changed files with 50 additions and 31 deletions

View File

@ -1,4 +1,4 @@
# Warning, "version" should be the same in gradle.properties and Version.java
# Any idea anyone how to magically synchronize those :-) ?
version = 1.2023.11beta2
version = 1.2023.11beta3
org.gradle.workers.max = 3

View File

@ -388,11 +388,11 @@ public class ActivityDiagram3 extends UmlDiagram {
}
public CommandExecutionResult backward(Display label, BoxStyle boxStyle, LinkRendering incoming1,
LinkRendering incoming2) {
LinkRendering incoming2, Stereotype stereotype) {
manageSwimlaneStrategy();
if (current() instanceof InstructionRepeat) {
final InstructionRepeat instructionRepeat = (InstructionRepeat) current();
instructionRepeat.setBackward(label, swinlanes.getCurrentSwimlane(), boxStyle, incoming1, incoming2);
instructionRepeat.setBackward(label, swinlanes.getCurrentSwimlane(), boxStyle, incoming1, incoming2, stereotype);
return CommandExecutionResult.ok();
}
if (current() instanceof InstructionWhile) {

View File

@ -57,6 +57,7 @@ import net.sourceforge.plantuml.klimt.font.StringBounder;
import net.sourceforge.plantuml.klimt.geom.VerticalAlignment;
import net.sourceforge.plantuml.sequencediagram.NotePosition;
import net.sourceforge.plantuml.sequencediagram.NoteType;
import net.sourceforge.plantuml.stereo.Stereotype;
import net.sourceforge.plantuml.style.ISkinParam;
public class InstructionRepeat extends AbstractInstruction implements Instruction {
@ -74,6 +75,7 @@ public class InstructionRepeat extends AbstractInstruction implements Instructio
private Display backward = Display.NULL;
private Stereotype stereotype;
private LinkRendering incoming1 = LinkRendering.none();
private LinkRendering incoming2 = LinkRendering.none();
private List<PositionedNote> backwardNotes = new ArrayList<>();
@ -110,12 +112,13 @@ public class InstructionRepeat extends AbstractInstruction implements Instructio
}
public void setBackward(Display label, Swimlane swimlaneBackward, BoxStyle boxStyle, LinkRendering incoming1,
LinkRendering incoming2) {
LinkRendering incoming2, Stereotype stereotype) {
this.backward = label;
this.swimlaneBackward = swimlaneBackward;
this.boxStyle = boxStyle;
this.incoming1 = incoming1;
this.incoming2 = incoming2;
this.stereotype = stereotype;
}
public boolean hasBackward() {
@ -166,7 +169,7 @@ public class InstructionRepeat extends AbstractInstruction implements Instructio
if (Display.isNull(backward))
return null;
Ftile result = factory.activity(backward, swimlaneBackward, boxStyle, Colors.empty(), null);
Ftile result = factory.activity(backward, swimlaneBackward, boxStyle, Colors.empty(), stereotype);
if (backwardNotes.size() > 0)
result = factory.addNote(result, swimlaneBackward, backwardNotes, VerticalAlignment.CENTER);

View File

@ -50,6 +50,7 @@ import net.sourceforge.plantuml.regex.RegexLeaf;
import net.sourceforge.plantuml.regex.RegexOptional;
import net.sourceforge.plantuml.regex.RegexOr;
import net.sourceforge.plantuml.regex.RegexResult;
import net.sourceforge.plantuml.stereo.Stereotype;
import net.sourceforge.plantuml.utils.LineLocation;
public class CommandBackward3 extends SingleLineCommand2<ActivityDiagram3> {
@ -96,12 +97,18 @@ public class CommandBackward3 extends SingleLineCommand2<ActivityDiagram3> {
else
boxStyle = BoxStyle.fromString(styleString);
final String stereo = arg.get("STYLE", 1);
Stereotype stereotype = null;
if (stereo != null)
stereotype = Stereotype.build(stereo);
final Display label = Display.getWithNewlines(arg.get("LABEL", 0));
final LinkRendering in = getBackRendering(diagram, arg, "INCOMING");
final LinkRendering out = getBackRendering(diagram, arg, "OUTCOMING");
return diagram.backward(label, boxStyle, in, out);
return diagram.backward(label, boxStyle, in, out, stereotype);
}
static public LinkRendering getBackRendering(ActivityDiagram3 diagram, RegexResult arg, String name)

View File

@ -47,6 +47,7 @@ import net.sourceforge.plantuml.regex.IRegex;
import net.sourceforge.plantuml.regex.RegexConcat;
import net.sourceforge.plantuml.regex.RegexLeaf;
import net.sourceforge.plantuml.regex.RegexResult;
import net.sourceforge.plantuml.stereo.Stereotype;
import net.sourceforge.plantuml.utils.BlocLines;
public class CommandBackwardLong3 extends CommandMultilines3<ActivityDiagram3> {
@ -86,6 +87,11 @@ public class CommandBackwardLong3 extends CommandMultilines3<ActivityDiagram3> {
final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString());
final RegexResult lineLast = getPatternEnd2().matcher(lines.getLast().getString());
final String end = lineLast.get("END", 0);
final String stereo = lineLast.get("END", 1);
Stereotype stereotype = null;
if (stereo != null)
stereotype = Stereotype.build(stereo);
final BoxStyle style = BoxStyle.fromString(end);
lines = lines.removeStartingAndEnding(line0.get("DATA", 0), end.length());
@ -93,6 +99,6 @@ public class CommandBackwardLong3 extends CommandMultilines3<ActivityDiagram3> {
final LinkRendering in = LinkRendering.none();
final LinkRendering out = LinkRendering.none();
return diagram.backward(lines.toDisplay(), style, in, out);
return diagram.backward(lines.toDisplay(), style, in, out, stereotype);
}
}

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml.sequencediagram;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import net.sourceforge.plantuml.klimt.UTranslate;
@ -64,17 +65,21 @@ import net.sourceforge.plantuml.style.WithStyle;
public class Doll implements WithStyle {
final private List<Participant> participants = new ArrayList<>();
// alls is only used for Teoz: refactor needed after puma will be removed
final private Map<ParticipantEnglober, Doll> alls;
final private ParticipantEnglober englober;
final private StyleBuilder styleBuilder;
final private TileArguments tileArguments;
public static Doll createPuma(ParticipantEnglober englober, Participant first, ISkinParam skinParam, Rose skin,
StringBounder stringBounder, StyleBuilder styleBuilder) {
return new Doll(englober, convertFunctionToBeRemoved(skinParam, skin, stringBounder), styleBuilder, first);
return new Doll(englober, convertFunctionToBeRemoved(skinParam, skin, stringBounder), styleBuilder, first,
null);
}
public static Doll createTeoz(ParticipantEnglober englober, TileArguments tileArguments) {
return new Doll(englober, tileArguments, tileArguments.getSkinParam().getCurrentStyleBuilder(), null);
public static Doll createTeoz(ParticipantEnglober englober, TileArguments tileArguments,
Map<ParticipantEnglober, Doll> alls) {
return new Doll(englober, tileArguments, tileArguments.getSkinParam().getCurrentStyleBuilder(), null, alls);
}
private static TileArguments convertFunctionToBeRemoved(ISkinParam skinParam, Rose skin,
@ -83,10 +88,11 @@ public class Doll implements WithStyle {
}
private Doll(ParticipantEnglober englober, TileArguments tileArguments, StyleBuilder styleBuilder,
Participant first) {
Participant first, Map<ParticipantEnglober, Doll> alls) {
this.englober = Objects.requireNonNull(englober);
this.styleBuilder = styleBuilder;
this.tileArguments = Objects.requireNonNull(tileArguments);
this.alls = alls;
if (first != null)
this.participants.add(first);
@ -186,8 +192,8 @@ public class Doll implements WithStyle {
final double x1 = getPosA(stringBounder).getCurrentValue() - 4;
final double x2 = getPosE(stringBounder).getCurrentValue() + 4;
if (group != null) {
final double titlePreferredHeight = group.getTitlePreferredHeight();
for (Doll current = group; current != null; current = current.getParent()) {
final double titlePreferredHeight = current.getTitlePreferredHeight();
ug = ug.apply(UTranslate.dy(titlePreferredHeight));
height -= titlePreferredHeight;
}
@ -196,6 +202,13 @@ public class Doll implements WithStyle {
getComponent().drawU(ug.apply(new UTranslate(x1, 1)), new Area(dim), context);
}
public Doll getParent() {
final ParticipantEnglober parent = getParticipantEnglober().getParent();
if (parent == null)
return null;
return alls.get(parent);
}
public void addInternalConstraints(StringBounder stringBounder) {
final double titleWidth = getTitleWidth();
final double x1 = getPosB(stringBounder).getCurrentValue();

View File

@ -67,19 +67,12 @@ public class Dolls {
private void addParticipant(Participant p, ParticipantEnglober englober, TileArguments tileArguments) {
Doll already = alls.get(englober);
if (already == null) {
already = Doll.createTeoz(englober, tileArguments);
already = Doll.createTeoz(englober, tileArguments, alls);
alls.put(englober, already);
}
already.addParticipant(p);
}
private Doll getParent(Doll doll) {
final ParticipantEnglober parent = doll.getParticipantEnglober().getParent();
if (parent == null)
return null;
return alls.get(parent);
}
public int size() {
return alls.size();
}
@ -87,10 +80,9 @@ public class Dolls {
public double getOffsetForEnglobers(StringBounder stringBounder) {
double result = 0;
for (Doll doll : alls.values()) {
double height = doll.getTitlePreferredHeight();
final Doll group = getParent(doll);
if (group != null)
height += group.getTitlePreferredHeight();
double height = 0;
for (Doll current = doll; current != null; current = current.getParent())
height += current.getTitlePreferredHeight();
if (height > result)
result = height;
@ -100,19 +92,17 @@ public class Dolls {
}
public void addConstraints(StringBounder stringBounder) {
for (Doll doll : alls.values()) {
for (Doll doll : alls.values())
doll.addInternalConstraints(stringBounder);
}
for (Doll doll : alls.values()) {
for (Doll doll : alls.values())
doll.addConstraintAfter(stringBounder);
}
}
public void drawEnglobers(UGraphic ug, double height, Context2D context) {
for (Doll doll : alls.values())
doll.drawMe(ug, height, context, getParent(doll));
doll.drawMe(ug, height, context, doll.getParent());
}

View File

@ -46,7 +46,7 @@ public class Version {
// Warning, "version" should be the same in gradle.properties and Version.java
// Any idea anyone how to magically synchronize those :-) ?
private static final String version = "1.2023.11beta2";
private static final String version = "1.2023.11beta3";
public static String versionString() {
return version;