From c670872511462d27ed79e295275bad6fa117aa03 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Mon, 12 Oct 2020 22:56:58 +0200 Subject: [PATCH] Import version 1.2020.19 --- pom.xml | 2 +- src/net/sourceforge/plantuml/Option.java | 12 ++ src/net/sourceforge/plantuml/OptionPrint.java | 1 + src/net/sourceforge/plantuml/Run.java | 12 ++ src/net/sourceforge/plantuml/SvgString.java | 25 +++ .../activitydiagram3/ActivityDiagram3.java | 11 +- .../activitydiagram3/InstructionRepeat.java | 20 +- .../activitydiagram3/InstructionWhile.java | 9 +- .../command/CommandBackward3.java | 15 +- .../command/CommandRepeatWhile3.java | 6 +- .../activitydiagram3/ftile/FtileFactory.java | 5 +- .../ftile/FtileFactoryDelegator.java | 8 +- .../activitydiagram3/ftile/Snake.java | 185 +++++++++++------- .../plantuml/activitydiagram3/ftile/Worm.java | 9 + .../vcompact/ConnectionVerticalDown.java | 13 +- .../vcompact/FtileFactoryDelegatorRepeat.java | 7 +- .../vcompact/FtileFactoryDelegatorWhile.java | 9 +- .../ftile/vcompact/FtileIfAndStop.java | 2 +- .../ftile/vcompact/FtileIfDown.java | 71 +++---- .../ftile/vcompact/FtileIfLongHorizontal.java | 19 +- .../ftile/vcompact/FtileIfLongVertical.java | 14 +- .../ftile/vcompact/FtileRepeat.java | 55 +++--- .../ftile/vcompact/FtileWhile.java | 51 ++--- .../ftile/vcompact/ParallelBuilderFork.java | 20 +- .../ftile/vcompact/ParallelBuilderMerge.java | 10 +- .../ftile/vcompact/ParallelBuilderSplit.java | 16 +- .../ftile/vcompact/VCompactFactory.java | 5 +- .../ftile/vcompact/cond/FtileIfWithLinks.java | 50 +++-- .../cond/FtileSwitchWithManyLinks.java | 35 ++-- .../vcompact/cond/FtileSwitchWithOneLink.java | 18 +- .../command/CommandLinkClass.java | 8 +- .../command/PSystemAbstractFactory.java | 10 +- .../sourceforge/plantuml/core/UmlSource.java | 4 + .../plantuml/cucadiagram/LeafType.java | 2 +- .../plantuml/cucadiagram/LinkDecor.java | 9 +- .../plantuml/cucadiagram/LinkMiddleDecor.java | 9 + .../plantuml/cucadiagram/LinkType.java | 2 +- .../command/CommandCreateElementFull.java | 36 +++- .../plantuml/directdot/PSystemDotFactory.java | 2 +- .../plantuml/error/PSystemError.java | 4 +- .../plantuml/error/PSystemErrorEmpty.java | 52 +++++ .../plantuml/error/PSystemErrorUtils.java | 16 +- .../plantuml/graphic/QuoteUtils.java | 5 +- .../plantuml/graphic/Splitter.java | 4 + .../sourceforge/plantuml/graphic/USymbol.java | 26 +-- .../plantuml/graphic/USymbolArtifact.java | 9 +- .../plantuml/graphic/USymbolCard.java | 3 +- .../plantuml/graphic/USymbolCloud.java | 3 +- .../plantuml/graphic/USymbolCollections.java | 3 +- .../plantuml/graphic/USymbolComponent1.java | 3 +- .../plantuml/graphic/USymbolComponent2.java | 6 +- .../plantuml/graphic/USymbolFile.java | 6 +- .../plantuml/graphic/USymbolFolder.java | 3 +- .../plantuml/graphic/USymbolFrame.java | 3 +- .../plantuml/graphic/USymbolLabel.java | 3 +- .../plantuml/graphic/USymbolRect.java | 6 +- .../graphic/USymbolSimpleAbstract.java | 3 +- .../plantuml/graphic/USymbolStack.java | 3 +- .../plantuml/graphic/USymbolStorage.java | 3 +- .../jdot/CucaDiagramFileMakerJDot.java | 57 ++++-- .../sourceforge/plantuml/jdot/JDotPath.java | 54 ++++- .../plantuml/picoweb/PicoWebServer.java | 155 +++++++++++++++ .../project/draw/TaskDrawRegular.java | 6 +- .../salt/element/AbstractElementText.java | 5 +- .../plantuml/sequencediagram/LinkAnchor.java | 4 +- .../plantuml/skin/ActorStickMan.java | 23 ++- .../sourceforge/plantuml/skin/ActorStyle.java | 6 +- .../sourceforge/plantuml/svek/Cluster.java | 4 + .../plantuml/svek/GeneralImageBuilder.java | 3 + .../plantuml/svek/UGraphicForSnake.java | 4 +- .../extremity/ExtremityFactoryTriangle.java | 15 +- .../svek/extremity/ExtremityTriangle.java | 12 +- .../svek/image/EntityImageDescription.java | 9 +- .../svek/image/EntityImageUseCase.java | 35 ++++ .../svek/image/QuadraticEquation.java | 61 ++++++ .../plantuml/svek/image/RotatedEllipse.java | 93 +++++++++ .../plantuml/ugraphic/UEllipse.java | 13 ++ .../plantuml/ugraphic/UGraphicStencil.java | 22 ++- .../sourceforge/plantuml/version/Version.java | 4 +- 79 files changed, 1142 insertions(+), 404 deletions(-) create mode 100644 src/net/sourceforge/plantuml/error/PSystemErrorEmpty.java create mode 100644 src/net/sourceforge/plantuml/picoweb/PicoWebServer.java create mode 100644 src/net/sourceforge/plantuml/svek/image/QuadraticEquation.java create mode 100644 src/net/sourceforge/plantuml/svek/image/RotatedEllipse.java diff --git a/pom.xml b/pom.xml index c58f20590..5b726b17c 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ net.sourceforge.plantuml plantuml - 1.2020.19-SNAPSHOT + 1.2020.20-SNAPSHOT jar PlantUML diff --git a/src/net/sourceforge/plantuml/Option.java b/src/net/sourceforge/plantuml/Option.java index 7104fada8..ad463f7ee 100644 --- a/src/net/sourceforge/plantuml/Option.java +++ b/src/net/sourceforge/plantuml/Option.java @@ -79,6 +79,7 @@ public class Option { private boolean textProgressBar = false; private int nbThreads = 0; private int ftpPort = -1; + private int picowebPort = -1; private boolean hideMetadata = false; private boolean checkMetadata = false; private int stdrpt = 0; @@ -368,6 +369,13 @@ public class Option { } else { this.ftpPort = Integer.parseInt(s.substring(x + 1)); } + } else if (StringUtils.goLowerCase(s).startsWith("-picoweb")) { + final int x = s.indexOf(':'); + if (x == -1) { + this.picowebPort = 8080; + } else { + this.picowebPort = Integer.parseInt(s.substring(x + 1)); + } } else if (s.startsWith("-c")) { s = s.substring(2); config.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s)); @@ -395,6 +403,10 @@ public class Option { return ftpPort; } + public int getPicowebPort() { + return picowebPort; + } + private void addInConfig(BufferedReader br) throws IOException { if (br == null) { return; diff --git a/src/net/sourceforge/plantuml/OptionPrint.java b/src/net/sourceforge/plantuml/OptionPrint.java index bc8cedb06..9588a1713 100644 --- a/src/net/sourceforge/plantuml/OptionPrint.java +++ b/src/net/sourceforge/plantuml/OptionPrint.java @@ -156,6 +156,7 @@ public class OptionPrint { System.out.println(" -filename \"example.puml\"\tTo override %filename% variable"); System.out.println(" -preproc\t\tTo output preprocessor text of diagrams"); System.out.println(" -cypher\t\tTo cypher texts of diagrams so that you can share them"); + System.out.println(" -picoweb\t\tTo start internal HTTP Server. See https://plantuml.com/picoweb"); System.out.println(); System.out.println("If needed, you can setup the environment variable GRAPHVIZ_DOT."); exit(0); diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index 8a903e1db..a6465e758 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -62,6 +62,7 @@ import net.sourceforge.plantuml.code.TranscoderUtil; import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.descdiagram.DescriptionDiagramFactory; import net.sourceforge.plantuml.ftp.FtpServer; +import net.sourceforge.plantuml.picoweb.PicoWebServer; import net.sourceforge.plantuml.png.MetadataTag; import net.sourceforge.plantuml.preproc.Stdlib; import net.sourceforge.plantuml.security.ImageIO; @@ -144,6 +145,11 @@ public class Run { return; } + if (option.getPicowebPort() != -1) { + goPicoweb(option); + return; + } + forceOpenJdkResourceLoad(); if (option.getPreprocessorOutputMode() == OptionPreprocOutputMode.CYPHER) { cypher = new LanguageDescriptor().getCypher(); @@ -327,6 +333,12 @@ public class Run { ftpServer.go(); } + private static void goPicoweb(Option option) throws IOException { + final int picoWebport = option.getPicowebPort(); + System.err.println("webPort=" + picoWebport); + PicoWebServer.startServer(picoWebport); + } + public static void printFonts() { final Font fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); for (Font f : fonts) { diff --git a/src/net/sourceforge/plantuml/SvgString.java b/src/net/sourceforge/plantuml/SvgString.java index 8baa9af37..1baca4f4d 100644 --- a/src/net/sourceforge/plantuml/SvgString.java +++ b/src/net/sourceforge/plantuml/SvgString.java @@ -68,12 +68,37 @@ public class SvgString { final int idx = result.indexOf(">"); result = "" + result.substring(idx + 1); } + final String style = extractSvgStyle(); + if (style != null) { + final String background = extractBackground(style); + if (background != null) { + result = result.replaceFirst("", " "); + } + } if (result.startsWith("") == false) { throw new IllegalArgumentException(); } return result; } + private String extractBackground(String style) { + final Pattern p = Pattern.compile("background:([^;]+)"); + final Matcher m = p.matcher(style); + if (m.find()) { + return m.group(1); + } + return null; + } + + private String extractSvgStyle() { + final Pattern p = Pattern.compile("(?i)\\]+style=\"([^\">]+)\""); + final Matcher m = p.matcher(svg); + if (m.find()) { + return m.group(1); + } + return null; + } + public int getData(String name) { final Pattern p = Pattern.compile("(?i)" + name + "\\W+(\\d+)"); final Matcher m = p.matcher(svg); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java index 779d2635b..74051f498 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java @@ -406,16 +406,16 @@ public class ActivityDiagram3 extends UmlDiagram { } - public CommandExecutionResult backwardWhile(Display label, BoxStyle boxStyle) { + public CommandExecutionResult backwardWhile(Display label, BoxStyle boxStyle, String incoming, String outcoming) { manageSwimlaneStrategy(); if (current() instanceof InstructionRepeat) { final InstructionRepeat instructionRepeat = (InstructionRepeat) current(); - instructionRepeat.setBackward(label, swinlanes.getCurrentSwimlane(), boxStyle); + instructionRepeat.setBackward(label, swinlanes.getCurrentSwimlane(), boxStyle, incoming, outcoming); return CommandExecutionResult.ok(); } if (current() instanceof InstructionWhile) { final InstructionWhile instructionWhile = (InstructionWhile) current(); - instructionWhile.setBackward(label, swinlanes.getCurrentSwimlane(), boxStyle); + instructionWhile.setBackward(label, swinlanes.getCurrentSwimlane(), boxStyle, incoming, outcoming); return CommandExecutionResult.ok(); } return CommandExecutionResult.error("Cannot find repeat"); @@ -489,6 +489,11 @@ public class ActivityDiagram3 extends UmlDiagram { } public void setLabelNextArrow(Display label) { + if (current() instanceof InstructionRepeat && ((InstructionRepeat) current()).hasBackward()) { + final InstructionRepeat instructionRepeat = (InstructionRepeat) current(); + instructionRepeat.setBackwardArrowLabel(label); + return; + } if (current() instanceof InstructionWhile && ((InstructionWhile) current()).getLast() == null) { ((InstructionWhile) current()).overwriteYes(label); return; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java index 98216f238..101ffc367 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java @@ -62,6 +62,9 @@ public class InstructionRepeat implements Instruction { private final BoxStyle boxStyleIn; private Display backward = Display.NULL; + private Display backwardArrowLabel = Display.NULL; + private String incoming; + private String outcoming; private List backwardNotes = new ArrayList(); private Display test = Display.NULL; private Display yes = Display.NULL; @@ -97,10 +100,21 @@ public class InstructionRepeat implements Instruction { return false; } - public void setBackward(Display label, Swimlane swimlaneOut, BoxStyle boxStyle) { + public void setBackward(Display label, Swimlane swimlaneOut, BoxStyle boxStyle, String incoming, String outcoming) { this.backward = label; this.swimlaneOut = swimlaneOut; this.boxStyle = boxStyle; + this.incoming = incoming; + this.outcoming = outcoming; + this.backwardArrowLabel = Display.getWithNewlines(outcoming); + } + + public void setBackwardArrowLabel(Display label) { + // this.backwardArrowLabel = label; + } + + public boolean hasBackward() { + return this.backward != Display.NULL; } public void add(Instruction ins) { @@ -110,8 +124,10 @@ public class InstructionRepeat implements Instruction { public Ftile createFtile(FtileFactory factory) { final Ftile back = getBackward(factory); final Ftile decorateOut = factory.decorateOut(repeatList.createFtile(factory), endRepeatLinkRendering); + final LinkRendering tmp = incoming == null ? backRepeatLinkRendering + : backRepeatLinkRendering.withDisplay(Display.create(incoming)); final Ftile result = factory.repeat(boxStyleIn, swimlane, swimlaneOut, startLabel, decorateOut, test, yes, out, - colors, backRepeatLinkRendering, back, isLastOfTheParent()); + colors, tmp, back, isLastOfTheParent(), backwardArrowLabel); if (killed) { return new FtileKilled(result); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java index 8925dc31b..564864fc7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java @@ -101,7 +101,8 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi final Ftile back = Display.isNull(backward) ? null : factory.activity(backward, swimlane, boxStyle, Colors.empty()); Ftile tmp = factory.decorateOut(repeatList.createFtile(factory), endInlinkRendering); - tmp = factory.createWhile(swimlane, tmp, test, yes, out, afterEndwhile, color, specialOut, back); + tmp = factory.createWhile(swimlane, tmp, test, yes, out, afterEndwhile, color, specialOut, back, incoming, + outcoming); if (getPositionedNotes().size() > 0) { tmp = FtileWithNoteOpale.create(tmp, getPositionedNotes(), skinParam, false); } @@ -176,11 +177,15 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi private BoxStyle boxStyle; private Swimlane swimlaneOut; private Display backward = Display.NULL; + private String incoming; + private String outcoming; - public void setBackward(Display label, Swimlane swimlaneOut, BoxStyle boxStyle) { + public void setBackward(Display label, Swimlane swimlaneOut, BoxStyle boxStyle, String incoming, String outcoming) { this.backward = label; this.swimlaneOut = swimlaneOut; this.boxStyle = boxStyle; + this.incoming = incoming; + this.outcoming = outcoming; } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java index 4d786b424..7592772cf 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; @@ -54,11 +55,19 @@ public class CommandBackward3 extends SingleLineCommand2 { static IRegex getRegexConcat() { return RegexConcat.build(CommandBackward3.class.getName(), RegexLeaf.start(), // + new RegexOptional( // + new RegexLeaf("INCOMING", "\\(-\\>(.*?)\\)")), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("backward"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf(":"), // - new RegexLeaf("LABEL", "(.*)"), // + new RegexLeaf("LABEL", "(.*?)"), // new RegexLeaf("STYLE", CommandActivity3.endingGroup()), // + RegexLeaf.spaceZeroOrMore(), // + new RegexOptional( // + new RegexLeaf("OUTCOMING", "\\(-\\>(.*?)\\)") // + ), // + RegexLeaf.spaceZeroOrMore(), // RegexLeaf.end()); } @@ -66,6 +75,8 @@ public class CommandBackward3 extends SingleLineCommand2 { protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { final BoxStyle boxStyle; final String styleString = arg.get("STYLE", 0); + final String incoming = arg.get("INCOMING", 0); + final String outcoming = arg.get("OUTCOMING", 0); if (styleString == null) { boxStyle = BoxStyle.PLAIN; } else { @@ -73,7 +84,7 @@ public class CommandBackward3 extends SingleLineCommand2 { } final Display label = Display.getWithNewlines(arg.get("LABEL", 0)); - return diagram.backwardWhile(label, boxStyle); + return diagram.backwardWhile(label, boxStyle, incoming, outcoming); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java index 2f9fccbc2..eb16ae64d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java @@ -94,7 +94,7 @@ public class CommandRepeatWhile3 extends SingleLineCommand2 { new RegexOr(// new RegexLeaf("LABEL", "(.*)"), // new RegexLeaf("")) // - )), // + )), // new RegexLeaf(";?"), // RegexLeaf.end()); } @@ -110,8 +110,8 @@ public class CommandRepeatWhile3 extends SingleLineCommand2 { if (colorString == null) { rainbow = Rainbow.none(); } else { - rainbow = Rainbow.build(diagram.getSkinParam(), colorString, diagram.getSkinParam() - .colorArrowSeparationSpace()); + rainbow = Rainbow.build(diagram.getSkinParam(), colorString, + diagram.getSkinParam().colorArrowSeparationSpace()); } final Display linkLabel = Display.getWithNewlines(arg.get("LABEL", 0)); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java index 33fb934b6..032f23d1a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java @@ -79,10 +79,11 @@ public interface FtileFactory { public Ftile repeat(BoxStyle boxStyleIn, Swimlane swimlane, Swimlane swimlaneOut, Display startLabel, Ftile repeat, Display test, Display yes, Display out, Colors colors, LinkRendering backRepeatLinkRendering, - Ftile backward, boolean noOut); + Ftile backward, boolean noOut, Display labelBackward); public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out, - LinkRendering afterEndwhile, HColor color, Instruction specialOut, Ftile backward); + LinkRendering afterEndwhile, HColor color, Instruction specialOut, Ftile backward, String incoming, + String outcoming); public Ftile createIf(Swimlane swimlane, List thens, Branch elseBranch, LinkRendering afterEndwhile, LinkRendering topInlinkRendering, Url url); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java index b034fcd4c..f6f82bbfd 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java @@ -181,14 +181,14 @@ public class FtileFactoryDelegator implements FtileFactory { public Ftile repeat(BoxStyle boxStyleIn, Swimlane swimlane, Swimlane swimlaneOut, Display startLabel, Ftile repeat, Display test, Display yes, Display out, Colors colors, LinkRendering backRepeatLinkRendering, - Ftile backward, boolean noOut) { + Ftile backward, boolean noOut, Display labelBackward) { return factory.repeat(boxStyleIn, swimlane, swimlaneOut, startLabel, repeat, test, yes, out, colors, - backRepeatLinkRendering, backward, noOut); + backRepeatLinkRendering, backward, noOut, labelBackward); } public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out, - LinkRendering afterEndwhile, HColor color, Instruction specialOut, Ftile back) { - return factory.createWhile(swimlane, whileBlock, test, yes, out, afterEndwhile, color, specialOut, back); + LinkRendering afterEndwhile, HColor color, Instruction specialOut, Ftile back, String incoming, String outcoming) { + return factory.createWhile(swimlane, whileBlock, test, yes, out, afterEndwhile, color, specialOut, back, incoming, outcoming); } public Ftile createIf(Swimlane swimlane, List thens, Branch elseBranch, LinkRendering afterEndwhile, diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java index ff1420083..4abb881a1 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java @@ -49,6 +49,7 @@ import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPolygon; @@ -58,25 +59,37 @@ import net.sourceforge.plantuml.ugraphic.comp.PiecewiseAffineTransform; public class Snake implements UShape { - private final Worm worm = new Worm(); - private UPolygon startDecoration; - private UPolygon endDecoration; - private final Rainbow color; - private TextBlock textBlock; - private String textBlockPosition; - private MergeStrategy mergeable = MergeStrategy.FULL; - private Direction emphasizeDirection; - private final HorizontalAlignment horizontalAlignment; + static class Text { + private final TextBlock textBlock; + private final VerticalAlignment verticalAlignment; + private final HorizontalAlignment horizontalAlignment; + + Text(TextBlock textBlock, VerticalAlignment verticalAlignment, HorizontalAlignment horizontalAlignment) { + if (textBlock == null) { + throw new IllegalArgumentException(); + } + this.textBlock = textBlock; + this.verticalAlignment = verticalAlignment; + this.horizontalAlignment = horizontalAlignment; + } + + private boolean hasText(StringBounder stringBounder) { + return TextBlockUtils.isEmpty(this.textBlock, stringBounder) == false; + } - public final void setIgnoreForCompression() { - this.worm.setIgnoreForCompression(); } + private final Worm worm; + private final UPolygon startDecoration; + private final UPolygon endDecoration; + private final Rainbow color; + + private final List texts; + private final MergeStrategy mergeable; + private final Direction emphasizeDirection; + public Snake transformX(PiecewiseAffineTransform compressionTransform) { - final Snake result = new Snake(startDecoration, horizontalAlignment, color, endDecoration); - result.textBlock = this.textBlock; - result.mergeable = this.mergeable; - result.emphasizeDirection = this.emphasizeDirection; + final Snake result = cloneEmpty(); for (Point2D.Double pt : worm) { final double x = compressionTransform.transform(pt.x); final double y = pt.y; @@ -85,50 +98,85 @@ public class Snake implements UShape { return result; } - public void removeEndDecoration() { - this.endDecoration = null; + public Snake move(double dx, double dy) { + final Snake result = cloneEmpty(); + for (Point2D pt : worm) { + result.addPoint(pt.getX() + dx, pt.getY() + dy); + } + return result; } - public Snake(HorizontalAlignment horizontalAlignment, Rainbow color, UPolygon endDecoration) { - this(null, horizontalAlignment, color, endDecoration); + private Snake cloneEmpty() { + return new Snake(startDecoration, color, endDecoration, worm.cloneEmpty(), mergeable, emphasizeDirection, + texts); } - public Snake(UPolygon startDecoration, HorizontalAlignment horizontalAlignment, Rainbow color, - UPolygon endDecoration) { + public final Snake ignoreForCompression() { + this.worm.setIgnoreForCompression(); + return this; + } + + public Snake emphasizeDirection(Direction emphasizeDirection) { + return new Snake(startDecoration, color, endDecoration, worm, mergeable, emphasizeDirection, texts); + } + + public Snake withoutEndDecoration() { + return new Snake(startDecoration, color, null, worm, mergeable, emphasizeDirection, texts); + } + + public Snake withMerge(MergeStrategy mergeable) { + return new Snake(startDecoration, color, endDecoration, worm, mergeable, emphasizeDirection, texts); + } + + public Snake withLabel(TextBlock textBlock, HorizontalAlignment horizontalAlignment) { + if (textBlock != null) { + this.texts.add(new Text(textBlock, null, horizontalAlignment)); + } + return this; + } + + public Snake withLabel(TextBlock textBlock, VerticalAlignment verticalAlignment) { + if (textBlock != null) { + this.texts.add(new Text(textBlock, verticalAlignment, null)); + } + if (verticalAlignment != VerticalAlignment.BOTTOM) { + throw new UnsupportedOperationException(); + } + return this; + } + + public static Snake create(Rainbow color) { + return new Snake(null, color, null, new Worm(), MergeStrategy.FULL, null, new ArrayList()); + } + + public static Snake create(Rainbow color, UPolygon endDecoration) { + return new Snake(null, color, endDecoration, new Worm(), MergeStrategy.FULL, null, new ArrayList()); + } + + public static Snake create(UPolygon startDecoration, Rainbow color, UPolygon endDecoration) { + return new Snake(startDecoration, color, endDecoration, new Worm(), MergeStrategy.FULL, null, + new ArrayList()); + } + + private Snake(UPolygon startDecoration, Rainbow color, UPolygon endDecoration, Worm worm, MergeStrategy mergeable, + Direction emphasizeDirection, List texts) { + if (color == null) { throw new IllegalArgumentException(); } if (color.size() == 0) { throw new IllegalArgumentException(); } + if (texts == null) { + throw new IllegalArgumentException(); + } + this.worm = worm; + this.texts = texts; + this.emphasizeDirection = emphasizeDirection; this.startDecoration = startDecoration; this.endDecoration = endDecoration; this.color = color; - this.horizontalAlignment = horizontalAlignment; - } - - public Snake(HorizontalAlignment horizontalAlignment, Rainbow color) { - this(null, horizontalAlignment, color, null); - } - - public void setLabel(TextBlock label, String position) { - this.textBlock = label; - this.textBlockPosition = position; - } - - public void setLabel(TextBlock label) { - this.textBlock = label; - } - - public Snake move(double dx, double dy) { - final Snake result = new Snake(startDecoration, horizontalAlignment, color, endDecoration); - for (Point2D pt : worm) { - result.addPoint(pt.getX() + dx, pt.getY() + dy); - } - result.textBlock = this.textBlock; - result.mergeable = this.mergeable; - result.emphasizeDirection = this.emphasizeDirection; - return result; + this.mergeable = mergeable; } public Snake translate(UTranslate translate) { @@ -186,9 +234,9 @@ public class Snake implements UShape { } private void drawInternalLabel(UGraphic ug) { - if (textBlock != null) { - final Point2D position = getTextBlockPosition(ug.getStringBounder()); - textBlock.drawU(ug.apply(new UTranslate(position))); + for (Text text : texts) { + final Point2D position = getTextBlockPosition(ug.getStringBounder(), text); + text.textBlock.drawU(ug.apply(new UTranslate(position))); } } @@ -197,27 +245,27 @@ public class Snake implements UShape { for (Point2D pt : worm) { result = Math.max(result, pt.getX()); } - if (textBlock != null) { - final Point2D position = getTextBlockPosition(stringBounder); - final Dimension2D dim = textBlock.calculateDimension(stringBounder); + for (Text text : texts) { + final Point2D position = getTextBlockPosition(stringBounder, text); + final Dimension2D dim = text.textBlock.calculateDimension(stringBounder); result = Math.max(result, position.getX() + dim.getWidth()); } return result; } - private Point2D getTextBlockPosition(StringBounder stringBounder) { + private Point2D getTextBlockPosition(StringBounder stringBounder, Text text) { final Point2D pt1 = worm.get(0); final Point2D pt2 = worm.get(1); - final Dimension2D dim = textBlock.calculateDimension(stringBounder); + final Dimension2D dim = text.textBlock.calculateDimension(stringBounder); double x = Math.max(pt1.getX(), pt2.getX()) + 4; final boolean zigzag = worm.getDirectionsCode().startsWith("DLD") || worm.getDirectionsCode().startsWith("DRD"); double y = (pt1.getY() + pt2.getY()) / 2 - dim.getHeight() / 2; - if ("bottom".equalsIgnoreCase(textBlockPosition)) { + if (text.verticalAlignment == VerticalAlignment.BOTTOM) { x = worm.getLast().getX(); - } else if (horizontalAlignment == HorizontalAlignment.CENTER && zigzag) { + } else if (text.horizontalAlignment == HorizontalAlignment.CENTER && zigzag) { final Point2D pt3 = worm.get(2); x = (pt2.getX() + pt3.getX()) / 2 - dim.getWidth() / 2; - } else if (horizontalAlignment == HorizontalAlignment.RIGHT && zigzag) { + } else if (text.horizontalAlignment == HorizontalAlignment.RIGHT && zigzag) { x = Math.max(pt1.getX(), pt2.getX()) - dim.getWidth() - 4; } else if (worm.getDirectionsCode().equals("RD")) { x = Math.max(pt1.getX(), pt2.getX()); @@ -260,22 +308,19 @@ public class Snake implements UShape { if (strategy == MergeStrategy.NONE) { return null; } - final boolean emptyOther = TextBlockUtils.isEmpty(other.textBlock, stringBounder); - // final boolean emptyThis = TextBlockUtils.isEmpty(this.textBlock, stringBounder); - if (emptyOther == false /* || emptyThis == false */) { - // System.err.println("merge other.textBlock="+other.textBlock+" "+other.textBlock.calculateDimension(TextBlockUtils.getDummyStringBounder())); - return null; + for (Text text : other.texts) { + if (text.hasText(stringBounder)) { + return null; + } } if (same(this.getLast(), other.getFirst())) { final UPolygon oneOf = other.endDecoration == null ? endDecoration : other.endDecoration; if (this.startDecoration != null || other.startDecoration != null) { throw new UnsupportedOperationException("Not yet coded: to be done"); } - final Snake result = new Snake(null, horizontalAlignment, color, oneOf); + final Snake result = new Snake(null, color, oneOf, this.worm.merge(other.worm, strategy), strategy, + emphasizeDirection == null ? other.emphasizeDirection : emphasizeDirection, new ArrayList()); // result.textBlock = oneOf(this.textBlock, other.textBlock, stringBounder); - result.emphasizeDirection = emphasizeDirection == null ? other.emphasizeDirection : emphasizeDirection; - result.worm.addAll(this.worm.merge(other.worm, strategy)); - result.mergeable = strategy; return result; } if (same(this.getFirst(), other.getLast())) { @@ -294,14 +339,6 @@ public class Snake implements UShape { return same(this.getLast(), other.getFirst()); } - public void goUnmergeable(MergeStrategy strategy) { - this.mergeable = strategy; - } - - public void emphasizeDirection(Direction direction) { - this.emphasizeDirection = direction; - } - public boolean doesHorizontalCross(MinMax minMax) { return worm.doesHorizontalCross(minMax); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Worm.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Worm.java index 7308ebbfd..9fc4ea0af 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Worm.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Worm.java @@ -65,7 +65,16 @@ public class Worm implements Iterable { private boolean ignoreForCompression; + public Worm cloneEmpty() { + final Worm result = new Worm(); + result.ignoreForCompression = this.ignoreForCompression; + return result; + } + public final void setIgnoreForCompression() { + if (points.size() > 0) { + throw new IllegalStateException(); + } this.ignoreForCompression = true; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ConnectionVerticalDown.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ConnectionVerticalDown.java index 2361c2cbc..d125ae253 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ConnectionVerticalDown.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ConnectionVerticalDown.java @@ -55,7 +55,8 @@ public class ConnectionVerticalDown extends AbstractConnection implements Connec private final Rainbow color; private final TextBlock textBlock; - public ConnectionVerticalDown(Ftile ftile1, Ftile ftile2, Point2D p1, Point2D p2, Rainbow color, TextBlock textBlock) { + public ConnectionVerticalDown(Ftile ftile1, Ftile ftile2, Point2D p1, Point2D p2, Rainbow color, + TextBlock textBlock) { super(ftile1, ftile2); if (color.size() == 0) { throw new IllegalArgumentException(); @@ -75,16 +76,16 @@ public class ConnectionVerticalDown extends AbstractConnection implements Connec } private Snake getSimpleSnake() { - final Snake snake = new Snake(arrowHorizontalAlignment(), color, Arrows.asToDown()); - snake.setLabel(textBlock); + final Snake snake = Snake.create(color, Arrows.asToDown()).withLabel(textBlock, + arrowHorizontalAlignment()); snake.addPoint(p1); snake.addPoint(p2); return snake; } public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { - final Snake snake = new Snake(arrowHorizontalAlignment(), color, Arrows.asToDown()); - snake.setLabel(textBlock); + final Snake snake = Snake.create(color, Arrows.asToDown()).withLabel(textBlock, + arrowHorizontalAlignment()); final Point2D mp1a = translate1.getTranslated(p1); final Point2D mp2b = translate2.getTranslated(p2); final double middle = (mp1a.getY() + mp2b.getY()) / 2.0; @@ -94,7 +95,7 @@ public class ConnectionVerticalDown extends AbstractConnection implements Connec snake.addPoint(mp2b); ug.draw(snake); - // final Snake small = new Snake(color, Arrows.asToDown()); + // final Snake small = Snake.create(color, Arrows.asToDown()); // small.addPoint(mp2b.getX(), middle); // small.addPoint(mp2b); // ug.draw(small); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java index 702038be8..b46744885 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java @@ -76,7 +76,7 @@ public class FtileFactoryDelegatorRepeat extends FtileFactoryDelegator { @Override public Ftile repeat(BoxStyle boxStyleIn, Swimlane swimlane, Swimlane swimlaneOut, Display startLabel, final Ftile repeat, Display test, Display yes, Display out, Colors colors, - LinkRendering backRepeatLinkRendering, Ftile backward, boolean noOut) { + LinkRendering backRepeatLinkRendering, Ftile backward, boolean noOut, Display labelBackward) { final ConditionStyle conditionStyle = skinParam().getConditionStyle(); @@ -116,7 +116,7 @@ public class FtileFactoryDelegatorRepeat extends FtileFactoryDelegator { Ftile result = FtileRepeat.create(backRepeatLinkRendering, swimlane, swimlaneOut, entry, repeat, test, yes, out, borderColor, diamondColor, arrowColor, endRepeatLinkColor, conditionStyle, this.skinParam(), fcDiamond, - fcArrow, backward, noOut); + fcArrow, backward, noOut, labelBackward); final List weldingPoints = repeat.getWeldingPoints(); if (weldingPoints.size() > 0) { @@ -134,8 +134,7 @@ public class FtileFactoryDelegatorRepeat extends FtileFactoryDelegator { final UTranslate tr2 = genealogy.getTranslate(diamondBreak, ug.getStringBounder()); final Dimension2D dimDiamond = diamondBreak.calculateDimension(ug.getStringBounder()); - final Snake snake = new Snake(getFtile1().arrowHorizontalAlignment(), arrowColor, - Arrows.asToRight()); + final Snake snake = Snake.create(arrowColor, Arrows.asToRight()); snake.addPoint(tr1.getDx(), tr1.getDy()); snake.addPoint(0, tr1.getDy()); snake.addPoint(0, tr2.getDy() + dimDiamond.getHeight() / 2); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java index dbce40534..ce9179d57 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java @@ -72,7 +72,8 @@ public class FtileFactoryDelegatorWhile extends FtileFactoryDelegator { @Override public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out, - LinkRendering afterEndwhile, HColor color, Instruction specialOut, Ftile backward) { + LinkRendering afterEndwhile, HColor color, Instruction specialOut, Ftile backward, String incoming, + String outcoming) { final HColor borderColor; final HColor backColor; @@ -107,7 +108,8 @@ public class FtileFactoryDelegatorWhile extends FtileFactoryDelegator { : endInlinkRendering.getRainbow(); Ftile result = FtileWhile.create(swimlane, whileBlock, test, borderColor, backColor, arrowColor, yes, out, - endInlinkColor, afterEndwhile, fontArrow, getFactory(), conditionStyle, fcTest, specialOut, backward); + endInlinkColor, afterEndwhile, fontArrow, getFactory(), conditionStyle, fcTest, specialOut, backward, + incoming, outcoming); final List weldingPoints = whileBlock.getWeldingPoints(); if (weldingPoints.size() > 0) { @@ -121,8 +123,7 @@ public class FtileFactoryDelegatorWhile extends FtileFactoryDelegator { public void drawU(UGraphic ug) { final UTranslate tr1 = genealogy.getTranslate(ftileBreak, ug.getStringBounder()); - final Snake snake = new Snake(getFtile1().arrowHorizontalAlignment(), arrowColor, - Arrows.asToLeft()); + final Snake snake = Snake.create(arrowColor, Arrows.asToLeft()); snake.addPoint(tr1.getDx(), tr1.getDy()); snake.addPoint(Diamond.diamondHalfSize, tr1.getDy()); ug.draw(snake); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java index a1e6a0eb2..899b89556 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java @@ -233,7 +233,7 @@ class FtileIfAndStop extends AbstractFtile { final Point2D p1 = getP1(stringBounder); final Point2D p2 = getP2(stringBounder); - final Snake snake = new Snake(arrowHorizontalAlignment(), color, Arrows.asToRight()); + final Snake snake = Snake.create(color, Arrows.asToRight()); snake.addPoint(p1); snake.addPoint(p2); ug.draw(snake); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java index a0739c312..3cddc5592 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java @@ -115,8 +115,9 @@ public class FtileIfDown extends AbstractFtile { ConditionEndStyle conditionEndStyle, FtileFactory ftileFactory, Ftile optionalStop, Rainbow elseColor) { elseColor = elseColor.withDefault(arrowColor); - final FtileIfDown result = new FtileIfDown(thenBlock, diamond1, optionalStop == null ? diamond2 - : new FtileEmpty(ftileFactory.skinParam()), optionalStop, conditionEndStyle); + final FtileIfDown result = new FtileIfDown(thenBlock, diamond1, + optionalStop == null ? diamond2 : new FtileEmpty(ftileFactory.skinParam()), optionalStop, + conditionEndStyle); final List conns = new ArrayList(); conns.add(result.new ConnectionIn(thenBlock.getInLinkRendering().getRainbow(arrowColor))); @@ -154,7 +155,7 @@ public class FtileIfDown extends AbstractFtile { final Point2D p2 = getP2(stringBounder); // p2 = new Point2D.Double(p2.getX(), p1.getY()); - final Snake snake = new Snake(arrowHorizontalAlignment(), color, Arrows.asToRight()); + final Snake snake = Snake.create(color, Arrows.asToRight()); snake.addPoint(p1); snake.addPoint(p2); ug.draw(snake); @@ -185,19 +186,19 @@ public class FtileIfDown extends AbstractFtile { } private Point2D getP1(final StringBounder stringBounder) { - return getTranslateDiamond1(stringBounder).getTranslated( - getFtile1().calculateDimension(stringBounder).getPointOut()); + return getTranslateDiamond1(stringBounder) + .getTranslated(getFtile1().calculateDimension(stringBounder).getPointOut()); } private Point2D getP2(final StringBounder stringBounder) { - return getTranslateForThen(stringBounder).getTranslated( - getFtile2().calculateDimension(stringBounder).getPointIn()); + return getTranslateForThen(stringBounder) + .getTranslated(getFtile2().calculateDimension(stringBounder).getPointIn()); } public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + final Snake snake = Snake.create(arrowColor, Arrows.asToDown()); snake.addPoint(getP1(stringBounder)); snake.addPoint(getP2(stringBounder)); @@ -208,7 +209,7 @@ public class FtileIfDown extends AbstractFtile { final StringBounder stringBounder = ug.getStringBounder(); final Point2D p1 = getP1(stringBounder); final Point2D p2 = getP2(stringBounder); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + final Snake snake = Snake.create(arrowColor, Arrows.asToDown()); final Point2D mp1a = translate1.getTranslated(p1); final Point2D mp2b = translate2.getTranslated(p2); final double middle = (mp1a.getY() + mp2b.getY()) / 2.0; @@ -229,13 +230,13 @@ public class FtileIfDown extends AbstractFtile { } private Point2D getP1(final StringBounder stringBounder) { - return getTranslateForThen(stringBounder).getTranslated( - getFtile1().calculateDimension(stringBounder).getPointOut()); + return getTranslateForThen(stringBounder) + .getTranslated(getFtile1().calculateDimension(stringBounder).getPointOut()); } private Point2D getP2(final StringBounder stringBounder) { - return getTranslateDiamond2(stringBounder).getTranslated( - getFtile2().calculateDimension(stringBounder).getPointIn()); + return getTranslateDiamond2(stringBounder) + .getTranslated(getFtile2().calculateDimension(stringBounder).getPointIn()); } private Point2D getP2hline(final StringBounder stringBounder) { @@ -253,7 +254,7 @@ public class FtileIfDown extends AbstractFtile { return; } - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + final Snake snake = Snake.create(arrowColor, Arrows.asToDown()); snake.addPoint(getP1(stringBounder)); if (conditionEndStyle == ConditionEndStyle.DIAMOND) { @@ -274,7 +275,7 @@ public class FtileIfDown extends AbstractFtile { final StringBounder stringBounder = ug.getStringBounder(); final Point2D p1 = getP1(stringBounder); final Point2D p2 = getP2(stringBounder); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + final Snake snake = Snake.create(arrowColor, Arrows.asToDown()); final Point2D mp1a = translate1.getTranslated(p1); final Point2D mp2b = translate2.getTranslated(p2); final double middle = (mp1a.getY() + mp2b.getY()) / 2.0; @@ -325,15 +326,15 @@ public class FtileIfDown extends AbstractFtile { final double y2 = p2.getY(); final FtileGeometry thenGeom = thenBlock.calculateDimension(stringBounder); - final double xmax = Math.max(x1 + Diamond.diamondHalfSize, getTranslateForThen(stringBounder).getDx() - + thenGeom.getWidth()); + final double xmax = Math.max(x1 + Diamond.diamondHalfSize, + getTranslateForThen(stringBounder).getDx() + thenGeom.getWidth()); - final Snake snake = new Snake(arrowHorizontalAlignment(), endInlinkColor, Arrows.asToLeft()); + final Snake snake = Snake.create(endInlinkColor, Arrows.asToLeft()) + .emphasizeDirection(Direction.DOWN); snake.addPoint(x1, y1); snake.addPoint(xmax, y1); snake.addPoint(xmax, y2); snake.addPoint(x2, y2); - snake.emphasizeDirection(Direction.DOWN); ug.apply(new UTranslate(x2, y2 - Diamond.diamondHalfSize)).draw(new UEmpty(5, Diamond.diamondHalfSize)); ug.draw(snake); @@ -365,25 +366,27 @@ public class FtileIfDown extends AbstractFtile { final double y2 = p2.getY(); final FtileGeometry thenGeom = thenBlock.calculateDimension(stringBounder); - final double xmax = Math.max(x1 + Diamond.diamondHalfSize, getTranslateForThen(stringBounder).getDx() - + thenGeom.getWidth()); + final double xmax = Math.max(x1 + Diamond.diamondHalfSize, + getTranslateForThen(stringBounder).getDx() + thenGeom.getWidth()); /* - * if( conditionEndStyle == ConditionEndStyle.DIAMOND ) { final Snake snake = new - * Snake(arrowHorizontalAlignment(), endInlinkColor, Arrows.asToLeft()); snake.addPoint(x1, y1); - * snake.addPoint(xmax, y1); snake.addPoint(xmax, y2); snake.addPoint(x2, y2); - * snake.emphasizeDirection(Direction.DOWN); ug.apply(new UTranslate(x2, y2 - - * Diamond.diamondHalfSize)).draw(new UEmpty(5, Diamond.diamondHalfSize)); ug.draw(snake); } + * if( conditionEndStyle == ConditionEndStyle.DIAMOND ) { final Snake snake = + * new Snake(arrowHorizontalAlignment(), endInlinkColor, Arrows.asToLeft()); + * snake.addPoint(x1, y1); snake.addPoint(xmax, y1); snake.addPoint(xmax, y2); + * snake.addPoint(x2, y2); snake.emphasizeDirection(Direction.DOWN); + * ug.apply(new UTranslate(x2, y2 - Diamond.diamondHalfSize)).draw(new UEmpty(5, + * Diamond.diamondHalfSize)); ug.draw(snake); } */ - final Snake snake = new Snake(arrowHorizontalAlignment(), endInlinkColor, Arrows.asToDown()); + final Snake snake = Snake.create(endInlinkColor, Arrows.asToDown()); snake.addPoint(x1, y1); snake.addPoint(xmax, y1); snake.addPoint(xmax, y2); ug.apply(new UTranslate(xmax, y2 - Diamond.diamondHalfSize)).draw(new UEmpty(5, Diamond.diamondHalfSize)); ug.draw(snake); /* - * final Snake snake2 = new Snake(arrowHorizontalAlignment(), endInlinkColor); snake2.addPoint(xmax, y2); - * snake2.addPoint(x2, y2); ug.draw(snake2); + * final Snake snake2 = Snake.create(arrowHorizontalAlignment(), + * endInlinkColor); snake2.addPoint(xmax, y2); snake2.addPoint(x2, y2); + * ug.draw(snake2); */ } @@ -454,16 +457,16 @@ public class FtileIfDown extends AbstractFtile { final double y3 = p3.getY(); final FtileGeometry thenGeom = thenBlock.calculateDimension(stringBounder); - final double xmax = Math.max(x1 + Diamond.diamondHalfSize, getTranslateForThen(stringBounder).getDx() - + thenGeom.getWidth()); + final double xmax = Math.max(x1 + Diamond.diamondHalfSize, + getTranslateForThen(stringBounder).getDx() + thenGeom.getWidth()); - final Snake snake = new Snake(arrowHorizontalAlignment(), endInlinkColor); + final Snake snake = Snake.create(endInlinkColor).withMerge(MergeStrategy.NONE); snake.addPoint(xmax, y2); - // ug.apply(new UTranslate(xmax, y2 - Diamond.diamondHalfSize)).draw(new UEmpty(5, + // ug.apply(new UTranslate(xmax, y2 - Diamond.diamondHalfSize)).draw(new + // UEmpty(5, // Diamond.diamondHalfSize)); snake.addPoint(x2, y2); snake.addPoint(x3, y3); - snake.goUnmergeable(MergeStrategy.NONE); ug.draw(snake); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java index a3e8f898e..5acd1eda7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java @@ -249,7 +249,7 @@ class FtileIfLongHorizontal extends AbstractFtile { final Point2D p1 = getP1(stringBounder); final Point2D p2 = getP2(stringBounder); - final Snake snake = new Snake(arrowHorizontalAlignment(), color, Arrows.asToRight()); + final Snake snake = Snake.create(color, Arrows.asToRight()); snake.addPoint(p1); snake.addPoint(p2); ug.draw(snake); @@ -287,7 +287,7 @@ class FtileIfLongHorizontal extends AbstractFtile { public void drawU(UGraphic ug) { final UTranslate tr = getTranslateDiamond1(getFtile2(), ug.getStringBounder()); final Point2D p2 = tr.getTranslated(getFtile2().calculateDimension(ug.getStringBounder()).getPointIn()); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + final Snake snake = Snake.create(arrowColor, Arrows.asToDown()); final Point2D p1 = calculateDimensionInternal(ug.getStringBounder()).getPointIn(); snake.addPoint(p1); @@ -311,7 +311,7 @@ class FtileIfLongHorizontal extends AbstractFtile { final Point2D p1 = getP1(ug.getStringBounder()); final UTranslate tr2 = getTranslate2(ug.getStringBounder()); final Point2D p2 = tr2.getTranslated(getFtile2().calculateDimension(ug.getStringBounder()).getPointIn()); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + final Snake snake = Snake.create(arrowColor, Arrows.asToDown()); snake.addPoint(p1); snake.addPoint(p2.getX(), p1.getY()); snake.addPoint(p2); @@ -352,8 +352,7 @@ class FtileIfLongHorizontal extends AbstractFtile { final double totalHeight = full.getHeight(); final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); - snake.setLabel(out2); + final Snake snake = Snake.create(arrowColor, Arrows.asToDown()).withLabel(out2, arrowHorizontalAlignment()); snake.addPoint(p1); snake.addPoint(p2); if (nbOut == 0) { @@ -378,7 +377,7 @@ class FtileIfLongHorizontal extends AbstractFtile { final Point2D p1 = getP1(stringBounder); final Point2D p2 = getP2(stringBounder); - final Snake snake = new Snake(arrowHorizontalAlignment(), color, Arrows.asToDown()); + final Snake snake = Snake.create(color, Arrows.asToDown()); snake.addPoint(p1); snake.addPoint(p2); ug.draw(snake); @@ -398,7 +397,7 @@ class FtileIfLongHorizontal extends AbstractFtile { final Point2D p1 = getP1(ug.getStringBounder()); final Point2D p2 = getP2(ug.getStringBounder()); - final Snake snake = new Snake(arrowHorizontalAlignment(), color, Arrows.asToDown()); + final Snake snake = Snake.create(color, Arrows.asToDown()); final Point2D mp1a = translate1.getTranslated(p1); final Point2D mp2b = translate2.getTranslated(p2); @@ -432,8 +431,7 @@ class FtileIfLongHorizontal extends AbstractFtile { } final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight); - final Snake snake = new Snake(arrowHorizontalAlignment(), color, Arrows.asToDown()); - snake.setLabel(out2); + final Snake snake = Snake.create(color, Arrows.asToDown()).withLabel(out2, arrowHorizontalAlignment()); snake.addPoint(p1); snake.addPoint(p2); ug.draw(snake); @@ -482,8 +480,7 @@ class FtileIfLongHorizontal extends AbstractFtile { return; } - final Snake s = new Snake(arrowHorizontalAlignment(), arrowColor); - s.goUnmergeable(MergeStrategy.NONE); + final Snake s = Snake.create(arrowColor).withMerge(MergeStrategy.NONE); s.addPoint(minX, totalDim.getHeight()); s.addPoint(maxX, totalDim.getHeight()); ug.draw(s); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongVertical.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongVertical.java index 3faa9a3ab..fbedfe954 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongVertical.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongVertical.java @@ -199,7 +199,7 @@ class FtileIfLongVertical extends AbstractFtile { public void drawU(UGraphic ug) { final UTranslate tr = getTranslateDiamond(getFtile2(), ug.getStringBounder()); final Point2D p2 = tr.getTranslated(getFtile2().calculateDimension(ug.getStringBounder()).getPointIn()); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + final Snake snake = Snake.create(arrowColor, Arrows.asToDown()); final Point2D p1 = calculateDimensionInternal(ug.getStringBounder()).getPointIn(); snake.addPoint(p1); @@ -225,7 +225,7 @@ class FtileIfLongVertical extends AbstractFtile { final Point2D p1 = getP1(stringBounder); final Point2D p2 = getP2(stringBounder); - final Snake snake = new Snake(arrowHorizontalAlignment(), color, Arrows.asToDown()); + final Snake snake = Snake.create(color, Arrows.asToDown()); snake.addPoint(p1); snake.addPoint(p2.getX(), p1.getY()); snake.addPoint(p2); @@ -260,7 +260,7 @@ class FtileIfLongVertical extends AbstractFtile { final Point2D p1 = getP1(stringBounder); final Point2D p2 = getP2(stringBounder); - final Snake snake = new Snake(arrowHorizontalAlignment(), color, Arrows.asToDown()); + final Snake snake = Snake.create(color, Arrows.asToDown()); snake.addPoint(p1); snake.addPoint(p2); ug.draw(snake); @@ -296,7 +296,7 @@ class FtileIfLongVertical extends AbstractFtile { final Point2D p2 = getTranslate2(stringBounder).getTranslated( getFtile2().calculateDimension(stringBounder).getPointIn()); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + final Snake snake = Snake.create(arrowColor, Arrows.asToDown()); snake.addPoint(p1); snake.addPoint(p1.getX(), p2.getY() - 15); snake.addPoint(p2.getX(), p2.getY() - 15); @@ -325,7 +325,7 @@ class FtileIfLongVertical extends AbstractFtile { final Point2D p2 = getTranslateLastDiamond(stringBounder).getTranslated( getFtile2().calculateDimension(stringBounder).getPointIn()); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + final Snake snake = Snake.create(arrowColor, Arrows.asToDown()); snake.addPoint(p1); snake.addPoint(p1.getX(), p2.getY() - 15); snake.addPoint(p2.getX(), p2.getY() - 15); @@ -359,7 +359,7 @@ class FtileIfLongVertical extends AbstractFtile { final Dimension2D dimTotal = calculateDimensionInternal(stringBounder); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToLeft()); + final Snake snake = Snake.create(arrowColor, Arrows.asToLeft()); snake.addPoint(p1); snake.addPoint(p1.getX(), p1.getY() + 15); snake.addPoint(dimTotal.getWidth(), p1.getY() + 15); @@ -390,7 +390,7 @@ class FtileIfLongVertical extends AbstractFtile { final Point2D p2 = new Point2D.Double(dimTotal.getWidth(), p1.getY() + 15); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToRight()); + final Snake snake = Snake.create(arrowColor, Arrows.asToRight()); snake.addPoint(p1); snake.addPoint(p1.getX(), p2.getY()); snake.addPoint(p2); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java index f61616c82..a35617b82 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java @@ -113,7 +113,8 @@ class FtileRepeat extends AbstractFtile { public static Ftile create(LinkRendering backRepeatLinkRendering, Swimlane swimlane, Swimlane swimlaneOut, Ftile entry, Ftile repeat, Display test, Display yes, Display out, HColor borderColor, HColor diamondColor, Rainbow arrowColor, Rainbow endRepeatLinkColor, ConditionStyle conditionStyle, ISkinSimple spriteContainer, - FontConfiguration fcDiamond, FontConfiguration fcArrow, Ftile backward, boolean noOut) { + FontConfiguration fcDiamond, FontConfiguration fcArrow, Ftile backward, boolean noOut, + Display labelBackward) { final FontConfiguration fontConfiguration1 = conditionStyle == ConditionStyle.INSIDE ? fcDiamond : fcArrow; @@ -167,7 +168,10 @@ class FtileRepeat extends AbstractFtile { } else { conns.add(result.new ConnectionBackBackward1(backRepeatLinkRendering.getRainbow(arrowColor), tbbackLink1)); - conns.add(result.new ConnectionBackBackward2(backRepeatLinkRendering.getRainbow(arrowColor))); + final TextBlock backArrowLabel = labelBackward == Display.NULL ? null + : labelBackward.create(fcArrow, HorizontalAlignment.LEFT, spriteContainer); + conns.add(result.new ConnectionBackBackward2(backRepeatLinkRendering.getRainbow(arrowColor), + backArrowLabel)); } } else { conns.add(result.new ConnectionBackComplex1(backRepeatLinkRendering.getRainbow(arrowColor))); @@ -207,8 +211,8 @@ class FtileRepeat extends AbstractFtile { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); - snake.setLabel(tbin); + final Snake snake = Snake.create(arrowColor, Arrows.asToDown()).withLabel(tbin, + arrowHorizontalAlignment()); snake.addPoint(getP1(stringBounder)); snake.addPoint(getP2(stringBounder)); @@ -242,8 +246,8 @@ class FtileRepeat extends AbstractFtile { return; } - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); - snake.setLabel(tbout); + final Snake snake = Snake.create(arrowColor, Arrows.asToDown()).withLabel(tbout, + arrowHorizontalAlignment()); snake.addPoint(getP1(stringBounder)); snake.addPoint(getP2(stringBounder)); @@ -255,8 +259,8 @@ class FtileRepeat extends AbstractFtile { if (getFtile1().calculateDimension(stringBounder).hasPointOut() == false) { return; } - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor); - snake.setLabel(tbout); + final Snake snake = Snake.create(arrowColor).withLabel(tbout, + arrowHorizontalAlignment()); final Point2D mp1a = translate1.getTranslated(getP1(stringBounder)); final Point2D mp2b = translate2.getTranslated(getP2(stringBounder)); final double middle = (mp1a.getY() + mp2b.getY()) / 2.0; @@ -266,7 +270,7 @@ class FtileRepeat extends AbstractFtile { // snake.addPoint(mp2b); ug.draw(snake); - final Snake small = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + final Snake small = Snake.create(arrowColor, Arrows.asToDown()); small.addPoint(mp2b.getX(), middle); small.addPoint(mp2b); ug.draw(small); @@ -317,8 +321,8 @@ class FtileRepeat extends AbstractFtile { arrow = Arrows.asToRight(); x2 = p2.getX(); } - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, arrow); - snake.emphasizeDirection(Direction.UP); + final Snake snake = Snake.create(arrowColor, arrow) + .emphasizeDirection(Direction.UP); snake.addPoint(xmax, y1); snake.addPoint(xmax, y2); @@ -346,8 +350,8 @@ class FtileRepeat extends AbstractFtile { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, null); - snake.setLabel(tbback); + final Snake snake = Snake.create(arrowColor, null).withLabel(tbback, + arrowHorizontalAlignment()); final Dimension2D dimRepeat = repeat.calculateDimension(stringBounder); final Point2D p1 = getP1(stringBounder); final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder); @@ -385,8 +389,8 @@ class FtileRepeat extends AbstractFtile { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToUp()); - snake.setLabel(tbback); + final Snake snake = Snake.create(arrowColor, Arrows.asToUp()).withLabel(tbback, + arrowHorizontalAlignment()); final Point2D p1 = getP1(stringBounder); final Point2D p2 = getP2(stringBounder); final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder); @@ -406,9 +410,11 @@ class FtileRepeat extends AbstractFtile { class ConnectionBackBackward2 extends AbstractConnection { private final Rainbow arrowColor; + private final TextBlock label; - public ConnectionBackBackward2(Rainbow arrowColor) { + public ConnectionBackBackward2(Rainbow arrowColor, TextBlock label) { super(backward, diamond1); + this.label = label; this.arrowColor = arrowColor; } @@ -424,8 +430,11 @@ class FtileRepeat extends AbstractFtile { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToLeft()); - snake.emphasizeDirection(Direction.UP); + Snake snake = Snake.create(arrowColor, Arrows.asToLeft()) + .emphasizeDirection(Direction.UP); + if (label != null) { + snake = snake.withLabel(label, arrowHorizontalAlignment()); + } final Point2D p1 = getP1(stringBounder); final Point2D p2 = getP2(stringBounder); final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder); @@ -464,9 +473,8 @@ class FtileRepeat extends AbstractFtile { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToLeft()); - snake.setLabel(tbback); - snake.emphasizeDirection(Direction.UP); + final Snake snake = Snake.create(arrowColor, Arrows.asToLeft()) + .emphasizeDirection(Direction.UP).withLabel(tbback, arrowHorizontalAlignment()); final Dimension2D dimTotal = calculateDimensionInternal(stringBounder); final Point2D p1 = getP1(stringBounder); final Point2D p2 = getP2(stringBounder); @@ -488,9 +496,8 @@ class FtileRepeat extends AbstractFtile { public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToLeft()); - snake.setLabel(tbback); - snake.emphasizeDirection(Direction.UP); + final Snake snake = Snake.create(arrowColor, Arrows.asToLeft()) + .emphasizeDirection(Direction.UP).withLabel(tbback, arrowHorizontalAlignment()); final Dimension2D dimRepeat = repeat.calculateDimension(stringBounder); Point2D p1 = getP1(stringBounder); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java index 1f10d16aa..71051711f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java @@ -116,7 +116,7 @@ class FtileWhile extends AbstractFtile { public static Ftile create(Swimlane swimlane, Ftile whileBlock, Display test, HColor borderColor, HColor backColor, Rainbow arrowColor, Display yes, Display out2, Rainbow endInlinkColor, LinkRendering afterEndwhile, FontConfiguration fontArrow, FtileFactory ftileFactory, ConditionStyle conditionStyle, - FontConfiguration fcTest, Instruction specialOut, Ftile backward) { + FontConfiguration fcTest, Instruction specialOut, Ftile backward, String incoming, String outcoming) { final TextBlock yesTb = yes.create(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam()); final TextBlock testTb = test.isWhite() ? TextBlockUtils.empty(0, 0) @@ -147,8 +147,8 @@ class FtileWhile extends AbstractFtile { } final Dimension2D dim = whileBlock.calculateDimension(ftileFactory.getStringBounder()); - final Display backDisplay = whileBlock.getOutLinkRendering().getDisplay(); - final TextBlock back = backDisplay.create(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam()); + final TextBlock back = whileBlock.getOutLinkRendering().getDisplay().create(fontArrow, HorizontalAlignment.LEFT, + ftileFactory.skinParam()); final List conns = new ArrayList(); if (dim.getWidth() == 0 || dim.getHeight() == 0) { @@ -158,8 +158,12 @@ class FtileWhile extends AbstractFtile { if (backward == null) { conns.add(result.new ConnectionBackSimple(endInlinkColor, back)); } else { - conns.add(result.new ConnectionBackBackward1(endInlinkColor, back)); - conns.add(result.new ConnectionBackBackward2(endInlinkColor)); + final TextBlock back1 = Display.getWithNewlines(incoming).create(fontArrow, HorizontalAlignment.LEFT, + ftileFactory.skinParam()); + final TextBlock back2 = Display.getWithNewlines(outcoming).create(fontArrow, HorizontalAlignment.LEFT, + ftileFactory.skinParam()); + conns.add(result.new ConnectionBackBackward1(endInlinkColor, back1)); + conns.add(result.new ConnectionBackBackward2(endInlinkColor, back2)); } } if (specialOut == null) { @@ -191,7 +195,7 @@ class FtileWhile extends AbstractFtile { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + final Snake snake = Snake.create(arrowColor, Arrows.asToDown()); snake.addPoint(getP1(stringBounder)); snake.addPoint(getP2(stringBounder)); @@ -202,7 +206,7 @@ class FtileWhile extends AbstractFtile { final StringBounder stringBounder = ug.getStringBounder(); final Point2D p1 = getP1(stringBounder); final Point2D p2 = getP2(stringBounder); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + final Snake snake = Snake.create(arrowColor, Arrows.asToDown()).withMerge(MergeStrategy.LIMITED); final Point2D mp1a = translate1.getTranslated(p1); final Point2D mp2b = translate2.getTranslated(p2); final double middle = (mp1a.getY() + mp2b.getY()) / 2.0; @@ -210,7 +214,6 @@ class FtileWhile extends AbstractFtile { snake.addPoint(mp1a.getX(), middle); snake.addPoint(mp2b.getX(), middle); snake.addPoint(mp2b); - snake.goUnmergeable(MergeStrategy.LIMITED); ug.draw(snake); } } @@ -245,7 +248,6 @@ class FtileWhile extends AbstractFtile { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), endInlinkColor, Arrows.asToLeft()); final Dimension2D dimTotal = calculateDimension(stringBounder); final Point2D p1 = getP1(stringBounder); if (p1 == null) { @@ -260,7 +262,8 @@ class FtileWhile extends AbstractFtile { final double half = (dimDiamond1.getOutY() - dimDiamond1.getInY()) / 2; final double y2 = p2.getY() + dimDiamond1.getInY() + half; - snake.setLabel(back); + final Snake snake = Snake.create(endInlinkColor, Arrows.asToLeft()).emphasizeDirection(Direction.UP) + .withLabel(back, arrowHorizontalAlignment()); snake.addPoint(x1, y1); final double y1bis = Math.max(y1, getBottom(stringBounder)) + Diamond.diamondHalfSize; snake.addPoint(x1, y1bis); @@ -268,7 +271,6 @@ class FtileWhile extends AbstractFtile { snake.addPoint(xx, y1bis); snake.addPoint(xx, y2); snake.addPoint(x2, y2); - snake.emphasizeDirection(Direction.UP); ug.draw(snake); ug.apply(new UTranslate(x1, y1bis)).draw(new UEmpty(5, Diamond.diamondHalfSize)); @@ -277,7 +279,7 @@ class FtileWhile extends AbstractFtile { public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), endInlinkColor, Arrows.asToLeft()); + final Snake snake = Snake.create(endInlinkColor, Arrows.asToLeft()).withMerge(MergeStrategy.LIMITED); final Dimension2D dimTotal = calculateDimension(stringBounder); final Point2D ap1 = getP1(stringBounder); final Point2D ap2 = getP2(stringBounder); @@ -298,7 +300,6 @@ class FtileWhile extends AbstractFtile { snake.addPoint(xx, y1 + Diamond.diamondHalfSize); snake.addPoint(xx, y2); snake.addPoint(x2, y2); - snake.goUnmergeable(MergeStrategy.LIMITED); ug.draw(snake); @@ -342,7 +343,6 @@ class FtileWhile extends AbstractFtile { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), endInlinkColor, Arrows.asToUp()); final Point2D p1 = getP1(stringBounder); if (p1 == null) { return; @@ -353,7 +353,8 @@ class FtileWhile extends AbstractFtile { final double x2 = p2.getX(); final double y2 = p2.getY(); - snake.setLabel(back); + final Snake snake = Snake.create(endInlinkColor, Arrows.asToUp()).withLabel(back, + arrowHorizontalAlignment()); snake.addPoint(x1, y1); final double y1bis = Math.max(y1, getBottom(stringBounder)) + Diamond.diamondHalfSize; snake.addPoint(x1, y1bis); @@ -367,10 +368,12 @@ class FtileWhile extends AbstractFtile { class ConnectionBackBackward2 extends AbstractConnection { private final Rainbow endInlinkColor; + private final TextBlock back; - public ConnectionBackBackward2(Rainbow endInlinkColor) { + public ConnectionBackBackward2(Rainbow endInlinkColor, TextBlock back) { super(backward, diamond1); this.endInlinkColor = endInlinkColor; + this.back = back; } private Point2D getP1(final StringBounder stringBounder) { @@ -385,7 +388,9 @@ class FtileWhile extends AbstractFtile { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), endInlinkColor, Arrows.asToLeft()); + final Snake snake = Snake.create(endInlinkColor, Arrows.asToLeft()).withLabel(back, + arrowHorizontalAlignment()); + final Point2D p1 = getP1(stringBounder); final Point2D p2 = getP2(stringBounder); final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder); @@ -429,7 +434,7 @@ class FtileWhile extends AbstractFtile { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), endInlinkColor, Arrows.asToLeft()); + final Snake snake = Snake.create(endInlinkColor, Arrows.asToLeft()).emphasizeDirection(Direction.UP); final Dimension2D dimTotal = calculateDimension(stringBounder); final Point2D p1 = getP1(stringBounder); final Point2D p2 = getP2(stringBounder); @@ -449,7 +454,6 @@ class FtileWhile extends AbstractFtile { snake.addPoint(xx, y1bis); snake.addPoint(xx, y2); snake.addPoint(x2, y2); - snake.emphasizeDirection(Direction.UP); ug.draw(snake); @@ -479,7 +483,8 @@ class FtileWhile extends AbstractFtile { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), afterEndwhileColor); + final Snake snake = Snake.create(afterEndwhileColor).withMerge(MergeStrategy.LIMITED) + .emphasizeDirection(Direction.DOWN); final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder); final Point2D p1 = getP1(stringBounder); @@ -494,12 +499,10 @@ class FtileWhile extends AbstractFtile { snake.addPoint(x1, y1); snake.addPoint(Diamond.diamondHalfSize, y1); snake.addPoint(Diamond.diamondHalfSize, y2); - snake.emphasizeDirection(Direction.DOWN); - snake.goUnmergeable(MergeStrategy.LIMITED); ug.draw(snake); - final Snake snake2 = new Snake(arrowHorizontalAlignment(), afterEndwhileColor); + final Snake snake2 = Snake.create(afterEndwhileColor); snake2.addPoint(Diamond.diamondHalfSize, y2); snake2.addPoint(x2, y2); // snake2.goUnmergeable(MergeStrategy.LIMITED); @@ -528,7 +531,7 @@ class FtileWhile extends AbstractFtile { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = new Snake(arrowHorizontalAlignment(), afterEndwhileColor, Arrows.asToDown()); + final Snake snake = Snake.create(afterEndwhileColor, Arrows.asToDown()); final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder); final Point2D p1 = getP1(stringBounder); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java index 29415d76f..5f48e256a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java @@ -231,9 +231,9 @@ public class ParallelBuilderFork extends AbstractParallelFtilesBuilder { public void drawU(UGraphic ug) { ug = ug.apply(UTranslate.dx(x)); final FtileGeometry geo2 = getFtile2().calculateDimension(getStringBounder()); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + Snake snake = Snake.create(arrowColor, Arrows.asToDown()); if (Display.isNull(label) == false) { - snake.setLabel(getTextBlock(label)); + snake = snake.withLabel(getTextBlock(label), arrowHorizontalAlignment()); } final Point2D p1 = new Point2D.Double(geo2.getLeft(), 0); final Point2D p2 = new Point2D.Double(geo2.getLeft(), geo2.getInY()); @@ -248,9 +248,10 @@ public class ParallelBuilderFork extends AbstractParallelFtilesBuilder { final Point2D p1 = new Point2D.Double(geo2.getLeft(), 0); final Point2D p2 = new Point2D.Double(geo2.getLeft(), geo2.getInY()); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + Snake snake = Snake.create(arrowColor, Arrows.asToDown()) + .ignoreForCompression(); if (Display.isNull(label) == false) { - snake.setLabel(getTextBlock(label)); + snake = snake.withLabel(getTextBlock(label), arrowHorizontalAlignment()); } final Point2D mp1a = translate1.getTranslated(p1); final Point2D mp2b = translate2.getTranslated(p2); @@ -259,7 +260,6 @@ public class ParallelBuilderFork extends AbstractParallelFtilesBuilder { snake.addPoint(mp1a.getX(), middle); snake.addPoint(mp2b.getX(), middle); snake.addPoint(mp2b); - snake.setIgnoreForCompression(); ug.draw(snake); } } @@ -285,9 +285,9 @@ public class ParallelBuilderFork extends AbstractParallelFtilesBuilder { if (geo1.hasPointOut() == false) { return; } - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + Snake snake = Snake.create(arrowColor, Arrows.asToDown()); if (Display.isNull(label) == false) { - snake.setLabel(getTextBlock(label)); + snake = snake.withLabel(getTextBlock(label), arrowHorizontalAlignment()); } final Point2D p1 = new Point2D.Double(geo1.getLeft(), barHeight + geo1.getOutY()); final Point2D p2 = new Point2D.Double(geo1.getLeft(), justBeforeBar2); @@ -305,9 +305,10 @@ public class ParallelBuilderFork extends AbstractParallelFtilesBuilder { final Point2D p1 = new Point2D.Double(geo.getLeft(), barHeight + geo.getOutY()); final Point2D p2 = new Point2D.Double(geo.getLeft(), justBeforeBar2); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + Snake snake = Snake.create(arrowColor, Arrows.asToDown()) + .ignoreForCompression(); if (Display.isNull(label) == false) { - snake.setLabel(getTextBlock(label)); + snake = snake.withLabel(getTextBlock(label), arrowHorizontalAlignment()); } final Point2D mp1a = translate1.getTranslated(p1); final Point2D mp2b = translate2.getTranslated(p2); @@ -316,7 +317,6 @@ public class ParallelBuilderFork extends AbstractParallelFtilesBuilder { snake.addPoint(mp1a.getX(), middle); snake.addPoint(mp2b.getX(), middle); snake.addPoint(mp2b); - snake.setIgnoreForCompression(); ug.draw(snake); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderMerge.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderMerge.java index eba09e2bf..89e950847 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderMerge.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderMerge.java @@ -157,7 +157,7 @@ public class ParallelBuilderMerge extends AbstractParallelFtilesBuilder { } else if (counter == 1) { endDecoration = Arrows.asToLeft(); } - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, endDecoration); + final Snake snake = Snake.create(arrowColor, endDecoration); snake.addPoint(x1, y1); snake.addPoint(x1, y2); snake.addPoint(x2, y2); @@ -200,9 +200,9 @@ public class ParallelBuilderMerge extends AbstractParallelFtilesBuilder { public void drawU(UGraphic ug) { ug = ug.apply(UTranslate.dx(x)); final FtileGeometry geo = getFtile2().calculateDimension(getStringBounder()); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + Snake snake = Snake.create(arrowColor, Arrows.asToDown()); if (Display.isNull(label) == false) { - snake.setLabel(getTextBlock(label)); + snake = snake.withLabel(getTextBlock(label), arrowHorizontalAlignment()); } snake.addPoint(geo.getLeft(), 0); snake.addPoint(geo.getLeft(), geo.getInY()); @@ -215,9 +215,9 @@ public class ParallelBuilderMerge extends AbstractParallelFtilesBuilder { final Point2D p1 = new Point2D.Double(geo.getLeft(), 0); final Point2D p2 = new Point2D.Double(geo.getLeft(), geo.getInY()); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + Snake snake = Snake.create(arrowColor, Arrows.asToDown()); if (Display.isNull(label) == false) { - snake.setLabel(getTextBlock(label)); + snake = snake.withLabel(getTextBlock(label), arrowHorizontalAlignment()); } final Point2D mp1a = translate1.getTranslated(p1); final Point2D mp2b = translate2.getTranslated(p2); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit.java index 221b37bf5..ad6ee2807 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit.java @@ -221,9 +221,9 @@ public class ParallelBuilderSplit extends AbstractParallelFtilesBuilder { public void drawU(UGraphic ug) { ug = ug.apply(UTranslate.dx(x)); final FtileGeometry geo = getFtile2().calculateDimension(getStringBounder()); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + Snake snake = Snake.create(arrowColor, Arrows.asToDown()); if (Display.isNull(label) == false) { - snake.setLabel(getTextBlock(label)); + snake = snake.withLabel(getTextBlock(label), arrowHorizontalAlignment()); } snake.addPoint(geo.getLeft(), 0); snake.addPoint(geo.getLeft(), geo.getInY()); @@ -236,9 +236,9 @@ public class ParallelBuilderSplit extends AbstractParallelFtilesBuilder { final Point2D p1 = new Point2D.Double(geo.getLeft(), 0); final Point2D p2 = new Point2D.Double(geo.getLeft(), geo.getInY()); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + Snake snake = Snake.create(arrowColor, Arrows.asToDown()); if (Display.isNull(label) == false) { - snake.setLabel(getTextBlock(label)); + snake = snake.withLabel(getTextBlock(label), arrowHorizontalAlignment()); } final Point2D mp1a = translate1.getTranslated(p1); final Point2D mp2b = translate2.getTranslated(p2); @@ -275,9 +275,9 @@ public class ParallelBuilderSplit extends AbstractParallelFtilesBuilder { if (geo.hasPointOut() == false) { return; } - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + Snake snake = Snake.create(arrowColor, Arrows.asToDown()); if (Display.isNull(label) == false) { - snake.setLabel(getTextBlock(label)); + snake = snake.withLabel(getTextBlock(label), arrowHorizontalAlignment()); } final Point2D p1 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), geo.getOutY())); final Point2D p2 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), height)); @@ -295,9 +295,9 @@ public class ParallelBuilderSplit extends AbstractParallelFtilesBuilder { final Point2D p1 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), geo.getOutY())); final Point2D p2 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), height)); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + Snake snake = Snake.create(arrowColor, Arrows.asToDown()); if (Display.isNull(label) == false) { - snake.setLabel(getTextBlock(label)); + snake = snake.withLabel(getTextBlock(label), arrowHorizontalAlignment()); } final Point2D mp1a = translate1.getTranslated(p1); final Point2D mp2b = translate2.getTranslated(p2); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java index 7abb12a2f..7c1bfdc19 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java @@ -164,12 +164,13 @@ public class VCompactFactory implements FtileFactory { public Ftile repeat(BoxStyle boxStyleIn, Swimlane swimlane, Swimlane swimlaneOut, Display startLabel, Ftile repeat, Display test, Display yes, Display out, Colors colors, LinkRendering backRepeatLinkRendering, - Ftile backward, boolean noOut) { + Ftile backward, boolean noOut, Display labelBackward) { return repeat; } public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out, - LinkRendering afterEndwhile, HColor color, Instruction specialOut, Ftile back) { + LinkRendering afterEndwhile, HColor color, Instruction specialOut, Ftile back, String incoming, + String outcoming) { return whileBlock; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java index afcf468f3..90940a37b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java @@ -114,7 +114,7 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { final double x2 = p2.getX(); final double y2 = p2.getY(); - final Snake snake = new Snake(arrowHorizontalAlignment(), color, usingArrow); + final Snake snake = Snake.create(color, usingArrow); snake.addPoint(x1, y1); snake.addPoint(x2, y1); snake.addPoint(x2, y2); @@ -160,18 +160,18 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { if (originalDirection != newDirection) { final double delta = (originalDirection == Direction.RIGHT ? -1 : 1) * Diamond.diamondHalfSize; final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder); - final Snake small = new Snake(arrowHorizontalAlignment(), color); + final Snake small = Snake.create(color); small.addPoint(p1); small.addPoint(p1.getX() + delta, p1.getY()); small.addPoint(p1.getX() + delta, p1.getY() + dimDiamond1.getHeight() * .75); ug.draw(small); p1 = small.getLast(); } - final Snake snake = new Snake(arrowHorizontalAlignment(), color, usingArrow); + final Snake snake = Snake.create(color, usingArrow) + .withMerge(MergeStrategy.LIMITED); snake.addPoint(p1); snake.addPoint(p2.getX(), p1.getY()); snake.addPoint(p2); - snake.goUnmergeable(MergeStrategy.LIMITED); ug.draw(snake); } @@ -204,9 +204,9 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { final double y2 = p2.getY(); final UPolygon arrow = x2 > x1 ? Arrows.asToRight() : Arrows.asToLeft(); - final Snake snake = new Snake(arrowHorizontalAlignment(), myArrowColor, arrow); + Snake snake = Snake.create(myArrowColor, arrow); if (branchEmpty) { - snake.emphasizeDirection(Direction.DOWN); + snake = snake.emphasizeDirection(Direction.DOWN); } snake.addPoint(x1, y1); snake.addPoint(x1, y2); @@ -257,35 +257,35 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { if (originalDirection == newDirection) { final double delta = (x2 > x1 ? -1 : 1) * 1.5 * Diamond.diamondHalfSize; final Point2D mp2bc = new Point2D.Double(mp2b.getX() + delta, mp2b.getY()); - final Snake snake = new Snake(arrowHorizontalAlignment(), myArrowColor); + final Snake snake = Snake.create(myArrowColor) + .withMerge(MergeStrategy.LIMITED); final double middle = (mp1a.getY() + mp2b.getY()) / 2.0; snake.addPoint(mp1a); snake.addPoint(mp1a.getX(), middle); snake.addPoint(mp2bc.getX(), middle); snake.addPoint(mp2bc); - snake.goUnmergeable(MergeStrategy.LIMITED); ug.draw(snake); - final Snake small = new Snake(arrowHorizontalAlignment(), myArrowColor, arrow); + final Snake small = Snake.create(myArrowColor, arrow) + .withMerge(MergeStrategy.LIMITED); small.addPoint(mp2bc); small.addPoint(mp2bc.getX(), mp2b.getY()); small.addPoint(mp2b); - small.goUnmergeable(MergeStrategy.LIMITED); ug.draw(small); } else { final double delta = (x2 > x1 ? -1 : 1) * 1.5 * Diamond.diamondHalfSize; - final Point2D mp2bb = new Point2D.Double(mp2b.getX() + delta, mp2b.getY() - 1.5 - * Diamond.diamondHalfSize); - final Snake snake = new Snake(arrowHorizontalAlignment(), myArrowColor); + final Point2D mp2bb = new Point2D.Double(mp2b.getX() + delta, + mp2b.getY() - 1.5 * Diamond.diamondHalfSize); + final Snake snake = Snake.create(myArrowColor) + .withMerge(MergeStrategy.LIMITED); snake.addPoint(mp1a); snake.addPoint(mp1a.getX(), mp2bb.getY()); snake.addPoint(mp2bb); - snake.goUnmergeable(MergeStrategy.LIMITED); ug.draw(snake); - final Snake small = new Snake(arrowHorizontalAlignment(), myArrowColor, arrow); + final Snake small = Snake.create(myArrowColor, arrow) + .withMerge(MergeStrategy.LIMITED); small.addPoint(mp2bb); small.addPoint(mp2bb.getX(), mp2b.getY()); small.addPoint(mp2b); - small.goUnmergeable(MergeStrategy.LIMITED); ug.draw(small); } @@ -320,9 +320,9 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { final double x2 = p2.getX(); final double y2 = p2.getY(); - final Snake snake = new Snake(arrowHorizontalAlignment(), myArrowColor); + Snake snake = Snake.create(myArrowColor); if (branchEmpty) { - snake.emphasizeDirection(Direction.DOWN); + snake = snake.emphasizeDirection(Direction.DOWN); } snake.addPoint(x1, y1); snake.addPoint(x1, y2); @@ -346,7 +346,7 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { final Point2D mp1a = translate1.getTranslated(p1); final Point2D mp2b = translate2.getTranslated(p2); - final Snake snake = new Snake(arrowHorizontalAlignment(), myArrowColor); + final Snake snake = Snake.create(myArrowColor).withMerge(MergeStrategy.LIMITED); // snake.emphasizeDirection(Direction.DOWN); final double x1 = mp1a.getX(); @@ -357,7 +357,6 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { snake.addPoint(x1, y2); snake.addPoint(mp2b); snake.addPoint(x2, dimTotal.getHeight()); - snake.goUnmergeable(MergeStrategy.LIMITED); ug.draw(snake); } @@ -403,8 +402,7 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { } final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight); - final Snake snake = new Snake(arrowHorizontalAlignment(), color, Arrows.asToDown()); - snake.setLabel(out2); + final Snake snake = Snake.create(color, Arrows.asToDown()).withLabel(out2, arrowHorizontalAlignment()); snake.addPoint(p1); snake.addPoint(p2); ug.draw(snake); @@ -422,8 +420,9 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { /* * private Point2D getP1(StringBounder stringBounder) { * - * final FtileGeometry geo = getFtile1().calculateDimension(stringBounder); if (geo.hasPointOut() == false) { - * return null; } final Point2D p = geo.getPointOut(); return getTranslate1(stringBounder).getTranslated(p); } + * final FtileGeometry geo = getFtile1().calculateDimension(stringBounder); if + * (geo.hasPointOut() == false) { return null; } final Point2D p = + * geo.getPointOut(); return getTranslate1(stringBounder).getTranslated(p); } */ } @@ -474,8 +473,7 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { return; } - final Snake s = new Snake(arrowHorizontalAlignment(), arrowColor); - s.goUnmergeable(MergeStrategy.NONE); + final Snake s = Snake.create(arrowColor).withMerge(MergeStrategy.NONE); final double height = totalDim.getHeight(); s.addPoint(minX, height); s.addPoint(maxX, height); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithManyLinks.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithManyLinks.java index 3cf2ce70c..0a9d7bb35 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithManyLinks.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithManyLinks.java @@ -50,6 +50,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -83,8 +84,8 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds { final double x2 = p2.getX(); final double y2 = p2.getY(); - final Snake snake = new Snake(null, arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); - snake.setLabel(getLabelPositive(branch)); + final Snake snake = Snake.create(null, arrowColor, Arrows.asToDown()).withLabel(getLabelPositive(branch), + arrowHorizontalAlignment()); snake.addPoint(x1, y1); snake.addPoint(x2, y1); snake.addPoint(x2, y2); @@ -106,8 +107,8 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds { } private Point2D getP2(final StringBounder stringBounder) { - return getTranslateOf(getFtile2(), stringBounder).getTranslated( - getFtile2().calculateDimension(stringBounder).getPointIn()); + return getTranslateOf(getFtile2(), stringBounder) + .getTranslated(getFtile2().calculateDimension(stringBounder).getPointIn()); } } @@ -133,7 +134,7 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds { final double y2 = p2.getY(); final UPolygon arrow = x2 > x1 ? Arrows.asToRight() : Arrows.asToLeft(); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, arrow); + final Snake snake = Snake.create(arrowColor, arrow); snake.addPoint(x1, y1); snake.addPoint(x1, y2); snake.addPoint(x2, y2); @@ -142,8 +143,8 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds { } private Point2D getP1(StringBounder stringBounder) { - return getTranslateOf(getFtile1(), stringBounder).getTranslated( - getFtile1().calculateDimension(stringBounder).getPointOut()); + return getTranslateOf(getFtile1(), stringBounder) + .getTranslated(getFtile1().calculateDimension(stringBounder).getPointOut()); } private Point2D getP2(StringBounder stringBounder) { @@ -162,8 +163,10 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds { } - // protected UTranslate getTranslateOf(Ftile tile, StringBounder stringBounder) { - // return getTranslateNude(tile, stringBounder).compose(getTranslateMain(stringBounder)); + // protected UTranslate getTranslateOf(Ftile tile, StringBounder stringBounder) + // { + // return getTranslateNude(tile, + // stringBounder).compose(getTranslateMain(stringBounder)); // // } @@ -188,8 +191,8 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds { final double x2 = p2.getX(); final double y2 = p2.getY(); - final Snake snake = new Snake(null, arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); - snake.setLabel(getLabelPositive(branch), "BOTTOM"); + final Snake snake = Snake.create(null, arrowColor, Arrows.asToDown()) + .withLabel(getLabelPositive(branch), VerticalAlignment.BOTTOM); if (x2 < p1d.getX() - margin || x2 > p1b.getX() + margin) { snake.addPoint(x2, p1d.getY()); snake.addPoint(x2, y2); @@ -207,8 +210,8 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds { } private Point2D getP2(final StringBounder stringBounder) { - return getTranslateOf(getFtile2(), stringBounder).getTranslated( - getFtile2().calculateDimension(stringBounder).getPointIn()); + return getTranslateOf(getFtile2(), stringBounder) + .getTranslated(getFtile2().calculateDimension(stringBounder).getPointIn()); } } @@ -241,7 +244,7 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds { final double ym = (y1 + y2) / 2; - final Snake snake = new Snake(null, arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + final Snake snake = Snake.create(null, arrowColor, Arrows.asToDown()); if (x1 < p1d.getX() - margin || x1 > p1b.getX() + margin) { snake.addPoint(x1, y1); @@ -257,8 +260,8 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds { } private Point2D getP1(StringBounder stringBounder) { - return getTranslateOf(getFtile1(), stringBounder).getTranslated( - getFtile1().calculateDimension(stringBounder).getPointOut()); + return getTranslateOf(getFtile1(), stringBounder) + .getTranslated(getFtile1().calculateDimension(stringBounder).getPointOut()); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithOneLink.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithOneLink.java index 32d521e08..0c7fcfedd 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithOneLink.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithOneLink.java @@ -56,8 +56,8 @@ public class FtileSwitchWithOneLink extends FtileSwitchWithDiamonds { private final Rainbow arrowColor; - public FtileSwitchWithOneLink(List tiles, List branches, Swimlane in, Ftile diamond1, - Ftile diamond2, StringBounder stringBounder, Rainbow arrowColor) { + public FtileSwitchWithOneLink(List tiles, List branches, Swimlane in, Ftile diamond1, Ftile diamond2, + StringBounder stringBounder, Rainbow arrowColor) { super(tiles, branches, in, diamond1, diamond2, stringBounder); this.arrowColor = arrowColor; } @@ -80,8 +80,8 @@ public class FtileSwitchWithOneLink extends FtileSwitchWithDiamonds { final double x2 = p2.getX(); final double y2 = p2.getY(); - final Snake snake = new Snake(null, arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); - snake.setLabel(getLabelPositive(branch)); + final Snake snake = Snake.create(null, arrowColor, Arrows.asToDown()) + .withLabel(getLabelPositive(branch), arrowHorizontalAlignment()); // snake.addPoint(x1, y1); snake.addPoint(x2, y1); snake.addPoint(x2, y2); @@ -95,8 +95,8 @@ public class FtileSwitchWithOneLink extends FtileSwitchWithDiamonds { } private Point2D getP2(final StringBounder stringBounder) { - return getTranslateOf(getFtile2(), stringBounder).getTranslated( - getFtile2().calculateDimension(stringBounder).getPointIn()); + return getTranslateOf(getFtile2(), stringBounder) + .getTranslated(getFtile2().calculateDimension(stringBounder).getPointIn()); } } @@ -115,7 +115,7 @@ public class FtileSwitchWithOneLink extends FtileSwitchWithDiamonds { final double x2 = p2.getX(); final double y2 = p2.getY(); - final Snake snake = new Snake(null, arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + final Snake snake = Snake.create(null, arrowColor, Arrows.asToDown()); // snake.addPoint(x1, y1); snake.addPoint(x2, y1); snake.addPoint(x2, y2); @@ -124,8 +124,8 @@ public class FtileSwitchWithOneLink extends FtileSwitchWithDiamonds { } private Point2D getP1(StringBounder stringBounder) { - return getTranslateOf(getFtile1(), stringBounder).getTranslated( - getFtile1().calculateDimension(stringBounder).getPointOut()); + return getTranslateOf(getFtile1(), stringBounder) + .getTranslated(getFtile1().calculateDimension(stringBounder).getPointOut()); } private Point2D getP2(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java index 78b7547ca..b46c79936 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java @@ -66,7 +66,9 @@ import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram; final public class CommandLinkClass extends SingleLineCommand2 { private static final String SINGLE = "[.\\\\]{0,2}[\\p{L}0-9_]+(?:[.\\\\]{1,2}[\\p{L}0-9_]+)*"; - private static final String COUPLE = "\\([%s]*(" + SINGLE + ")[%s]*,[%s]*(" + SINGLE + ")[%s]*\\)"; + private static final String SINGLE_GUILLEMENT = "[%g][.\\\\]{0,2}[\\p{L}0-9_]+(?:[.\\\\]{1,2}[\\p{L}0-9_]+)*[%g]"; + private static final String SINGLE2 = "(?:" + SINGLE + "|" + SINGLE_GUILLEMENT + ")"; + private static final String COUPLE = "\\([%s]*(" + SINGLE2 + ")[%s]*,[%s]*(" + SINGLE2 + ")[%s]*\\)"; public CommandLinkClass(UmlDiagramType umlDiagramType) { super(getRegexConcat(umlDiagramType)); @@ -364,8 +366,8 @@ final public class CommandLinkClass extends SingleLineCommand2 trace) { - final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, EMPTY_DESCRIPTION, /* 1, */lineLocation); - // final AbstractPSystemError result = PSystemErrorUtils.buildV1(source, err, null); + final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, EMPTY_DESCRIPTION, lineLocation); final PSystemError result = PSystemErrorUtils.buildV2(source, err, null, trace); result.setSource(source); return result; } - final protected PSystemError buildExecutionError(UmlSource source, String stringError, - LineLocation lineLocation, List trace) { - final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, stringError, /* 1, */ - lineLocation); + final protected PSystemError buildExecutionError(UmlSource source, String stringError, LineLocation lineLocation, + List trace) { + final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, stringError, lineLocation); final PSystemError result = PSystemErrorUtils.buildV2(source, err, null, trace); result.setSource(source); return result; diff --git a/src/net/sourceforge/plantuml/core/UmlSource.java b/src/net/sourceforge/plantuml/core/UmlSource.java index ea905114a..fc382684e 100644 --- a/src/net/sourceforge/plantuml/core/UmlSource.java +++ b/src/net/sourceforge/plantuml/core/UmlSource.java @@ -201,6 +201,10 @@ final public class UmlSource { return source.size(); } + public boolean getTotalLineCountLessThan5() { + return getTotalLineCount() < 5; + } + /** * Check if a source diagram description is empty. Does not take comment line * into account. diff --git a/src/net/sourceforge/plantuml/cucadiagram/LeafType.java b/src/net/sourceforge/plantuml/cucadiagram/LeafType.java index 1a6766eac..7b0f7395c 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/LeafType.java +++ b/src/net/sourceforge/plantuml/cucadiagram/LeafType.java @@ -44,7 +44,7 @@ public enum LeafType { ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION, LOLLIPOP_FULL, LOLLIPOP_HALF, NOTE, TIPS, OBJECT, MAP, ASSOCIATION, ENUM, CIRCLE, - USECASE, + USECASE, USECASE_BUSINESS, DESCRIPTION, diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkDecor.java b/src/net/sourceforge/plantuml/cucadiagram/LinkDecor.java index d6fa7b5a5..a59f0f2c1 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/LinkDecor.java +++ b/src/net/sourceforge/plantuml/cucadiagram/LinkDecor.java @@ -101,6 +101,13 @@ public enum LinkDecor { return this == EXTENDS || this == REDEFINES || this == DEFINEDBY; } + public ExtremityFactory getExtremityFactoryComplete(HColor backgroundColor) { + if (this == EXTENDS) { + return new ExtremityFactoryTriangle(backgroundColor, 16, 6); + } + return getExtremityFactory(backgroundColor); + } + public ExtremityFactory getExtremityFactory(HColor backgroundColor) { switch (this) { case PLUS: @@ -112,7 +119,7 @@ public enum LinkDecor { case HALF_ARROW: return new ExtremityFactoryHalfArrow(); case ARROW_TRIANGLE: - return new ExtremityFactoryTriangle(); + return new ExtremityFactoryTriangle(null, 8, 3); case CROWFOOT: return new ExtremityFactoryCrowfoot(); case CIRCLE_CROWFOOT: diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkMiddleDecor.java b/src/net/sourceforge/plantuml/cucadiagram/LinkMiddleDecor.java index f368b643b..4b98bc4fa 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/LinkMiddleDecor.java +++ b/src/net/sourceforge/plantuml/cucadiagram/LinkMiddleDecor.java @@ -61,4 +61,13 @@ public enum LinkMiddleDecor { throw new UnsupportedOperationException(); } + public LinkMiddleDecor getInversed() { + if (this == CIRCLE_CIRCLED1) { + return CIRCLE_CIRCLED2; + } else if (this == CIRCLE_CIRCLED2) { + return CIRCLE_CIRCLED1; + } + return this; + } + } diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkType.java b/src/net/sourceforge/plantuml/cucadiagram/LinkType.java index 57c038623..711dbb1fa 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/LinkType.java +++ b/src/net/sourceforge/plantuml/cucadiagram/LinkType.java @@ -138,7 +138,7 @@ public class LinkType { } public LinkType getInversed() { - return new LinkType(hat2, decor2, style, middleDecor, decor1, hat1); + return new LinkType(hat2, decor2, style, middleDecor.getInversed(), decor1, hat1); } public LinkType withMiddleCircle() { diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementFull.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementFull.java index 9d7faa9e5..1b4b54b28 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementFull.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementFull.java @@ -69,7 +69,7 @@ import net.sourceforge.plantuml.ugraphic.color.HColor; public class CommandCreateElementFull extends SingleLineCommand2 { - public static final String ALL_TYPES = "artifact|actor|folder|card|file|package|rectangle|label|node|frame|cloud|database|queue|stack|storage|agent|usecase|component|boundary|control|entity|interface|circle|collections|port|portin|portout"; + public static final String ALL_TYPES = "artifact|actor/|actor|folder|card|file|package|rectangle|label|node|frame|cloud|database|queue|stack|storage|agent|usecase/|usecase|component|boundary|control|entity|interface|circle|collections|port|portin|portout"; public CommandCreateElementFull() { super(getRegexConcat()); @@ -137,11 +137,11 @@ public class CommandCreateElementFull extends SingleLineCommand2 2 ? codeRaw.charAt(0) : 0; } } - \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/directdot/PSystemDotFactory.java b/src/net/sourceforge/plantuml/directdot/PSystemDotFactory.java index a7fd314a1..adfbd9b75 100644 --- a/src/net/sourceforge/plantuml/directdot/PSystemDotFactory.java +++ b/src/net/sourceforge/plantuml/directdot/PSystemDotFactory.java @@ -53,7 +53,7 @@ public class PSystemDotFactory extends PSystemBasicFactory { @Override public PSystemDot executeLine(PSystemDot system, String line) { - if (system == null && line.matches("(strict\\s+)?(di)?graph\\s+\\w+\\s*\\{")) { + if (system == null && line.matches("(strict\\s+)?(di)?graph\\s+\"?[-\\w]+\"?\\s*\\{")) { data = new StringBuilder(line); data.append("\n"); return new PSystemDot(data.toString()); diff --git a/src/net/sourceforge/plantuml/error/PSystemError.java b/src/net/sourceforge/plantuml/error/PSystemError.java index 2155c2222..fff1696ff 100644 --- a/src/net/sourceforge/plantuml/error/PSystemError.java +++ b/src/net/sourceforge/plantuml/error/PSystemError.java @@ -175,7 +175,7 @@ public abstract class PSystemError extends AbstractPSystem { return result; } - private List getTextFullBody() { + protected List getTextFullBody() { final List result = new ArrayList(); result.add(" "); final int traceSize = trace.size(); @@ -227,7 +227,7 @@ public abstract class PSystemError extends AbstractPSystem { final ImageBuilder imageBuilder = ImageBuilder.buildA(new ColorMapperIdentity(), false, null, getMetadata(), null, 1.0, result.getBackcolor()); imageBuilder.setRandomPixel(true); - if (getSource().getTotalLineCount() < 5) { + if (getSource().getTotalLineCountLessThan5()) { udrawable = addWelcome(result); } else { udrawable = result; diff --git a/src/net/sourceforge/plantuml/error/PSystemErrorEmpty.java b/src/net/sourceforge/plantuml/error/PSystemErrorEmpty.java new file mode 100644 index 000000000..2eb228213 --- /dev/null +++ b/src/net/sourceforge/plantuml/error/PSystemErrorEmpty.java @@ -0,0 +1,52 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + */ +package net.sourceforge.plantuml.error; + +import java.util.List; + +import net.sourceforge.plantuml.ErrorUml; +import net.sourceforge.plantuml.StringLocated; +import net.sourceforge.plantuml.core.UmlSource; + +public class PSystemErrorEmpty extends PSystemError { + + public PSystemErrorEmpty(UmlSource source, List trace, ErrorUml singleError) { + this.setSource(source); + this.trace = trace; + this.singleError = singleError; + + } + +} diff --git a/src/net/sourceforge/plantuml/error/PSystemErrorUtils.java b/src/net/sourceforge/plantuml/error/PSystemErrorUtils.java index d68f56f8e..be30cd4e9 100644 --- a/src/net/sourceforge/plantuml/error/PSystemErrorUtils.java +++ b/src/net/sourceforge/plantuml/error/PSystemErrorUtils.java @@ -45,13 +45,11 @@ import net.sourceforge.plantuml.core.UmlSource; public class PSystemErrorUtils { - // public static AbstractPSystemError buildV1(UmlSource source, ErrorUml singleError, List debugLines) { - // return new PSystemErrorV1(source, singleError, debugLines); - // } - public static PSystemError buildV2(UmlSource source, ErrorUml singleError, List debugLines, List list) { - // return new PSystemErrorV1(source, singleError, debugLines); +// if (source.isEmpty()) { +// return new PSystemErrorEmpty(source, list, singleError); +// } return new PSystemErrorV2(source, list, singleError); } @@ -68,12 +66,6 @@ public class PSystemErrorUtils { source = system.getSource(); } errors.addAll(system.getErrorsUml()); - // if (system instanceof PSystemErrorV1) { - // debugs.addAll(((PSystemErrorV1) system).debugLines); - // if (((PSystemErrorV1) system).debugLines.size() > 0) { - // debugs.add("-"); - // } - // } if (system instanceof PSystemErrorV2) { errorsV2.add((PSystemErrorV2) system); } @@ -85,7 +77,6 @@ public class PSystemErrorUtils { return mergeV2(errorsV2); } throw new IllegalStateException(); - // return new PSystemErrorV1(source, errors, debugs); } private static PSystemErrorV2 mergeV2(List errorsV2) { @@ -100,7 +91,6 @@ public class PSystemErrorUtils { public static boolean isDiagramError(Class type) { return PSystemError.class.isAssignableFrom(type); - // return type == PSystemErrorV1.class; } } diff --git a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java index eb51f24c7..00b67cc40 100644 --- a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java +++ b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java @@ -194,7 +194,7 @@ public class QuoteUtils { "Lbh xabj jung fhecevfrq zr gur zbfg? Vg jnfa'g zrrgvat gurz. Vg jnf zrrgvat lbh.", "Va jne gurer ner ab jvaaref, bayl jvqbjf", "Vs lbh guvax guvf Havirefr vf onq, lbh fubhyq frr fbzr bs gur bguref", "Cnp-Zna'f n onq thl?", - "Zl ernyvgl vf whfg qvssrerag guna lbhef", "L'ra n dh'bag rffnlr, vyf bag rh qrf ceboyrzrf", + "L'ra n dh'bag rffnlr, vyf bag rh qrf ceboyrzrf", "Gb ree vf uhzna, ohg gb ernyyl sbhy guvatf hc erdhverf n pbzchgre.", "Vs lbh oryvrir rirelguvat lbh ernq, lbh orggre abg ernq", "Gurer vf ab ceboyrz fb onq lbh pna'g znxr vg jbefr", "Pn p'rfg qh ybheq... Ha gehp qr znynqr.", @@ -276,7 +276,8 @@ public class QuoteUtils { "Vs lbh ner abg rzoneenffrq ol gur svefg irefvba bs lbhe cebqhpg, lbh'ir ynhapurq gbb yngr", "Zvfgnxrf znqr zl fhpprff: V znxr ehoore renfre", "Ovt Oebgure vf Jngpuvat Lbh.", "Ab bar'f gnyxvat nobhg yrnivat gur fvatyr znexrg", "...rnfvrfg oht gb svk va uhzna uvfgbel", - "Arire nggevohgr gb znyvpr jung pna or rkcynvarq ol fghcvqvgl", "Guvf oht nssrpgf iveghnyyl abobql"); + "Arire nggevohgr gb znyvpr jung pna or rkcynvarq ol fghcvqvgl", "Guvf oht nssrpgf iveghnyyl abobql", + "Qba'g rire hfr gur jbeq fzneg jvgu zr", "Gur Ertrareba vf ernyyl xvpxvat va guvf zbeavat"); private QuoteUtils() { } diff --git a/src/net/sourceforge/plantuml/graphic/Splitter.java b/src/net/sourceforge/plantuml/graphic/Splitter.java index b0fa5f05d..e91fd57ed 100644 --- a/src/net/sourceforge/plantuml/graphic/Splitter.java +++ b/src/net/sourceforge/plantuml/graphic/Splitter.java @@ -141,6 +141,10 @@ public class Splitter { return splitted; } + public static String purgeAllTag(String s) { + return s.replaceAll(htmlTag, ""); + } + public List getHtmlCommands(boolean newLineAlone) { final HtmlCommandFactory factory = new HtmlCommandFactory(); final List result = new ArrayList(); diff --git a/src/net/sourceforge/plantuml/graphic/USymbol.java b/src/net/sourceforge/plantuml/graphic/USymbol.java index c20a1c65e..7077130a0 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbol.java +++ b/src/net/sourceforge/plantuml/graphic/USymbol.java @@ -76,6 +76,8 @@ public abstract class USymbol { public final static USymbol AGENT = record("AGENT", SkinParameter.AGENT, new USymbolRect(SkinParameter.AGENT)); public final static USymbol ACTOR_STICKMAN = record("ACTOR_STICKMAN", SkinParameter.ACTOR, new USymbolActor(ActorStyle.STICKMAN)); + public final static USymbol ACTOR_STICKMAN_BUSINESS = record("ACTOR_STICKMAN_BUSINESS", SkinParameter.ACTOR, + new USymbolActor(ActorStyle.STICKMAN_BUSINESS)); public final static USymbol ACTOR_AWESOME = record("ACTOR_AWESOME", SkinParameter.ACTOR, new USymbolActor(ActorStyle.AWESOME)); public final static USymbol USECASE = null; @@ -170,17 +172,17 @@ public abstract class USymbol { return 0; } - final Stencil getRectangleStencil(final Dimension2D dim) { - return new Stencil() { - public double getStartingX(StringBounder stringBounder, double y) { - return 0; - } - - public double getEndingX(StringBounder stringBounder, double y) { - return dim.getWidth(); - } - }; - } +// final Stencil getRectangleStencil(final Dimension2D dim) { +// return new Stencil() { +// public double getStartingX(StringBounder stringBounder, double y) { +// return 0; +// } +// +// public double getEndingX(StringBounder stringBounder, double y) { +// return dim.getWidth(); +// } +// }; +// } public static USymbol fromString(String s, ActorStyle actorStyle, ComponentStyle componentStyle, PackageStyle packageStyle) { @@ -235,6 +237,8 @@ public abstract class USymbol { usymbol = USymbol.STORAGE; } else if (symbol.equalsIgnoreCase("agent")) { usymbol = USymbol.AGENT; + } else if (symbol.equalsIgnoreCase("actor/")) { + usymbol = USymbol.ACTOR_STICKMAN_BUSINESS; } else if (symbol.equalsIgnoreCase("actor")) { usymbol = skinParam.actorStyle().toUSymbol(); } else if (symbol.equalsIgnoreCase("component")) { diff --git a/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java b/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java index 93139e8bb..ab897fc71 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java @@ -43,7 +43,6 @@ import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; class USymbolArtifact extends USymbol { @@ -53,7 +52,8 @@ class USymbolArtifact extends USymbol { return SkinParameter.ARTIFACT; } - private void drawArtifact(UGraphic ug, double widthTotal, double heightTotal, boolean shadowing, double roundCorner) { + private void drawArtifact(UGraphic ug, double widthTotal, double heightTotal, boolean shadowing, + double roundCorner) { final URectangle form = new URectangle(widthTotal, heightTotal).rounded(roundCorner); if (shadowing) { @@ -100,7 +100,7 @@ class USymbolArtifact extends USymbol { public void drawU(UGraphic ug) { final Dimension2D dim = calculateDimension(ug.getStringBounder()); - ug = UGraphicStencil.create(ug, getRectangleStencil(dim), new UStroke()); + ug = UGraphicStencil.create(ug, dim); ug = symbolContext.apply(ug); drawArtifact(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), symbolContext.getRoundCorner()); @@ -119,7 +119,8 @@ class USymbolArtifact extends USymbol { @Override public TextBlock asBig(final TextBlock title, HorizontalAlignment labelAlignment, final TextBlock stereotype, - final double width, final double height, final SymbolContext symbolContext, final HorizontalAlignment stereoAlignment) { + final double width, final double height, final SymbolContext symbolContext, + final HorizontalAlignment stereoAlignment) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/graphic/USymbolCard.java b/src/net/sourceforge/plantuml/graphic/USymbolCard.java index 34ab25f72..ea4e77214 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolCard.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolCard.java @@ -42,7 +42,6 @@ import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; class USymbolCard extends USymbol { @@ -80,7 +79,7 @@ class USymbolCard extends USymbol { public void drawU(UGraphic ug) { final Dimension2D dim = calculateDimension(ug.getStringBounder()); - ug = UGraphicStencil.create(ug, getRectangleStencil(dim), new UStroke()); + ug = UGraphicStencil.create(ug, dim); ug = symbolContext.apply(ug); drawCard(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), 0, symbolContext.getRoundCorner()); diff --git a/src/net/sourceforge/plantuml/graphic/USymbolCloud.java b/src/net/sourceforge/plantuml/graphic/USymbolCloud.java index 9bd94cec3..c4748cb71 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolCloud.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolCloud.java @@ -45,7 +45,6 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.UPath; -import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; // https://stackoverflow.com/questions/39552127/algorithm-for-drawing-random-comic-style-clouds // http://martin-oehm.de/data/cloud.html @@ -225,7 +224,7 @@ class USymbolCloud extends USymbol { public void drawU(UGraphic ug) { final Dimension2D dim = calculateDimension(ug.getStringBounder()); - ug = UGraphicStencil.create(ug, getRectangleStencil(dim), new UStroke()); + ug = UGraphicStencil.create(ug, dim); ug = symbolContext.apply(ug); drawCloud(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing()); final Margin margin = getMargin(); diff --git a/src/net/sourceforge/plantuml/graphic/USymbolCollections.java b/src/net/sourceforge/plantuml/graphic/USymbolCollections.java index 5e86c1de2..017d6f8b4 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolCollections.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolCollections.java @@ -41,7 +41,6 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; class USymbolCollections extends USymbol { @@ -90,7 +89,7 @@ class USymbolCollections extends USymbol { public void drawU(UGraphic ug) { final Dimension2D dim = calculateDimension(ug.getStringBounder()); - ug = UGraphicStencil.create(ug, getRectangleStencil(dim), new UStroke()); + ug = UGraphicStencil.create(ug, dim); ug = symbolContext.apply(ug); drawCollections(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), symbolContext.getRoundCorner()); diff --git a/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java b/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java index cadcae315..a28dacdf4 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java @@ -42,7 +42,6 @@ import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.UShape; -import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; class USymbolComponent1 extends USymbol { @@ -81,7 +80,7 @@ class USymbolComponent1 extends USymbol { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); final Dimension2D dimTotal = calculateDimension(stringBounder); - ug = UGraphicStencil.create(ug, getRectangleStencil(dimTotal), new UStroke()); + ug = UGraphicStencil.create(ug, dimTotal); ug = symbolContext.apply(ug); drawComponent1(ug, dimTotal.getWidth(), dimTotal.getHeight(), symbolContext.isShadowing(), symbolContext.getRoundCorner()); diff --git a/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java b/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java index 868559b01..b69838122 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java @@ -42,7 +42,6 @@ import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.UShape; -import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; class USymbolComponent2 extends USymbol { @@ -83,7 +82,7 @@ class USymbolComponent2 extends USymbol { public void drawU(UGraphic ug) { final Dimension2D dim = calculateDimension(ug.getStringBounder()); - ug = UGraphicStencil.create(ug, getRectangleStencil(dim), new UStroke()); + ug = UGraphicStencil.create(ug, dim); ug = symbolContext.apply(ug); drawComponent2(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), symbolContext.getRoundCorner()); @@ -104,7 +103,8 @@ class USymbolComponent2 extends USymbol { @Override public TextBlock asBig(final TextBlock title, HorizontalAlignment labelAlignment, final TextBlock stereotype, - final double width, final double height, final SymbolContext symbolContext, final HorizontalAlignment stereoAlignment) { + final double width, final double height, final SymbolContext symbolContext, + final HorizontalAlignment stereoAlignment) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/graphic/USymbolFile.java b/src/net/sourceforge/plantuml/graphic/USymbolFile.java index 42db16d0b..f59b8b187 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolFile.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolFile.java @@ -44,7 +44,6 @@ import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.UPath; import net.sourceforge.plantuml.ugraphic.UPolygon; -import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; class USymbolFile extends USymbol { @@ -110,7 +109,7 @@ class USymbolFile extends USymbol { public void drawU(UGraphic ug) { final Dimension2D dim = calculateDimension(ug.getStringBounder()); - ug = UGraphicStencil.create(ug, getRectangleStencil(dim), new UStroke()); + ug = UGraphicStencil.create(ug, dim); ug = symbolContext.apply(ug); drawFile(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), symbolContext.getRoundCorner()); @@ -129,7 +128,8 @@ class USymbolFile extends USymbol { @Override public TextBlock asBig(final TextBlock title, HorizontalAlignment labelAlignment, final TextBlock stereotype, - final double width, final double height, final SymbolContext symbolContext, final HorizontalAlignment stereoAlignment) { + final double width, final double height, final SymbolContext symbolContext, + final HorizontalAlignment stereoAlignment) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/graphic/USymbolFolder.java b/src/net/sourceforge/plantuml/graphic/USymbolFolder.java index fcdaf34f9..fe91f0915 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolFolder.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolFolder.java @@ -45,7 +45,6 @@ import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UPath; import net.sourceforge.plantuml.ugraphic.UPolygon; -import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; public class USymbolFolder extends USymbol { @@ -147,7 +146,7 @@ public class USymbolFolder extends USymbol { public void drawU(UGraphic ug) { final Dimension2D dim = calculateDimension(ug.getStringBounder()); - ug = UGraphicStencil.create(ug, getRectangleStencil(dim), new UStroke()); + ug = UGraphicStencil.create(ug, dim); ug = symbolContext.apply(ug); final Dimension2D dimName = showTitle ? name.calculateDimension(ug.getStringBounder()) : new Dimension2DDouble(40, 15); diff --git a/src/net/sourceforge/plantuml/graphic/USymbolFrame.java b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java index a98871701..f14ebe422 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolFrame.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java @@ -43,7 +43,6 @@ import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.UPath; import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColorNone; @@ -105,7 +104,7 @@ class USymbolFrame extends USymbol { public void drawU(UGraphic ug) { final Dimension2D dim = calculateDimension(ug.getStringBounder()); - ug = UGraphicStencil.create(ug, getRectangleStencil(dim), new UStroke()); + ug = UGraphicStencil.create(ug, dim); ug = symbolContext.apply(ug); drawFrame(ug, dim.getWidth(), dim.getHeight(), new Dimension2DDouble(0, 0), symbolContext.isShadowing(), symbolContext.getRoundCorner()); diff --git a/src/net/sourceforge/plantuml/graphic/USymbolLabel.java b/src/net/sourceforge/plantuml/graphic/USymbolLabel.java index 08df00461..089077999 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolLabel.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolLabel.java @@ -40,7 +40,6 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; -import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; class USymbolLabel extends USymbol { @@ -67,7 +66,7 @@ class USymbolLabel extends USymbol { public void drawU(UGraphic ug) { final Dimension2D dim = calculateDimension(ug.getStringBounder()); - ug = UGraphicStencil.create(ug, getRectangleStencil(dim), new UStroke()); + ug = UGraphicStencil.create(ug, dim); ug = symbolContext.apply(ug); final Margin margin = getMargin(); final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, stereoAlignment); diff --git a/src/net/sourceforge/plantuml/graphic/USymbolRect.java b/src/net/sourceforge/plantuml/graphic/USymbolRect.java index aeaa20d22..d0bf75049 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolRect.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolRect.java @@ -42,7 +42,6 @@ import net.sourceforge.plantuml.ugraphic.Shadowable; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; class USymbolRect extends USymbol { @@ -61,8 +60,7 @@ class USymbolRect extends USymbol { private void drawRect(UGraphic ug, double width, double height, boolean shadowing, double roundCorner, double diagonalCorner) { final URectangle rect = new URectangle(width, height); - final Shadowable shape = diagonalCorner > 0 ? rect.diagonalCorner(diagonalCorner) - : rect.rounded(roundCorner); + final Shadowable shape = diagonalCorner > 0 ? rect.diagonalCorner(diagonalCorner) : rect.rounded(roundCorner); if (shadowing) { shape.setDeltaShadow(3.0); } @@ -80,7 +78,7 @@ class USymbolRect extends USymbol { public void drawU(UGraphic ug) { final Dimension2D dim = calculateDimension(ug.getStringBounder()); - ug = UGraphicStencil.create(ug, getRectangleStencil(dim), new UStroke()); + ug = UGraphicStencil.create(ug, dim); ug = symbolContext.apply(ug); drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), symbolContext.getRoundCorner(), symbolContext.getDiagonalCorner()); diff --git a/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java b/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java index 704545a4b..9487ea8d3 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java @@ -40,7 +40,6 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; -import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; abstract class USymbolSimpleAbstract extends USymbol { @@ -68,7 +67,7 @@ abstract class USymbolSimpleAbstract extends USymbol { final double labelY = dimStickMan.getHeight() + dimStereo.getHeight(); // Actor bug? - final UGraphic ug2 = UGraphicStencil.create(ug, getRectangleStencil(dimLabel), new UStroke()); + final UGraphic ug2 = UGraphicStencil.create(ug, dimLabel); label.drawU(ug2.apply(new UTranslate(labelX, labelY))); // label.drawU(ug.apply(new UTranslate(labelX, labelY))); diff --git a/src/net/sourceforge/plantuml/graphic/USymbolStack.java b/src/net/sourceforge/plantuml/graphic/USymbolStack.java index 4f6dcdcc1..72a34a674 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolStack.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolStack.java @@ -43,7 +43,6 @@ import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.UPath; import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColorNone; @@ -97,7 +96,7 @@ class USymbolStack extends USymbol { public void drawU(UGraphic ug) { final Dimension2D dim = calculateDimension(ug.getStringBounder()); - ug = UGraphicStencil.create(ug, getRectangleStencil(dim), new UStroke()); + ug = UGraphicStencil.create(ug, dim); ug = symbolContext.apply(ug); drawQueue(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), symbolContext.getRoundCorner()); diff --git a/src/net/sourceforge/plantuml/graphic/USymbolStorage.java b/src/net/sourceforge/plantuml/graphic/USymbolStorage.java index 8b07ba919..979fa1e9c 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolStorage.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolStorage.java @@ -41,7 +41,6 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; class USymbolStorage extends USymbol { @@ -70,7 +69,7 @@ class USymbolStorage extends USymbol { public void drawU(UGraphic ug) { final Dimension2D dim = calculateDimension(ug.getStringBounder()); - ug = UGraphicStencil.create(ug, getRectangleStencil(dim), new UStroke()); + ug = UGraphicStencil.create(ug, dim); ug = symbolContext.apply(ug); drawStorage(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing()); final Margin margin = getMargin(); diff --git a/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java b/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java index 47aef8780..4e0fe4d04 100644 --- a/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java +++ b/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java @@ -62,6 +62,7 @@ import h.ST_Agraph_s; import h.ST_Agraphinfo_t; import h.ST_GVC_s; import h.ST_boxf; +import net.sourceforge.plantuml.AnnotatedWorker; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; @@ -82,6 +83,7 @@ import net.sourceforge.plantuml.cucadiagram.Member; import net.sourceforge.plantuml.cucadiagram.MethodsOrFieldsArea; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; +import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.QuoteUtils; @@ -90,10 +92,11 @@ import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockEmpty; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.TextBlockWidth; -import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.svek.Bibliotekon; import net.sourceforge.plantuml.svek.Cluster; import net.sourceforge.plantuml.svek.CucaDiagramFileMaker; @@ -102,10 +105,12 @@ import net.sourceforge.plantuml.svek.GeneralImageBuilder; import net.sourceforge.plantuml.svek.GraphvizCrash; import net.sourceforge.plantuml.svek.IEntityImage; import net.sourceforge.plantuml.svek.Node; +import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.color.HColor; import smetana.core.CString; import smetana.core.JUtils; import smetana.core.JUtilsDebug; @@ -123,12 +128,14 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { private final DotStringFactory dotStringFactory; - class Drawing implements UDrawable { + class Drawing extends AbstractTextBlock implements TextBlockBackcolored { private final YMirror ymirror; + private final Dimension2D dim; - public Drawing(YMirror ymirror) { + public Drawing(YMirror ymirror, Dimension2D dim) { this.ymirror = ymirror; + this.dim = dim; } public void drawU(UGraphic ug) { @@ -149,12 +156,22 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { for (Map.Entry ent : edges.entrySet()) { final Link link = ent.getKey(); + if (link.isInvis()) { + continue; + } final ST_Agedge_s edge = ent.getValue(); new JDotPath(link, edge, ymirror, diagram, getLabel(link), getQualifier(link, 1), getQualifier(link, 2)) .drawU(ug); } } + public Dimension2D calculateDimension(StringBounder stringBounder) { + if (dim == null) { + throw new UnsupportedOperationException(); + } + return dim; + } + private Point2D getCorner(ST_Agnode_s n) { final ST_Agnodeinfo_t data = (ST_Agnodeinfo_t) Macro.AGDATA(n).castTo(ST_Agnodeinfo_t.class); final double width = data.width * 72; @@ -168,6 +185,10 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { return ymirror.getMirrored(new Point2D.Double(x - width / 2, y + height / 2)); } + public HColor getBackcolor() { + return null; + } + } public CucaDiagramFileMakerJDot(CucaDiagram diagram, StringBounder stringBounder) { @@ -419,23 +440,27 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { final double scale = 1; - final int margin1; - final int margin2; + final ClockwiseTopRightBottomLeft margins; if (SkinParam.USE_STYLES()) { - margin1 = SkinParam.zeroMargin(0); - margin2 = SkinParam.zeroMargin(0); + final Style style = StyleSignature.of(SName.root, SName.document) + .getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); + margins = style.getMargin(); } else { - margin1 = 0; - margin2 = 0; + margins = ClockwiseTopRightBottomLeft.topRightBottomLeft(0, 5, 5, 0); } - final ImageBuilder imageBuilder = ImageBuilder.buildD(diagram.getSkinParam(), - ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), diagram.getAnimation(), - fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, null, scale); - imageBuilder.setUDrawable(new Drawing(null)); + final ImageBuilder imageBuilder = ImageBuilder.buildD(diagram.getSkinParam(), margins, + diagram.getAnimation(), fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, null, + scale); + + imageBuilder.setUDrawable(new Drawing(null, null)); final Dimension2D dim = imageBuilder.getFinalDimension(stringBounder); - imageBuilder.setUDrawable(new Drawing(new YMirror(dim.getHeight()))); + final AnnotatedWorker annotatedWorker = new AnnotatedWorker(diagram, diagram.getSkinParam(), + fileFormatOption.getDefaultStringBounder()); + + // imageBuilder.setUDrawable(new Drawing(new YMirror(dim.getHeight()))); + imageBuilder.setUDrawable(annotatedWorker.addAdd(new Drawing(new YMirror(dim.getHeight()), dim))); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, diagram.seed(), os); } catch (Throwable e) { @@ -466,6 +491,10 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { private void exportGroup(ST_Agraph_s graph, IGroup group) { final Cluster cluster = getBibliotekon().getCluster(group); + if (cluster == null) { + System.err.println("CucaDiagramFileMakerJDot::exportGroup issue"); + return; + } JUtils.LOG2("cluster = " + cluster.getClusterId()); final ST_Agraph_s cluster1 = agsubg(graph, new CString(cluster.getClusterId()), true); if (cluster.isLabel()) { diff --git a/src/net/sourceforge/plantuml/jdot/JDotPath.java b/src/net/sourceforge/plantuml/jdot/JDotPath.java index a9c04e265..4f30e48c4 100644 --- a/src/net/sourceforge/plantuml/jdot/JDotPath.java +++ b/src/net/sourceforge/plantuml/jdot/JDotPath.java @@ -44,17 +44,21 @@ import h.ST_pointf; import h.ST_splines; import h.ST_textlabel_t; import net.sourceforge.plantuml.ColorParam; +import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.Link; +import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.posimo.DotPath; import net.sourceforge.plantuml.skin.rose.Rose; +import net.sourceforge.plantuml.svek.extremity.ExtremityFactory; import net.sourceforge.plantuml.ugraphic.UEllipse; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.URectangle; +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.HColorNone; @@ -118,7 +122,15 @@ public class JDotPath implements UDrawable { } if (dotPath != null) { - ug.apply(color).draw(dotPath); + final LinkType linkType = link.getType(); + UStroke stroke = linkType.getStroke3(diagram.getSkinParam().getThickness(LineParam.arrow, null)); + if (link.getColors() != null && link.getColors().getSpecificLineStroke() != null) { + stroke = link.getColors().getSpecificLineStroke(); + } + + ug.apply(stroke).apply(color).draw(dotPath); + printExtremityAtStart(ug.apply(color)); + printExtremityAtEnd(ug.apply(color)); } if (getLabelRectangleTranslate("label") != null) { label.drawU(ug.apply(getLabelRectangleTranslate("label"))); @@ -133,6 +145,46 @@ public class JDotPath implements UDrawable { } + private void printExtremityAtStart(UGraphic ug) { + final ExtremityFactory extremityFactory2 = link.getType().getDecor2() + .getExtremityFactoryComplete(HColorUtils.WHITE); + if (extremityFactory2 == null) { + return; + } + final ST_splines splines = getSplines(edge); + DotPath s = getDotPath(splines); + Point2D p0 = s.getStartPoint(); + double startAngle = s.getStartAngle(); + if (ymirror != null) { + p0 = ymirror.getMirrored(p0); + startAngle = -startAngle + Math.PI; + } + final UDrawable extremity2 = extremityFactory2.createUDrawable(p0, startAngle, null); + if (extremity2 != null) { + extremity2.drawU(ug); + } + } + + private void printExtremityAtEnd(UGraphic ug) { + final ExtremityFactory extremityFactory1 = link.getType().getDecor1() + .getExtremityFactoryComplete(HColorUtils.WHITE); + if (extremityFactory1 == null) { + return; + } + final ST_splines splines = getSplines(edge); + DotPath s = getDotPath(splines); + Point2D p0 = s.getEndPoint(); + double endAngle = s.getEndAngle(); + if (ymirror != null) { + p0 = ymirror.getMirrored(p0); + endAngle = -endAngle; + } + final UDrawable extremity1 = extremityFactory1.createUDrawable(p0, endAngle, null); + if (extremity1 != null) { + extremity1.drawU(ug); + } + } + private void printDebug(UGraphic ug) { ug = ug.apply(HColorUtils.BLUE).apply(HColorUtils.BLUE.bg()); final ST_splines splines = getSplines(edge); diff --git a/src/net/sourceforge/plantuml/picoweb/PicoWebServer.java b/src/net/sourceforge/plantuml/picoweb/PicoWebServer.java new file mode 100644 index 000000000..2c42a678b --- /dev/null +++ b/src/net/sourceforge/plantuml/picoweb/PicoWebServer.java @@ -0,0 +1,155 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * Highly inspired from https://www.ssaurel.com/blog/create-a-simple-http-web-server-in-java + * + */ +package net.sourceforge.plantuml.picoweb; + +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.ServerSocket; +import java.net.Socket; +import java.util.Date; +import java.util.StringTokenizer; + +import net.sourceforge.plantuml.FileFormat; +import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.SourceStringReader; +import net.sourceforge.plantuml.code.NoPlantumlCompressionException; +import net.sourceforge.plantuml.code.Transcoder; +import net.sourceforge.plantuml.code.TranscoderUtil; + +public class PicoWebServer implements Runnable { + + private final Socket connect; + + public PicoWebServer(Socket c) { + this.connect = c; + } + + public static void main(String[] args) throws IOException { + startServer(8080); + } + + public static void startServer(final int port) throws IOException { + final ServerSocket serverConnect = new ServerSocket(port); + while (true) { + final PicoWebServer myServer = new PicoWebServer(serverConnect.accept()); + final Thread thread = new Thread(myServer); + thread.start(); + } + } + + public void run() { + BufferedReader in = null; + BufferedOutputStream out = null; + + try { + in = new BufferedReader(new InputStreamReader(connect.getInputStream(), "UTF-8")); + out = new BufferedOutputStream(connect.getOutputStream()); + + final String first = in.readLine(); + if (first == null) { + return; + } + + final StringTokenizer parse = new StringTokenizer(first); + final String method = parse.nextToken().toUpperCase(); + + if (method.equals("GET")) { + final String path = parse.nextToken(); + if (path.startsWith("/plantuml/png/")) { + sendDiagram(out, path, "image/png", FileFormat.PNG); + return; + } + if (path.startsWith("/plantuml/svg/")) { + sendDiagram(out, path, "image/svg+xml", FileFormat.SVG); + return; + } + } + write(out, "HTTP/1.1 302 Found"); + write(out, "Location: /plantuml/png/oqbDJyrBuGh8ISmh2VNrKGZ8JCuFJqqAJYqgIotY0aefG5G00000"); + write(out, ""); + out.flush(); + + } catch (Throwable e) { + e.printStackTrace(); + } finally { + try { + in.close(); + out.close(); + connect.close(); + } catch (Throwable e) { + e.printStackTrace(); + } + } + } + + private void sendDiagram(BufferedOutputStream out, String path, final String mime, final FileFormat format) + throws NoPlantumlCompressionException, IOException { + final int x = path.lastIndexOf('/'); + final String compressed = path.substring(x + 1); + final Transcoder transcoder = TranscoderUtil.getDefaultTranscoderProtected(); + final String source = transcoder.decode(compressed); + final byte[] fileData = getData(source, format); + write(out, "HTTP/1.1 200 OK"); + write(out, "Cache-Control: no-cache"); + write(out, "Server: PlantUML PicoWebServer"); + write(out, "Date: " + new Date()); + write(out, "Content-type: " + mime); + write(out, "Content-length: " + fileData.length); + write(out, ""); + out.flush(); + out.write(fileData); + out.flush(); + } + + private byte[] getData(String source, FileFormat format) throws IOException { + final SourceStringReader ssr = new SourceStringReader(source); + final ByteArrayOutputStream os = new ByteArrayOutputStream(); + ssr.outputImage(os, new FileFormatOption(format)); + os.close(); + return os.toByteArray(); + } + + private void write(OutputStream os, String s) throws IOException { + s = s + "\r\n"; + os.write(s.getBytes("UTF-8")); + } + +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java b/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java index 4f00030e5..cf2291985 100644 --- a/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java +++ b/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java @@ -188,9 +188,9 @@ public class TaskDrawRegular extends AbstractTaskDraw { final double startPos = timeScale.getStartingPosition(start); final double endPos = timeScale.getEndingPosition(end); - final double fullLength = endPos - startPos - 2 * margin; - if (fullLength < 10) { - return; + double fullLength = endPos - startPos - 2 * margin; + if (fullLength < 3) { + fullLength = 3; } if (url != null) { ug.startUrl(url); diff --git a/src/net/sourceforge/plantuml/salt/element/AbstractElementText.java b/src/net/sourceforge/plantuml/salt/element/AbstractElementText.java index 4d47ec282..43b0131c7 100644 --- a/src/net/sourceforge/plantuml/salt/element/AbstractElementText.java +++ b/src/net/sourceforge/plantuml/salt/element/AbstractElementText.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.Splitter; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.ugraphic.UFont; @@ -68,6 +69,7 @@ abstract class AbstractElementText extends AbstractElement { private int getCharNumber(String text) { text = text.replaceAll("<&[-\\w]+>", "00"); + text = Splitter.purgeAllTag(text); return text.length(); } @@ -96,7 +98,8 @@ abstract class AbstractElementText extends AbstractElement { // double max = 0; // for (int i = 32; i < 127; i++) { // final char c = (char) i; - // final double w = Display.create(Arrays.asList("" + c), config, HorizontalAlignment.LEFT) + // final double w = Display.create(Arrays.asList("" + c), config, + // HorizontalAlignment.LEFT) // .calculateDimension(stringBounder).getWidth(); // if (w > max) { // Log.println("c="+c+" "+max); diff --git a/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java b/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java index fa40c429d..38b677d05 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java +++ b/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java @@ -93,12 +93,12 @@ public class LinkAnchor { final HColor color = new Rose().getHtmlColor(param, ColorParam.arrow); final Rainbow rainbow = Rainbow.fromColor(color, null); - final Snake snake = new Snake(Arrows.asToUp(), HorizontalAlignment.CENTER, rainbow, Arrows.asToDown()); final Display display = Display.getWithNewlines(message); final TextBlock title = display.create(new FontConfiguration(param, FontParam.ARROW, null), HorizontalAlignment.CENTER, param); - snake.setLabel(title); + final Snake snake = Snake.create(Arrows.asToUp(), rainbow, Arrows.asToDown()) + .withLabel(title, HorizontalAlignment.CENTER); snake.addPoint(x, ymin + 2); snake.addPoint(x, ymax - 2); diff --git a/src/net/sourceforge/plantuml/skin/ActorStickMan.java b/src/net/sourceforge/plantuml/skin/ActorStickMan.java index 1bee6f260..9f81108af 100644 --- a/src/net/sourceforge/plantuml/skin/ActorStickMan.java +++ b/src/net/sourceforge/plantuml/skin/ActorStickMan.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.skin; import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.graphic.AbstractTextBlock; @@ -44,6 +45,7 @@ import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.ugraphic.UEllipse; import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UPath; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColorNone; @@ -58,9 +60,11 @@ public class ActorStickMan extends AbstractTextBlock implements TextBlock { private final double headDiam = 16; private final SymbolContext symbolContext; + private final boolean actorBusiness; - ActorStickMan(SymbolContext symbolContext) { + ActorStickMan(SymbolContext symbolContext, boolean actorBusiness) { this.symbolContext = symbolContext; + this.actorBusiness = actorBusiness; } public void drawU(UGraphic ug) { @@ -86,9 +90,26 @@ public class ActorStickMan extends AbstractTextBlock implements TextBlock { ug = symbolContext.apply(ug); ug.apply(new UTranslate(startX, thickness())).draw(head); + if (actorBusiness) { + specialBusiness(ug.apply(new UTranslate(startX + headDiam / 2, thickness() + headDiam / 2))); + } ug.apply(new UTranslate(centerX, headDiam + thickness())).apply(new HColorNone().bg()).draw(path); } + private void specialBusiness(UGraphic ug) { + final double alpha = 21 * Math.PI / 64; + final Point2D p1 = getOnCircle(Math.PI / 4 + alpha); + final Point2D p2 = getOnCircle(Math.PI / 4 - alpha); + ug = ug.apply(new UTranslate(p1)); + ug.draw(new ULine(p2.getX() - p1.getX(), p2.getY() - p1.getY())); + } + + private Point2D getOnCircle(double alpha) { + final double x = headDiam / 2 * Math.cos(alpha); + final double y = headDiam / 2 * Math.sin(alpha); + return new Point2D.Double(x, y); + } + private double thickness() { return symbolContext.getStroke().getThickness(); } diff --git a/src/net/sourceforge/plantuml/skin/ActorStyle.java b/src/net/sourceforge/plantuml/skin/ActorStyle.java index 61a303fd3..02d0fd0e5 100644 --- a/src/net/sourceforge/plantuml/skin/ActorStyle.java +++ b/src/net/sourceforge/plantuml/skin/ActorStyle.java @@ -41,7 +41,7 @@ import net.sourceforge.plantuml.graphic.USymbol; public enum ActorStyle { - STICKMAN, AWESOME; + STICKMAN, STICKMAN_BUSINESS, AWESOME; public USymbol toUSymbol() { if (this == STICKMAN) { @@ -54,7 +54,9 @@ public enum ActorStyle { public TextBlock getTextBlock(SymbolContext symbolContext) { if (this == STICKMAN) { - return new ActorStickMan(symbolContext); + return new ActorStickMan(symbolContext, false); + } else if (this == STICKMAN_BUSINESS) { + return new ActorStickMan(symbolContext, true); } else if (this == AWESOME) { return new ActorAwesome(symbolContext); } diff --git a/src/net/sourceforge/plantuml/svek/Cluster.java b/src/net/sourceforge/plantuml/svek/Cluster.java index dbfa24a83..350729f90 100644 --- a/src/net/sourceforge/plantuml/svek/Cluster.java +++ b/src/net/sourceforge/plantuml/svek/Cluster.java @@ -483,6 +483,10 @@ public class Cluster implements Moveable { final HColor background = getColor(skinParam2, ColorParam.background, null); final TextBlockWidth attribute = getTextBlockAttribute(skinParam2); final double attributeHeight = attribute.calculateDimension(ug.getStringBounder()).getHeight(); + if (total.getWidth() == 0) { + System.err.println("Cluster::drawUState issue"); + return; + } final RoundedContainer r = new RoundedContainer(total, suppY, attributeHeight + (attributeHeight > 0 ? IEntityImage.MARGIN : 0), borderColor, stateBack, background, stroke); diff --git a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java index 805b98ee2..981f09b81 100644 --- a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java +++ b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java @@ -223,6 +223,9 @@ public final class GeneralImageBuilder { if (leaf.getLeafType() == LeafType.USECASE) { return new EntityImageUseCase(leaf, skinParam, portionShower); } + if (leaf.getLeafType() == LeafType.USECASE_BUSINESS) { + return new EntityImageUseCase(leaf, skinParam, portionShower); + } // if (leaf.getEntityType() == LeafType.CIRCLE_INTERFACE) { // return new EntityImageCircleInterface(leaf, skinParam); // } diff --git a/src/net/sourceforge/plantuml/svek/UGraphicForSnake.java b/src/net/sourceforge/plantuml/svek/UGraphicForSnake.java index b79634e27..1d07ccdc4 100644 --- a/src/net/sourceforge/plantuml/svek/UGraphicForSnake.java +++ b/src/net/sourceforge/plantuml/svek/UGraphicForSnake.java @@ -61,7 +61,7 @@ public class UGraphicForSnake extends UGraphicDelegator { } static class PendingSnake { - private final Snake snake; + private Snake snake; private final UGraphic ug; private final double dx; private final double dy; @@ -80,7 +80,7 @@ public class UGraphicForSnake extends UGraphicDelegator { void removeEndDecorationIfTouches(List snakes) { for (PendingSnake other : snakes) { if (moved().touches(other.moved())) { - this.snake.removeEndDecoration(); + this.snake = this.snake.withoutEndDecoration(); return; } } diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryTriangle.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryTriangle.java index e2a2d53dd..290b022b3 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryTriangle.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryTriangle.java @@ -40,17 +40,28 @@ import java.awt.geom.Point2D; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.svek.AbstractExtremityFactory; import net.sourceforge.plantuml.svek.Side; +import net.sourceforge.plantuml.ugraphic.color.HColor; public class ExtremityFactoryTriangle extends AbstractExtremityFactory implements ExtremityFactory { + private final HColor backgroundColor; + private final int xWing; + private final int yAperture; + + public ExtremityFactoryTriangle(HColor backgroundColor, int xWing, int yAperture) { + this.backgroundColor = backgroundColor; + this.xWing = xWing; + this.yAperture = yAperture; + } + @Override public UDrawable createUDrawable(Point2D p0, double angle, Side side) { - return new ExtremityTriangle(p0, angle - Math.PI / 2, false); + return new ExtremityTriangle(p0, angle - Math.PI / 2, false, backgroundColor, xWing, yAperture); } public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) { final double ortho = atan2(p0, p2); - return new ExtremityTriangle(p1, ortho, true); + return new ExtremityTriangle(p1, ortho, true, backgroundColor, xWing, yAperture); } } diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityTriangle.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityTriangle.java index e0ae89594..ae1f8c40a 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityTriangle.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityTriangle.java @@ -39,12 +39,14 @@ import java.awt.geom.Point2D; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPolygon; +import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorUtils; class ExtremityTriangle extends Extremity { private UPolygon polygon = new UPolygon(); private final boolean fill; + private final HColor backgroundColor; private final Point2D contact; @Override @@ -52,13 +54,13 @@ class ExtremityTriangle extends Extremity { return contact; } - public ExtremityTriangle(Point2D p1, double angle, boolean fill) { + public ExtremityTriangle(Point2D p1, double angle, boolean fill, HColor backgroundColor, int xWing, int yAperture) { + this.backgroundColor = backgroundColor; this.fill = fill; this.contact = new Point2D.Double(p1.getX(), p1.getY()); angle = manageround(angle); polygon.addPoint(0, 0); - final int xWing = 8; - final int yAperture = 3; + polygon.addPoint(-xWing, -yAperture); polygon.addPoint(-xWing, yAperture); polygon.addPoint(0, 0); @@ -67,7 +69,9 @@ class ExtremityTriangle extends Extremity { } public void drawU(UGraphic ug) { - if (fill) { + if (backgroundColor != null) { + ug = ug.apply(backgroundColor.bg()); + } else if (fill) { ug = ug.apply(HColorUtils.changeBack(ug)); } ug.draw(polygon); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java b/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java index 37dd130e7..9358274a8 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java @@ -75,6 +75,7 @@ import net.sourceforge.plantuml.svek.Margins; import net.sourceforge.plantuml.svek.ShapeType; import net.sourceforge.plantuml.ugraphic.UComment; import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; @@ -154,7 +155,7 @@ public class EntityImageDescription extends AbstractEntityImage { } assert getStereo() == stereotype; - + final SymbolContext ctx = new SymbolContext(backcolor, forecolor).withStroke(stroke).withShadow(deltaShadow) .withCorner(roundCorner, diagonalCorner); @@ -289,7 +290,11 @@ public class EntityImageDescription extends AbstractEntityImage { final Dimension2D dimSmall = asSmall.calculateDimension(ug.getStringBounder()); final Dimension2D dimDesc = desc.calculateDimension(ug.getStringBounder()); final double posx1 = (dimSmall.getWidth() - dimDesc.getWidth()) / 2; - desc.drawU(ug.apply(new UTranslate(posx1, space + dimSmall.getHeight()))); + + UGraphic ugDesc = ug.apply(new UTranslate(posx1, space + dimSmall.getHeight())); + ugDesc = UGraphicStencil.create(ugDesc, dimDesc); + desc.drawU(ugDesc); + final Dimension2D dimStereo = stereo.calculateDimension(ug.getStringBounder()); final double posx2 = (dimSmall.getWidth() - dimStereo.getWidth()) / 2; stereo.drawU(ug.apply(new UTranslate(posx2, -space - dimStereo.getHeight()))); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java b/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java index 9e9e19b2f..dbe33f98d 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.svek.image; import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; @@ -50,6 +51,7 @@ import net.sourceforge.plantuml.cucadiagram.BodyEnhanced; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -70,6 +72,7 @@ import net.sourceforge.plantuml.ugraphic.TextBlockInEllipse; import net.sourceforge.plantuml.ugraphic.UEllipse; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UHorizontalLine; +import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; @@ -141,12 +144,44 @@ public class EntityImageUseCase extends AbstractEntityImage { final UGraphic ug2 = new MyUGraphicEllipse(ug, 0, 0, ellipse.getUEllipse()); ellipse.drawU(ug2); + if (getEntity().getLeafType() == LeafType.USECASE_BUSINESS) { + specialBusiness(ug, ellipse.getUEllipse()); + } if (url != null) { ug.closeUrl(); } } + private void specialBusiness(UGraphic ug, UEllipse frontier) { + final RotatedEllipse rotatedEllipse = new RotatedEllipse(frontier, Math.PI / 4); + + final double theta1 = 20.0 * Math.PI / 180; + final double theta2 = rotatedEllipse.getOtherTheta(theta1); + + final UEllipse frontier2 = frontier.scale(0.99); + final Point2D p1 = frontier2.getPointAtAngle(-theta1); + final Point2D p2 = frontier2.getPointAtAngle(-theta2); + drawLine(ug, p1, p2); + } + + private void specialBusiness0(UGraphic ug, UEllipse frontier) { + final double c = frontier.getWidth() / frontier.getHeight(); + final double ouverture = Math.PI / 2; + final Point2D p1 = frontier.getPointAtAngle(getTrueAngle(c, Math.PI / 4 - ouverture)); + final Point2D p2 = frontier.getPointAtAngle(getTrueAngle(c, Math.PI / 4 + ouverture)); + drawLine(ug, p1, p2); + } + + private void drawLine(UGraphic ug, final Point2D p1, final Point2D p2) { + ug = ug.apply(new UTranslate(p1)); + ug.draw(new ULine(p2.getX() - p1.getX(), p2.getY() - p1.getY())); + } + + private double getTrueAngle(final double c, final double gamma) { + return Math.atan2(Math.sin(gamma), Math.cos(gamma) / c); + } + private HColor getBackColor() { HColor backcolor = getEntity().getColors(getSkinParam()).getColor(ColorType.BACK); if (backcolor == null) { diff --git a/src/net/sourceforge/plantuml/svek/image/QuadraticEquation.java b/src/net/sourceforge/plantuml/svek/image/QuadraticEquation.java new file mode 100644 index 000000000..2d2882664 --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/image/QuadraticEquation.java @@ -0,0 +1,61 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.svek.image; + +public class QuadraticEquation { + + private final double a; + private final double b; + private final double c; + + public QuadraticEquation(double a, double b, double c) { + this.a = a; + this.b = b; + this.c = c; + } + + public double[] solve() { + final double delta = b * b - 4 * a * c; + final double x0 = (-b - Math.sqrt(delta)) / 2 / a; + final double x1 = (-b + Math.sqrt(delta)) / 2 / a; + return new double[] { x0, x1 }; + } + + public double getV(double x) { + return a * x * x + b * x + c; + } + +} diff --git a/src/net/sourceforge/plantuml/svek/image/RotatedEllipse.java b/src/net/sourceforge/plantuml/svek/image/RotatedEllipse.java new file mode 100644 index 000000000..b5ec633f0 --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/image/RotatedEllipse.java @@ -0,0 +1,93 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.svek.image; + +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.ugraphic.UEllipse; + +public class RotatedEllipse { + + private final UEllipse ellipse; + private final double beta; + + public RotatedEllipse(UEllipse ellipse, double beta) { + this.ellipse = ellipse; + this.beta = beta; + } + + public double getA() { + return ellipse.getWidth() / 2; + } + + public double getB() { + return ellipse.getHeight() / 2; + } + + public double getBeta() { + return beta; + } + + public Point2D getPoint(double theta) { + final double x = getA() * Math.cos(theta); + final double y = getB() * Math.sin(theta); + + final double xp = x * Math.cos(beta) - y * Math.sin(beta); + final double yp = x * Math.sin(beta) + y * Math.cos(beta); + + return new Point2D.Double(xp, yp); + } + + public double getOtherTheta(double theta1) { + final double z = getPoint(theta1).getX(); + final double a = getA() * Math.cos(beta); + final double b = getB() * Math.sin(beta); + final double sum = 2 * a * z / (a * a + b * b); + final double other = sum - Math.cos(theta1); + return -Math.acos(other); + } + + private double other(double[] all, double some) { + final double diff0 = Math.abs(some - all[0]); + final double diff1 = Math.abs(some - all[1]); + + if (diff0 > diff1) { + return all[0]; + } + return all[1]; + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/UEllipse.java b/src/net/sourceforge/plantuml/ugraphic/UEllipse.java index 1bc41438d..b8faca214 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UEllipse.java +++ b/src/net/sourceforge/plantuml/ugraphic/UEllipse.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.ugraphic; import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; import net.sourceforge.plantuml.Dimension2DDouble; @@ -92,6 +93,12 @@ public class UEllipse extends AbstractShadowable implements Scalable, UShapeSize return result; } + public UEllipse scale(double factor) { + final UEllipse result = new UEllipse(width * factor, height * factor); + result.setDeltaShadow(getDeltaShadow()); + return result; + } + public double getStartingX(double y) { y = y / height * 2; final double x = 1 - Math.sqrt(1 - (y - 1) * (y - 1)); @@ -104,4 +111,10 @@ public class UEllipse extends AbstractShadowable implements Scalable, UShapeSize return x * width / 2; } + public Point2D getPointAtAngle(double alpha) { + final double x = width / 2 + width / 2 * Math.cos(alpha); + final double y = height / 2 + height / 2 * Math.sin(alpha); + return new Point2D.Double(x, y); + } + } diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicStencil.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicStencil.java index d887aa676..576e3816a 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UGraphicStencil.java +++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicStencil.java @@ -35,7 +35,10 @@ */ package net.sourceforge.plantuml.ugraphic; +import java.awt.geom.Dimension2D; + import net.sourceforge.plantuml.creole.Stencil; +import net.sourceforge.plantuml.graphic.StringBounder; public class UGraphicStencil extends AbstractUGraphicHorizontalLine { @@ -45,8 +48,23 @@ public class UGraphicStencil extends AbstractUGraphicHorizontalLine { public static UGraphic create(UGraphic ug, Stencil stencil, UStroke defaultStroke) { return new UGraphicStencil(ug, stencil, defaultStroke); } - - + + public static UGraphic create(UGraphic ug, Dimension2D dim) { + return new UGraphicStencil(ug, getRectangleStencil(dim), new UStroke()); + } + + private static Stencil getRectangleStencil(final Dimension2D dim) { + return new Stencil() { + public double getStartingX(StringBounder stringBounder, double y) { + return 0; + } + + public double getEndingX(StringBounder stringBounder, double y) { + return dim.getWidth(); + } + }; + } + private UGraphicStencil(UGraphic ug, Stencil stencil, UStroke defaultStroke) { super(ug); this.stencil = stencil; diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 622feefd2..e75fbb0f9 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -44,7 +44,7 @@ public class Version { private static final int MAJOR_SEPARATOR = 1000000; public static int version() { - return 1202018; + return 1202019; } public static int versionPatched() { @@ -93,7 +93,7 @@ public class Version { } public static long compileTime() { - return 1601494844773L; + return 1602515401258L; } public static String compileTimeString() {