1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-11 12:42:26 +00:00

Merge pull request #329 from SergeWenger/DeepeHistory

Sate deep history first implementation
This commit is contained in:
arnaudroques 2020-05-18 22:52:25 +02:00 committed by GitHub
commit 9ba7d08d52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 96 additions and 5 deletions

View File

@ -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,

View File

@ -30,7 +30,7 @@
*
*
* Original Author: Arnaud Roques
*
* Contribution : Serge Wenger
*
*/
package net.sourceforge.plantuml.statediagram;
@ -188,6 +188,34 @@ public class StateDiagram extends AbstractEntityDiagram {
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();

View File

@ -30,6 +30,7 @@
*
*
* Original Author: Arnaud Roques
* Contribution : Serge Wenger
*
*
*/
@ -92,7 +93,7 @@ public class CommandLinkState extends SingleLineCommand2<StateDiagram> {
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 @@ public class CommandLinkState extends SingleLineCommand2<StateDiagram> {
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);

View File

@ -31,6 +31,7 @@
*
* Original Author: Arnaud Roques
* Contribution : Hisashi Miyashita
* Contribution : Serge Wenger
*
*
*/
@ -111,6 +112,7 @@ import net.sourceforge.plantuml.svek.image.EntityImageBranch;
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 final class GeneralImageBuilder {
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);
}

View File

@ -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*");
}
}

View File

@ -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) {