2015-07-11 09:32:49 +00:00
|
|
|
/* ========================================================================
|
|
|
|
* PlantUML : a free UML diagram generator
|
|
|
|
* ========================================================================
|
|
|
|
*
|
2019-01-16 18:34:41 +00:00
|
|
|
* (C) Copyright 2009-2020, Arnaud Roques
|
2015-07-11 09:32:49 +00:00
|
|
|
*
|
2016-03-06 16:47:34 +00:00
|
|
|
* Project Info: http://plantuml.com
|
2015-07-11 09:32:49 +00:00
|
|
|
*
|
2017-03-15 19:13:31 +00:00
|
|
|
* 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
|
|
|
|
*
|
2015-07-11 09:32:49 +00:00
|
|
|
* 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.cond;
|
|
|
|
|
2015-09-06 17:28:59 +00:00
|
|
|
import java.awt.geom.Dimension2D;
|
|
|
|
|
2015-07-11 09:32:49 +00:00
|
|
|
import net.sourceforge.plantuml.ISkinParam;
|
2017-02-26 16:26:11 +00:00
|
|
|
import net.sourceforge.plantuml.LineBreakStrategy;
|
2019-06-26 19:24:49 +00:00
|
|
|
import net.sourceforge.plantuml.Url;
|
2020-12-01 21:39:27 +00:00
|
|
|
import net.sourceforge.plantuml.UseStyle;
|
2015-07-11 09:32:49 +00:00
|
|
|
import net.sourceforge.plantuml.activitydiagram3.Branch;
|
2021-10-27 16:43:04 +00:00
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon;
|
2015-07-11 09:32:49 +00:00
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileEmpty;
|
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
|
2020-05-07 14:12:08 +00:00
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMinWidthCentered;
|
2015-07-11 09:32:49 +00:00
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
|
2019-06-26 19:24:49 +00:00
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileWithUrl;
|
2015-07-11 09:32:49 +00:00
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
2016-08-25 20:45:37 +00:00
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileIfDown;
|
2015-07-11 09:32:49 +00:00
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
|
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
|
2020-12-19 21:21:54 +00:00
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondSquare;
|
2015-07-11 09:32:49 +00:00
|
|
|
import net.sourceforge.plantuml.creole.CreoleMode;
|
2020-05-17 21:15:50 +00:00
|
|
|
import net.sourceforge.plantuml.creole.Parser;
|
2015-07-11 09:32:49 +00:00
|
|
|
import net.sourceforge.plantuml.creole.Sheet;
|
|
|
|
import net.sourceforge.plantuml.creole.SheetBlock1;
|
|
|
|
import net.sourceforge.plantuml.creole.SheetBlock2;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
|
|
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
|
|
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
2016-05-11 21:31:47 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.Rainbow;
|
2015-07-11 09:32:49 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
|
|
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
2019-08-26 17:07:21 +00:00
|
|
|
import net.sourceforge.plantuml.style.PName;
|
|
|
|
import net.sourceforge.plantuml.style.SName;
|
|
|
|
import net.sourceforge.plantuml.style.Style;
|
|
|
|
import net.sourceforge.plantuml.style.StyleSignature;
|
2019-06-26 19:24:49 +00:00
|
|
|
import net.sourceforge.plantuml.svek.ConditionEndStyle;
|
2015-07-11 09:32:49 +00:00
|
|
|
import net.sourceforge.plantuml.svek.ConditionStyle;
|
2020-03-18 10:50:02 +00:00
|
|
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
2015-07-11 09:32:49 +00:00
|
|
|
|
|
|
|
public class ConditionalBuilder {
|
|
|
|
|
|
|
|
private final Swimlane swimlane;
|
2020-03-18 10:50:02 +00:00
|
|
|
private final HColor borderColor;
|
|
|
|
private final HColor backColor;
|
2021-10-07 16:51:26 +00:00
|
|
|
private final LineBreakStrategy diamondLineBreak;
|
|
|
|
private final LineBreakStrategy labelLineBreak;
|
2016-05-11 21:31:47 +00:00
|
|
|
private final Rainbow arrowColor;
|
2015-07-11 09:32:49 +00:00
|
|
|
private final FtileFactory ftileFactory;
|
|
|
|
private final ConditionStyle conditionStyle;
|
2019-06-26 19:24:49 +00:00
|
|
|
private final ConditionEndStyle conditionEndStyle;
|
2015-07-11 09:32:49 +00:00
|
|
|
private final Branch branch1;
|
|
|
|
private final Branch branch2;
|
|
|
|
private final ISkinParam skinParam;
|
|
|
|
private final StringBounder stringBounder;
|
2015-09-28 20:42:17 +00:00
|
|
|
private final FontConfiguration fontArrow;
|
|
|
|
private final FontConfiguration fontTest;
|
2015-07-11 09:32:49 +00:00
|
|
|
|
|
|
|
private final Ftile tile1;
|
|
|
|
private final Ftile tile2;
|
2019-06-26 19:24:49 +00:00
|
|
|
private final Url url;
|
2015-07-11 09:32:49 +00:00
|
|
|
|
2019-08-26 17:07:21 +00:00
|
|
|
public StyleSignature getDefaultStyleDefinitionDiamond() {
|
|
|
|
return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity, SName.diamond);
|
|
|
|
}
|
|
|
|
|
|
|
|
public StyleSignature getDefaultStyleDefinitionArrow() {
|
|
|
|
return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow);
|
|
|
|
}
|
|
|
|
|
2020-03-18 10:50:02 +00:00
|
|
|
public ConditionalBuilder(Swimlane swimlane, HColor borderColor, HColor backColor, Rainbow arrowColor,
|
2019-06-26 19:24:49 +00:00
|
|
|
FtileFactory ftileFactory, ConditionStyle conditionStyle, ConditionEndStyle conditionEndStyle,
|
|
|
|
Branch branch1, Branch branch2, ISkinParam skinParam, StringBounder stringBounder,
|
|
|
|
FontConfiguration fontArrow, FontConfiguration fontTest, Url url) {
|
2020-12-01 21:39:27 +00:00
|
|
|
if (UseStyle.useBetaStyle()) {
|
2022-02-01 20:21:45 +00:00
|
|
|
if (backColor == null)
|
|
|
|
throw new IllegalArgumentException();
|
|
|
|
if (borderColor == null)
|
|
|
|
throw new IllegalArgumentException();
|
|
|
|
if (arrowColor == null)
|
|
|
|
throw new IllegalArgumentException();
|
2019-08-26 17:07:21 +00:00
|
|
|
final Style styleArrow = getDefaultStyleDefinitionArrow()
|
|
|
|
.getMergedStyle(skinParam.getCurrentStyleBuilder());
|
2020-05-17 21:15:50 +00:00
|
|
|
final Style styleDiamond = getDefaultStyleDefinitionDiamond()
|
|
|
|
.getMergedStyle(skinParam.getCurrentStyleBuilder());
|
2021-10-07 16:51:26 +00:00
|
|
|
this.diamondLineBreak = styleDiamond.wrapWidth();
|
|
|
|
this.labelLineBreak = styleArrow.wrapWidth();
|
2022-02-01 20:21:45 +00:00
|
|
|
this.borderColor = borderColor; /*styleDiamond.value(PName.LineColor).asColor(skinParam.getThemeStyle(),
|
|
|
|
skinParam.getIHtmlColorSet());*/
|
|
|
|
this.backColor = backColor;/*styleDiamond.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(),
|
|
|
|
skinParam.getIHtmlColorSet())*/;
|
|
|
|
this.arrowColor = arrowColor;/* Rainbow.fromColor(
|
2021-05-06 21:23:05 +00:00
|
|
|
styleArrow.value(PName.LineColor).asColor(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet()),
|
2022-02-01 20:21:45 +00:00
|
|
|
null);*/
|
2021-05-06 21:23:05 +00:00
|
|
|
this.fontTest = styleDiamond.getFontConfiguration(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet());
|
|
|
|
this.fontArrow = styleArrow.getFontConfiguration(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet());
|
2019-08-26 17:07:21 +00:00
|
|
|
} else {
|
2021-10-07 16:51:26 +00:00
|
|
|
this.diamondLineBreak = LineBreakStrategy.NONE;
|
|
|
|
this.labelLineBreak = LineBreakStrategy.NONE;
|
2019-08-26 17:07:21 +00:00
|
|
|
this.borderColor = borderColor;
|
|
|
|
this.backColor = backColor;
|
|
|
|
this.arrowColor = arrowColor;
|
|
|
|
this.fontTest = fontTest;
|
|
|
|
this.fontArrow = fontArrow;
|
|
|
|
}
|
2015-07-11 09:32:49 +00:00
|
|
|
this.ftileFactory = ftileFactory;
|
2019-08-26 17:07:21 +00:00
|
|
|
this.swimlane = swimlane;
|
2015-07-11 09:32:49 +00:00
|
|
|
this.conditionStyle = conditionStyle;
|
2019-06-26 19:24:49 +00:00
|
|
|
this.conditionEndStyle = conditionEndStyle;
|
2015-07-11 09:32:49 +00:00
|
|
|
this.branch1 = branch1;
|
|
|
|
this.branch2 = branch2;
|
|
|
|
this.skinParam = skinParam;
|
|
|
|
this.stringBounder = stringBounder;
|
2019-06-26 19:24:49 +00:00
|
|
|
this.url = url;
|
2015-07-11 09:32:49 +00:00
|
|
|
|
2020-05-07 14:12:08 +00:00
|
|
|
this.tile1 = new FtileMinWidthCentered(branch1.getFtile(), 30);
|
|
|
|
this.tile2 = new FtileMinWidthCentered(branch2.getFtile(), 30);
|
2015-07-11 09:32:49 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-03-18 10:50:02 +00:00
|
|
|
static public Ftile create(Swimlane swimlane, HColor borderColor, HColor backColor, Rainbow arrowColor,
|
2019-06-26 19:24:49 +00:00
|
|
|
FtileFactory ftileFactory, ConditionStyle conditionStyle, ConditionEndStyle conditionEndStyle,
|
|
|
|
Branch branch1, Branch branch2, ISkinParam skinParam, StringBounder stringBounder,
|
|
|
|
FontConfiguration fcArrow, FontConfiguration fcTest, Url url) {
|
2015-09-28 20:42:17 +00:00
|
|
|
final ConditionalBuilder builder = new ConditionalBuilder(swimlane, borderColor, backColor, arrowColor,
|
2019-06-26 19:24:49 +00:00
|
|
|
ftileFactory, conditionStyle, conditionEndStyle, branch1, branch2, skinParam, stringBounder, fcArrow,
|
|
|
|
fcTest, url);
|
2018-03-09 21:37:34 +00:00
|
|
|
if (isEmptyOrOnlySingleStopOrSpot(branch2) && isEmptyOrOnlySingleStopOrSpot(branch1) == false) {
|
2016-11-04 21:39:29 +00:00
|
|
|
return builder.createDown(builder.branch1, builder.branch2);
|
|
|
|
}
|
2018-03-09 21:37:34 +00:00
|
|
|
if (branch1.isEmpty() && branch2.isOnlySingleStopOrSpot()) {
|
2016-11-04 21:39:29 +00:00
|
|
|
return builder.createDown(builder.branch1, builder.branch2);
|
|
|
|
}
|
2018-03-09 21:37:34 +00:00
|
|
|
if (isEmptyOrOnlySingleStopOrSpot(branch1) && isEmptyOrOnlySingleStopOrSpot(branch2) == false) {
|
2016-11-04 21:39:29 +00:00
|
|
|
return builder.createDown(builder.branch2, builder.branch1);
|
|
|
|
}
|
2018-03-09 21:37:34 +00:00
|
|
|
if (branch2.isEmpty() && branch1.isOnlySingleStopOrSpot()) {
|
2016-11-04 21:39:29 +00:00
|
|
|
return builder.createDown(builder.branch2, builder.branch1);
|
|
|
|
}
|
2015-07-11 09:32:49 +00:00
|
|
|
return builder.createWithLinks();
|
|
|
|
// return builder.createWithDiamonds();
|
|
|
|
// return builder.createNude();
|
2016-08-25 20:45:37 +00:00
|
|
|
}
|
2015-07-11 09:32:49 +00:00
|
|
|
|
2018-03-09 21:37:34 +00:00
|
|
|
private static boolean isEmptyOrOnlySingleStopOrSpot(Branch branch) {
|
|
|
|
return branch.isEmpty() || branch.isOnlySingleStopOrSpot();
|
2016-08-25 20:45:37 +00:00
|
|
|
}
|
|
|
|
|
2016-09-29 19:51:18 +00:00
|
|
|
private Ftile createDown(Branch branch1, Branch branch2) {
|
2020-05-07 14:12:08 +00:00
|
|
|
final Ftile tile1 = new FtileMinWidthCentered(branch1.getFtile(), 30);
|
|
|
|
final Ftile tile2 = new FtileMinWidthCentered(branch2.getFtile(), 30);
|
2016-09-29 19:51:18 +00:00
|
|
|
final TextBlock tb1 = getLabelPositive(branch1);
|
|
|
|
final TextBlock tb2 = getLabelPositive(branch2);
|
2021-10-27 16:43:04 +00:00
|
|
|
final Ftile diamond1 = getShape1(false, tb1, tb2);
|
|
|
|
final Ftile diamond2 = getShape2(branch1, branch2, true);
|
2018-03-09 21:37:34 +00:00
|
|
|
if (branch2.isOnlySingleStopOrSpot()) {
|
2016-08-25 20:45:37 +00:00
|
|
|
return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile1, 10),
|
2020-11-21 17:33:24 +00:00
|
|
|
arrowColor, conditionEndStyle, ftileFactory, branch2.getFtile(), branch2.getOut());
|
2016-08-25 20:45:37 +00:00
|
|
|
}
|
2018-03-09 21:37:34 +00:00
|
|
|
if (branch1.isOnlySingleStopOrSpot()) {
|
2016-08-25 20:45:37 +00:00
|
|
|
return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile2, 10),
|
2020-11-21 17:33:24 +00:00
|
|
|
arrowColor, conditionEndStyle, ftileFactory, branch1.getFtile(), branch1.getOut());
|
2016-08-25 20:45:37 +00:00
|
|
|
}
|
|
|
|
if (branch1.isEmpty()) {
|
|
|
|
return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile2, 10),
|
2019-06-26 19:24:49 +00:00
|
|
|
arrowColor, conditionEndStyle, ftileFactory, null, null);
|
2016-08-25 20:45:37 +00:00
|
|
|
}
|
|
|
|
return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile1, 10), arrowColor,
|
2020-11-21 17:33:24 +00:00
|
|
|
conditionEndStyle, ftileFactory, null, branch2.getOut());
|
2015-07-11 09:32:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private Ftile createNude() {
|
|
|
|
return new FtileIfNude(tile1, tile2, swimlane);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private Ftile createWithDiamonds() {
|
2016-08-25 20:45:37 +00:00
|
|
|
final Ftile diamond1 = getDiamond1(true);
|
2021-10-27 16:43:04 +00:00
|
|
|
final Ftile diamond2 = getShape2(branch1, branch2, false);
|
2015-09-06 17:28:59 +00:00
|
|
|
final FtileIfWithDiamonds ftile = new FtileIfWithDiamonds(diamond1, tile1, tile2, diamond2, swimlane,
|
|
|
|
stringBounder);
|
2016-09-29 19:51:18 +00:00
|
|
|
final Dimension2D label1 = getLabelPositive(branch1).calculateDimension(stringBounder);
|
|
|
|
final Dimension2D label2 = getLabelPositive(branch2).calculateDimension(stringBounder);
|
2015-09-06 17:28:59 +00:00
|
|
|
final double diff1 = ftile.computeMarginNeedForBranchLabe1(stringBounder, label1);
|
|
|
|
final double diff2 = ftile.computeMarginNeedForBranchLabe2(stringBounder, label2);
|
|
|
|
Ftile result = FtileUtils.addHorizontalMargin(ftile, diff1, diff2);
|
|
|
|
final double suppHeight = ftile.computeVerticalMarginNeedForBranchs(stringBounder, label1, label2);
|
|
|
|
result = FtileUtils.addVerticalMargin(result, suppHeight, 0);
|
|
|
|
return result;
|
2015-07-11 09:32:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private Ftile createWithLinks() {
|
2019-06-26 19:24:49 +00:00
|
|
|
Ftile diamond1 = getDiamond1(true);
|
|
|
|
if (url != null) {
|
|
|
|
diamond1 = new FtileWithUrl(diamond1, url);
|
|
|
|
}
|
2021-10-27 16:43:04 +00:00
|
|
|
final Ftile diamond2 = getShape2(branch1, branch2, false);
|
2015-07-11 09:32:49 +00:00
|
|
|
final Ftile tmp1 = FtileUtils.addHorizontalMargin(tile1, 10);
|
|
|
|
final Ftile tmp2 = FtileUtils.addHorizontalMargin(tile2, 10);
|
2015-09-06 17:28:59 +00:00
|
|
|
final FtileIfWithLinks ftile = new FtileIfWithLinks(diamond1, tmp1, tmp2, diamond2, swimlane, arrowColor,
|
2019-06-26 19:24:49 +00:00
|
|
|
conditionEndStyle, stringBounder);
|
2016-09-29 19:51:18 +00:00
|
|
|
final Dimension2D label1 = getLabelPositive(branch1).calculateDimension(stringBounder);
|
|
|
|
final Dimension2D label2 = getLabelPositive(branch2).calculateDimension(stringBounder);
|
2015-09-06 17:28:59 +00:00
|
|
|
final double diff1 = ftile.computeMarginNeedForBranchLabe1(stringBounder, label1);
|
|
|
|
final double diff2 = ftile.computeMarginNeedForBranchLabe2(stringBounder, label2);
|
|
|
|
final double suppHeight = ftile.computeVerticalMarginNeedForBranchs(stringBounder, label1, label2);
|
|
|
|
Ftile result = ftile.addLinks(branch1, branch2, stringBounder);
|
|
|
|
result = FtileUtils.addHorizontalMargin(result, diff1, diff2);
|
|
|
|
result = FtileUtils.addVerticalMargin(result, suppHeight, 0);
|
|
|
|
return result;
|
2015-07-11 09:32:49 +00:00
|
|
|
}
|
|
|
|
|
2016-08-25 20:45:37 +00:00
|
|
|
private Ftile getDiamond1(boolean eastWest) {
|
2021-10-27 16:43:04 +00:00
|
|
|
return getShape1(eastWest, getLabelPositive(branch1), getLabelPositive(branch2));
|
2016-08-25 20:45:37 +00:00
|
|
|
}
|
|
|
|
|
2021-10-27 16:43:04 +00:00
|
|
|
private Ftile getShape1(boolean eastWest, TextBlock tb1, TextBlock tb2) {
|
2015-07-11 09:32:49 +00:00
|
|
|
final Display labelTest = branch1.getLabelTest();
|
|
|
|
|
2020-05-17 21:15:50 +00:00
|
|
|
final Sheet sheet = Parser.build(fontTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
|
2016-07-25 19:25:28 +00:00
|
|
|
skinParam, CreoleMode.FULL).createSheet(labelTest);
|
2021-10-07 16:51:26 +00:00
|
|
|
final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, diamondLineBreak, skinParam.getPadding());
|
2021-10-27 16:43:04 +00:00
|
|
|
final TextBlock tbTest = new SheetBlock2(sheetBlock1, Hexagon.asStencil(sheetBlock1), tile1.getThickness());
|
2015-07-11 09:32:49 +00:00
|
|
|
|
2021-10-27 16:43:04 +00:00
|
|
|
final Ftile shape1;
|
2020-12-06 21:43:09 +00:00
|
|
|
if (conditionStyle == ConditionStyle.INSIDE_HEXAGON) {
|
2016-08-25 20:45:37 +00:00
|
|
|
if (eastWest) {
|
2021-10-27 16:43:04 +00:00
|
|
|
shape1 = new FtileDiamondInside(tbTest, tile1.skinParam(), backColor, borderColor, swimlane)
|
2016-08-25 20:45:37 +00:00
|
|
|
.withWestAndEast(tb1, tb2);
|
|
|
|
} else {
|
2021-10-27 16:43:04 +00:00
|
|
|
shape1 = new FtileDiamondInside(tbTest, tile1.skinParam(), backColor, borderColor, swimlane)
|
2016-08-25 20:45:37 +00:00
|
|
|
.withSouth(tb1).withEast(tb2);
|
|
|
|
}
|
2020-12-06 21:43:09 +00:00
|
|
|
} else if (conditionStyle == ConditionStyle.EMPTY_DIAMOND) {
|
2016-08-25 20:45:37 +00:00
|
|
|
if (eastWest) {
|
2021-10-27 16:43:04 +00:00
|
|
|
shape1 = new FtileDiamond(tile1.skinParam(), backColor, borderColor, swimlane).withNorth(tbTest)
|
2016-08-25 20:45:37 +00:00
|
|
|
.withWestAndEast(tb1, tb2);
|
|
|
|
} else {
|
2021-10-27 16:43:04 +00:00
|
|
|
shape1 = new FtileDiamond(tile1.skinParam(), backColor, borderColor, swimlane).withNorth(tbTest)
|
2016-08-25 20:45:37 +00:00
|
|
|
.withSouth(tb1).withEast(tb2);
|
|
|
|
}
|
2020-12-06 21:43:09 +00:00
|
|
|
} else if (conditionStyle == ConditionStyle.INSIDE_DIAMOND) {
|
2020-11-21 17:33:24 +00:00
|
|
|
if (eastWest) {
|
2021-10-27 16:43:04 +00:00
|
|
|
shape1 = new FtileDiamondSquare(tbTest, tile1.skinParam(), backColor, borderColor, swimlane)
|
2020-11-21 17:33:24 +00:00
|
|
|
.withWestAndEast(tb1, tb2);
|
|
|
|
} else {
|
2021-10-27 16:43:04 +00:00
|
|
|
shape1 = new FtileDiamondSquare(tbTest, tile1.skinParam(), backColor, borderColor, swimlane)
|
2020-12-06 21:43:09 +00:00
|
|
|
.withSouth(tb1).withEast(tb2);
|
2020-11-21 17:33:24 +00:00
|
|
|
}
|
2015-07-11 09:32:49 +00:00
|
|
|
} else {
|
|
|
|
throw new IllegalStateException();
|
|
|
|
}
|
2021-10-27 16:43:04 +00:00
|
|
|
return shape1;
|
2015-07-11 09:32:49 +00:00
|
|
|
}
|
|
|
|
|
2016-09-29 19:51:18 +00:00
|
|
|
private TextBlock getLabelPositive(Branch branch) {
|
2021-10-20 16:33:09 +00:00
|
|
|
return branch.getDisplayPositive().create0(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam(),
|
2021-10-07 16:51:26 +00:00
|
|
|
labelLineBreak, CreoleMode.SIMPLE_LINE, null, null);
|
2015-09-06 17:28:59 +00:00
|
|
|
}
|
|
|
|
|
2021-10-27 16:43:04 +00:00
|
|
|
private Ftile getShape2(Branch branch1, Branch branch2, boolean useNorth) {
|
|
|
|
final Ftile shape2;
|
2019-06-26 19:24:49 +00:00
|
|
|
if (conditionEndStyle == ConditionEndStyle.HLINE) {
|
2021-10-28 17:40:22 +00:00
|
|
|
return new FtileEmpty(tile1.skinParam(), 0, Hexagon.hexagonHalfSize, swimlane);
|
2019-06-26 19:24:49 +00:00
|
|
|
}
|
|
|
|
// else use default ConditionEndStyle.DIAMOND
|
2015-07-11 09:32:49 +00:00
|
|
|
if (hasTwoBranches()) {
|
2016-05-11 21:31:47 +00:00
|
|
|
final Display out1 = branch1.getFtile().getOutLinkRendering().getDisplay();
|
2020-05-17 21:15:50 +00:00
|
|
|
final TextBlock tbout1 = out1 == null ? null
|
|
|
|
: out1.create7(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam(),
|
|
|
|
CreoleMode.SIMPLE_LINE);
|
2016-05-11 21:31:47 +00:00
|
|
|
final Display out2 = branch2.getFtile().getOutLinkRendering().getDisplay();
|
2020-05-17 21:15:50 +00:00
|
|
|
final TextBlock tbout2 = out2 == null ? null
|
|
|
|
: out2.create7(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam(),
|
|
|
|
CreoleMode.SIMPLE_LINE);
|
2016-09-29 19:51:18 +00:00
|
|
|
FtileDiamond tmp = new FtileDiamond(tile1.skinParam(), backColor, borderColor, swimlane);
|
|
|
|
tmp = useNorth ? tmp.withNorth(tbout1) : tmp.withWest(tbout1);
|
|
|
|
tmp = tmp.withEast(tbout2);
|
2021-10-27 16:43:04 +00:00
|
|
|
shape2 = tmp;
|
2015-07-11 09:32:49 +00:00
|
|
|
} else {
|
2021-10-28 17:40:22 +00:00
|
|
|
shape2 = new FtileEmpty(tile1.skinParam(), 0, Hexagon.hexagonHalfSize / 2, swimlane);
|
2015-07-11 09:32:49 +00:00
|
|
|
}
|
2021-10-27 16:43:04 +00:00
|
|
|
return shape2;
|
2015-07-11 09:32:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasTwoBranches() {
|
|
|
|
return tile1.calculateDimension(stringBounder).hasPointOut()
|
|
|
|
&& tile2.calculateDimension(stringBounder).hasPointOut();
|
|
|
|
}
|
|
|
|
|
2016-01-09 12:15:40 +00:00
|
|
|
// private HtmlColor fontColor() {
|
|
|
|
// return skinParam.getFontHtmlColor(FontParam.ACTIVITY_DIAMOND, null);
|
|
|
|
// }
|
2015-07-11 09:32:49 +00:00
|
|
|
|
|
|
|
}
|