From 38c5765a995fabead538c5659ba69ada4d5cfc8c Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Thu, 24 Aug 2023 19:01:41 +0200 Subject: [PATCH] fix: minor issues https://github.com/plantuml/plantuml/issues/1515 https://forum.plantuml.net/18157/last-label-on-last-elseif-branch-does-not-get-rendered --- src/net/atmp/CucaDiagram.java | 20 +++++++++---------- .../plantuml/abel/EntityFactory.java | 16 +++++++-------- .../plantuml/abel/LinkStrategy.java | 5 +++-- .../activitydiagram3/InstructionIf.java | 3 ++- .../{HideOrShow2.java => HideOrShow.java} | 8 ++++---- .../statediagram/command/CommandEndState.java | 4 ++-- .../sourceforge/plantuml/svek/SvekLine.java | 2 +- .../plantuml/url/UrlBuilderTest.java | 6 +----- 8 files changed, 31 insertions(+), 33 deletions(-) rename src/net/sourceforge/plantuml/cucadiagram/{HideOrShow2.java => HideOrShow.java} (94%) diff --git a/src/net/atmp/CucaDiagram.java b/src/net/atmp/CucaDiagram.java index 90d2a9d82..39cd59929 100644 --- a/src/net/atmp/CucaDiagram.java +++ b/src/net/atmp/CucaDiagram.java @@ -65,7 +65,7 @@ import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.cucadiagram.GroupHierarchy; -import net.sourceforge.plantuml.cucadiagram.HideOrShow2; +import net.sourceforge.plantuml.cucadiagram.HideOrShow; import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.cucadiagram.LinkConstraint; import net.sourceforge.plantuml.cucadiagram.Magma; @@ -93,8 +93,8 @@ import net.sourceforge.plantuml.xmlsc.StateDiagramScxmlMaker; public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, PortionShower, ICucaDiagram { - private final List hides2 = new ArrayList<>(); - private final List removed = new ArrayList<>(); + private final List hides2 = new ArrayList<>(); + private final List removed = new ArrayList<>(); protected final EntityFactory entityFactory = new EntityFactory(hides2, removed, this); private List stacks = new ArrayList<>(); @@ -516,7 +516,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, return false; boolean result = true; - for (HideOrShow cmd : hideOrShows) + for (EntityHideOrShow cmd : hideOrShows) if (cmd.portion == portion && cmd.gender.contains(entity)) result = cmd.show; @@ -525,7 +525,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, public final void hideOrShow(EntityGender gender, EntityPortion portions, boolean show) { for (EntityPortion portion : portions.asSet()) - this.hideOrShows.add(new HideOrShow(gender, portion, show)); + this.hideOrShows.add(new EntityHideOrShow(gender, portion, show)); } @@ -537,22 +537,22 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, } public void hideOrShow2(String what, boolean show) { - this.hides2.add(new HideOrShow2(what, show)); + this.hides2.add(new HideOrShow(what, show)); } public void removeOrRestore(String what, boolean show) { - this.removed.add(new HideOrShow2(what, show)); + this.removed.add(new HideOrShow(what, show)); } - private final List hideOrShows = new ArrayList<>(); + private final List hideOrShows = new ArrayList<>(); private final Set hides = new HashSet<>(); - static class HideOrShow { + static class EntityHideOrShow { private final EntityGender gender; private final EntityPortion portion; private final boolean show; - public HideOrShow(EntityGender gender, EntityPortion portion, boolean show) { + public EntityHideOrShow(EntityGender gender, EntityPortion portion, boolean show) { this.gender = gender; this.portion = portion; this.show = show; diff --git a/src/net/sourceforge/plantuml/abel/EntityFactory.java b/src/net/sourceforge/plantuml/abel/EntityFactory.java index f8d826e11..9e6df0013 100644 --- a/src/net/sourceforge/plantuml/abel/EntityFactory.java +++ b/src/net/sourceforge/plantuml/abel/EntityFactory.java @@ -46,7 +46,7 @@ import net.sourceforge.plantuml.cucadiagram.Bodier; import net.sourceforge.plantuml.cucadiagram.BodierJSon; import net.sourceforge.plantuml.cucadiagram.BodierMap; import net.sourceforge.plantuml.cucadiagram.BodyFactory; -import net.sourceforge.plantuml.cucadiagram.HideOrShow2; +import net.sourceforge.plantuml.cucadiagram.HideOrShow; import net.sourceforge.plantuml.cucadiagram.ICucaDiagram; import net.sourceforge.plantuml.plasma.Plasma; import net.sourceforge.plantuml.plasma.Quark; @@ -64,12 +64,12 @@ public final class EntityFactory implements IEntityFactory { private final Entity rootGroup; - private final List hides2; - private final List removed; + private final List hides2; + private final List removed; final private ICucaDiagram diagram; // - public EntityFactory(List hides2, List removed, ICucaDiagram diagram) { + public EntityFactory(List hides2, List removed, ICucaDiagram diagram) { this.hides2 = hides2; this.removed = removed; this.diagram = diagram; @@ -84,7 +84,7 @@ public final class EntityFactory implements IEntityFactory { return isHidden(other); boolean hidden = false; - for (HideOrShow2 hide : hides2) + for (HideOrShow hide : hides2) hidden = hide.apply(hidden, leaf); return hidden; @@ -92,7 +92,7 @@ public final class EntityFactory implements IEntityFactory { public boolean isRemoved(Stereotype stereotype) { boolean result = false; - for (HideOrShow2 hide : removed) + for (HideOrShow hide : removed) result = hide.apply(result, stereotype); return result; @@ -104,7 +104,7 @@ public final class EntityFactory implements IEntityFactory { return isRemoved((Entity) other); boolean result = false; - for (HideOrShow2 hide : removed) + for (HideOrShow hide : removed) result = hide.apply(result, leaf); return result; @@ -133,7 +133,7 @@ public final class EntityFactory implements IEntityFactory { public boolean isRemovedIgnoreUnlinked(Entity leaf) { boolean result = false; - for (HideOrShow2 hide : removed) + for (HideOrShow hide : removed) if (hide.isAboutUnlinked() == false) result = hide.apply(result, leaf); diff --git a/src/net/sourceforge/plantuml/abel/LinkStrategy.java b/src/net/sourceforge/plantuml/abel/LinkStrategy.java index fe61059b4..17fff6404 100644 --- a/src/net/sourceforge/plantuml/abel/LinkStrategy.java +++ b/src/net/sourceforge/plantuml/abel/LinkStrategy.java @@ -45,12 +45,13 @@ public enum LinkStrategy { * We then retrieve tail/head in generated SVG to compute link decoration angle. * * Drawbacks: sometimes, GraphViz does NOT draw those decorations, which causes issues + * This is to be removed */ - LEGACY, + LEGACY_toberemoved, /* * In simplier mode, there are no tail/head in GraphViz generated dot. - * The decoration angle is retrieve using Bezier data. + * The decoration angle is retrieved using Bezier data. * */ SIMPLIER diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java index c97f0627b..23ddbae23 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java @@ -162,6 +162,8 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC } public boolean swithToElse2(LinkRendering whenElse, LinkRendering nextLinkRenderer) { + this.current.setSpecial(nextLinkRenderer); + if (elseBranch != null) return false; @@ -177,7 +179,6 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC if (elseBranch != null) return false; - // this.current.setInlinkRendering(nextLinkRenderer); this.current.setSpecial(nextLinkRenderer); this.current = new Branch(skinParam.getCurrentStyleBuilder(), swimlane, whenThen, test, color, inlabel); this.thens.add(current); diff --git a/src/net/sourceforge/plantuml/cucadiagram/HideOrShow2.java b/src/net/sourceforge/plantuml/cucadiagram/HideOrShow.java similarity index 94% rename from src/net/sourceforge/plantuml/cucadiagram/HideOrShow2.java rename to src/net/sourceforge/plantuml/cucadiagram/HideOrShow.java index 0ec7559b9..651bf3e46 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/HideOrShow2.java +++ b/src/net/sourceforge/plantuml/cucadiagram/HideOrShow.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.abel.Entity; import net.sourceforge.plantuml.stereo.Stereotag; import net.sourceforge.plantuml.stereo.Stereotype; -public class HideOrShow2 { +public class HideOrShow { private final String what; private final boolean show; @@ -59,8 +59,8 @@ public class HideOrShow2 { if (isAboutUnlinked()) return isApplyableUnlinked(leaf); - final String fullName = leaf.getName(); - // System.err.println("fullName=" + fullName); + final String fullName = leaf.getQuark().getQualifiedName(); + // System.err.println("isApplyable leaf=" + leaf + " fullName=" + fullName); return match(fullName, what); } @@ -112,7 +112,7 @@ public class HideOrShow2 { return s.equals(pattern); } - public HideOrShow2(String what, boolean show) { + public HideOrShow(String what, boolean show) { this.what = what; this.show = show; } diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandEndState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandEndState.java index e69d7d64e..e88435df5 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandEndState.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandEndState.java @@ -60,9 +60,9 @@ public class CommandEndState extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(StateDiagram diagram, LineLocation location, RegexResult arg) { final Entity currentPackage = diagram.getCurrentGroup(); - if (currentPackage == null) { + if (currentPackage == null || currentPackage.isRoot()) return CommandExecutionResult.error("No inner state defined"); - } + diagram.endGroup(); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/svek/SvekLine.java b/src/net/sourceforge/plantuml/svek/SvekLine.java index 9c085d249..cd976eeb0 100644 --- a/src/net/sourceforge/plantuml/svek/SvekLine.java +++ b/src/net/sourceforge/plantuml/svek/SvekLine.java @@ -683,7 +683,7 @@ public class SvekLine implements Moveable, Hideable, GuideLine { if (link.getEntity2().getLeafType() == LeafType.LOLLIPOP_HALF) svekNode2.addImpact(dotPath.getEndAngle()); - if (getLinkStrategy() == LinkStrategy.LEGACY && extremity1 instanceof Extremity + if (getLinkStrategy() == LinkStrategy.LEGACY_toberemoved && extremity1 instanceof Extremity && extremity2 instanceof Extremity) { final XPoint2D p1 = ((Extremity) extremity1).somePoint(); final XPoint2D p2 = ((Extremity) extremity2).somePoint(); diff --git a/test/net/sourceforge/plantuml/url/UrlBuilderTest.java b/test/net/sourceforge/plantuml/url/UrlBuilderTest.java index d5cd77324..f95d5b7a4 100644 --- a/test/net/sourceforge/plantuml/url/UrlBuilderTest.java +++ b/test/net/sourceforge/plantuml/url/UrlBuilderTest.java @@ -1,14 +1,10 @@ -package net.sourceforge.plantuml; +package net.sourceforge.plantuml.url; import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; -import net.sourceforge.plantuml.url.Url; -import net.sourceforge.plantuml.url.UrlBuilder; -import net.sourceforge.plantuml.url.UrlMode; - class UrlBuilderTest { @ParameterizedTest @CsvSource(value = {