From 180b8eddd191be52f1a5c6b61abd3d939b74f7fd Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Wed, 15 Dec 2021 18:40:12 +0100 Subject: [PATCH] Fix (again) https://forum.plantuml.net/5261 --- .../activitydiagram3/InstructionGroup.java | 13 ++-- .../activitydiagram3/InstructionRepeat.java | 42 +++++++---- ...GConnectionHorizontalThenVerticalDown.java | 4 -- ... GConnectionSideThenVerticalThenSide.java} | 19 ++--- .../gtile/GConnectionVerticalDown.java | 4 -- .../GConnectionVerticalDownThenBack.java | 71 +++++++++++-------- ...GConnectionVerticalDownThenHorizontal.java | 4 -- .../activitydiagram3/gtile/GtileColumns.java | 2 - .../activitydiagram3/gtile/GtileGroup.java | 42 +++++++++-- .../activitydiagram3/gtile/GtileIfAlone.java | 2 +- .../gtile/GtileIfHexagon.java | 1 - .../activitydiagram3/gtile/GtileRepeat.java | 32 +++++++-- .../activitydiagram3/gtile/GtileWhile.java | 14 +++- .../gtile/GtileWithNotes.java | 2 - .../sourceforge/plantuml/security/SURL.java | 10 ++- .../plantuml/svek/PortGeometry.java | 21 ++++-- src/net/sourceforge/plantuml/svek/Ports.java | 20 ++++-- .../sourceforge/plantuml/svek/SvekNode.java | 5 +- .../sourceforge/plantuml/version/Version.java | 2 +- 19 files changed, 203 insertions(+), 107 deletions(-) rename src/net/sourceforge/plantuml/activitydiagram3/gtile/{GConnectionLeftThenVerticalThenRight.java => GConnectionSideThenVerticalThenSide.java} (87%) diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java index 28a01d9ea..cb0e6ba45 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java @@ -44,6 +44,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNotes; import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; +import net.sourceforge.plantuml.activitydiagram3.gtile.GtileGroup; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.StringBounder; @@ -52,6 +53,7 @@ import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.HColorUtils; public class InstructionGroup extends AbstractInstruction implements Instruction, InstructionCollection { @@ -63,7 +65,7 @@ public class InstructionGroup extends AbstractInstruction implements Instruction private final LinkRendering linkRendering; private final USymbol type; - private final Display test; + private final Display title; private final double roundCorner; private PositionedNote note = null; @@ -72,13 +74,13 @@ public class InstructionGroup extends AbstractInstruction implements Instruction return list.containsBreak(); } - public InstructionGroup(Instruction parent, Display test, HColor backColor, HColor titleColor, Swimlane swimlane, + public InstructionGroup(Instruction parent, Display title, HColor backColor, HColor titleColor, Swimlane swimlane, HColor borderColor, LinkRendering linkRendering, USymbol type, double roundCorner) { this.list = new InstructionList(swimlane); this.type = type; this.linkRendering = linkRendering; this.parent = parent; - this.test = test; + this.title = title; this.borderColor = borderColor; this.backColor = backColor; this.titleColor = titleColor; @@ -93,7 +95,8 @@ public class InstructionGroup extends AbstractInstruction implements Instruction @Override public Gtile createGtile(ISkinParam skinParam, StringBounder stringBounder) { Gtile tmp = list.createGtile(skinParam, stringBounder); - return tmp; + return new GtileGroup(tmp, title, null, HColorUtils.BLUE, backColor, titleColor, tmp.skinParam(), borderColor, + type, roundCorner); } @Override @@ -102,7 +105,7 @@ public class InstructionGroup extends AbstractInstruction implements Instruction if (note != null) { tmp = new FtileWithNotes(tmp, Collections.singleton(note), factory.skinParam()); } - return factory.createGroup(tmp, test, backColor, titleColor, null, borderColor, type, roundCorner); + return factory.createGroup(tmp, title, backColor, titleColor, null, borderColor, type, roundCorner); } public Instruction getParent() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java index 0345f8913..91fe6795b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java @@ -48,6 +48,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlanes; import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; +import net.sourceforge.plantuml.activitydiagram3.gtile.GtileBox; import net.sourceforge.plantuml.activitydiagram3.gtile.GtileRepeat; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; @@ -100,9 +101,9 @@ public class InstructionRepeat extends AbstractInstruction implements Instructio } private boolean isLastOfTheParent() { - if (parent instanceof InstructionList) { + if (parent instanceof InstructionList) return ((InstructionList) parent).getLast() == this; - } + return false; } @@ -123,35 +124,48 @@ public class InstructionRepeat extends AbstractInstruction implements Instructio public CommandExecutionResult add(Instruction ins) { return repeatList.add(ins); } - + @Override public Gtile createGtile(ISkinParam skinParam, StringBounder stringBounder) { final Gtile tile = repeatList.createGtile(skinParam, stringBounder); - return new GtileRepeat(swimlane, tile, null, test); + final Gtile backward = getGtileBackward(skinParam, stringBounder); + + return new GtileRepeat(swimlane, tile, null, test, backward); + } + + private Gtile getGtileBackward(ISkinParam skinParam, StringBounder stringBounder) { + if (Display.isNull(backward)) + return null; + + GtileBox result = GtileBox.create(stringBounder, skinParam, backward, getSwimlaneIn(), boxStyle, null); +// if (backwardNotes.size() > 0) { +// result = factory.addNote(result, swimlaneOut, backwardNotes); +// } + return result; } public Ftile createFtile(FtileFactory factory) { - final Ftile back = getBackward(factory); + final Ftile back = getFtileBackward(factory); final Ftile decorateOut = factory.decorateOut(repeatList.createFtile(factory), endRepeatLinkRendering); if (this.testCalled == false && incoming1.isNone()) incoming1 = swimlanes.nextLinkRenderer(); final Ftile result = factory.repeat(boxStyleIn, swimlane, swimlaneOut, startLabel, decorateOut, test, yes, out, colors, back, isLastOfTheParent(), incoming1, incoming2); - if (killed) { + if (killed) return new FtileKilled(result); - } + return result; } - private Ftile getBackward(FtileFactory factory) { - if (Display.isNull(backward)) { + private Ftile getFtileBackward(FtileFactory factory) { + if (Display.isNull(backward)) return null; - } + Ftile result = factory.activity(backward, swimlaneOut, boxStyle, Colors.empty(), null); - if (backwardNotes.size() > 0) { + if (backwardNotes.size() > 0) result = factory.addNote(result, swimlaneOut, backwardNotes); - } + return result; } @@ -186,9 +200,9 @@ public class InstructionRepeat extends AbstractInstruction implements Instructio @Override public boolean addNote(Display note, NotePosition position, NoteType type, Colors colors, Swimlane swimlaneNote) { - if (Display.isNull(backward)) { + if (Display.isNull(backward)) return repeatList.addNote(note, position, type, colors, swimlaneNote); - } + this.backwardNotes.add(new PositionedNote(note, position, type, colors, swimlaneNote)); return true; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionHorizontalThenVerticalDown.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionHorizontalThenVerticalDown.java index a4afbce99..f6a7fbefb 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionHorizontalThenVerticalDown.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionHorizontalThenVerticalDown.java @@ -40,16 +40,12 @@ import java.awt.geom.Point2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Direction; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon; import net.sourceforge.plantuml.activitydiagram3.ftile.MergeStrategy; import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.UTranslate; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionLeftThenVerticalThenRight.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionSideThenVerticalThenSide.java similarity index 87% rename from src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionLeftThenVerticalThenRight.java rename to src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionSideThenVerticalThenSide.java index e2e3799f8..510466f87 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionLeftThenVerticalThenRight.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionSideThenVerticalThenSide.java @@ -41,32 +41,32 @@ import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class GConnectionLeftThenVerticalThenRight extends GAbstractConnection { +public class GConnectionSideThenVerticalThenSide extends GAbstractConnection { private final TextBlock textBlock; private final UTranslate pos1; private final UTranslate pos2; - private final double xright; + private final double xpos; - public GConnectionLeftThenVerticalThenRight(UTranslate pos1, GPoint gpoint1, UTranslate pos2, GPoint gpoint2, - double xright, TextBlock textBlock) { + public GConnectionSideThenVerticalThenSide(UTranslate pos1, GPoint gpoint1, UTranslate pos2, GPoint gpoint2, + double xpos, TextBlock textBlock) { super(gpoint1, gpoint2); this.textBlock = textBlock; this.pos1 = pos1; this.pos2 = pos2; - this.xright = xright; + this.xpos = xpos; // See FtileFactoryDelegatorAssembly } @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { - throw new UnsupportedOperationException(); + throw new UnsupportedOperationException("wip3"); } @@ -75,10 +75,11 @@ public class GConnectionLeftThenVerticalThenRight extends GAbstractConnection { final Point2D p1 = pos1.getTranslated(gpoint1.getPoint2D()); final Point2D p2 = pos2.getTranslated(gpoint2.getPoint2D()); final Direction direction = p1.getY() < p2.getY() ? Direction.DOWN : Direction.UP; - final Snake snake = Snake.create(getInLinkRenderingColor(), Arrows.asToLeft()).emphasizeDirection(direction) + final UPolygon tmp = p1.getX() < p2.getX() ? Arrows.asToRight() : Arrows.asToLeft(); + final Snake snake = Snake.create(getInLinkRenderingColor(), tmp).emphasizeDirection(direction) .withLabel(textBlock, HorizontalAlignment.LEFT); // final double maxX = Math.max(p1.getX(), p2.getX()); - final double maxX = xright; + final double maxX = xpos; snake.addPoint(p1); snake.addPoint(new Point2D.Double(maxX, p1.getY())); snake.addPoint(new Point2D.Double(maxX, p2.getY())); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDown.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDown.java index ef8e3032a..89a3ee357 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDown.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDown.java @@ -37,14 +37,10 @@ package net.sourceforge.plantuml.activitydiagram3.gtile; import java.awt.geom.Point2D; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDownThenBack.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDownThenBack.java index 36d6f3902..014178b6b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDownThenBack.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDownThenBack.java @@ -38,16 +38,10 @@ package net.sourceforge.plantuml.activitydiagram3.gtile; import java.awt.geom.Point2D; import net.sourceforge.plantuml.Direction; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; -import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon; -import net.sourceforge.plantuml.activitydiagram3.ftile.MergeStrategy; import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -57,26 +51,60 @@ public class GConnectionVerticalDownThenBack extends GAbstractConnection { private final TextBlock textBlock; private final UTranslate pos1; private final UTranslate pos2; + private final double xpos; public GConnectionVerticalDownThenBack(UTranslate pos1, GPoint gpoint1, UTranslate pos2, GPoint gpoint2, - TextBlock textBlock) { + TextBlock textBlock, double xpos) { super(gpoint1, gpoint2); this.textBlock = textBlock; this.pos1 = pos1; this.pos2 = pos2; + this.xpos = xpos; // See FtileFactoryDelegatorAssembly } + @Override + public void drawU(UGraphic ug) { + final Point2D p1 = pos1.getTranslated(gpoint1.getPoint2D()); + final Point2D p2 = pos2.getTranslated(gpoint2.getPoint2D()); + final UPolygon arrow = Arrows.asToLeft(); + final Snake snake = Snake.create(getInLinkRenderingColor(), arrow) + .withLabel(textBlock, HorizontalAlignment.LEFT).emphasizeDirection(Direction.UP); + + snake.addPoint(p1); + final Point2D p1bis = UTranslate.dy(10).getTranslated(p1); + snake.addPoint(p1bis); + final double border = xpos; + + snake.addPoint(new Point2D.Double(border, p1bis.getY())); + snake.addPoint(new Point2D.Double(border, p2.getY())); + snake.addPoint(p2); + ug.draw(snake); + } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { - throw new UnsupportedOperationException("wip"); -// Point2D p1 = pos1.getTranslated(gpoint1.getPoint2D()); -// Point2D p2 = pos2.getTranslated(gpoint2.getPoint2D()); -// + // throw new UnsupportedOperationException("wip"); + Point2D p1 = pos1.getTranslated(gpoint1.getPoint2D()); + Point2D p2 = pos2.getTranslated(gpoint2.getPoint2D()); + // final Direction originalDirection = Direction.leftOrRight(p1, p2); // -//// p1 = translate1.getTranslated(p1); -//// p2 = translate2.getTranslated(p2); + p1 = translate1.getTranslated(p1); + p2 = translate2.getTranslated(p2); + + final UPolygon arrow = Arrows.asToLeft(); + final Snake snake = Snake.create(getInLinkRenderingColor(), arrow) + .withLabel(textBlock, HorizontalAlignment.LEFT).emphasizeDirection(Direction.UP); + + snake.addPoint(p1); + final Point2D p1bis = UTranslate.dy(10).getTranslated(p1); + snake.addPoint(p1bis); + snake.addPoint(new Point2D.Double(p2.getX() + 20, p1bis.getY())); + snake.addPoint(new Point2D.Double(p2.getX() + 20, p2.getY())); + snake.addPoint(p2); + ug.draw(snake); + // // final double x1 = p1.getX(); // final double x2 = p2.getX(); @@ -117,23 +145,6 @@ public class GConnectionVerticalDownThenBack extends GAbstractConnection { } - @Override - public void drawU(UGraphic ug) { - final Point2D p1 = pos1.getTranslated(gpoint1.getPoint2D()); - final Point2D p2 = pos2.getTranslated(gpoint2.getPoint2D()); - final UPolygon arrow = Arrows.asToLeft(); - final Snake snake = Snake.create(getInLinkRenderingColor(), arrow).withLabel(textBlock, - HorizontalAlignment.LEFT).emphasizeDirection(Direction.UP); - - snake.addPoint(p1); - final Point2D p1bis = UTranslate.dy(10).getTranslated(p1); - snake.addPoint(p1bis); - snake.addPoint(new Point2D.Double(p2.getX() + 20, p1bis.getY())); - snake.addPoint(new Point2D.Double(p2.getX() + 20, p2.getY())); - snake.addPoint(p2); - ug.draw(snake); - } - // public double getMaxX(StringBounder stringBounder) { // return getSimpleSnake().getMaxX(stringBounder); // } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDownThenHorizontal.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDownThenHorizontal.java index 963f664d1..bc3a3d34c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDownThenHorizontal.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDownThenHorizontal.java @@ -38,16 +38,12 @@ package net.sourceforge.plantuml.activitydiagram3.gtile; import java.awt.geom.Point2D; import net.sourceforge.plantuml.Direction; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon; import net.sourceforge.plantuml.activitydiagram3.ftile.MergeStrategy; import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.UTranslate; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileColumns.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileColumns.java index 13e0de903..266a5432c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileColumns.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileColumns.java @@ -36,11 +36,9 @@ package net.sourceforge.plantuml.activitydiagram3.gtile; import java.awt.geom.Dimension2D; -import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; -import java.util.ListIterator; import java.util.Set; import net.sourceforge.plantuml.Dimension2DDouble; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileGroup.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileGroup.java index 89842d6b1..4cf1502e6 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileGroup.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileGroup.java @@ -40,16 +40,20 @@ import java.util.Collection; import java.util.Collections; import java.util.Set; +import net.sourceforge.plantuml.AlignmentParam; +import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.UseStyle; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FloatingNote; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.USymbol; @@ -63,6 +67,7 @@ import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorUtils; +import net.sourceforge.plantuml.utils.MathUtils; public class GtileGroup extends AbstractGtileRoot { @@ -81,6 +86,15 @@ public class GtileGroup extends AbstractGtileRoot { return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.partition); } + private double suppWidth(StringBounder stringBounder) { + final Dimension2D orig = inner.calculateDimension(stringBounder); + final Dimension2D dimTitle = name.calculateDimension(stringBounder); + final Dimension2D dimHeaderNote = headerNote.calculateDimension(stringBounder); + final double suppWidth = MathUtils.max(orig.getWidth(), dimTitle.getWidth() + 20, dimHeaderNote.getWidth() + 20) + - orig.getWidth(); + return suppWidth; + } + public GtileGroup(Gtile inner, Display title, Display displayNote, HColor arrowColor, HColor backColor, HColor titleColor, ISkinParam skinParam, HColor borderColor, USymbol type, double roundCorner) { super(inner.getStringBounder(), skinParam); @@ -136,20 +150,38 @@ public class GtileGroup extends AbstractGtileRoot { @Override public Dimension2D calculateDimension(StringBounder stringBounder) { - // TODO Auto-generated method stub - return null; + final Dimension2D orig = inner.calculateDimension(stringBounder); + return Dimension2DDouble.delta(orig, 18, suppHeight(stringBounder)); + } + + private double suppHeight(StringBounder stringBounder) { + final Dimension2D dimTitle = name.calculateDimension(stringBounder); + return dimTitle.getHeight() + 30; + } + + private UTranslate getTranslate() { + return new UTranslate(9, suppHeight(getStringBounder()) - 10); } @Override protected UTranslate getCoordImpl(String name) { - // TODO Auto-generated method stub - return null; + return inner.getCoord(name).compose(getTranslate()); } @Override protected void drawUInternal(UGraphic ug) { - // TODO Auto-generated method stub + final Dimension2D dimTotal = calculateDimension(stringBounder); + + final SymbolContext symbolContext = new SymbolContext(backColor, borderColor).withShadow(shadowing) + .withStroke(stroke).withCorner(roundCorner, 0); + + final HorizontalAlignment align = inner.skinParam().getHorizontalAlignment(AlignmentParam.packageTitleAlignment, + null, false, null); + type.asBig(name, align, TextBlockUtils.empty(0, 0), dimTotal.getWidth(), dimTotal.getHeight(), symbolContext, + skinParam().getStereotypeAlignment()).drawU(ug); + + inner.drawU(ug.apply(getTranslate())); } // @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfAlone.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfAlone.java index df79023a0..4d1564b34 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfAlone.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfAlone.java @@ -101,7 +101,7 @@ public class GtileIfAlone extends GtileTopDown3 { final double xright = calculateDimension(stringBounder).getWidth(); - final GConnection arrow3 = new GConnectionLeftThenVerticalThenRight(getPos1(), tile1.getGPoint(GPoint.EAST_HOOK), + final GConnection arrow3 = new GConnectionSideThenVerticalThenSide(getPos1(), tile1.getGPoint(GPoint.EAST_HOOK), getPos3(), tile3.getGPoint(GPoint.EAST_HOOK), xright, TextBlockUtils.EMPTY_TEXT_BLOCK); return Arrays.asList(arrow1, arrow2, arrow3); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfHexagon.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfHexagon.java index 697f3b381..fc65bdc75 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfHexagon.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfHexagon.java @@ -50,7 +50,6 @@ import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.utils.MathUtils; public class GtileIfHexagon extends GtileColumns { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileRepeat.java index 0d49a661d..e3514d5c0 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileRepeat.java @@ -36,8 +36,11 @@ package net.sourceforge.plantuml.activitydiagram3.gtile; import java.awt.geom.Dimension2D; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; +import java.util.List; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ISkinParam; @@ -47,15 +50,19 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.StyleSignature; +import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.color.HColor; public class GtileRepeat extends GtileTopDown3 { private static final double SUPP_WIDTH = 15; - public GtileRepeat(Swimlane swimlane, Gtile gtile, HColor color, Display test) { + private final Gtile backward; + + public GtileRepeat(Swimlane swimlane, Gtile gtile, HColor color, Display test, Gtile backward) { super(getShape1(swimlane, color, gtile.getStringBounder(), gtile.skinParam()), gtile, getShape2(swimlane, color, gtile.getStringBounder(), gtile.skinParam(), test)); + this.backward = backward; } @@ -93,20 +100,37 @@ public class GtileRepeat extends GtileTopDown3 { return Dimension2DDouble.delta(super.calculateDimension(stringBounder), SUPP_WIDTH, 0); } + @Override + protected void drawUInternal(UGraphic ug) { + super.drawUInternal(ug); + if (backward != null) { + backward.drawU(ug); + } + } + @Override public Collection getInnerConnections() { + final List result = new ArrayList(); final GConnection arrow1 = new GConnectionVerticalDown(getPos1(), tile1.getGPoint(GPoint.SOUTH_HOOK), getPos2(), tile2.getGPoint(GPoint.NORTH_HOOK), TextBlockUtils.EMPTY_TEXT_BLOCK); final GConnection arrow2 = new GConnectionVerticalDown(getPos2(), tile2.getGPoint(GPoint.SOUTH_HOOK), getPos3(), tile3.getGPoint(GPoint.NORTH_HOOK), TextBlockUtils.EMPTY_TEXT_BLOCK); + result.add(arrow1); + result.add(arrow2); + final double xright = calculateDimension(stringBounder).getWidth(); - final GConnection arrow3 = new GConnectionLeftThenVerticalThenRight(getPos3(), tile3.getGPoint(GPoint.EAST_HOOK), - getPos1(), tile1.getGPoint(GPoint.EAST_HOOK), xright, TextBlockUtils.EMPTY_TEXT_BLOCK); + if (backward == null) { + final GConnection arrow3 = new GConnectionSideThenVerticalThenSide(getPos3(), + tile3.getGPoint(GPoint.EAST_HOOK), getPos1(), tile1.getGPoint(GPoint.EAST_HOOK), xright, + TextBlockUtils.EMPTY_TEXT_BLOCK); + result.add(arrow3); + } - return Arrays.asList(arrow1, arrow2, arrow3); + // final List result = Arrays.asList(arrow1, arrow2, arrow3); + return Collections.unmodifiableList(result); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWhile.java index 8e365b44c..0c86bdea2 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWhile.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWhile.java @@ -76,10 +76,18 @@ public class GtileWhile extends GtileTopDown3 { public Collection getInnerConnections() { final GConnection arrow1 = new GConnectionVerticalDown(getPos1(), tile1.getGPoint(GPoint.SOUTH_HOOK), getPos2(), tile2.getGPoint(GPoint.NORTH_HOOK), TextBlockUtils.EMPTY_TEXT_BLOCK); - final GConnection arrow2 = new GConnectionVerticalDownThenBack(getPos2(), tile2.getGPoint(GPoint.SOUTH_HOOK), - getPos1(), tile1.getGPoint(GPoint.EAST_HOOK), TextBlockUtils.EMPTY_TEXT_BLOCK); - return Arrays.asList(arrow1, arrow2); + final double xright = calculateDimension(stringBounder).getWidth(); + + final GConnection arrow2 = new GConnectionVerticalDownThenBack(getPos2(), tile2.getGPoint(GPoint.SOUTH_HOOK), + getPos1(), tile1.getGPoint(GPoint.EAST_HOOK), TextBlockUtils.EMPTY_TEXT_BLOCK, xright); + + final double xleft = 0; + + final GConnection arrow3 = new GConnectionSideThenVerticalThenSide(getPos1(), tile1.getGPoint(GPoint.WEST_HOOK), + getPos3(), tile3.getGPoint(GPoint.SOUTH_HOOK), xleft, TextBlockUtils.EMPTY_TEXT_BLOCK); + + return Arrays.asList(arrow1, arrow2, arrow3); } // private final Ftile whileBlock; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithNotes.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithNotes.java index 5755c1e15..db4ae0a8d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithNotes.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithNotes.java @@ -46,8 +46,6 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.activitydiagram3.PositionedNote; -import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.Parser; diff --git a/src/net/sourceforge/plantuml/security/SURL.java b/src/net/sourceforge/plantuml/security/SURL.java index 0aefbf793..77f985e45 100644 --- a/src/net/sourceforge/plantuml/security/SURL.java +++ b/src/net/sourceforge/plantuml/security/SURL.java @@ -233,7 +233,7 @@ public class SURL { return true; if (SecurityUtils.getSecurityProfile() == SecurityProfile.INTERNET) { - if (pureIP(cleanPath(internal.toString()))) + if (forbiddenURL(cleanPath(internal.toString()))) return false; final int port = internal.getPort(); @@ -243,8 +243,12 @@ public class SURL { return false; } - private boolean pureIP(String full) { - return full.matches("^https?://\\d+\\.\\d+\\.\\d+\\.\\d+.*"); + private boolean forbiddenURL(String full) { + if (full.matches("^https?://\\d+\\.\\d+\\.\\d+\\.\\d+.*")) + return true; + if (full.matches("^https?://[^.]+/.*")) + return true; + return false; } private boolean isInAllowList() { diff --git a/src/net/sourceforge/plantuml/svek/PortGeometry.java b/src/net/sourceforge/plantuml/svek/PortGeometry.java index 0c5b2a3f2..93d22b181 100644 --- a/src/net/sourceforge/plantuml/svek/PortGeometry.java +++ b/src/net/sourceforge/plantuml/svek/PortGeometry.java @@ -35,25 +35,27 @@ */ package net.sourceforge.plantuml.svek; -public class PortGeometry { +public final class PortGeometry implements Comparable { + private final String id; private final double position; private final double height; private final int score; - public PortGeometry(double position, double height, int score) { + public PortGeometry(String id, double position, double height, int score) { + this.id = id; this.position = position; this.height = height; this.score = score; } public PortGeometry translateY(double deltaY) { - return new PortGeometry(position + deltaY, height, score); + return new PortGeometry(id, position + deltaY, height, score); } @Override public String toString() { - return "pos=" + position + " height=" + height; + return "pos=" + position + " height=" + height + " (" + score + ")"; } public double getHeight() { @@ -68,8 +70,17 @@ public class PortGeometry { return position + height; } - public final int getScore() { + public int getScore() { return score; } + public String getId() { + return id; + } + + @Override + public int compareTo(PortGeometry other) { + return Double.compare(this.position, other.position); + } + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/Ports.java b/src/net/sourceforge/plantuml/svek/Ports.java index 7c235a59d..4f8b1af34 100644 --- a/src/net/sourceforge/plantuml/svek/Ports.java +++ b/src/net/sourceforge/plantuml/svek/Ports.java @@ -35,7 +35,11 @@ */ package net.sourceforge.plantuml.svek; -import java.util.LinkedHashMap; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; @@ -44,7 +48,7 @@ import net.sourceforge.plantuml.SignatureUtils; public class Ports { - private final Map ids = new LinkedHashMap(); + private final Map ids = new HashMap(); public static String encodePortNameToId(String portName) { return "p" + SignatureUtils.getMD5Hex(portName); @@ -57,9 +61,9 @@ public class Ports { public Ports translateY(double deltaY) { final Ports result = new Ports(); - for (Map.Entry ent : ids.entrySet()) { + for (Map.Entry ent : ids.entrySet()) result.ids.put(ent.getKey(), ent.getValue().translateY(deltaY)); - } + return result; } @@ -67,7 +71,7 @@ public class Ports { final String id = encodePortNameToId(Objects.requireNonNull(portName)); final PortGeometry already = ids.get(id); if (already == null || already.getScore() < score) - ids.put(id, new PortGeometry(position, height, score)); + ids.put(id, new PortGeometry(id, position, height, score)); } public void addThis(Ports other) { @@ -79,8 +83,10 @@ public class Ports { } } - public Map getAllWithEncodedPortId() { - return ids; + public Collection getAllPortGeometry() { + final List result = new ArrayList(ids.values()); + Collections.sort(result); + return Collections.unmodifiableCollection(result); } } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/SvekNode.java b/src/net/sourceforge/plantuml/svek/SvekNode.java index bff3f30af..0a7333f6c 100644 --- a/src/net/sourceforge/plantuml/svek/SvekNode.java +++ b/src/net/sourceforge/plantuml/svek/SvekNode.java @@ -206,9 +206,8 @@ public class SvekNode implements Positionable, IShapePseudo, Hideable { sb.append(""); double position = 0; - for (Map.Entry ent : ports.getAllWithEncodedPortId().entrySet()) { - final String portId = ent.getKey(); - final PortGeometry geom = ent.getValue(); + for (PortGeometry geom : ports.getAllPortGeometry()) { + final String portId = geom.getId(); final double missing = geom.getPosition() - position; appendTr(sb, null, missing); appendTr(sb, portId, geom.getHeight()); diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index eea1aa399..50b37b808 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -80,7 +80,7 @@ public class Version { } public static int beta() { - final int beta = 2; + final int beta = 3; return beta; }