1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-26 06:46:45 +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);
}
// final GtileColumns tmp = new GtileColumns(all, swimlaneIn);
// return new GtileSplit(tmp, 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() {
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

View File

@ -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<StringLocated> iteratorRaw() {
return Collections.unmodifiableCollection(rawSource).iterator();
}
/**
* 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;
try {
final StringBuilder sb = new StringBuilder();
styleExtractor = new StyleExtractor(source.iterator2());
styleExtractor = new StyleExtractor(source.iteratorRaw(), source.iterator2());
final Iterator<String> it = styleExtractor.getIterator();
it.next();
while (true) {

View File

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

View File

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