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;
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
2016-06-19 14:16:41 +00:00
|
|
|
import net.sourceforge.plantuml.ISkinParam;
|
2020-12-01 21:39:27 +00:00
|
|
|
import net.sourceforge.plantuml.UseStyle;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
|
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
2016-12-01 20:29:25 +00:00
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
2016-05-11 21:31:47 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.Rainbow;
|
2016-07-04 19:06:50 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.color.Colors;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.sequencediagram.NotePosition;
|
2016-05-19 18:41:37 +00:00
|
|
|
import net.sourceforge.plantuml.sequencediagram.NoteType;
|
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.StyleBuilder;
|
|
|
|
import net.sourceforge.plantuml.style.StyleSignature;
|
2020-03-18 10:50:02 +00:00
|
|
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
2013-12-10 19:36:50 +00:00
|
|
|
|
|
|
|
public class Branch {
|
|
|
|
|
|
|
|
private final InstructionList list;
|
|
|
|
private final Display labelTest;
|
2020-11-21 17:33:24 +00:00
|
|
|
|
|
|
|
private final LinkRendering labelPositive;
|
|
|
|
|
2016-05-11 21:31:47 +00:00
|
|
|
private LinkRendering inlinkRendering = LinkRendering.none();
|
2020-11-21 17:33:24 +00:00
|
|
|
private final LinkRendering inlabel;
|
|
|
|
private LinkRendering special;
|
|
|
|
|
|
|
|
private final HColor color;
|
2013-12-10 19:36:50 +00:00
|
|
|
|
|
|
|
private Ftile ftile;
|
|
|
|
|
2019-08-26 17:07:21 +00:00
|
|
|
public StyleSignature getDefaultStyleDefinitionArrow() {
|
|
|
|
return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow);
|
|
|
|
}
|
|
|
|
|
|
|
|
public StyleSignature getDefaultStyleDefinitionDiamond() {
|
|
|
|
return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity, SName.diamond);
|
|
|
|
}
|
|
|
|
|
2019-03-29 22:14:07 +00:00
|
|
|
public boolean containsBreak() {
|
|
|
|
return list.containsBreak();
|
|
|
|
}
|
|
|
|
|
2020-11-21 17:33:24 +00:00
|
|
|
public Branch(StyleBuilder styleBuilder, Swimlane swimlane, LinkRendering labelPositive, Display labelTest,
|
|
|
|
HColor color, LinkRendering inlabel) {
|
2015-07-11 09:32:49 +00:00
|
|
|
if (labelPositive == null) {
|
|
|
|
throw new IllegalArgumentException();
|
|
|
|
}
|
|
|
|
if (labelTest == null) {
|
|
|
|
throw new IllegalArgumentException();
|
|
|
|
}
|
2016-09-29 19:51:18 +00:00
|
|
|
if (inlabel == null) {
|
|
|
|
throw new IllegalArgumentException();
|
|
|
|
}
|
2020-12-01 21:39:27 +00:00
|
|
|
if (UseStyle.useBetaStyle()) {
|
2019-08-26 17:07:21 +00:00
|
|
|
final Style style = getDefaultStyleDefinitionDiamond().getMergedStyle(styleBuilder);
|
2020-11-21 17:33:24 +00:00
|
|
|
this.color = color == null
|
|
|
|
? style.value(PName.BackGroundColor).asColor(styleBuilder.getSkinParam().getIHtmlColorSet())
|
|
|
|
: color;
|
2019-08-26 17:07:21 +00:00
|
|
|
} else {
|
|
|
|
this.color = color;
|
|
|
|
}
|
|
|
|
|
2016-09-29 19:51:18 +00:00
|
|
|
this.inlabel = inlabel;
|
2013-12-10 19:36:50 +00:00
|
|
|
this.list = new InstructionList(swimlane);
|
|
|
|
this.labelTest = labelTest;
|
|
|
|
this.labelPositive = labelPositive;
|
|
|
|
}
|
2018-09-23 12:15:14 +00:00
|
|
|
|
2016-12-01 20:29:25 +00:00
|
|
|
public Collection<WeldingPoint> getWeldingPoints() {
|
|
|
|
return ftile.getWeldingPoints();
|
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public void add(Instruction ins) {
|
|
|
|
list.add(ins);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean kill() {
|
|
|
|
return list.kill();
|
|
|
|
}
|
|
|
|
|
2017-05-10 19:51:15 +00:00
|
|
|
public boolean addNote(Display note, NotePosition position, NoteType type, Colors colors, Swimlane swimlaneNote) {
|
|
|
|
return list.addNote(note, position, type, colors, swimlaneNote);
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final void setInlinkRendering(LinkRendering inlinkRendering) {
|
2016-05-11 21:31:47 +00:00
|
|
|
if (inlinkRendering == null) {
|
|
|
|
throw new IllegalArgumentException();
|
|
|
|
}
|
2013-12-10 19:36:50 +00:00
|
|
|
this.inlinkRendering = inlinkRendering;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updateFtile(FtileFactory factory) {
|
|
|
|
this.ftile = factory.decorateOut(list.createFtile(factory), inlinkRendering);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Collection<? extends Swimlane> getSwimlanes() {
|
|
|
|
return list.getSwimlanes();
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Display getLabelPositive() {
|
2015-04-07 18:18:37 +00:00
|
|
|
final LinkRendering in = ftile.getInLinkRendering();
|
2015-07-11 09:32:49 +00:00
|
|
|
if (in != null && Display.isNull(in.getDisplay()) == false) {
|
2015-04-07 18:18:37 +00:00
|
|
|
return in.getDisplay();
|
|
|
|
}
|
2020-11-21 17:33:24 +00:00
|
|
|
return labelPositive.getDisplay();
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final Display getLabelTest() {
|
|
|
|
return labelTest;
|
|
|
|
}
|
|
|
|
|
2020-11-21 17:33:24 +00:00
|
|
|
public final Rainbow getOut() {
|
|
|
|
if (special != null) {
|
|
|
|
return special.getRainbow();
|
|
|
|
}
|
|
|
|
// if (labelPositive.getRainbow().size() > 0) {
|
|
|
|
// return labelPositive.getRainbow();
|
|
|
|
// }
|
|
|
|
if (inlinkRendering == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return inlinkRendering.getRainbow();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Rainbow getInColor(Rainbow arrowColor) {
|
|
|
|
if (isEmpty()) {
|
|
|
|
return getFtile().getOutLinkRendering().getRainbow(arrowColor);
|
|
|
|
}
|
|
|
|
if (labelPositive.getRainbow().size() > 0) {
|
|
|
|
return labelPositive.getRainbow();
|
|
|
|
}
|
|
|
|
final LinkRendering linkIn = getFtile().getInLinkRendering();
|
|
|
|
final Rainbow color = linkIn.getRainbow(arrowColor);
|
|
|
|
if (color.size() == 0) {
|
|
|
|
return arrowColor;
|
|
|
|
}
|
|
|
|
return color;
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
2016-09-29 19:51:18 +00:00
|
|
|
public Display getInlabel() {
|
2020-11-21 17:33:24 +00:00
|
|
|
return inlabel.getDisplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Rainbow getInRainbow(Rainbow defaultColor) {
|
|
|
|
return inlabel.getRainbow(defaultColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Rainbow getLabelPositiveRainbow(Rainbow defaultColor) {
|
|
|
|
return labelPositive.getRainbow(defaultColor);
|
2016-09-29 19:51:18 +00:00
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public final Ftile getFtile() {
|
|
|
|
return ftile;
|
|
|
|
}
|
|
|
|
|
2016-06-19 14:16:41 +00:00
|
|
|
public ISkinParam skinParam() {
|
|
|
|
return ftile.skinParam();
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
2015-04-07 18:18:37 +00:00
|
|
|
|
2020-03-18 10:50:02 +00:00
|
|
|
public final HColor getColor() {
|
2015-04-07 18:18:37 +00:00
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isEmpty() {
|
|
|
|
return list.isEmpty();
|
|
|
|
}
|
|
|
|
|
2015-09-06 17:28:59 +00:00
|
|
|
public Instruction getLast() {
|
|
|
|
return list.getLast();
|
|
|
|
}
|
|
|
|
|
2018-03-09 21:37:34 +00:00
|
|
|
public boolean isOnlySingleStopOrSpot() {
|
|
|
|
return list.isOnlySingleStopOrSpot();
|
2016-08-25 20:45:37 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 12:15:14 +00:00
|
|
|
public void setSpecial(LinkRendering link) {
|
|
|
|
this.special = link;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final LinkRendering getSpecial() {
|
|
|
|
return special;
|
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|