diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java index ccd48090d..95d77267f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java @@ -102,8 +102,6 @@ public class InstructionSplit extends AbstractInstruction implements Instruction all.add(tmp); } -// final GtileColumns tmp = new GtileColumns(all, swimlaneIn); -// return new GtileSplit(tmp, getInLinkRenderingColor(skinParam).getColor()); return new GtileSplit(all, swimlaneIn, getInLinkRenderingColor(skinParam).getColor()); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileHLine.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileHLine.java deleted file mode 100644 index 4dfa5b156..000000000 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileHLine.java +++ /dev/null @@ -1,73 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * 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 - * - * 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.gtile; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.ugraphic.color.HColor; - -public class GtileHLine extends AbstractGtile { - - private final double start; - private final double width; - private final HColor lineColor; - - public GtileHLine(StringBounder stringBounder, ISkinParam skinParam, Swimlane swimlane, HColor lineColor) { - super(stringBounder, skinParam, swimlane); - this.start = 0; - this.width = 10; - this.lineColor = lineColor; - } - - @Override - protected void drawUInternal(UGraphic ug) { - ug.apply(lineColor).apply(new UStroke(1.5)).apply(UTranslate.dx(start)).draw(ULine.hline(width)); - } - - @Override - public Dimension2D calculateDimension(StringBounder stringBounder) { - return new Dimension2DDouble(width, 1.5); - } - -} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileSplit.java index 1c5dde47f..dddd1ea15 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileSplit.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileSplit.java @@ -60,18 +60,6 @@ public class GtileSplit extends GtileColumns { } - private static Gtile getShape1(Swimlane swimlane, HColor color, StringBounder stringBounder, ISkinParam skinParam, - Gtile first) { - final double start = first.getCoord(GPoint.NORTH_HOOK).getDx(); - final GtileHLine tmp = new GtileHLine(stringBounder, skinParam, swimlane, color); - return tmp; - } - - private static Gtile getShape2(Swimlane swimlane, HColor color, StringBounder stringBounder, ISkinParam skinParam) { - final GtileHLine tmp = new GtileHLine(stringBounder, skinParam, swimlane, color); - return tmp; - } - final public StyleSignature getDefaultStyleDefinitionActivity() { return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity); } @@ -87,10 +75,19 @@ public class GtileSplit extends GtileColumns { @Override protected void drawUInternal(UGraphic ug) { super.drawUInternal(ug); - gtiles.get(0).getCoord(GPoint.NORTH_HOOK); - ug.apply(lineColor).apply(new UStroke(1.5)) - .apply(UTranslate.dx(gtiles.get(0).getCoord(GPoint.NORTH_HOOK).getDx())).apply(positions.get(0)) - .draw(ULine.hline(10)); + + final double x0 = gtiles.get(0).getCoord(GPoint.NORTH_HOOK).compose(positions.get(0)).getDx(); + assert gtiles.size() == positions.size(); + final int last = gtiles.size() - 1; + final double xLast = gtiles.get(last).getCoord(GPoint.NORTH_HOOK).compose(positions.get(last)).getDx(); + final ULine hline = ULine.hline(xLast - x0); + + ug = ug.apply(lineColor).apply(new UStroke(1.5)); + ug.apply(UTranslate.dx(x0)).draw(hline); + + final double y = getCoord(GPoint.SOUTH_BORDER).getDy(); + ug.apply(new UTranslate(x0, y)).draw(hline); + } @Override diff --git a/src/net/sourceforge/plantuml/core/UmlSource.java b/src/net/sourceforge/plantuml/core/UmlSource.java index 78f973d04..f2fac7a5b 100644 --- a/src/net/sourceforge/plantuml/core/UmlSource.java +++ b/src/net/sourceforge/plantuml/core/UmlSource.java @@ -36,6 +36,8 @@ package net.sourceforge.plantuml.core; import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -147,6 +149,10 @@ final public class UmlSource { return new IteratorCounter2Impl(source); } + public Iterator iteratorRaw() { + return Collections.unmodifiableCollection(rawSource).iterator(); + } + /** * Return the source as a single String with \n as line separator. * diff --git a/src/net/sourceforge/plantuml/jsondiagram/JsonDiagramFactory.java b/src/net/sourceforge/plantuml/jsondiagram/JsonDiagramFactory.java index daca00169..17ba7768c 100644 --- a/src/net/sourceforge/plantuml/jsondiagram/JsonDiagramFactory.java +++ b/src/net/sourceforge/plantuml/jsondiagram/JsonDiagramFactory.java @@ -63,7 +63,7 @@ public class JsonDiagramFactory extends PSystemAbstractFactory { JsonValue json; try { final StringBuilder sb = new StringBuilder(); - styleExtractor = new StyleExtractor(source.iterator2()); + styleExtractor = new StyleExtractor(source.iteratorRaw(), source.iterator2()); final Iterator it = styleExtractor.getIterator(); it.next(); while (true) { diff --git a/src/net/sourceforge/plantuml/jsondiagram/StyleExtractor.java b/src/net/sourceforge/plantuml/jsondiagram/StyleExtractor.java index f4b9c8583..93094feef 100644 --- a/src/net/sourceforge/plantuml/jsondiagram/StyleExtractor.java +++ b/src/net/sourceforge/plantuml/jsondiagram/StyleExtractor.java @@ -51,21 +51,40 @@ public class StyleExtractor { private final List list = new ArrayList<>(); private final List style = new ArrayList<>(); - public StyleExtractor(Iterator data) { - while (data.hasNext()) { - StringLocated line = data.next(); - if (line.getString().trim().equals("")) { + public StyleExtractor(Iterator dataRaw, Iterator data) { + while (dataRaw.hasNext()) { + StringLocated lineRaw = dataRaw.next(); + if (startStyle(lineRaw)) { + while (dataRaw.hasNext()) { + style.add(lineRaw); + if (endStyle(lineRaw)) break; - } - line = data.next(); + lineRaw = dataRaw.next(); + } + } else if (lineRaw.getString().trim().startsWith("!theme ")) { + while (data.hasNext()) { + StringLocated line = data.next(); + if (startStyle(line)) + while (data.hasNext()) { + style.add(line); + if (endStyle(line)) + break; + line = data.next(); + } } } else { - list.add(line.getString()); + list.add(lineRaw.getString()); } } + + } + + private boolean startStyle(StringLocated line) { + return line.getString().trim().equals(""); } public void applyStyles(ISkinParam skinParam) { diff --git a/src/net/sourceforge/plantuml/yaml/YamlDiagramFactory.java b/src/net/sourceforge/plantuml/yaml/YamlDiagramFactory.java index 133fdd6f7..1173b2975 100644 --- a/src/net/sourceforge/plantuml/yaml/YamlDiagramFactory.java +++ b/src/net/sourceforge/plantuml/yaml/YamlDiagramFactory.java @@ -62,7 +62,7 @@ public class YamlDiagramFactory extends PSystemAbstractFactory { StyleExtractor styleExtractor = null; try { final List list = new ArrayList<>(); - styleExtractor = new StyleExtractor(source.iterator2()); + styleExtractor = new StyleExtractor(source.iteratorRaw(), source.iterator2()); final Iterator it = styleExtractor.getIterator(); it.next(); while (true) {