From 0dc09da9a885b647abc64104755a81f46a701573 Mon Sep 17 00:00:00 2001 From: Serge Wenger Date: Mon, 18 May 2020 22:01:37 +0200 Subject: [PATCH] Sate deep history first implementation --- .../plantuml/cucadiagram/LeafType.java | 3 +- .../plantuml/statediagram/StateDiagram.java | 30 +++++++++++- .../command/CommandLinkState.java | 9 +++- .../plantuml/svek/GeneralImageBuilder.java | 6 +++ .../svek/image/EntityImageDeepHistory.java | 47 +++++++++++++++++++ .../svek/image/EntityImagePseudoState.java | 6 ++- 6 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 src/net/sourceforge/plantuml/svek/image/EntityImageDeepHistory.java diff --git a/src/net/sourceforge/plantuml/cucadiagram/LeafType.java b/src/net/sourceforge/plantuml/cucadiagram/LeafType.java index b5c9848f50d..1a6766eacbe 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/LeafType.java +++ b/src/net/sourceforge/plantuml/cucadiagram/LeafType.java @@ -31,6 +31,7 @@ * * Original Author: Arnaud Roques * Contribution : Hisashi Miyashita + * Contribution : Serge Wenger * */ package net.sourceforge.plantuml.cucadiagram; @@ -51,7 +52,7 @@ public enum LeafType { ACTIVITY, BRANCH, SYNCHRO_BAR, CIRCLE_START, CIRCLE_END, POINT_FOR_ASSOCIATION, ACTIVITY_CONCURRENT, - STATE, STATE_CONCURRENT, PSEUDO_STATE, STATE_CHOICE, STATE_FORK_JOIN, + STATE, STATE_CONCURRENT, PSEUDO_STATE, DEEP_HISTORY, STATE_CHOICE, STATE_FORK_JOIN, BLOCK, ENTITY, diff --git a/src/net/sourceforge/plantuml/statediagram/StateDiagram.java b/src/net/sourceforge/plantuml/statediagram/StateDiagram.java index b2a9889af59..0c8f3ebff56 100644 --- a/src/net/sourceforge/plantuml/statediagram/StateDiagram.java +++ b/src/net/sourceforge/plantuml/statediagram/StateDiagram.java @@ -30,7 +30,7 @@ * * * Original Author: Arnaud Roques - * + * Contribution : Serge Wenger * */ package net.sourceforge.plantuml.statediagram; @@ -188,6 +188,34 @@ public IEntity getHistorical(String idShort) { endGroup(); return result; } + public IEntity getDeepHistory() { + final IGroup g = getCurrentGroup(); + if (EntityUtils.groupRoot(g)) { + final Ident ident = buildLeafIdent("*deephistory"); + final Code code = buildCode("*deephistory"); + return getOrCreateLeaf(ident, code, LeafType.DEEP_HISTORY, null); + } + + final String idShort = "*deephistory*" + g.getCodeGetName(); + final Ident ident = buildLeafIdent(idShort); + final Code code = this.V1972() ? ident : buildCode(idShort); + return getOrCreateLeaf(ident, code, LeafType.DEEP_HISTORY, null); + } + + public IEntity getDeepHistory(String idShort) { + final Ident idNewLong = buildLeafIdent(idShort); + final Code codeGroup = this.V1972() ? idNewLong : buildCode(idShort); + gotoGroup(idNewLong, codeGroup, Display.getWithNewlines(codeGroup), GroupType.STATE, getRootGroup(), + NamespaceStrategy.SINGLE); + final IEntity g = getCurrentGroup(); + final String tmp = "*deephistory*" + g.getCodeGetName(); + final Ident ident = buildLeafIdent(tmp); + final Code code = this.V1972() ? ident : buildCode(tmp); + final IEntity result = getOrCreateLeaf(ident, code, LeafType.DEEP_HISTORY, null); + endGroup(); + return result; + } + public boolean concurrentState(char direction) { final IGroup cur = getCurrentGroup(); diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java index 72274b0c538..b1fa847bfb7 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java @@ -30,6 +30,7 @@ * * * Original Author: Arnaud Roques + * Contribution : Serge Wenger * * */ @@ -92,7 +93,7 @@ static RegexConcat getRegex() { private static RegexLeaf getStatePattern(String name) { return new RegexLeaf( name, - "([\\p{L}0-9_.]+|[\\p{L}0-9_.]+\\[H\\]|\\[\\*\\]|\\[H\\]|(?:==+)(?:[\\p{L}0-9_.]+)(?:==+))[%s]*(\\<\\<.*\\>\\>)?[%s]*(#\\w+)?"); + "([\\p{L}0-9_.]+|[\\p{L}0-9_.]+\\[H\\*?\\]|\\[\\*\\]|\\[H\\*?\\]|(?:==+)(?:[\\p{L}0-9_.]+)(?:==+))[%s]*(\\<\\<.*\\>\\>)?[%s]*(#\\w+)?"); } @Override @@ -181,6 +182,12 @@ private IEntity getFoo1(StateDiagram diagram, final String codeString) { if (codeString.endsWith("[H]")) { return diagram.getHistorical(codeString.substring(0, codeString.length() - 3)); } + if (codeString.equalsIgnoreCase("[H*]")) { + return diagram.getDeepHistory(); + } + if (codeString.endsWith("[H*]")) { + return diagram.getDeepHistory(codeString.substring(0, codeString.length() - 4)); + } if (codeString.startsWith("=") && codeString.endsWith("=")) { final String codeString1 = removeEquals(codeString); final Ident ident1 = diagram.buildLeafIdent(codeString1); diff --git a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java index 44083d7bda6..0b88a86fe20 100644 --- a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java +++ b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java @@ -31,6 +31,7 @@ * * Original Author: Arnaud Roques * Contribution : Hisashi Miyashita + * Contribution : Serge Wenger * * */ @@ -111,6 +112,7 @@ import net.sourceforge.plantuml.svek.image.EntityImageCircleEnd; import net.sourceforge.plantuml.svek.image.EntityImageCircleStart; import net.sourceforge.plantuml.svek.image.EntityImageClass; +import net.sourceforge.plantuml.svek.image.EntityImageDeepHistory; import net.sourceforge.plantuml.svek.image.EntityImageDescription; import net.sourceforge.plantuml.svek.image.EntityImageEmptyPackage; import net.sourceforge.plantuml.svek.image.EntityImageGroup; @@ -249,6 +251,10 @@ public static IEntityImage createEntityImageBlock(ILeaf leaf, ISkinParam skinPar if (leaf.getLeafType() == LeafType.PSEUDO_STATE) { return new EntityImagePseudoState(leaf, skinParam); } + if (leaf.getLeafType() == LeafType.DEEP_HISTORY) { + return new EntityImageDeepHistory(leaf, skinParam); + } + if (leaf.getLeafType() == LeafType.TIPS) { return new EntityImageTips(leaf, skinParam, bibliotekon); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageDeepHistory.java b/src/net/sourceforge/plantuml/svek/image/EntityImageDeepHistory.java new file mode 100644 index 00000000000..0c353b33f8a --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageDeepHistory.java @@ -0,0 +1,47 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * Contribution : Serge Wenger + * + */ +package net.sourceforge.plantuml.svek.image; + +import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.ISkinParam; + +public class EntityImageDeepHistory extends EntityImagePseudoState { + + public EntityImageDeepHistory(ILeaf entity, ISkinParam skinParam) { + super(entity, skinParam, "H*"); + + } +} diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java b/src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java index a62e7a8ebbb..24109104099 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java @@ -62,11 +62,13 @@ public class EntityImagePseudoState extends AbstractEntityImage { private final TextBlock desc; public EntityImagePseudoState(ILeaf entity, ISkinParam skinParam) { + this(entity, skinParam, "H"); + } + public EntityImagePseudoState(ILeaf entity, ISkinParam skinParam, String historyText) { super(entity, skinParam); final Stereotype stereotype = entity.getStereotype(); - this.desc = Display.create("H").create(new FontConfiguration(getSkinParam(), FontParam.STATE, stereotype), + this.desc = Display.create(historyText).create(new FontConfiguration(getSkinParam(), FontParam.STATE, stereotype), HorizontalAlignment.CENTER, skinParam); - } public Dimension2D calculateDimension(StringBounder stringBounder) {