1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-22 04:55:10 +00:00
Arnaud Roques 2023-03-20 23:19:33 +01:00
parent 05fbba535e
commit 897a4736bc
12 changed files with 38 additions and 263 deletions

View File

@ -92,7 +92,13 @@ public class InstructionList extends WithNote implements Instruction, Instructio
if (getLast() instanceof InstructionSpot)
return true;
return getLast() instanceof InstructionStop && ((InstructionStop) getLast()).hasNotes() == false;
if (getLast() instanceof InstructionStop)
return ((InstructionStop) getLast()).hasNotes() == false;
if (getLast() instanceof InstructionEnd)
return ((InstructionEnd) getLast()).hasNotes() == false;
return false;
}
@Override

View File

@ -1,244 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2024, Arnaud Roques
*
* Project Info: https://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* https://plantuml.com/patreon (only 1$ per month!)
* https://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.ftile.vcompact;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.activitydiagram3.Branch;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon;
import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
import net.sourceforge.plantuml.decoration.Rainbow;
import net.sourceforge.plantuml.klimt.LineBreakStrategy;
import net.sourceforge.plantuml.klimt.UStroke;
import net.sourceforge.plantuml.klimt.UTranslate;
import net.sourceforge.plantuml.klimt.color.HColor;
import net.sourceforge.plantuml.klimt.creole.CreoleMode;
import net.sourceforge.plantuml.klimt.creole.Display;
import net.sourceforge.plantuml.klimt.creole.Sheet;
import net.sourceforge.plantuml.klimt.creole.SheetBlock1;
import net.sourceforge.plantuml.klimt.creole.SheetBlock2;
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
import net.sourceforge.plantuml.klimt.font.FontConfiguration;
import net.sourceforge.plantuml.klimt.font.StringBounder;
import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment;
import net.sourceforge.plantuml.klimt.geom.XDimension2D;
import net.sourceforge.plantuml.klimt.geom.XPoint2D;
import net.sourceforge.plantuml.klimt.shape.TextBlock;
import net.sourceforge.plantuml.style.ISkinParam;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignatureBasic;
import net.sourceforge.plantuml.svek.ConditionStyle;
class FtileIfAndStop extends AbstractFtile {
private final Ftile tile1;
private final Ftile diamond1;
private final Ftile stop2;
private final Rainbow arrowColor;
private FtileIfAndStop(Ftile diamond1, Ftile tile1, Rainbow arrowColor, Ftile stopFtile) {
super(tile1.skinParam());
this.diamond1 = diamond1;
this.tile1 = tile1;
this.stop2 = stopFtile;
this.arrowColor = arrowColor;
}
public Set<Swimlane> getSwimlanes() {
final Set<Swimlane> result = new HashSet<>();
if (getSwimlaneIn() != null)
result.add(getSwimlaneIn());
result.addAll(tile1.getSwimlanes());
return Collections.unmodifiableSet(result);
}
public Swimlane getSwimlaneIn() {
return diamond1.getSwimlaneIn();
}
public Swimlane getSwimlaneOut() {
return getSwimlaneIn();
}
static Ftile create(Swimlane swimlane, HColor borderColor, HColor backColor, Rainbow arrowColor,
FtileFactory ftileFactory, ConditionStyle conditionStyle, Branch nonStop, ISkinParam skinParam,
StringBounder stringBounder, Display labelTest) {
final Ftile tileNonStop = nonStop.getFtile();
final Ftile stopFtile = ftileFactory.stop(swimlane);
final Style style = StyleSignatureBasic.activityDiamond().getMergedStyle(skinParam.getCurrentStyleBuilder());
final UStroke thickness = tileNonStop.getThickness(style);
final FontConfiguration fcTest = FontConfiguration.create(skinParam, style);
final Sheet sheet = skinParam
.sheet(fcTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), CreoleMode.FULL)
.createSheet(labelTest);
final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding());
final TextBlock tbTest = new SheetBlock2(sheetBlock1, Hexagon.asStencil(sheetBlock1), thickness);
final Ftile diamond1;
if (conditionStyle == ConditionStyle.INSIDE_HEXAGON)
diamond1 = new FtileDiamondInside(tbTest, tileNonStop.skinParam(), backColor, borderColor, swimlane);
else if (conditionStyle == ConditionStyle.EMPTY_DIAMOND)
diamond1 = new FtileDiamond(tileNonStop.skinParam(), backColor, borderColor, swimlane).withNorth(tbTest);
else
throw new IllegalStateException();
final FtileIfAndStop result = new FtileIfAndStop(diamond1, tileNonStop, arrowColor, stopFtile);
final List<Connection> conns = new ArrayList<>();
conns.add(result.new ConnectionHorizontal(arrowColor));
return FtileUtils.addConnection(result, conns);
}
private UTranslate getTranslate1(StringBounder stringBounder) {
final FtileGeometry dimTotal = calculateDimension(stringBounder);
final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
final FtileGeometry dim1 = tile1.calculateDimension(stringBounder);
final double x1 = calculateDimension(stringBounder).getLeft() - dim1.getLeft();
final double y1 = dimDiamond1.getHeight() + getSuppHeight();
return new UTranslate(x1, y1);
}
private int getSuppHeight() {
return 30;
}
private UTranslate getTranslateDiamond1(StringBounder stringBounder) {
final double y1 = 0;
final XDimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
final double x1 = calculateDimension(stringBounder).getLeft() - dimDiamond1.getWidth() / 2;
return new UTranslate(x1, y1);
}
private UTranslate getTranslateStop(StringBounder stringBounder) {
final XDimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
final XDimension2D dimStop = stop2.calculateDimension(stringBounder);
final double y1 = (dimDiamond1.getHeight() - dimStop.getHeight()) / 2;
final double x1 = calculateDimension(stringBounder).getLeft() + dimDiamond1.getWidth() / 2
+ getDiamondStopDistance();
return new UTranslate(x1, y1);
}
private double getDiamondStopDistance() {
return 40;
}
class ConnectionHorizontal extends AbstractConnection {
private final Rainbow color;
public ConnectionHorizontal(Rainbow color) {
super(diamond1, stop2);
this.color = color;
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final XPoint2D p1 = getP1(stringBounder);
final XPoint2D p2 = getP2(stringBounder);
final Snake snake = Snake.create(skinParam(), color, skinParam().arrows().asToRight());
snake.addPoint(p1);
snake.addPoint(p2);
ug.draw(snake);
}
private XPoint2D getP1(StringBounder stringBounder) {
final XDimension2D dimDiamond1 = getFtile1().calculateDimension(stringBounder);
final XPoint2D p = new XPoint2D(dimDiamond1.getWidth(), dimDiamond1.getHeight() / 2);
return getTranslateDiamond1(stringBounder).getTranslated(p);
}
private XPoint2D getP2(StringBounder stringBounder) {
final XDimension2D dimStop = getFtile2().calculateDimension(stringBounder);
final XPoint2D p = new XPoint2D(0, dimStop.getHeight() / 2);
return getTranslateStop(stringBounder).getTranslated(p);
}
}
@Override
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
if (child == diamond1)
return getTranslateDiamond1(stringBounder);
if (child == tile1)
return getTranslate1(stringBounder);
throw new UnsupportedOperationException();
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1);
ug.apply(getTranslate1(stringBounder)).draw(tile1);
ug.apply(getTranslateStop(stringBounder)).draw(stop2);
}
@Override
protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder) {
final XDimension2D dimStop2 = stop2.calculateDimension(stringBounder);
final FtileGeometry dim1 = tile1.calculateDimension(stringBounder).addDim(0,
getDiamondStopDistance() + dimStop2.getWidth());
final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
return dimDiamond1.appendBottom(dim1).addDim(0, getSuppHeight());
}
}

