1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-02 00:20:49 +00:00
plantuml/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/UGraphicInterceptorOneSwimlane.java

109 lines
3.6 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;
2020-04-19 16:04:39 +00:00
import java.util.Collections;
import java.util.List;
2013-12-10 19:36:50 +00:00
import java.util.Set;
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.graphic.UGraphicDelegator;
import net.sourceforge.plantuml.ugraphic.UChange;
import net.sourceforge.plantuml.ugraphic.UGraphic;
2015-04-07 18:18:37 +00:00
import net.sourceforge.plantuml.ugraphic.ULine;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.ugraphic.UShape;
2020-03-18 10:50:02 +00:00
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
2013-12-10 19:36:50 +00:00
public class UGraphicInterceptorOneSwimlane extends UGraphicDelegator {
private final Swimlane swimlane;
2020-04-19 16:04:39 +00:00
private final List<Swimlane> orderedList;
2013-12-10 19:36:50 +00:00
2020-04-19 16:04:39 +00:00
public UGraphicInterceptorOneSwimlane(UGraphic ug, Swimlane swimlane, List<Swimlane> orderedList) {
2013-12-10 19:36:50 +00:00
super(ug);
this.swimlane = swimlane;
2020-04-19 16:04:39 +00:00
this.orderedList = orderedList;
2013-12-10 19:36:50 +00:00
}
public void draw(UShape shape) {
// System.err.println("inter=" + shape.getClass());
if (shape instanceof Ftile) {
final Ftile tile = (Ftile) shape;
final Set<Swimlane> swinlanes = tile.getSwimlanes();
final boolean contained = swinlanes.contains(swimlane);
if (contained) {
2015-04-07 18:18:37 +00:00
tile.drawU(this);
// drawGoto();
2013-12-10 19:36:50 +00:00
}
} else if (shape instanceof Connection) {
final Connection connection = (Connection) shape;
final Ftile tile1 = connection.getFtile1();
final Ftile tile2 = connection.getFtile2();
final boolean contained1 = tile1 == null || tile1.getSwimlaneOut() == null
|| tile1.getSwimlaneOut() == swimlane;
final boolean contained2 = tile2 == null || tile2.getSwimlaneIn() == null
|| tile2.getSwimlaneIn() == swimlane;
2015-04-07 18:18:37 +00:00
2013-12-10 19:36:50 +00:00
if (contained1 && contained2) {
connection.drawU(this);
}
} else {
getUg().draw(shape);
// System.err.println("Drawing " + shape);
}
}
2015-04-07 18:18:37 +00:00
private void drawGoto() {
2020-04-19 16:04:39 +00:00
final UGraphic ugGoto = getUg().apply(HColorUtils.GREEN).apply(HColorUtils.GREEN.bg());
2015-04-07 18:18:37 +00:00
ugGoto.draw(new ULine(100, 100));
}
2013-12-10 19:36:50 +00:00
public UGraphic apply(UChange change) {
2020-04-19 16:04:39 +00:00
return new UGraphicInterceptorOneSwimlane(getUg().apply(change), swimlane, orderedList);
2013-12-10 19:36:50 +00:00
}
2015-06-07 10:23:10 +00:00
public final Swimlane getSwimlane() {
return swimlane;
}
2020-04-19 16:04:39 +00:00
public final List<Swimlane> getOrderedListOfAllSwimlanes() {
return Collections.unmodifiableList(orderedList);
}
2013-12-10 19:36:50 +00:00
}