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/Branch.java

192 lines
5.4 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;
import java.util.Collection;
2016-06-19 14:16:41 +00:00
import net.sourceforge.plantuml.ISkinParam;
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.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;
import net.sourceforge.plantuml.graphic.HtmlColor;
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;
2013-12-10 19:36:50 +00:00
public class Branch {
private final InstructionList list;
private final Display labelTest;
private final Display labelPositive;
2016-09-29 19:51:18 +00:00
private final Display inlabel;
2015-04-07 18:18:37 +00:00
private final HtmlColor color;
2016-05-11 21:31:47 +00:00
private LinkRendering inlinkRendering = LinkRendering.none();
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();
}
2019-08-26 17:07:21 +00:00
public Branch(StyleBuilder styleBuilder, Swimlane swimlane, Display labelPositive, Display labelTest,
HtmlColor color, Display 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();
}
2019-08-26 17:07:21 +00:00
if (SkinParam.USE_STYLES()) {
final Style style = getDefaultStyleDefinitionDiamond().getMergedStyle(styleBuilder);
this.color = color == null ? style.value(PName.BackGroundColor).asColor(
styleBuilder.getSkinParam().getIHtmlColorSet()) : color;
} 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();
}
2013-12-10 19:36:50 +00:00
return labelPositive;
}
public final Display getLabelTest() {
return labelTest;
}
2016-05-11 21:31:47 +00:00
public final Rainbow getInlinkRenderingColorAndStyle() {
return inlinkRendering == null ? null : inlinkRendering.getRainbow();
2013-12-10 19:36:50 +00:00
}
2016-09-29 19:51:18 +00:00
public Display getInlabel() {
return inlabel;
}
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
public final HtmlColor getColor() {
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
private LinkRendering special;
public void setSpecial(LinkRendering link) {
this.special = link;
}
public final LinkRendering getSpecial() {
return special;
}
2013-12-10 19:36:50 +00:00
}