diff --git a/pom.xml b/pom.xml index 60828793f..61249a87a 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ net.sourceforge.plantuml plantuml - 8054-SNAPSHOT + 8055-SNAPSHOT jar PlantUML diff --git a/src/net/sourceforge/plantuml/ColorParam.java b/src/net/sourceforge/plantuml/ColorParam.java index 88151dd17..0c5d01751 100644 --- a/src/net/sourceforge/plantuml/ColorParam.java +++ b/src/net/sourceforge/plantuml/ColorParam.java @@ -36,10 +36,10 @@ import net.sourceforge.plantuml.graphic.color.ColorType; public enum ColorParam { - background(HtmlColorUtils.WHITE, ColorType.BACK), + background(HtmlColorUtils.WHITE, true, ColorType.BACK), hyperlink(HtmlColorUtils.BLUE), - activityBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + activityBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), activityBorder(HtmlColorUtils.MY_RED, ColorType.LINE), activityStart(HtmlColorUtils.BLACK), activityEnd(HtmlColorUtils.BLACK), @@ -48,15 +48,15 @@ public enum ColorParam { swimlaneBorder(HtmlColorUtils.BLACK), usecaseBorder(HtmlColorUtils.MY_RED, ColorType.LINE), - usecaseBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + usecaseBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), usecaseArrow(HtmlColorUtils.MY_RED, ColorType.ARROW), - objectBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + objectBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), objectBorder(HtmlColorUtils.MY_RED, ColorType.LINE), objectArrow(HtmlColorUtils.MY_RED, ColorType.ARROW), - classHeaderBackground(null, ColorType.BACK), - classBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + classHeaderBackground(null, true, ColorType.BACK), + classBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), classBorder(HtmlColorUtils.MY_RED, ColorType.LINE), stereotypeCBackground(HtmlColorUtils.COL_ADD1B2), stereotypeNBackground(HtmlColorUtils.COL_E3664A), @@ -65,19 +65,19 @@ public enum ColorParam { stereotypeEBackground(HtmlColorUtils.COL_EB937F), classArrow(HtmlColorUtils.MY_RED, ColorType.ARROW), - packageBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + packageBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), packageBorder(HtmlColorUtils.BLACK, ColorType.LINE), - partitionBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + partitionBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), partitionBorder(HtmlColorUtils.BLACK, ColorType.LINE), - componentBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + componentBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), componentBorder(HtmlColorUtils.MY_RED, ColorType.LINE), - interfaceBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + interfaceBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), interfaceBorder(HtmlColorUtils.MY_RED, ColorType.LINE), componentArrow(HtmlColorUtils.MY_RED, ColorType.ARROW), - stateBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + stateBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), stateBorder(HtmlColorUtils.MY_RED, ColorType.LINE), stateArrow(HtmlColorUtils.MY_RED, ColorType.ARROW), stateStart(HtmlColorUtils.BLACK), @@ -113,35 +113,35 @@ public enum ColorParam { sequenceBoxBorder(HtmlColorUtils.MY_RED, ColorType.LINE), sequenceBoxBackground(HtmlColorUtils.COL_DDDDDD, true, ColorType.BACK), - artifactBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + artifactBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), artifactBorder(HtmlColorUtils.BLACK, ColorType.LINE), - cloudBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + cloudBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), cloudBorder(HtmlColorUtils.BLACK, ColorType.LINE), - queueBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + queueBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), queueBorder(HtmlColorUtils.MY_RED, ColorType.LINE), - databaseBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + databaseBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), databaseBorder(HtmlColorUtils.BLACK, ColorType.LINE), - folderBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + folderBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), folderBorder(HtmlColorUtils.BLACK, ColorType.LINE), - fileBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + fileBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), fileBorder(HtmlColorUtils.BLACK, ColorType.LINE), - frameBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + frameBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), frameBorder(HtmlColorUtils.BLACK, ColorType.LINE), - nodeBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + nodeBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), nodeBorder(HtmlColorUtils.BLACK, ColorType.LINE), - rectangleBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + rectangleBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), rectangleBorder(HtmlColorUtils.BLACK, ColorType.LINE), - agentBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + agentBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), agentBorder(HtmlColorUtils.MY_RED, ColorType.LINE), - storageBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + storageBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), storageBorder(HtmlColorUtils.BLACK, ColorType.LINE), - boundaryBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + boundaryBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), boundaryBorder(HtmlColorUtils.MY_RED, ColorType.LINE), - collectionsBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + collectionsBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), collectionsBorder(HtmlColorUtils.MY_RED, ColorType.LINE), - controlBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + controlBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), controlBorder(HtmlColorUtils.MY_RED, ColorType.LINE), - entityBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), + entityBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), entityBorder(HtmlColorUtils.MY_RED, ColorType.LINE), @@ -152,8 +152,9 @@ public enum ColorParam { iconProtected(HtmlColorUtils.COL_B38D22), iconProtectedBackground(HtmlColorUtils.COL_FFFF44), iconPublic(HtmlColorUtils.COL_038048), - iconPublicBackground(HtmlColorUtils.COL_84BE84); - + iconPublicBackground(HtmlColorUtils.COL_84BE84), + iconIEMandatory(HtmlColorUtils.BLACK); + private final boolean isBackground; private final HtmlColor defaultValue; private final ColorType colorType; @@ -178,6 +179,10 @@ public enum ColorParam { this.isBackground = isBackground; this.defaultValue = defaultValue; this.colorType = colorType; + if (colorType == ColorType.BACK && isBackground == false) { + System.err.println(this); + throw new IllegalStateException(); + } } protected boolean isBackground() { diff --git a/src/net/sourceforge/plantuml/OptionFlags.java b/src/net/sourceforge/plantuml/OptionFlags.java index df221e901..b0223684b 100644 --- a/src/net/sourceforge/plantuml/OptionFlags.java +++ b/src/net/sourceforge/plantuml/OptionFlags.java @@ -60,7 +60,7 @@ public class OptionFlags { static public final boolean FORCE_TEOZ = false; static public final boolean USE_INTERFACE_EYE1 = false; static public final boolean USE_INTERFACE_EYE2 = false; - static public final boolean SWI2 = false; + // static public final boolean SWI2 = false; // static public final boolean USE_COMPOUND = false; static public final boolean OMEGA_CROSSING = false; diff --git a/src/net/sourceforge/plantuml/SkinParamBackcolored.java b/src/net/sourceforge/plantuml/SkinParamBackcolored.java index c31207909..0293b4277 100644 --- a/src/net/sourceforge/plantuml/SkinParamBackcolored.java +++ b/src/net/sourceforge/plantuml/SkinParamBackcolored.java @@ -54,6 +54,11 @@ public class SkinParamBackcolored extends SkinParamDelegator { this(skinParam, backColorElement, backColorGeneral, false); } + @Override + public String toString() { + return super.toString() + " " + backColorElement + " " + backColorGeneral; + } + public SkinParamBackcolored(ISkinParam skinParam, HtmlColor backColorElement, HtmlColor backColorGeneral, boolean forceClickage) { super(skinParam); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java index 846934804..5453029c9 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java @@ -218,9 +218,10 @@ public class ActivityDiagram3 extends UmlDiagram { return CommandExecutionResult.error("Cannot find fork"); } - public CommandExecutionResult endFork() { + public CommandExecutionResult endFork(ForkStyle forkStyle, String label) { if (current() instanceof InstructionFork) { final InstructionFork currentFork = (InstructionFork) current(); + currentFork.setStyle(forkStyle, label); currentFork.manageOutRendering(nextLinkRenderer(), true); setNextLinkRendererInternal(LinkRendering.none()); setCurrent(currentFork.getParent()); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ForkStyle.java b/src/net/sourceforge/plantuml/activitydiagram3/ForkStyle.java new file mode 100644 index 000000000..4a44bfd62 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ForkStyle.java @@ -0,0 +1,35 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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.activitydiagram3; + +public enum ForkStyle { + FORK, SPLIT, MERGE +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java index e83e1586e..999fb90cd 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java @@ -50,6 +50,8 @@ public class InstructionFork extends WithNote implements Instruction { private final Instruction parent; private final LinkRendering inlinkRendering; private final ISkinParam skinParam; + private ForkStyle style = ForkStyle.FORK; + private String label; boolean finished = false; public InstructionFork(Instruction parent, LinkRendering inlinkRendering, ISkinParam skinParam) { @@ -75,7 +77,7 @@ public class InstructionFork extends WithNote implements Instruction { for (InstructionList list : forks) { all.add(list.createFtile(factory)); } - Ftile result = factory.createFork(getSwimlaneIn(), all); + Ftile result = factory.createParallel(getSwimlaneIn(), all, style, label); if (getPositionedNotes().size() > 0) { result = FtileWithNoteOpale.create(result, getPositionedNotes(), skinParam, false); } @@ -120,7 +122,7 @@ public class InstructionFork extends WithNote implements Instruction { public Swimlane getSwimlaneOut() { return forks.get(0).getSwimlaneOut(); - //return getLastList().getSwimlaneOut(); + // return getLastList().getSwimlaneOut(); } public void manageOutRendering(LinkRendering nextLinkRenderer, boolean endFork) { @@ -133,4 +135,9 @@ public class InstructionFork extends WithNote implements Instruction { getLastList().setOutRendering(nextLinkRenderer); } + public void setStyle(ForkStyle style, String label) { + this.style = style; + this.label = label; + } + } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java index a6aa79020..92aa2ad70 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java @@ -70,7 +70,7 @@ public class InstructionSplit implements Instruction { for (InstructionList list : splits) { all.add(list.createFtile(factory)); } - return factory.createSplit(all); + return factory.createParallel(getSwimlaneIn(), all, ForkStyle.SPLIT, null); } public Instruction getParent() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkEnd3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkEnd3.java index 856e67809..1c3428d44 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkEnd3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkEnd3.java @@ -31,6 +31,7 @@ package net.sourceforge.plantuml.activitydiagram3.command; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; +import net.sourceforge.plantuml.activitydiagram3.ForkStyle; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.RegexConcat; @@ -46,13 +47,18 @@ public class CommandForkEnd3 extends SingleLineCommand2 { static RegexConcat getRegexConcat() { return new RegexConcat(// new RegexLeaf("^"), // - new RegexLeaf("(end[%s]?fork|fork[%s]?end)"), // + new RegexLeaf("STYLE", "(end[%s]?fork|fork[%s]?end|end[%s]?merge)"), // + new RegexLeaf("\\s*"), // + new RegexLeaf("LABEL", "(\\{.+\\})?"), // new RegexLeaf(";?$")); } @Override protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) { - return diagram.endFork(); + final String style = arg.get("STYLE", 0); + final ForkStyle forkStyle = style.contains("merge") ? ForkStyle.MERGE : ForkStyle.FORK; + final String label = arg.get("LABEL", 0); + return diagram.endFork(forkStyle, label); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java index 4f5b59b08..8de711f41 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java @@ -36,6 +36,7 @@ import java.util.List; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.activitydiagram3.Branch; +import net.sourceforge.plantuml.activitydiagram3.ForkStyle; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.PositionedNote; import net.sourceforge.plantuml.cucadiagram.Display; @@ -76,9 +77,7 @@ public interface FtileFactory { public Ftile createIf(Swimlane swimlane, List thens, Branch elseBranch, LinkRendering afterEndwhile, LinkRendering topInlinkRendering); - public Ftile createFork(Swimlane swimlane, List all); - - public Ftile createSplit(List all); + public Ftile createParallel(Swimlane swimlane, List all, ForkStyle style, String label); public Ftile createGroup(Ftile list, Display name, HtmlColor backColor, HtmlColor titleColor, PositionedNote note, HtmlColor borderColor); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java index 0e1bb0330..3a814bfd1 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java @@ -37,6 +37,7 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.activitydiagram3.Branch; +import net.sourceforge.plantuml.activitydiagram3.ForkStyle; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.PositionedNote; import net.sourceforge.plantuml.creole.CreoleMode; @@ -72,6 +73,7 @@ public class FtileFactoryDelegator implements FtileFactory { } protected final TextBlock getTextBlock(Display display) { + // DUP3945 if (Display.isNull(display)) { return null; } @@ -148,12 +150,8 @@ public class FtileFactoryDelegator implements FtileFactory { return factory.createIf(swimlane, thens, elseBranch, afterEndwhile, topInlinkRendering); } - public Ftile createFork(Swimlane swimlane, List all) { - return factory.createFork(swimlane, all); - } - - public Ftile createSplit(List all) { - return factory.createSplit(all); + public Ftile createParallel(Swimlane swimlane, List all, ForkStyle style, String label) { + return factory.createParallel(swimlane, all, style, label); } public Ftile createGroup(Ftile list, Display name, HtmlColor backColor, HtmlColor titleColor, PositionedNote note, diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java index 4f597b62e..2750c48d9 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java @@ -38,7 +38,6 @@ import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineParam; -import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.Pragma; import net.sourceforge.plantuml.activitydiagram3.Instruction; import net.sourceforge.plantuml.activitydiagram3.InstructionList; @@ -46,9 +45,8 @@ import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorAddNote; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorAddUrl; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorAssembly; -import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorCreateFork; +import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorCreateParallel; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorCreateGroup; -import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorCreateSplit; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorIf; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorRepeat; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorWhile; @@ -59,7 +57,6 @@ import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; @@ -67,10 +64,8 @@ import net.sourceforge.plantuml.graphic.UGraphicDelegator; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.svek.UGraphicForSnake; -import net.sourceforge.plantuml.ugraphic.CompressionTransform; import net.sourceforge.plantuml.ugraphic.LimitFinder; import net.sourceforge.plantuml.ugraphic.MinMax; -import net.sourceforge.plantuml.ugraphic.SlotFinderX; import net.sourceforge.plantuml.ugraphic.SlotSet; import net.sourceforge.plantuml.ugraphic.UChange; import net.sourceforge.plantuml.ugraphic.UChangeBackColor; @@ -112,8 +107,7 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock { factory = new FtileFactoryDelegatorIf(factory, pragma); factory = new FtileFactoryDelegatorWhile(factory); factory = new FtileFactoryDelegatorRepeat(factory); - factory = new FtileFactoryDelegatorCreateFork(factory); - factory = new FtileFactoryDelegatorCreateSplit(factory); + factory = new FtileFactoryDelegatorCreateParallel(factory); factory = new FtileFactoryDelegatorAddNote(factory); factory = new FtileFactoryDelegatorCreateGroup(factory); return factory; @@ -188,43 +182,43 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock { return; } - if (OptionFlags.SWI2) { - - final SlotFinderX slotFinder = new SlotFinderX(ug.getStringBounder()); - drawWhenSwimlanes(slotFinder, full); - final SlotSet slotX = slotFinder.getXSlotSet().reverse(); - // - // // final SlotSet ysSlotSet = slotFinder.getYSlotSet().reverse().smaller(5.0); - // - System.err.println("slotX=" + slotX); - - printDebug(ug, slotX, HtmlColorUtils.GRAY, full); - - double x2 = 0; - double y2 = 0; - final double stepy = 40; - int i = 0; - final SlotSet deconnectedSwimlanes = new SlotSet(); - for (Swimlane swimlane : swimlanes) { - final UGraphic ug2 = ug.apply(new UChangeColor(HtmlColorUtils.GREEN)).apply( - new UChangeBackColor(HtmlColorUtils.GREEN)); - final double totalWidth = swimlane.getTotalWidth(); - final SlotSet slot2 = slotX.filter(x2 + separationMargin, x2 + totalWidth - separationMargin); - deconnectedSwimlanes.addAll(slot2); - // ug2.apply(new UTranslate(x2, y2)).draw(new URectangle(totalWidth, stepy)); - x2 += totalWidth; - y2 += stepy; - i++; - } - // printDebug(ug, deconnectedSwimlanes, HtmlColorUtils.GRAY, full); - - // - final CompressionTransform compressionTransform = new CompressionTransform(deconnectedSwimlanes); - // ug = new UGraphicCompress2(ug, compressionTransform); - drawWhenSwimlanes(ug, full); - } else { - drawWhenSwimlanes(ug, full); - } + // if (OptionFlags.SWI2) { + // + // final SlotFinderX slotFinder = new SlotFinderX(ug.getStringBounder()); + // drawWhenSwimlanes(slotFinder, full); + // final SlotSet slotX = slotFinder.getXSlotSet().reverse(); + // // + // // // final SlotSet ysSlotSet = slotFinder.getYSlotSet().reverse().smaller(5.0); + // // + // System.err.println("slotX=" + slotX); + // + // printDebug(ug, slotX, HtmlColorUtils.GRAY, full); + // + // double x2 = 0; + // double y2 = 0; + // final double stepy = 40; + // int i = 0; + // final SlotSet deconnectedSwimlanes = new SlotSet(); + // for (Swimlane swimlane : swimlanes) { + // final UGraphic ug2 = ug.apply(new UChangeColor(HtmlColorUtils.GREEN)).apply( + // new UChangeBackColor(HtmlColorUtils.GREEN)); + // final double totalWidth = swimlane.getTotalWidth(); + // final SlotSet slot2 = slotX.filter(x2 + separationMargin, x2 + totalWidth - separationMargin); + // deconnectedSwimlanes.addAll(slot2); + // // ug2.apply(new UTranslate(x2, y2)).draw(new URectangle(totalWidth, stepy)); + // x2 += totalWidth; + // y2 += stepy; + // i++; + // } + // // printDebug(ug, deconnectedSwimlanes, HtmlColorUtils.GRAY, full); + // + // // + // final CompressionTransform compressionTransform = new CompressionTransform(deconnectedSwimlanes); + // // ug = new UGraphicCompress2(ug, compressionTransform); + // drawWhenSwimlanes(ug, full); + // } else { + drawWhenSwimlanes(ug, full); + // } // getCollisionDetector(ug, titleHeightTranslate).drawDebug(ug); } @@ -252,13 +246,13 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock { + titleHeightTranslate.getDy())); } - if (OptionFlags.SWI2 == false) { - final TextBlock swTitle = swimlane.getDisplay().create(getFontConfiguration(), - HorizontalAlignment.LEFT, skinParam); - final double titleWidth = swTitle.calculateDimension(stringBounder).getWidth(); - final double posTitle = x2 + (swimlane.getTotalWidth() - titleWidth) / 2; - swTitle.drawU(ug.apply(new UTranslate(posTitle, 0))); - } + // if (OptionFlags.SWI2 == false) { + final TextBlock swTitle = swimlane.getDisplay().create(getFontConfiguration(), HorizontalAlignment.LEFT, + skinParam); + final double titleWidth = swTitle.calculateDimension(stringBounder).getWidth(); + final double posTitle = x2 + (swimlane.getTotalWidth() - titleWidth) / 2; + swTitle.drawU(ug.apply(new UTranslate(posTitle, 0))); + // } drawSeparation(ug.apply(new UTranslate(x2, 0)), dimensionFull.getHeight() + titleHeightTranslate.getDy()); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel.java new file mode 100644 index 000000000..60d876025 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel.java @@ -0,0 +1,81 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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.activitydiagram3.ftile.vcompact; + +import java.awt.geom.Dimension2D; +import java.util.ArrayList; +import java.util.List; + +import net.sourceforge.plantuml.activitydiagram3.ForkStyle; +import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileHeightFixed; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; + +public class FtileFactoryDelegatorCreateParallel extends FtileFactoryDelegator { + + private final double spaceArroundBlackBar = 20; + private final double xMargin = 14; + + public FtileFactoryDelegatorCreateParallel(FtileFactory factory) { + super(factory); + } + + @Override + public Ftile createParallel(Swimlane swimlane, List all, ForkStyle style, String label) { + + final Dimension2D dimSuper = super.createParallel(swimlane, all, style, label).calculateDimension( + getStringBounder()); + final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar; + + final List list = new ArrayList(); + for (Ftile tmp : all) { + list.add(new FtileHeightFixed(FtileUtils.addHorizontalMargin(tmp, xMargin), height1)); + } + final Ftile inner = super.createParallel(swimlane, list, style, label); + + ParallelFtilesBuilder builder; + + if (style == ForkStyle.SPLIT) { + builder = new ParallelBuilderSplit(skinParam(), getStringBounder(), list, inner, swimlane); + } else if (style == ForkStyle.MERGE) { + builder = new ParallelBuilderMerge(skinParam(), getStringBounder(), list, inner, swimlane); + } else if (style == ForkStyle.FORK) { + builder = new ParallelBuilderFork(skinParam(), getStringBounder(), list, inner, swimlane, label); + } else { + throw new IllegalStateException(); + } + return builder.build(); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java index b2491e700..a92c14a22 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java @@ -34,7 +34,6 @@ import java.awt.geom.Dimension2D; import java.util.List; import net.sourceforge.plantuml.ColorParam; -import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateFork.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java similarity index 68% rename from src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateFork.java rename to src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java index 9b819b533..0265fcb38 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateFork.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java @@ -36,70 +36,75 @@ import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.ColorParam; +import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection; import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; import net.sourceforge.plantuml.activitydiagram3.ftile.Connection; import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileHeightFixed; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBlackBlock; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; import net.sourceforge.plantuml.graphic.Rainbow; -import net.sourceforge.plantuml.skin.rose.Rose; +import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class FtileFactoryDelegatorCreateFork extends FtileFactoryDelegator { +public class ParallelBuilderFork extends ParallelFtilesBuilder { - private final double spaceArroundBlackBar = 20; - private final double barHeight = 6; - private final double xMargin = 14; + private final String label; - private final Rose rose = new Rose(); - - public FtileFactoryDelegatorCreateFork(FtileFactory factory) { - super(factory); + public ParallelBuilderFork(ISkinParam skinParam, StringBounder stringBounder, + final List list, Ftile inner, Swimlane swimlane, String label) { + super(skinParam, stringBounder, list, inner, swimlane); + this.label = label; } @Override - public Ftile createFork(Swimlane swimlane, List all) { - final HtmlColor colorBar = rose.getHtmlColor(skinParam(), ColorParam.activityBar); - final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam()); - - final Dimension2D dimSuper = super.createFork(swimlane, all).calculateDimension(getStringBounder()); - final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar; - - final List list = new ArrayList(); - for (Ftile tmp : all) { - list.add(new FtileHeightFixed(FtileUtils.addHorizontalMargin(tmp, xMargin), height1)); - } - - Ftile inner = super.createFork(swimlane, list); - + protected Ftile doStep1() { + Ftile result = getMiddle(); final List conns = new ArrayList(); - - final Ftile black = new FtileBlackBlock(skinParam(), colorBar, list.get(0).getSwimlaneIn()); + final Ftile black = new FtileBlackBlock(skinParam(), getRose() + .getHtmlColor(skinParam(), ColorParam.activityBar), getList().get(0).getSwimlaneIn()); double x = 0; - for (Ftile tmp : list) { + for (Ftile tmp : getList()) { final Dimension2D dim = tmp.calculateDimension(getStringBounder()); - conns.add(new ConnectionIn(black, tmp, x, tmp.getInLinkRendering().getRainbow(arrowColor))); - conns.add(new ConnectionOut(tmp, black, x, tmp.getOutLinkRendering().getRainbow(arrowColor), height1)); + conns.add(new ConnectionIn(black, tmp, x, tmp.getInLinkRendering().getRainbow( + HtmlColorAndStyle.build(skinParam())))); x += dim.getWidth(); } - inner = FtileUtils.addConnection(inner, conns); - ((FtileBlackBlock) black).setDimenstion(inner.calculateDimension(getStringBounder()).getWidth(), barHeight); - final Ftile tmp1 = new FtileAssemblySimple(black, inner); - return new FtileAssemblySimple(tmp1, black); + result = FtileUtils.addConnection(result, conns); + ((FtileBlackBlock) black).setBlackBlockDimension(result.calculateDimension(getStringBounder()).getWidth(), barHeight); + + return new FtileAssemblySimple(black, result); + } + + @Override + protected Ftile doStep2(Ftile result) { + final Ftile out = new FtileBlackBlock(skinParam(), getRose().getHtmlColor(skinParam(), ColorParam.activityBar), + getList().get(0).getSwimlaneIn()); + ((FtileBlackBlock) out).setBlackBlockDimension(result.calculateDimension(getStringBounder()).getWidth(), barHeight); + if (label != null) { + ((FtileBlackBlock) out).setLabel(getTextBlock(Display.getWithNewlines(label))); + } + result = new FtileAssemblySimple(result, out); + final List conns = new ArrayList(); + double x = 0; + for (Ftile tmp : getList()) { + final UTranslate translate0 = new UTranslate(0, barHeight); + final Dimension2D dim = tmp.calculateDimension(getStringBounder()); + conns.add(new ConnectionOut(translate0, tmp, out, x, tmp.getOutLinkRendering().getRainbow( + HtmlColorAndStyle.build(skinParam())), getHeightOfMiddle())); + x += dim.getWidth(); + } + result = FtileUtils.addConnection(result, conns); + return result; } class ConnectionIn extends AbstractConnection implements ConnectionTranslatable { @@ -154,10 +159,13 @@ public class FtileFactoryDelegatorCreateFork extends FtileFactoryDelegator { private final Rainbow arrowColor; private final double height; private final Display label; + private final UTranslate translate0; - public ConnectionOut(Ftile ftile1, Ftile ftile2, double x, Rainbow arrowColor, double height) { + public ConnectionOut(UTranslate translate0, Ftile ftile1, Ftile ftile2, double x, Rainbow arrowColor, + double height) { super(ftile1, ftile2); - label = ftile1.getOutLinkRendering().getDisplay(); + this.translate0 = translate0; + this.label = ftile1.getOutLinkRendering().getDisplay(); this.x = x; this.arrowColor = arrowColor; this.height = height; @@ -173,8 +181,10 @@ public class FtileFactoryDelegatorCreateFork extends FtileFactoryDelegator { if (Display.isNull(label) == false) { snake.setLabel(getTextBlock(label)); } - snake.addPoint(geo.getLeft(), geo.getOutY()); - snake.addPoint(geo.getLeft(), height); + final Point2D p1 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), geo.getOutY())); + final Point2D p2 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), height)); + snake.addPoint(p1); + snake.addPoint(p2); ug.draw(snake); } @@ -184,8 +194,8 @@ public class FtileFactoryDelegatorCreateFork extends FtileFactoryDelegator { if (geo.hasPointOut() == false) { return; } - final Point2D p1 = new Point2D.Double(geo.getLeft(), geo.getOutY()); - final Point2D p2 = new Point2D.Double(geo.getLeft(), height); + 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(arrowColor, Arrows.asToDown()); if (Display.isNull(label) == false) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderMerge.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderMerge.java new file mode 100644 index 000000000..6a165f484 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderMerge.java @@ -0,0 +1,214 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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.activitydiagram3.ftile.vcompact; + +import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; + +import net.sourceforge.plantuml.ColorParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection; +import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; +import net.sourceforge.plantuml.activitydiagram3.ftile.Connection; +import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable; +import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; +import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBlackBlock; +import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; +import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UPolygon; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class ParallelBuilderMerge extends ParallelFtilesBuilder { + + public ParallelBuilderMerge(ISkinParam skinParam, StringBounder stringBounder, + final List list, Ftile inner, Swimlane swimlane) { + super(skinParam, stringBounder, list, inner, swimlane); + } + + @Override + protected Ftile doStep1() { + Ftile result = getMiddle(); + final List conns = new ArrayList(); + final HtmlColor colorBar = getRose().getHtmlColor(skinParam(), ColorParam.activityBar); + + final Ftile black = new FtileBlackBlock(skinParam(), colorBar, getList().get(0).getSwimlaneIn()); + double x = 0; + for (Ftile tmp : getList()) { + final Dimension2D dim = tmp.calculateDimension(getStringBounder()); + conns.add(new ConnectionIn(black, tmp, x, tmp.getInLinkRendering().getRainbow( + HtmlColorAndStyle.build(skinParam())))); + x += dim.getWidth(); + } + + result = FtileUtils.addConnection(result, conns); + ((FtileBlackBlock) black).setBlackBlockDimension(result.calculateDimension(getStringBounder()).getWidth(), barHeight); + + return new FtileAssemblySimple(black, result); + } + + @Override + protected Ftile doStep2(Ftile result) { + final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityBorder); + final HtmlColor backColor = getRose().getHtmlColor(skinParam(), ColorParam.activityBackground); + final Ftile out = new FtileDiamond(skinParam(), backColor, borderColor, swimlane()); + result = new FtileAssemblySimple(result, out); + final List conns = new ArrayList(); + final UTranslate diamondTranslate = result.getTranslateFor(out, getStringBounder()); + int i = 0; + double x = 0; + for (Ftile tmp : getList()) { + final Dimension2D dim = tmp.calculateDimension(getStringBounder()); + final UTranslate translate0 = new UTranslate(x, barHeight); + conns.add(new ConnectionHorizontalThenVertical(tmp, out, tmp.getOutLinkRendering().getRainbow( + HtmlColorAndStyle.build(skinParam())), translate0, diamondTranslate, i)); + x += dim.getWidth(); + i++; + } + return FtileUtils.addConnection(result, conns); + } + + class ConnectionHorizontalThenVertical extends AbstractConnection /* implements ConnectionTranslatable */{ + + private final Rainbow arrowColor; + private final UTranslate diamondTranslate; + private final UTranslate translate0; + private final int counter; + + public ConnectionHorizontalThenVertical(Ftile tile, Ftile diamond, Rainbow arrowColor, UTranslate translate0, + UTranslate diamondTranslate, int counter) { + super(tile, diamond); + this.arrowColor = arrowColor; + this.diamondTranslate = diamondTranslate; + this.translate0 = translate0; + this.counter = counter; + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final Point2D p1 = getP1(stringBounder); + final Point2D p2 = getP2(stringBounder); + final double x1 = p1.getX(); + final double y1 = p1.getY(); + final double x2 = p2.getX(); + final double y2 = p2.getY(); + + UPolygon endDecoration = null; + if (counter == 0) { + endDecoration = Arrows.asToRight(); + } else if (counter == 1) { + endDecoration = Arrows.asToLeft(); + } + final Snake snake = new Snake(arrowColor, endDecoration); + snake.addPoint(x1, y1); + snake.addPoint(x1, y2); + snake.addPoint(x2, y2); + + ug.draw(snake); + } + + private Point2D getP1(StringBounder stringBounder) { + return translate0.getTranslated(getFtile1().calculateDimension(stringBounder).getPointOut()); + } + + private Point2D getP2(final StringBounder stringBounder) { + final Point2D result = diamondTranslate.getTranslated(getFtile2().calculateDimension(stringBounder) + .getPointOut()); + final Dimension2D dim = getFtile2().calculateDimension(stringBounder); + UTranslate arrival = new UTranslate(); + if (counter == 0) { + arrival = new UTranslate(-dim.getWidth() / 2, -dim.getHeight() / 2); + } else if (counter == 1) { + arrival = new UTranslate(dim.getWidth() / 2, -dim.getHeight() / 2); + } + return arrival.getTranslated(result); + } + + } + + class ConnectionIn extends AbstractConnection implements ConnectionTranslatable { + + private final double x; + private final Rainbow arrowColor; + private final Display label; + + public ConnectionIn(Ftile ftile1, Ftile ftile2, double x, Rainbow arrowColor) { + super(ftile1, ftile2); + label = ftile2.getInLinkRendering().getDisplay(); + this.x = x; + this.arrowColor = arrowColor; + } + + public void drawU(UGraphic ug) { + ug = ug.apply(new UTranslate(x, 0)); + final FtileGeometry geo = getFtile2().calculateDimension(getStringBounder()); + final Snake snake = new Snake(arrowColor, Arrows.asToDown()); + if (Display.isNull(label) == false) { + snake.setLabel(getTextBlock(label)); + } + snake.addPoint(geo.getLeft(), 0); + snake.addPoint(geo.getLeft(), geo.getInY()); + ug.draw(snake); + } + + public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { + ug = ug.apply(new UTranslate(x, 0)); + final FtileGeometry geo = getFtile2().calculateDimension(getStringBounder()); + final Point2D p1 = new Point2D.Double(geo.getLeft(), 0); + final Point2D p2 = new Point2D.Double(geo.getLeft(), geo.getInY()); + + final Snake snake = new Snake(arrowColor, Arrows.asToDown()); + if (Display.isNull(label) == false) { + snake.setLabel(getTextBlock(label)); + } + final Point2D mp1a = translate1.getTranslated(p1); + final Point2D mp2b = translate2.getTranslated(p2); + final double middle = mp1a.getY() + 4; + snake.addPoint(mp1a); + snake.addPoint(mp1a.getX(), middle); + snake.addPoint(mp2b.getX(), middle); + snake.addPoint(mp2b); + ug.draw(snake); + } + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit.java similarity index 52% rename from src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateSplit.java rename to src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit.java index e44bc0812..064769375 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateSplit.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit.java @@ -32,219 +32,78 @@ package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact; import java.awt.geom.Dimension2D; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; -import java.util.Set; -import net.sourceforge.plantuml.OptionFlags; -import net.sourceforge.plantuml.activitydiagram3.LinkRendering; +import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection; import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; import net.sourceforge.plantuml.activitydiagram3.ftile.Connection; import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileHeightFixed; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; import net.sourceforge.plantuml.activitydiagram3.ftile.MergeStrategy; import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; -import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class FtileFactoryDelegatorCreateSplit extends FtileFactoryDelegator { +public class ParallelBuilderSplit extends ParallelFtilesBuilder { - private final double spaceArroundBlackBar = 20; - private final double barHeight = 6; - private final double xMargin = 14; - - private final Rose rose = new Rose(); - - public FtileFactoryDelegatorCreateSplit(FtileFactory factory) { - super(factory); - } - - static private boolean isSimpleSwimlanes(List all) { - final Set already = new HashSet(); - for (Ftile ftile : all) { - final Set currents = ftile.getSwimlanes(); - if (currents.size() != 1) { - return false; - } - assert currents.size() == 1; - final Swimlane current = currents.iterator().next(); - if (already.contains(current)) { - return false; - } - already.add(current); - } - return already.size() > 1; - } - - static private boolean isSeveralSwimlanes(List all) { - final Set already = new HashSet(); - for (Ftile ftile : all) { - final Set currents = ftile.getSwimlanes(); - if (currents.size() > 1) { - return true; - } - assert currents.size() == 0 || currents.size() == 1; - if (currents.size() == 1) { - final Swimlane current = currents.iterator().next(); - already.add(current); - } - } - return already.size() > 1; + public ParallelBuilderSplit(ISkinParam skinParam, StringBounder stringBounder, + final List list, Ftile inner, Swimlane swimlane) { + super(skinParam, stringBounder, list, inner, swimlane); } @Override - public Ftile createSplit(List all) { - // OptionFlags.SWI2 - // if (all != null) - // return severalSwimlanes(all); - // // if (isSimpleSwimlanes(all)) { - // return simpleSwimlanes(all); - // // return severalSwimlanes(all); - // // } else if (isSeveralSwimlanes(all)) { - // // return severalSwimlanes(all); - // } - final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam()); - - final Dimension2D dimSuper = super.createSplit(all).calculateDimension(getStringBounder()); - final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar; - - final List list = new ArrayList(); - for (Ftile tmp : all) { - list.add(new FtileHeightFixed(FtileUtils.addHorizontalMargin(tmp, xMargin), height1)); - } - - Ftile inner = super.createSplit(list); - + protected Ftile doStep1() { + Ftile result = getMiddle(); final List conns = new ArrayList(); - double x = 0; - boolean hasOut = false; - for (Ftile tmp : list) { + double x1 = 0; + for (Ftile tmp : getList()) { final Dimension2D dim = tmp.calculateDimension(getStringBounder()); - conns.add(new ConnectionIn(tmp, x, tmp.getInLinkRendering().getRainbow(arrowColor), getTextBlock(tmp - .getInLinkRendering()))); - final boolean hasOutTmp = tmp.calculateDimension(getStringBounder()).hasPointOut(); - if (hasOutTmp) { - conns.add(new ConnectionOut(tmp, x, tmp.getOutLinkRendering().getRainbow(arrowColor), height1, - getTextBlock(tmp.getOutLinkRendering()))); - hasOut = true; - } - x += dim.getWidth(); + conns.add(new ConnectionIn(tmp, x1, tmp.getInLinkRendering().getRainbow( + HtmlColorAndStyle.build(skinParam())), getTextBlock(tmp.getInLinkRendering()))); + x1 += dim.getWidth(); } - final double totalWidth = inner.calculateDimension(getStringBounder()).getWidth(); - conns.add(new ConnectionHline2(inner, OptionFlags.SWI2 ? HtmlColorAndStyle.fromColor(HtmlColorUtils.BLUE) - : arrowColor, 0, list, totalWidth)); - if (hasOut) { - conns.add(new ConnectionHline2(inner, OptionFlags.SWI2 ? HtmlColorAndStyle.fromColor(HtmlColorUtils.GREEN) - : arrowColor, height1, list, totalWidth)); - } - - inner = FtileUtils.addConnection(inner, conns); - if (hasOut == false) { - inner = new FtileKilled(inner); - } - return inner; + final double totalWidth1 = result.calculateDimension(getStringBounder()).getWidth(); + conns.add(new ConnectionHline2(result, HtmlColorAndStyle.build(skinParam()), 0, getList(), totalWidth1)); + result = FtileUtils.addConnection(result, conns); + return result; } - // private Ftile severalSwimlanes(List all) { - // final HtmlColor arrowColor = rose.getHtmlColor(getSkinParam(), ColorParam.activityArrow); - // final Dimension2D dimSuper = new FtileForkInner1(all).calculateDimension(getStringBounder()); - // final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar; - // final List list = new ArrayList(); - // for (Ftile tmp : all) { - // list.add(new FtileHeightFixed(new FtileMarged(tmp, xMargin), height1)); - // // list.add(new FtileMarged(tmp, xMargin)); - // // list.add(tmp); - // } - // - // Ftile inner = new FtileForkInner1(list); - // final List conns = new ArrayList(); - // boolean hasOut = false; - // for (Ftile tmp : list) { - // // final Dimension2D dim = tmp.calculateDimension(getStringBounder()); - // final UTranslate translateFor = inner.getTranslateFor(tmp, getStringBounder()); - // if (translateFor == null) { - // continue; - // } - // final double x = translateFor.getDx(); - // conns.add(new ConnectionIn(tmp, x, arrowColor)); - // final boolean hasOutTmp = tmp.calculateDimension(getStringBounder()).hasPointOut(); - // if (hasOutTmp) { - // conns.add(new ConnectionOut(tmp, x, arrowColor, height1)); - // hasOut = true; - // } - // // x += dim.getWidth(); - // } - // final double totalWidth = inner.calculateDimension(getStringBounder()).getWidth(); - // conns.add(new ConnectionHline2(inner, arrowColor, 0, list, totalWidth)); - // if (hasOut) { - // conns.add(new ConnectionHline2(inner, arrowColor, height1, list, totalWidth)); - // } - // inner = FtileUtils.addConnection(inner, conns); - // - // return inner; - // } - - private TextBlock getTextBlock(LinkRendering linkRendering) { - // DUP1433 - final Display display = linkRendering.getDisplay(); - return getTextBlock(display); - } - - private Ftile simpleSwimlanes(List all) { - final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam()); - - final Dimension2D dimSuper = new FtileSplit1(all).calculateDimension(getStringBounder()); - final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar; - - final List list = new ArrayList(); - for (Ftile tmp : all) { - list.add(new FtileHeightFixed(FtileUtils.addHorizontalMargin(tmp, xMargin), height1)); - } - - Ftile inner = new FtileSplit1(list); - - final List conns = new ArrayList(); - + @Override + protected Ftile doStep2(Ftile result) { + final List conns2 = new ArrayList(); + double x2 = 0; boolean hasOut = false; - for (Ftile tmp : list) { - // final Dimension2D dim = tmp.calculateDimension(getStringBounder()); - final double x = inner.getTranslateFor(tmp, getStringBounder()).getDx(); - conns.add(new ConnectionIn(tmp, x, arrowColor, null)); + for (Ftile tmp : getList()) { + final Dimension2D dim = tmp.calculateDimension(getStringBounder()); final boolean hasOutTmp = tmp.calculateDimension(getStringBounder()).hasPointOut(); if (hasOutTmp) { - conns.add(new ConnectionOut(tmp, x, arrowColor, height1, null)); + conns2.add(new ConnectionOut(tmp, x2, tmp.getOutLinkRendering().getRainbow( + HtmlColorAndStyle.build(skinParam())), getHeightOfMiddle(), getTextBlock(tmp + .getOutLinkRendering()))); hasOut = true; } - // x += dim.getWidth(); + x2 += dim.getWidth(); } - final double totalWidth = inner.calculateDimension(getStringBounder()).getWidth(); - conns.add(new ConnectionHline3(inner, arrowColor, 0, list, totalWidth)); - if (hasOut) { - conns.add(new ConnectionHline3(inner, arrowColor, height1, list, totalWidth)); - } - // - inner = FtileUtils.addConnection(inner, conns); - if (hasOut == false) { - inner = new FtileKilled(inner); - } - return inner; + if (hasOut) { + final double totalWidth2 = result.calculateDimension(getStringBounder()).getWidth(); + conns2.add(new ConnectionHline2(result, HtmlColorAndStyle.build(skinParam()), getHeightOfMiddle(), + getList(), totalWidth2)); + result = FtileUtils.addConnection(result, conns2); + } else { + result = new FtileKilled(result); + } + return result; } static class ConnectionHline2 extends AbstractConnection { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelFtilesBuilder.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelFtilesBuilder.java new file mode 100644 index 000000000..cbdc2e4b9 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelFtilesBuilder.java @@ -0,0 +1,126 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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.activitydiagram3.ftile.vcompact; + +import java.util.Collections; +import java.util.List; + +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.activitydiagram3.LinkRendering; +import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.skin.rose.Rose; + +public abstract class ParallelFtilesBuilder { + + protected final double barHeight = 6; + + private final Rose rose = new Rose(); + + private final ISkinParam skinParam; + private final StringBounder stringBounder; + + private final List list; + private final Ftile middle; + private final FtileGeometry middleDimension; + private final Swimlane swimlane; + + public ParallelFtilesBuilder(ISkinParam skinParam, StringBounder stringBounder, final List list, + Ftile middle, Swimlane swimlane) { + this.skinParam = skinParam; + this.stringBounder = stringBounder; + this.list = list; + this.middle = middle; + this.middleDimension = middle.calculateDimension(getStringBounder()); + this.swimlane = swimlane; + } + + public final Ftile build() { + final Ftile step1 = doStep1(); + return doStep2(step1); + } + + protected abstract Ftile doStep1(); + + protected abstract Ftile doStep2(Ftile step1); + + protected StringBounder getStringBounder() { + return stringBounder; + } + + protected Rose getRose() { + return rose; + } + + protected ISkinParam skinParam() { + return skinParam; + } + + protected final TextBlock getTextBlock(Display display) { + // DUP3945 + if (Display.isNull(display)) { + return null; + } + final FontConfiguration fontConfiguration = new FontConfiguration(skinParam(), FontParam.ACTIVITY_ARROW, null); + return display.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam(), CreoleMode.SIMPLE_LINE); + } + + protected TextBlock getTextBlock(LinkRendering linkRendering) { + // DUP1433 + final Display display = linkRendering.getDisplay(); + return getTextBlock(display); + } + + protected final List getList() { + return Collections.unmodifiableList(list); + } + + protected final Ftile getMiddle() { + return middle; + } + + protected final double getHeightOfMiddle() { + return middleDimension.getHeight(); + } + + protected final Swimlane swimlane() { + return swimlane; + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java index aec23ef2a..f1816c767 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.activitydiagram3.Branch; +import net.sourceforge.plantuml.activitydiagram3.ForkStyle; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.PositionedNote; import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; @@ -129,11 +130,7 @@ public class VCompactFactory implements FtileFactory { return new FtileForkInner(ftiles); } - public Ftile createFork(Swimlane swimlane, List all) { - return new FtileForkInner(all); - } - - public Ftile createSplit(List all) { + public Ftile createParallel(Swimlane swimlane, List all, ForkStyle style, String label) { return new FtileForkInner(all); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBlackBlock.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBlackBlock.java index 8862ab490..c2b7aaefa 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBlackBlock.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBlackBlock.java @@ -30,6 +30,7 @@ */ package net.sourceforge.plantuml.activitydiagram3.ftile.vertical; +import java.awt.geom.Dimension2D; import java.util.Collections; import java.util.Set; @@ -39,15 +40,21 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.URectangle; +import net.sourceforge.plantuml.ugraphic.UTranslate; public class FtileBlackBlock extends AbstractFtile { + private final double labelMargin = 5; + private double width; private double height; + private TextBlock label = TextBlockUtils.empty(0, 0); private final HtmlColor colorBar; private final Swimlane swimlane; @@ -57,13 +64,24 @@ public class FtileBlackBlock extends AbstractFtile { this.swimlane = swimlane; } - public void setDimenstion(double width, double height) { + public void setBlackBlockDimension(double width, double height) { this.height = height; this.width = width; } + public void setLabel(TextBlock label) { + if (label == null) { + throw new IllegalArgumentException(); + } + this.label = label; + } + public FtileGeometry calculateDimension(StringBounder stringBounder) { - return new FtileGeometry(width, height, width / 2, 0, height); + double supp = label.calculateDimension(stringBounder).getWidth(); + if (supp > 0) { + supp += labelMargin; + } + return new FtileGeometry(width + supp, height, width / 2, 0, height); } public void drawU(UGraphic ug) { @@ -72,6 +90,8 @@ public class FtileBlackBlock extends AbstractFtile { rect.setDeltaShadow(3); } ug.apply(new UChangeColor(colorBar)).apply(new UChangeBackColor(colorBar)).draw(rect); + final Dimension2D dimLabel = label.calculateDimension(ug.getStringBounder()); + label.drawU(ug.apply(new UTranslate(width + labelMargin, -dimLabel.getHeight() / 2))); } public Set getSwimlanes() { diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java index edb7b3a0c..3cbf400a9 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java @@ -68,7 +68,7 @@ public class CommandCreateClass extends SingleLineCommand2 { private static RegexConcat getRegexConcat() { return new RegexConcat(new RegexLeaf("^"), // new RegexLeaf("TYPE", // - "(interface|enum|annotation|abstract[%s]+class|abstract|class)[%s]+"), // + "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity)[%s]+"), // new RegexOr(// new RegexConcat(// new RegexLeaf("DISPLAY1", "[%g](.+)[%g]"), // diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java index 6be0d0b90..42e3da551 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java @@ -81,7 +81,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2 private static RegexConcat getRegexConcat(Mode mode) { - String regex = "(?:(actor|usecase|component)[%s]+)"; + // String regex = "(?:(actor|usecase|component)[%s]+)"; + String regex = "(?:(state|" + CommandCreateElementFull.ALL_TYPES + ")[%s]+)"; if (mode == Mode.WITH_MIX_PREFIX) { regex = "mix_" + regex; } @@ -130,62 +132,18 @@ public class CommandCreateElementFull2 extends SingleLineCommand2 if (symbol == null) { type = LeafType.DESCRIPTION; usymbol = USymbol.ACTOR; - } else if (symbol.equalsIgnoreCase("artifact")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.ARTIFACT; - } else if (symbol.equalsIgnoreCase("folder")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.FOLDER; - } else if (symbol.equalsIgnoreCase("package")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.PACKAGE; - } else if (symbol.equalsIgnoreCase("rectangle")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.RECTANGLE; - } else if (symbol.equalsIgnoreCase("node")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.NODE; - } else if (symbol.equalsIgnoreCase("frame")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.FRAME; - } else if (symbol.equalsIgnoreCase("cloud")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.CLOUD; - } else if (symbol.equalsIgnoreCase("database")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.DATABASE; - } else if (symbol.equalsIgnoreCase("storage")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.STORAGE; - } else if (symbol.equalsIgnoreCase("agent")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.AGENT; - } else if (symbol.equalsIgnoreCase("actor")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.ACTOR; - } else if (symbol.equalsIgnoreCase("component")) { - type = LeafType.DESCRIPTION; - usymbol = diagram.getSkinParam().useUml2ForComponent() ? USymbol.COMPONENT2 : USymbol.COMPONENT1; - } else if (symbol.equalsIgnoreCase("boundary")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.BOUNDARY; - } else if (symbol.equalsIgnoreCase("control")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.CONTROL; - } else if (symbol.equalsIgnoreCase("entity")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.ENTITY_DOMAIN; - } else if (symbol.equalsIgnoreCase("interface")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.INTERFACE; - } else if (symbol.equalsIgnoreCase("()")) { - type = LeafType.DESCRIPTION; - usymbol = USymbol.INTERFACE; } else if (symbol.equalsIgnoreCase("usecase")) { type = LeafType.USECASE; usymbol = null; + } else if (symbol.equalsIgnoreCase("state")) { + type = LeafType.STATE; + usymbol = null; } else { - throw new IllegalStateException(); + type = LeafType.DESCRIPTION; + usymbol = USymbol.getFoo1(symbol, diagram.getSkinParam().useUml2ForComponent()); + if (usymbol == null) { + throw new IllegalStateException(); + } } final Code code = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw)); @@ -211,7 +169,8 @@ public class CommandCreateElementFull2 extends SingleLineCommand2 entity.addUrl(url); } - entity.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0))); + entity.setSpecificColorTOBEREMOVED(ColorType.BACK, + diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0))); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java index f8bde0806..b68c22f5c 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java @@ -81,7 +81,7 @@ final public class CommandLinkClass extends SingleLineCommand2*+^{]|\\|[>\\]])?")), // + new RegexLeaf("ARROW_HEAD2", "([ox][%s]+|[#\\]>*+^\\{]|\\|[>\\]]|o\\{|\\|\\{|o\\||\\|\\|)?")), // new RegexLeaf("[%s]*"), // new RegexLeaf("SECOND_LABEL", "(?:[%g]([^%g]+)[%g])?"), new RegexLeaf("[%s]*"), // @@ -119,7 +119,7 @@ final public class CommandLinkClass extends SingleLineCommand2 { - public static final String ALL_TYPES = "artifact|actor|folder|file|package|rectangle|node|frame|cloud|database|queue|storage|agent|usecase|component|boundary|control|entity|interface"; + public static final String ALL_TYPES = "artifact|actor|folder|card|file|package|rectangle|node|frame|cloud|database|queue|storage|agent|usecase|component|boundary|control|entity|interface"; public CommandCreateElementFull() { super(getRegexConcat()); @@ -137,68 +137,15 @@ public class CommandCreateElementFull extends SingleLineCommand2 cols = getCols(getDonors(), 3, 5); + final List cols = getCols(getDonors(), 4, 5); return new UDrawable() { public void drawU(UGraphic ug) { final TextBlockBackcolored header = GraphicStrings.createBlackOnWhite(Arrays diff --git a/src/net/sourceforge/plantuml/graphic/SkinParameter.java b/src/net/sourceforge/plantuml/graphic/SkinParameter.java index 1072656ea..0a1f19734 100644 --- a/src/net/sourceforge/plantuml/graphic/SkinParameter.java +++ b/src/net/sourceforge/plantuml/graphic/SkinParameter.java @@ -115,6 +115,9 @@ public class SkinParameter { } public String getUpperCaseName() { + if (name.endsWith("1") || name.endsWith("2")) { + return name.substring(0, name.length() - 1); + } return name; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbol.java b/src/net/sourceforge/plantuml/graphic/USymbol.java index 129ad8777..bd9fb6d2c 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbol.java +++ b/src/net/sourceforge/plantuml/graphic/USymbol.java @@ -176,4 +176,49 @@ public abstract class USymbol { }; } + public static USymbol getFoo1(String symbol, boolean useUml2ForComponent) { + USymbol usymbol = null; + if (symbol.equalsIgnoreCase("artifact")) { + usymbol = USymbol.ARTIFACT; + } else if (symbol.equalsIgnoreCase("folder")) { + usymbol = USymbol.FOLDER; + } else if (symbol.equalsIgnoreCase("file")) { + usymbol = USymbol.FILE; + } else if (symbol.equalsIgnoreCase("package")) { + usymbol = USymbol.PACKAGE; + } else if (symbol.equalsIgnoreCase("rectangle")) { + usymbol = USymbol.RECTANGLE; + } else if (symbol.equalsIgnoreCase("node")) { + usymbol = USymbol.NODE; + } else if (symbol.equalsIgnoreCase("frame")) { + usymbol = USymbol.FRAME; + } else if (symbol.equalsIgnoreCase("cloud")) { + usymbol = USymbol.CLOUD; + } else if (symbol.equalsIgnoreCase("database")) { + usymbol = USymbol.DATABASE; + } else if (symbol.equalsIgnoreCase("queue")) { + usymbol = USymbol.QUEUE; + } else if (symbol.equalsIgnoreCase("storage")) { + usymbol = USymbol.STORAGE; + } else if (symbol.equalsIgnoreCase("agent")) { + usymbol = USymbol.AGENT; + } else if (symbol.equalsIgnoreCase("actor")) { + usymbol = USymbol.ACTOR; + } else if (symbol.equalsIgnoreCase("component")) { + usymbol = useUml2ForComponent ? USymbol.COMPONENT2 : USymbol.COMPONENT1; + } else if (symbol.equalsIgnoreCase("boundary")) { + usymbol = USymbol.BOUNDARY; + } else if (symbol.equalsIgnoreCase("control")) { + usymbol = USymbol.CONTROL; + } else if (symbol.equalsIgnoreCase("entity")) { + usymbol = USymbol.ENTITY_DOMAIN; + } else if (symbol.equalsIgnoreCase("card")) { + usymbol = USymbol.CARD; + } else if (symbol.equalsIgnoreCase("interface")) { + usymbol = USymbol.INTERFACE; + } else if (symbol.equalsIgnoreCase("()")) { + usymbol = USymbol.INTERFACE; + } + return usymbol; + } } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/skin/VisibilityModifier.java b/src/net/sourceforge/plantuml/skin/VisibilityModifier.java index 37af36d8b..f454a7922 100644 --- a/src/net/sourceforge/plantuml/skin/VisibilityModifier.java +++ b/src/net/sourceforge/plantuml/skin/VisibilityModifier.java @@ -55,13 +55,15 @@ public enum VisibilityModifier { PRIVATE_METHOD(ColorParam.iconPrivate, ColorParam.iconPrivateBackground), PROTECTED_METHOD( ColorParam.iconProtected, ColorParam.iconProtectedBackground), PACKAGE_PRIVATE_METHOD( ColorParam.iconPackage, ColorParam.iconPackageBackground), PUBLIC_METHOD(ColorParam.iconPublic, - ColorParam.iconPublicBackground); + ColorParam.iconPublicBackground), + + IE_MANDATORY(ColorParam.iconIEMandatory, ColorParam.iconIEMandatory); private final ColorParam foregroundParam; private final ColorParam backgroundParam; public static String regexForVisibilityCharacter() { - return "[-#+~]"; + return "[-#+~*]"; } private VisibilityModifier(ColorParam foreground, ColorParam background) { @@ -137,6 +139,10 @@ public enum VisibilityModifier { drawCircle(ug, true, size, x, y); break; + case IE_MANDATORY: + drawCircle(ug, true, size, x, y); + break; + default: throw new IllegalStateException(); } @@ -189,6 +195,9 @@ public enum VisibilityModifier { if (c == '~') { return true; } + if (c == '*') { + return true; + } return false; } @@ -212,6 +221,9 @@ public enum VisibilityModifier { if (c == '~') { return VisibilityModifier.PACKAGE_PRIVATE_FIELD; } + if (c == '*') { + return VisibilityModifier.IE_MANDATORY; + } return null; } @@ -228,6 +240,9 @@ public enum VisibilityModifier { if (c == '~') { return VisibilityModifier.PACKAGE_PRIVATE_METHOD; } + if (c == '*') { + return VisibilityModifier.IE_MANDATORY; + } return null; } diff --git a/src/net/sourceforge/plantuml/svek/PackageStyle.java b/src/net/sourceforge/plantuml/svek/PackageStyle.java index ae7b4d2d3..21f952997 100644 --- a/src/net/sourceforge/plantuml/svek/PackageStyle.java +++ b/src/net/sourceforge/plantuml/svek/PackageStyle.java @@ -46,7 +46,7 @@ import net.sourceforge.plantuml.ugraphic.UTranslate; public enum PackageStyle { - FOLDER, RECT, NODE, FRAME, CLOUD, DATABASE, AGENT, STORAGE, COMPONENT1, COMPONENT2, ARTIFACT, CARD; + FOLDER, RECTANGLE, NODE, FRAME, CLOUD, DATABASE, AGENT, STORAGE, COMPONENT1, COMPONENT2, ARTIFACT, CARD; public static PackageStyle fromString(String value) { for (PackageStyle p : EnumSet.allOf(PackageStyle.class)) { @@ -54,6 +54,9 @@ public enum PackageStyle { return p; } } + if ("rect".equalsIgnoreCase(value)) { + return RECTANGLE; + } return null; } @@ -73,7 +76,7 @@ public enum PackageStyle { if (this == FRAME) { return USymbol.FRAME; } - if (this == RECT) { + if (this == RECTANGLE) { return USymbol.RECTANGLE; } if (this == FOLDER) { @@ -96,7 +99,7 @@ public enum PackageStyle { drawFrame(ug, width, height, titleDim, shadowing); } else if (this == CLOUD) { drawCloud(ug, width, height, shadowing); - } else if (this == RECT) { + } else if (this == RECTANGLE) { drawRect(ug, width, height, shadowing); } else if (this == COMPONENT1) { drawComponent1(ug, width, height, shadowing); diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleCrowfoot.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleCrowfoot.java new file mode 100644 index 000000000..ef1491e8c --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleCrowfoot.java @@ -0,0 +1,84 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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.extremity; + +import java.awt.geom.AffineTransform; +import java.awt.geom.Point2D; +import net.sourceforge.plantuml.ugraphic.UEllipse; + +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +class ExtremityCircleCrowfoot extends Extremity { + + private final Point2D contact; + private final double angle; + private final double radius = 4; + + + @Override + public Point2D somePoint() { + return contact; + } + + public ExtremityCircleCrowfoot(Point2D p1, double angle) { + this.contact = new Point2D.Double(p1.getX(), p1.getY()); + this.angle = manageround(angle + Math.PI / 2); + } + + public void drawU(UGraphic ug) { + final int xAile = 8; + final int yOuverture = 6; + final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle); + Point2D middle = new Point2D.Double(0, 0); + Point2D left = new Point2D.Double(0, -yOuverture); + Point2D base = new Point2D.Double(-xAile, 0); + Point2D right = new Point2D.Double(0, yOuverture); + Point2D circleBase = new Point2D.Double(-xAile-radius-2, 0); + rotate.transform(left, left); + rotate.transform(base, base); + rotate.transform(right, right); + rotate.transform(circleBase, circleBase); + + drawLine(ug, contact.getX(), contact.getY(), base, left); + drawLine(ug, contact.getX(), contact.getY(), base, right); + drawLine(ug, contact.getX(), contact.getY(), base, middle); + ug.apply(new UTranslate(contact.getX()+circleBase.getX()-radius, contact.getY()+circleBase.getY()-radius)).draw(new UEllipse(2*radius, 2*radius)); + } + + static private void drawLine(UGraphic ug, double x, double y, Point2D p1, Point2D p2) { + final double dx = p2.getX() - p1.getX(); + final double dy = p2.getY() - p1.getY(); + ug.apply(new UTranslate(x + p1.getX(), y + p1.getY())).draw(new ULine(dx, dy)); + } + +} diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleLine.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleLine.java new file mode 100644 index 000000000..35105adf2 --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleLine.java @@ -0,0 +1,84 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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.extremity; + +import java.awt.geom.AffineTransform; +import java.awt.geom.Point2D; +import net.sourceforge.plantuml.ugraphic.UEllipse; + +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +class ExtremityCircleLine extends Extremity { + + private final Point2D contact; + private final double angle; + private final double radius = 4; + private final double lineHeight = 4; + + @Override + public Point2D somePoint() { + return contact; + } + + public ExtremityCircleLine(Point2D p1, double angle) { + this.contact = new Point2D.Double(p1.getX(), p1.getY()); + this.angle = manageround(angle + Math.PI / 2); + } + + public void drawU(UGraphic ug) { + final int xAile = 4; + final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle); + Point2D middle = new Point2D.Double(0, 0); + Point2D base = new Point2D.Double(-xAile-radius-3, 0); + Point2D circleBase = new Point2D.Double(-xAile-radius-3, 0); + + Point2D lineTop = new Point2D.Double(-xAile, -lineHeight); + Point2D lineBottom = new Point2D.Double(-xAile, lineHeight); + + rotate.transform(lineTop, lineTop); + rotate.transform(lineBottom, lineBottom); + rotate.transform(base, base); + rotate.transform(circleBase, circleBase); + + drawLine(ug, contact.getX(), contact.getY(), base, middle); + ug.apply(new UTranslate(contact.getX()+circleBase.getX()-radius, contact.getY()+circleBase.getY()-radius)).draw(new UEllipse(2*radius, 2*radius)); + drawLine(ug, contact.getX(), contact.getY(), lineTop, lineBottom); + } + + static private void drawLine(UGraphic ug, double x, double y, Point2D p1, Point2D p2) { + final double dx = p2.getX() - p1.getX(); + final double dy = p2.getY() - p1.getY(); + ug.apply(new UTranslate(x + p1.getX(), y + p1.getY())).draw(new ULine(dx, dy)); + } + +} diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityDoubleLine.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityDoubleLine.java new file mode 100644 index 000000000..aa8534735 --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityDoubleLine.java @@ -0,0 +1,86 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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.extremity; + +import java.awt.geom.AffineTransform; +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +class ExtremityDoubleLine extends Extremity { + + private final Point2D contact; + private final double angle; + private final double lineHeight = 4; + + @Override + public Point2D somePoint() { + return contact; + } + + public ExtremityDoubleLine(Point2D p1, double angle) { + this.contact = new Point2D.Double(p1.getX(), p1.getY()); + this.angle = manageround(angle + Math.PI / 2); + } + + public void drawU(UGraphic ug) { + final int xAile = 4; + final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle); + Point2D firstLineTop = new Point2D.Double(-xAile, -lineHeight); + Point2D firstLineBottom = new Point2D.Double(-xAile, lineHeight); + Point2D secondLineTop = new Point2D.Double(-xAile - 3, -lineHeight); + Point2D secondLineBottom = new Point2D.Double(-xAile - 3, lineHeight); + + Point2D middle = new Point2D.Double(0, 0); + Point2D base = new Point2D.Double(-xAile - 4, 0); + + rotate.transform(middle, middle); + rotate.transform(base, base); + + rotate.transform(firstLineTop, firstLineTop); + rotate.transform(firstLineBottom, firstLineBottom); + rotate.transform(secondLineTop, secondLineTop); + rotate.transform(secondLineBottom, secondLineBottom); + + drawLine(ug, contact.getX(), contact.getY(), firstLineTop, firstLineBottom); + drawLine(ug, contact.getX(), contact.getY(), secondLineTop, secondLineBottom); + drawLine(ug, contact.getX(), contact.getY(), base, middle); + } + + static private void drawLine(UGraphic ug, double x, double y, Point2D p1, Point2D p2) { + final double dx = p2.getX() - p1.getX(); + final double dy = p2.getY() - p1.getY(); + ug.apply(new UTranslate(x + p1.getX(), y + p1.getY())).draw(new ULine(dx, dy)); + } + +} diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleCrowfoot.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleCrowfoot.java new file mode 100644 index 000000000..d745616c1 --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleCrowfoot.java @@ -0,0 +1,46 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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.extremity; + +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.svek.AbstractExtremityFactory; +import net.sourceforge.plantuml.svek.Side; + +public class ExtremityFactoryCircleCrowfoot extends AbstractExtremityFactory implements ExtremityFactory { + + public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) { + final double ortho = atan2(p0, p2); + return new ExtremityCircleCrowfoot(p1, ortho); + } + +} diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleLine.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleLine.java new file mode 100644 index 000000000..6aae3388b --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleLine.java @@ -0,0 +1,45 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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.extremity; + +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.svek.AbstractExtremityFactory; +import net.sourceforge.plantuml.svek.Side; + +public class ExtremityFactoryCircleLine extends AbstractExtremityFactory implements ExtremityFactory { + + public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) { + final double ortho = atan2(p0, p2); + return new ExtremityCircleLine(p1, ortho); + } +} diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryDoubleLine.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryDoubleLine.java new file mode 100644 index 000000000..9b94e0ff7 --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryDoubleLine.java @@ -0,0 +1,45 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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.extremity; + +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.svek.AbstractExtremityFactory; +import net.sourceforge.plantuml.svek.Side; + +public class ExtremityFactoryDoubleLine extends AbstractExtremityFactory implements ExtremityFactory { + + public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) { + final double ortho = atan2(p0, p2); + return new ExtremityDoubleLine(p1, ortho); + } +} diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryLineCrowfoot.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryLineCrowfoot.java new file mode 100644 index 000000000..d55e020fd --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryLineCrowfoot.java @@ -0,0 +1,45 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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.extremity; + +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.svek.AbstractExtremityFactory; +import net.sourceforge.plantuml.svek.Side; + +public class ExtremityFactoryLineCrowfoot extends AbstractExtremityFactory implements ExtremityFactory { + + public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) { + final double ortho = atan2(p0, p2); + return new ExtremityLineCrowfoot(p1, ortho); + } +} diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityLineCrowfoot.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityLineCrowfoot.java new file mode 100644 index 000000000..272d4c41d --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityLineCrowfoot.java @@ -0,0 +1,86 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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.extremity; + +import java.awt.geom.AffineTransform; +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +class ExtremityLineCrowfoot extends Extremity { + + private final Point2D contact; + private final double angle; + private final double lineHeight = 4; + + + @Override + public Point2D somePoint() { + return contact; + } + + public ExtremityLineCrowfoot(Point2D p1, double angle) { + this.contact = new Point2D.Double(p1.getX(), p1.getY()); + this.angle = manageround(angle + Math.PI / 2); + } + + public void drawU(UGraphic ug) { + + final int xAile = 8; + final int yOuverture = 6; + final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle); + Point2D middle = new Point2D.Double(0, 0); + Point2D left = new Point2D.Double(0, -yOuverture); + Point2D base = new Point2D.Double(-xAile, 0); + Point2D lineTop = new Point2D.Double(-xAile-2, -lineHeight); + Point2D lineBottom = new Point2D.Double(-xAile-2, lineHeight); + Point2D right = new Point2D.Double(0, yOuverture); + rotate.transform(left, left); + rotate.transform(base, base); + rotate.transform(right, right); + rotate.transform(lineTop, lineTop); + rotate.transform(lineBottom, lineBottom); + + drawLine(ug, contact.getX(), contact.getY(), base, left); + drawLine(ug, contact.getX(), contact.getY(), base, right); + drawLine(ug, contact.getX(), contact.getY(), base, middle); + drawLine(ug, contact.getX(), contact.getY(), lineTop, lineBottom); + } + + static private void drawLine(UGraphic ug, double x, double y, Point2D p1, Point2D p2) { + final double dx = p2.getX() - p1.getX(); + final double dy = p2.getY() - p1.getY(); + ug.apply(new UTranslate(x + p1.getX(), y + p1.getY())).draw(new ULine(dx, dy)); + } + +} diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java index 47885ba92..6e2842a97 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java @@ -165,6 +165,11 @@ public class EntityImageClassHeader2 extends AbstractEntityImage { getSkinParam(), ColorParam.stereotypeEBackground, stereotype), classBorder, SkinParamUtils.getFontColor(getSkinParam(), FontParam.CIRCLED_CHARACTER, null)); } + if (entity.getEntityType() == LeafType.ENTITY) { + return new CircledCharacter('E', getSkinParam().getCircledCharacterRadius(), font, SkinParamUtils.getColor( + getSkinParam(), ColorParam.stereotypeCBackground, stereotype), classBorder, + SkinParamUtils.getFontColor(getSkinParam(), FontParam.CIRCLED_CHARACTER, null)); + } assert false; return null; } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java b/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java index 10bd9b65c..7f7be9ee7 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java @@ -103,8 +103,12 @@ public class EntityImageUseCase extends AbstractEntityImage { ug.startUrl(url); } - ug = ug.apply(stroke).apply( - new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.usecaseBorder, getStereo()))); + ug = ug.apply(stroke); + HtmlColor linecolor = getEntity().getColors(getSkinParam()).getColor(ColorType.LINE); + if (linecolor == null) { + linecolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.usecaseBorder, getStereo()); + } + ug = ug.apply(new UChangeColor(linecolor)); HtmlColor backcolor = getEntity().getColors(getSkinParam()).getColor(ColorType.BACK); if (backcolor == null) { backcolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.usecaseBackground, getStereo()); diff --git a/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java b/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java index 9020b8139..859f6fb26 100644 --- a/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java +++ b/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java @@ -58,7 +58,7 @@ public class LanguageDescriptor { type.add("object"); type.add("artifact"); type.add("folder"); - type.add("rect"); + type.add("rectangle"); type.add("node"); type.add("frame"); type.add("cloud"); @@ -69,9 +69,16 @@ public class LanguageDescriptor { type.add("control"); type.add("entity"); type.add("card"); + type.add("file"); + type.add("package"); + type.add("queue"); keyword.add("@startuml"); keyword.add("@enduml"); + keyword.add("@startdot"); + keyword.add("@enddot"); + keyword.add("@startsalt"); + keyword.add("@endsalt"); keyword.add("as"); keyword.add("also"); keyword.add("autonumber"); @@ -137,6 +144,7 @@ public class LanguageDescriptor { keyword.add("kill"); preproc.add("!include"); + preproc.add("!pragma"); preproc.add("!define"); preproc.add("!undef"); preproc.add("!ifdef"); diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 670d219b3..bcdb498cf 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -36,7 +36,7 @@ import java.util.Date; public class Version { public static int version() { - return 8053; + return 8054; } public static String versionString() { @@ -68,7 +68,7 @@ public class Version { } public static long compileTime() { - return 1482342693198L; + return 1484996122445L; } public static String compileTimeString() { diff --git a/src/net/sourceforge/plantuml/xmi/CucaDiagramXmiMaker.java b/src/net/sourceforge/plantuml/xmi/CucaDiagramXmiMaker.java index 89be85f79..9eb4f60b9 100644 --- a/src/net/sourceforge/plantuml/xmi/CucaDiagramXmiMaker.java +++ b/src/net/sourceforge/plantuml/xmi/CucaDiagramXmiMaker.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.cucadiagram.CucaDiagram; +import net.sourceforge.plantuml.descdiagram.DescriptionDiagram; import net.sourceforge.plantuml.statediagram.StateDiagram; public final class CucaDiagramXmiMaker { @@ -62,6 +63,8 @@ public final class CucaDiagramXmiMaker { final IXmiClassDiagram xmi; if (diagram instanceof StateDiagram) { xmi = new XmiStateDiagram((StateDiagram) diagram); + } else if (diagram instanceof DescriptionDiagram) { + xmi = new XmiDescriptionDiagram((DescriptionDiagram) diagram); } else if (fileFormat == FileFormat.XMI_STANDARD) { xmi = new XmiClassDiagramStandard((ClassDiagram) diagram); } else if (fileFormat == FileFormat.XMI_ARGO) { diff --git a/src/net/sourceforge/plantuml/xmi/XmiDescriptionDiagram.java b/src/net/sourceforge/plantuml/xmi/XmiDescriptionDiagram.java new file mode 100644 index 000000000..bfd0e72f7 --- /dev/null +++ b/src/net/sourceforge/plantuml/xmi/XmiDescriptionDiagram.java @@ -0,0 +1,238 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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.xmi; + +import java.io.OutputStream; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.GroupRoot; +import net.sourceforge.plantuml.cucadiagram.IEntity; +import net.sourceforge.plantuml.cucadiagram.IGroup; +import net.sourceforge.plantuml.cucadiagram.Link; +import net.sourceforge.plantuml.cucadiagram.LinkDecor; +import net.sourceforge.plantuml.cucadiagram.Member; +import net.sourceforge.plantuml.descdiagram.DescriptionDiagram; +import net.sourceforge.plantuml.utils.UniqueSequence; +import net.sourceforge.plantuml.version.Version; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +public class XmiDescriptionDiagram implements IXmiClassDiagram { + + private final DescriptionDiagram diagram; + private final Document document; + private final Element ownedElement; + + public XmiDescriptionDiagram(DescriptionDiagram diagram) throws ParserConfigurationException { + this.diagram = diagram; + final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + + final DocumentBuilder builder = factory.newDocumentBuilder(); + this.document = builder.newDocument(); + document.setXmlVersion("1.0"); + document.setXmlStandalone(true); + + final Element xmi = document.createElement("XMI"); + xmi.setAttribute("xmi.version", "1.1"); + xmi.setAttribute("xmlns:UML", "href://org.omg/UML/1.3"); + document.appendChild(xmi); + + final Element header = document.createElement("XMI.header"); + xmi.appendChild(header); + + final Element metamodel = document.createElement("XMI.metamodel"); + metamodel.setAttribute("xmi.name", "UML"); + metamodel.setAttribute("xmi.version", "1.3"); + header.appendChild(metamodel); + + final Element content = document.createElement("XMI.content"); + xmi.appendChild(content); + + // + final Element model = document.createElement("UML:Model"); + model.setAttribute("xmi.id", CucaDiagramXmiMaker.getModel(diagram)); + model.setAttribute("name", "PlantUML "+Version.versionString()); + content.appendChild(model); + + // + this.ownedElement = document.createElement("UML:Namespace.ownedElement"); + model.appendChild(ownedElement); + + for (final IGroup gr : diagram.getGroups(false)) { + if (gr.getParentContainer() instanceof GroupRoot) { + addState(gr, ownedElement); + } + } + + for (final IEntity ent : diagram.getLeafsvalues()) { + if (ent.getParentContainer() instanceof GroupRoot) { + addState(ent, ownedElement); + } + } + + for (final Link link : diagram.getLinks()) { + addLink(link); + } + } + + private void addState(final IEntity tobeAdded, Element container) { + final Element elementState = createEntityNode(tobeAdded); + container.appendChild(elementState); + for (final IEntity ent : diagram.getGroups(false)) { + if (ent.getParentContainer() == tobeAdded) { + addState(ent, elementState); + } + } + for (final IEntity ent : diagram.getLeafsvalues()) { + if (ent.getParentContainer() == tobeAdded) { + addState(ent, elementState); + } + } + } + + public static String forXMI(String s) { + return s.replace(':', ' '); + } + + public static String forXMI(Display s) { + return s.get(0).toString().replace(':', ' '); + } + + private void addLink(Link link) { + final String assId = "ass" + UniqueSequence.getValue(); + + final Element association = document.createElement("UML:Association"); + association.setAttribute("xmi.id", assId); + association.setAttribute("namespace", CucaDiagramXmiMaker.getModel(diagram)); + if (Display.isNull(link.getLabel()) == false) { + association.setAttribute("name", forXMI(link.getLabel())); + } + + final Element connection = document.createElement("UML:Association.connection"); + final Element end1 = document.createElement("UML:AssociationEnd"); + end1.setAttribute("xmi.id", "end" + UniqueSequence.getValue()); + end1.setAttribute("association", assId); + end1.setAttribute("type", link.getEntity1().getUid()); + if (link.getQualifier1() != null) { + end1.setAttribute("name", forXMI(link.getQualifier1())); + } + final Element endparticipant1 = document.createElement("UML:AssociationEnd.participant"); + + if (link.getType().getDecor2() == LinkDecor.COMPOSITION) { + end1.setAttribute("aggregation", "composite"); + } + if (link.getType().getDecor2() == LinkDecor.AGREGATION) { + end1.setAttribute("aggregation", "aggregate"); + } + // } + end1.appendChild(endparticipant1); + connection.appendChild(end1); + + final Element end2 = document.createElement("UML:AssociationEnd"); + end2.setAttribute("xmi.id", "end" + UniqueSequence.getValue()); + end2.setAttribute("association", assId); + end2.setAttribute("type", link.getEntity2().getUid()); + if (link.getQualifier2() != null) { + end2.setAttribute("name", forXMI(link.getQualifier2())); + } + final Element endparticipant2 = document.createElement("UML:AssociationEnd.participant"); + if (link.getType().getDecor1() == LinkDecor.COMPOSITION) { + end2.setAttribute("aggregation", "composite"); + } + if (link.getType().getDecor1() == LinkDecor.AGREGATION) { + end2.setAttribute("aggregation", "aggregate"); + } + // } + end2.appendChild(endparticipant2); + connection.appendChild(end2); + + association.appendChild(connection); + + ownedElement.appendChild(association); + + } + + private Element createEntityNode(IEntity entity) { + final Element cla = document.createElement("UML:Component"); + + cla.setAttribute("xmi.id", entity.getUid()); + cla.setAttribute("name", entity.getDisplay().get(0).toString()); + cla.setAttribute("namespace", CucaDiagramXmiMaker.getModel(diagram)); + + final Element feature = document.createElement("UML:Classifier.feature"); + cla.appendChild(feature); + + for (Member m : entity.getBodier().getFieldsToDisplay()) { + final Element attribute = document.createElement("UML:Attribute"); + attribute.setAttribute("xmi.id", "att" + UniqueSequence.getValue()); + attribute.setAttribute("name", m.getDisplay(false)); + feature.appendChild(attribute); + } + + for (Member m : entity.getBodier().getMethodsToDisplay()) { + final Element operation = document.createElement("UML:Operation"); + operation.setAttribute("xmi.id", "att" + UniqueSequence.getValue()); + operation.setAttribute("name", m.getDisplay(false)); + feature.appendChild(operation); + } + return cla; + } + + public void transformerXml(OutputStream os) throws TransformerException, ParserConfigurationException { + final Source source = new DOMSource(document); + + final Result resultat = new StreamResult(os); + + final TransformerFactory fabrique = TransformerFactory.newInstance(); + final Transformer transformer = fabrique.newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + // transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + // tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + transformer.transform(source, resultat); + } + +}