Skip to content

Commit

Permalink
Sate deep history first implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeWenger committed May 18, 2020
1 parent bb94634 commit 0dc09da
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/net/sourceforge/plantuml/cucadiagram/LeafType.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*
* Original Author: Arnaud Roques
* Contribution : Hisashi Miyashita
* Contribution : Serge Wenger
*
*/
package net.sourceforge.plantuml.cucadiagram;
Expand All @@ -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,

Expand Down
30 changes: 29 additions & 1 deletion src/net/sourceforge/plantuml/statediagram/StateDiagram.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
*
* Original Author: Arnaud Roques
*
* Contribution : Serge Wenger
*
*/
package net.sourceforge.plantuml.statediagram;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*
*
* Original Author: Arnaud Roques
* Contribution : Serge Wenger
*
*
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*
* Original Author: Arnaud Roques
* Contribution : Hisashi Miyashita
* Contribution : Serge Wenger
*
*
*/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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*");

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0dc09da

Please sign in to comment.