1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-05-31 23:50:49 +00:00
plantuml/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java

155 lines
6.5 KiB
Java
Raw Normal View History

2013-12-10 19:36:50 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2019-01-16 18:34:41 +00:00
* (C) Copyright 2009-2020, Arnaud Roques
2013-12-10 19:36:50 +00:00
*
2016-03-06 16:47:34 +00:00
* Project Info: http://plantuml.com
2013-12-10 19:36:50 +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
*
2013-12-10 19:36:50 +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;
2016-12-14 21:01:03 +00:00
import java.awt.geom.Dimension2D;
2016-12-01 20:29:25 +00:00
import java.util.List;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.FontParam;
2019-08-26 17:07:21 +00:00
import net.sourceforge.plantuml.SkinParam;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
2016-12-14 21:01:03 +00:00
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
2017-04-05 17:37:42 +00:00
import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
2016-12-14 21:01:03 +00:00
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
2016-12-01 20:29:25 +00:00
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileBreak;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
2016-12-14 21:01:03 +00:00
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
import net.sourceforge.plantuml.activitydiagram3.ftile.Genealogy;
import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
2016-12-01 20:29:25 +00:00
import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.cucadiagram.Display;
2015-09-28 20:42:17 +00:00
import net.sourceforge.plantuml.graphic.FontConfiguration;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.graphic.HtmlColor;
2016-05-11 21:31:47 +00:00
import net.sourceforge.plantuml.graphic.Rainbow;
2017-04-05 17:37:42 +00:00
import net.sourceforge.plantuml.graphic.color.Colors;
2019-08-26 17:07:21 +00:00
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.Style;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.svek.ConditionStyle;
2016-12-14 21:01:03 +00:00
import net.sourceforge.plantuml.ugraphic.UGraphic;
2016-12-01 20:29:25 +00:00
import net.sourceforge.plantuml.ugraphic.UTranslate;
2013-12-10 19:36:50 +00:00
public class FtileFactoryDelegatorRepeat extends FtileFactoryDelegator {
2016-06-19 14:16:41 +00:00
public FtileFactoryDelegatorRepeat(FtileFactory factory) {
super(factory);
2013-12-10 19:36:50 +00:00
}
@Override
2017-04-05 17:37:42 +00:00
public Ftile repeat(Swimlane swimlane, Swimlane swimlaneOut, Display startLabel, final Ftile repeat, Display test,
2017-10-07 09:46:53 +00:00
Display yes, Display out, HtmlColor color, LinkRendering backRepeatLinkRendering, Ftile backward,
boolean noOut) {
2016-12-01 20:29:25 +00:00
2016-06-19 14:16:41 +00:00
final ConditionStyle conditionStyle = skinParam().getConditionStyle();
2013-12-10 19:36:50 +00:00
2019-08-26 17:07:21 +00:00
final HtmlColor borderColor;
final HtmlColor backColor;
final Rainbow arrowColor;
final FontConfiguration fcDiamond;
final FontConfiguration fcArrow;
if (SkinParam.USE_STYLES()) {
final Style styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle(
skinParam().getCurrentStyleBuilder());
final Style styleDiamond = getDefaultStyleDefinitionDiamond().getMergedStyle(
skinParam().getCurrentStyleBuilder());
borderColor = styleDiamond.value(PName.LineColor).asColor(skinParam().getIHtmlColorSet());
backColor = styleDiamond.value(PName.BackGroundColor).asColor(skinParam().getIHtmlColorSet());
arrowColor = Rainbow.build(styleArrow, skinParam().getIHtmlColorSet());
fcDiamond = styleDiamond.getFontConfiguration(skinParam().getIHtmlColorSet());
fcArrow = styleArrow.getFontConfiguration(skinParam().getIHtmlColorSet());
} else {
borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder);
backColor = color == null ? getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground)
: color;
arrowColor = Rainbow.build(skinParam());
fcDiamond = new FontConfiguration(skinParam(), FontParam.ACTIVITY_DIAMOND, null);
fcArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null);
}
2013-12-10 19:36:50 +00:00
final LinkRendering endRepeatLinkRendering = repeat.getOutLinkRendering();
2016-06-19 14:16:41 +00:00
final Rainbow endRepeatLinkColor = endRepeatLinkRendering == null ? null : endRepeatLinkRendering.getRainbow();
2013-12-10 19:36:50 +00:00
2017-04-05 17:37:42 +00:00
final Ftile backStart = Display.isNull(startLabel) ? null : this.activity(startLabel, swimlane, BoxStyle.PLAIN,
Colors.empty());
Ftile result = FtileRepeat.create(backRepeatLinkRendering, swimlane, swimlaneOut, backStart, repeat, test, yes,
out, borderColor, backColor, arrowColor, endRepeatLinkColor, conditionStyle, this.skinParam(),
2017-10-07 09:46:53 +00:00
fcDiamond, fcArrow, backward, noOut);
2016-12-01 20:29:25 +00:00
final List<WeldingPoint> weldingPoints = repeat.getWeldingPoints();
if (weldingPoints.size() > 0) {
2016-12-14 21:01:03 +00:00
// printAllChild(repeat);
2016-12-01 20:29:25 +00:00
final Ftile diamondBreak = new FtileDiamond(repeat.skinParam(), backColor, borderColor, swimlane);
2016-12-21 22:10:29 +00:00
result = assembly(FtileUtils.addHorizontalMargin(result, 10, 0), diamondBreak);
2016-12-14 21:01:03 +00:00
final Genealogy genealogy = new Genealogy(result);
2016-12-01 20:29:25 +00:00
final FtileBreak ftileBreak = (FtileBreak) weldingPoints.get(0);
2016-12-14 21:01:03 +00:00
result = FtileUtils.addConnection(result, new Connection() {
public void drawU(UGraphic ug) {
final UTranslate tr1 = genealogy.getTranslate(ftileBreak, ug.getStringBounder());
final UTranslate tr2 = genealogy.getTranslate(diamondBreak, ug.getStringBounder());
final Dimension2D dimDiamond = diamondBreak.calculateDimension(ug.getStringBounder());
2017-10-07 09:46:53 +00:00
final Snake snake = new Snake(getFtile1().arrowHorizontalAlignment(), arrowColor, Arrows
.asToRight());
2016-12-14 21:01:03 +00:00
snake.addPoint(tr1.getDx(), tr1.getDy());
snake.addPoint(0, tr1.getDy());
snake.addPoint(0, tr2.getDy() + dimDiamond.getHeight() / 2);
snake.addPoint(tr2.getDx(), tr2.getDy() + dimDiamond.getHeight() / 2);
ug.draw(snake);
}
public Ftile getFtile1() {
return ftileBreak;
}
public Ftile getFtile2() {
return diamondBreak;
}
});
2016-12-01 20:29:25 +00:00
}
return result;
2015-09-28 20:42:17 +00:00
}
2013-12-10 19:36:50 +00:00
}