1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-01 17:24:01 +00:00
This commit is contained in:
Arnaud Roques 2021-11-08 18:23:42 +01:00
parent 562cad88bc
commit 69d735e7ae
7 changed files with 50 additions and 103 deletions

View File

@ -102,8 +102,6 @@ public class InstructionSplit extends AbstractInstruction implements Instruction
all.add(tmp); 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()); return new GtileSplit(all, swimlaneIn, getInLinkRenderingColor(skinParam).getColor());
} }

View File

@ -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);
}
}

View File

@ -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() { final public StyleSignature getDefaultStyleDefinitionActivity() {
return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity); return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity);
} }
@ -87,10 +75,19 @@ public class GtileSplit extends GtileColumns {
@Override @Override
protected void drawUInternal(UGraphic ug) { protected void drawUInternal(UGraphic ug) {
super.drawUInternal(ug); super.drawUInternal(ug);
gtiles.get(0).getCoord(GPoint.NORTH_HOOK);
ug.apply(lineColor).apply(new UStroke(1.5)) final double x0 = gtiles.get(0).getCoord(GPoint.NORTH_HOOK).compose(positions.get(0)).getDx();
.apply(UTranslate.dx(gtiles.get(0).getCoord(GPoint.NORTH_HOOK).getDx())).apply(positions.get(0)) assert gtiles.size() == positions.size();
.draw(ULine.hline(10)); 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 @Override

View File

@ -36,6 +36,8 @@
package net.sourceforge.plantuml.core; package net.sourceforge.plantuml.core;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -147,6 +149,10 @@ final public class UmlSource {
return new IteratorCounter2Impl(source); return new IteratorCounter2Impl(source);
} }
public Iterator<StringLocated> iteratorRaw() {
return Collections.unmodifiableCollection(rawSource).iterator();
}
/** /**
* Return the source as a single String with <code>\n</code> as line separator. * Return the source as a single String with <code>\n</code> as line separator.
* *

View File

@ -63,7 +63,7 @@ public class JsonDiagramFactory extends PSystemAbstractFactory {
JsonValue json; JsonValue json;
try { try {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
styleExtractor = new StyleExtractor(source.iterator2()); styleExtractor = new StyleExtractor(source.iteratorRaw(), source.iterator2());
final Iterator<String> it = styleExtractor.getIterator(); final Iterator<String> it = styleExtractor.getIterator();
it.next(); it.next();
while (true) { while (true) {

View File

@ -51,21 +51,40 @@ public class StyleExtractor {
private final List<String> list = new ArrayList<>(); private final List<String> list = new ArrayList<>();
private final List<StringLocated> style = new ArrayList<>(); private final List<StringLocated> style = new ArrayList<>();
public StyleExtractor(Iterator<StringLocated> data) { public StyleExtractor(Iterator<StringLocated> dataRaw, Iterator<StringLocated> data) {
while (data.hasNext()) { while (dataRaw.hasNext()) {
StringLocated line = data.next(); StringLocated lineRaw = dataRaw.next();
if (line.getString().trim().equals("<style>")) { if (startStyle(lineRaw)) {
while (data.hasNext()) { while (dataRaw.hasNext()) {
style.add(line); style.add(lineRaw);
if (line.getString().trim().equals("</style>")) { if (endStyle(lineRaw))
break; break;
} lineRaw = dataRaw.next();
line = data.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 { } else {
list.add(line.getString()); list.add(lineRaw.getString());
} }
} }
}
private boolean startStyle(StringLocated line) {
return line.getString().trim().equals("<style>");
}
private boolean endStyle(StringLocated line) {
return line.getString().trim().equals("</style>");
} }
public void applyStyles(ISkinParam skinParam) { public void applyStyles(ISkinParam skinParam) {

View File

@ -62,7 +62,7 @@ public class YamlDiagramFactory extends PSystemAbstractFactory {
StyleExtractor styleExtractor = null; StyleExtractor styleExtractor = null;
try { try {
final List<String> list = new ArrayList<>(); final List<String> list = new ArrayList<>();
styleExtractor = new StyleExtractor(source.iterator2()); styleExtractor = new StyleExtractor(source.iteratorRaw(), source.iterator2());
final Iterator<String> it = styleExtractor.getIterator(); final Iterator<String> it = styleExtractor.getIterator();
it.next(); it.next();
while (true) { while (true) {