View File

@ -264,7 +264,7 @@ public class SmetanaForJson {
private String getDotLabelArray(double widthA, double widthB, double[] lineHeights) {
final int size = lineHeights.length;
final double height = 0;
final StringBuilder sb = new StringBuilder("");
for (int i = 0; i < size; i++) {

View File

@ -72,6 +72,9 @@ import net.sourceforge.plantuml.yaml.Highlighted;
public class TextBlockJson extends AbstractTextBlock {
// ::remove folder when __HAXE__
private static final double MIN_WIDTH = 30;
private static final double MIN_HEIGHT = 15;
private final List<Line> lines = new ArrayList<>();
private final ISkinParam skinParam;
@ -232,8 +235,9 @@ public class TextBlockJson extends AbstractTextBlock {
}
public XDimension2D calculateDimension(StringBounder stringBounder) {
return new XDimension2D(getWidthColA(stringBounder) + getWidthColB(stringBounder),
getTotalHeight(stringBounder));
final double width = getWidthColA(stringBounder) + getWidthColB(stringBounder);
final double height = getTotalHeight(stringBounder);
return new XDimension2D(width, height);
}
public double getWidthColA(StringBounder stringBounder) {
@ -270,9 +274,9 @@ public class TextBlockJson extends AbstractTextBlock {
y += heightOfRow;
}
if (y == 0)
y = 15;
y = MIN_HEIGHT;
if (trueWidth == 0)
trueWidth = 30;
trueWidth = MIN_WIDTH;
final double round = styleNode.value(PName.RoundCorner).asDouble();
final URectangle fullNodeRectangle = URectangle.build(trueWidth, y).rounded(round);
@ -320,6 +324,9 @@ public class TextBlockJson extends AbstractTextBlock {
for (Line line : lines)
height += line.getHeightOfRow(stringBounder);
if (height == 0)
return MIN_HEIGHT;
return height;
}

View File

@ -225,7 +225,7 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
cluster.setTitlePosition(new XPoint2D(x, Math.min(upperRight.getY(), lowerLeft.getY())));
}
JUtils.LOG2("cluster=" + cluster);
cluster.drawU(ug, diagram.getUmlDiagramType(), diagram.getSkinParam());
cluster.drawU(ug, diagram.getUmlDiagramType());
// ug.apply(new UTranslate(llx, lly)).apply(HColors.BLUE).draw(new
// URectangle(urx - llx, ury - lly));
} catch (Exception e) {

View File

@ -75,6 +75,7 @@ import net.sourceforge.plantuml.klimt.shape.TextBlock;
import net.sourceforge.plantuml.klimt.shape.UComment;
import net.sourceforge.plantuml.klimt.shape.ULine;
import net.sourceforge.plantuml.skin.AlignmentParam;
import net.sourceforge.plantuml.skin.ComponentStyle;
import net.sourceforge.plantuml.skin.UmlDiagramType;
import net.sourceforge.plantuml.stereo.Stereotype;
import net.sourceforge.plantuml.style.ISkinParam;
@ -281,7 +282,7 @@ public class Cluster implements Moveable {
return StyleSignatureBasic.of(SName.root, SName.element, diagramStyleName, SName.group, symbol.getSName());
}
public void drawU(UGraphic ug, UmlDiagramType umlDiagramType, ISkinParam skinParam2unused) {
public void drawU(UGraphic ug, UmlDiagramType umlDiagramType) {
if (group.isHidden())
return;
@ -305,7 +306,11 @@ public class Cluster implements Moveable {
borderColor = group.getColors().getColor(ColorType.LINE);
else
borderColor = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet());
final double rounded = style.value(PName.RoundCorner).asDouble();
double rounded = style.value(PName.RoundCorner).asDouble();
if (skinParam.strictUmlStyle())
rounded = 0;
final double diagonalCorner = style.value(PName.DiagonalCorner).asDouble();
ug.startGroup(Collections.singletonMap(UGroupType.ID, "cluster_" + fullName));

View File

@ -102,10 +102,10 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
if (fileFormatOption.isDebugSvek() && os instanceof NamedOutputStream)
basefile = ((NamedOutputStream) os).getBasefile();
TextBlock result = svek2.buildImage(basefile, diagram.getDotStringSkek());
TextBlock result = svek2.buildImage(basefile, diagram.getDotStringSkek(), fileFormatOption.isDebugSvek());
if (result instanceof GraphvizCrash) {
svek2 = createDotDataImageBuilder(DotMode.NO_LEFT_RIGHT_AND_XLABEL, stringBounder);
result = svek2.buildImage(basefile, diagram.getDotStringSkek());
result = svek2.buildImage(basefile, diagram.getDotStringSkek(), fileFormatOption.isDebugSvek());
}
// TODO There is something strange with the left margin of mainframe, I think
// because AnnotatedWorker is used here

View File

@ -389,7 +389,7 @@ public final class GeneralImageBuilder {
return style.value(PName.BackGroundColor).asColor(dotData.getSkinParam().getIHtmlColorSet());
}
public IEntityImage buildImage(BaseFile basefile, String dotStrings[]) {
public IEntityImage buildImage(BaseFile basefile, String dotStrings[], boolean fileFormatOptionIsDebugSvek) {
// ::comment when __CORE__
if (dotData.isDegeneratedWithFewEntities(0))
return new EntityImageSimpleEmpty(dotData.getSkinParam().getBackgroundColor());
@ -446,7 +446,7 @@ public final class GeneralImageBuilder {
if (dotStringFactory.illegalDotExe())
return error(dotStringFactory.getDotExe());
if (basefile == null && isSvekTrace()
if (basefile == null && (fileFormatOptionIsDebugSvek || isSvekTrace())
&& (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE
|| SecurityUtils.getSecurityProfile() == SecurityProfile.LEGACY
|| SecurityUtils.getSecurityProfile() == SecurityProfile.SANDBOX))

View File

@ -131,7 +131,7 @@ public final class GroupMakerActivity {
final Style style = getDefaultStyleDefinitionGroup().getMergedStyle(skinParam.getCurrentStyleBuilder());
final double shadowing = style.value(PName.Shadowing).asDouble();
return new InnerActivity(svek2.buildImage(null, new String[0]), borderColor, backColor, shadowing);
return new InnerActivity(svek2.buildImage(null, new String[0], false), borderColor, backColor, shadowing);
}
throw new UnsupportedOperationException(group.getGroupType().toString());

View File

@ -133,7 +133,7 @@ public final class GroupMakerState {
return new EntityImageState(group, diagram.getSkinParam());
if (group.getGroupType() == GroupType.CONCURRENT_STATE)
return createGeneralImageBuilder(group.leafs(), skinParam).buildImage(null, new String[0]);
return createGeneralImageBuilder(group.leafs(), skinParam).buildImage(null, new String[0], false);
if (group.getGroupType() != GroupType.STATE)
throw new UnsupportedOperationException(group.getGroupType().toString());
@ -153,13 +153,14 @@ public final class GroupMakerState {
final IEntityImage image;
if (containsSomeConcurrentStates()) {
final List<IEntityImage> inners = new ArrayList<>();
inners.add(createGeneralImageBuilder(filter(group.leafs()), skinParam).buildImage(null, new String[0]));
inners.add(
createGeneralImageBuilder(filter(group.leafs()), skinParam).buildImage(null, new String[0], false));
for (Entity inner : group.leafs())
if (inner.getLeafType() == LeafType.STATE_CONCURRENT)
inners.add(inner.getSvekImage());
image = new ConcurrentStates(inners, group.getConcurrentSeparator(), skinParam, group.getStereotype());
} else {
image = createGeneralImageBuilder(filter(group.leafs()), skinParam).buildImage(null, new String[0]);
image = createGeneralImageBuilder(filter(group.leafs()), skinParam).buildImage(null, new String[0], false);
}
final HColor bodyColor = styleBody.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet());

View File

@ -72,7 +72,7 @@ public final class SvekResult extends AbstractTextBlock implements IEntityImage
public void drawU(UGraphic ug) {
for (Cluster cluster : dotStringFactory.getBibliotekon().allCluster())
cluster.drawU(ug, dotData.getUmlDiagramType(), dotData.getSkinParam());
cluster.drawU(ug, dotData.getUmlDiagramType());
final Style style2 = getDefaultStyleDefinition(null)
.getMergedStyle(dotData.getSkinParam().getCurrentStyleBuilder());

View File

@ -82,7 +82,7 @@ public class Version {
}
public static int beta() {
final int beta = 4;
final int beta = 5;
return beta;
}