1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-22 21:15:09 +00:00
This commit is contained in:
Arnaud Roques 2021-10-27 18:43:04 +02:00
parent 7141113050
commit 03c34c18c3
39 changed files with 553 additions and 644 deletions

View File

@ -351,8 +351,8 @@ public class ActivityDiagram3 extends UmlDiagram {
public void startRepeat(HColor color, Display label, BoxStyle boxStyleIn, Colors colors) {
manageSwimlaneStrategy();
final InstructionRepeat instructionRepeat = new InstructionRepeat(swinlanes.getCurrentSwimlane(), current(),
nextLinkRenderer(), color, label, boxStyleIn, colors);
final InstructionRepeat instructionRepeat = new InstructionRepeat(swinlanes, current(), nextLinkRenderer(),
color, label, boxStyleIn, colors);
current().add(instructionRepeat);
setCurrent(instructionRepeat);
setNextLinkRendererInternal(LinkRendering.none());

View File

@ -53,6 +53,7 @@ import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.Rainbow;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.sequencediagram.NotePosition;
import net.sourceforge.plantuml.sequencediagram.NoteType;
@ -212,7 +213,7 @@ public class Branch {
public final LinkRendering getSpecial() {
return special;
}
public final Display getDisplayPositive() {
final LinkRendering in = ftile.getInLinkRendering();
if (in != null && Display.isNull(in.getDisplay()) == false) {
@ -221,8 +222,17 @@ public class Branch {
return labelPositive.getDisplay();
}
public final TextBlock getTextBlockPositive() {
public Display getSpecialDisplay() {
if (special != null && Display.isNull(special.getDisplay()) == false) {
return special.getDisplay();
}
return null;
}
private TextBlock getTextBlock(Display display) {
if (display == null)
return TextBlockUtils.EMPTY_TEXT_BLOCK;
LineBreakStrategy lineBreak = LineBreakStrategy.NONE;
final FontConfiguration fcArrow;
if (UseStyle.useBetaStyle()) {
@ -233,10 +243,16 @@ public class Branch {
fcArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null);
}
return getDisplayPositive().create0(fcArrow, HorizontalAlignment.LEFT, skinParam(), lineBreak,
CreoleMode.SIMPLE_LINE, null, null);
return display.create0(fcArrow, HorizontalAlignment.LEFT, skinParam(), lineBreak, CreoleMode.SIMPLE_LINE, null,
null);
}
public final TextBlock getTextBlockPositive() {
return getTextBlock(getDisplayPositive());
}
public final TextBlock getTextBlockSpecial() {
return getTextBlock(getSpecialDisplay());
}
}

View File

@ -45,6 +45,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlanes;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.color.Colors;
@ -58,6 +59,7 @@ public class InstructionRepeat implements Instruction {
private final Instruction parent;
private final LinkRendering nextLinkRenderer;
private final Swimlane swimlane;
private final Swimlanes swimlanes;
private Swimlane swimlaneOut;
private BoxStyle boxStyle;
private boolean killed = false;
@ -81,13 +83,14 @@ public class InstructionRepeat implements Instruction {
return repeatList.containsBreak();
}
public InstructionRepeat(Swimlane swimlane, Instruction parent, LinkRendering nextLinkRenderer, HColor color,
public InstructionRepeat(Swimlanes swimlanes, Instruction parent, LinkRendering nextLinkRenderer, HColor color,
Display startLabel, BoxStyle boxStyleIn, Colors colors) {
this.repeatList = new InstructionList(swimlane);
this.swimlanes = swimlanes;
this.swimlane = swimlanes.getCurrentSwimlane();
this.repeatList = new InstructionList(this.swimlane);
this.boxStyleIn = boxStyleIn;
this.startLabel = startLabel;
this.parent = parent;
this.swimlane = swimlane;
this.nextLinkRenderer = Objects.requireNonNull(nextLinkRenderer);
this.colors = colors;
}
@ -119,6 +122,8 @@ public class InstructionRepeat implements Instruction {
public Ftile createFtile(FtileFactory factory) {
final Ftile back = getBackward(factory);
final Ftile decorateOut = factory.decorateOut(repeatList.createFtile(factory), endRepeatLinkRendering);
if (this.testCalled == false && incoming1.isNone())
incoming1 = swimlanes.nextLinkRenderer();
final Ftile result = factory.repeat(boxStyleIn, swimlane, swimlaneOut, startLabel, decorateOut, test, yes, out,
colors, back, isLastOfTheParent(), incoming1, incoming2);
if (killed) {

View File

@ -131,6 +131,8 @@ public class InstructionSwitch extends WithNote implements Instruction, Instruct
}
public boolean switchCase(Display labelCase, LinkRendering nextLinkRenderer) {
if (this.current != null)
this.current.setSpecial(nextLinkRenderer);
this.current = new Branch(skinParam.getCurrentStyleBuilder(), swimlane,
LinkRendering.none().withDisplay(labelCase), labelCase, null,
LinkRendering.none().withDisplay(labelCase));

View File

@ -120,13 +120,24 @@ public class FtileGeometry extends Dimension2D {
return new FtileGeometry(width, height + northHeight, left, inY + northHeight, Double.MIN_NORMAL);
}
public FtileGeometry addBottom(double southHeight) {
if (hasPointOut())
return new FtileGeometry(width, height + southHeight, left, inY, outY);
return new FtileGeometry(width, height + southHeight, left, inY, Double.MIN_NORMAL);
}
public FtileGeometry incRight(double missing) {
return new FtileGeometry(width + missing, height, left, inY, outY);
}
// public FtileGeometry incInnerHeight(double northHeight) {
// return new FtileGeometry(width, height + northHeight, left, inY, outY + northHeight);
// }
public FtileGeometry incLeft(double missing) {
return new FtileGeometry(width + missing, height, left + missing, inY, outY);
}
public FtileGeometry incVertically(double missing1, double missing2) {
return new FtileGeometry(width, height + missing1 + missing2, left, inY + missing1,
hasPointOut() ? outY + missing1 : outY);
}
public FtileGeometry(Dimension2D dim, double left, double inY, double outY) {
this(dim.getWidth(), dim.getHeight(), left, inY, outY);

View File

@ -68,9 +68,7 @@ public class FtileMargedVertically extends FtileDecorate {
}
private FtileGeometry calculateDimensionSlow(StringBounder stringBounder) {
final FtileGeometry orig = getFtileDelegated().calculateDimension(stringBounder);
return new FtileGeometry(orig.getWidth(), orig.getHeight() + margin1 + margin2, orig.getLeft(), orig.getInY()
+ margin1, orig.hasPointOut() ? orig.getOutY() + margin1 : orig.getOutY());
return super.calculateDimension(stringBounder).incVertically(margin1, margin2);
}
}

View File

@ -35,10 +35,29 @@
*/
package net.sourceforge.plantuml.activitydiagram3.ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorate;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public interface FtileOverpassing extends Ftile {
public class FtileMargedWest extends FtileDecorate {
public FtileGeometry getOverpassDimension(StringBounder stringBounder);
private final double margin;
public FtileMargedWest(Ftile tile, double margin) {
super(tile);
this.margin = margin;
}
public void drawU(UGraphic ug) {
super.drawU(ug.apply(UTranslate.dx(margin)));
}
@Override
public FtileGeometry calculateDimension(StringBounder stringBounder) {
FtileGeometry result = super.calculateDimension(stringBounder);
result = result.incLeft(margin);
return result;
}
}

View File

@ -42,18 +42,18 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.ugraphic.UPolygon;
public class Diamond {
public class Hexagon {
final static public double diamondHalfSize = 12;
final static public double hexagonHalfSize = 12;
public static UPolygon asPolygon(double shadowing) {
final UPolygon diams = new UPolygon();
diams.addPoint(diamondHalfSize, 0);
diams.addPoint(diamondHalfSize * 2, diamondHalfSize);
diams.addPoint(diamondHalfSize, diamondHalfSize * 2);
diams.addPoint(0, diamondHalfSize);
diams.addPoint(diamondHalfSize, 0);
diams.addPoint(hexagonHalfSize, 0);
diams.addPoint(hexagonHalfSize * 2, hexagonHalfSize);
diams.addPoint(hexagonHalfSize, hexagonHalfSize * 2);
diams.addPoint(0, hexagonHalfSize);
diams.addPoint(hexagonHalfSize, 0);
// if (shadowing) {
// diams.setDeltaShadow(3);
@ -66,13 +66,13 @@ public class Diamond {
public static UPolygon asPolygon(double shadowing, double width, double height) {
final UPolygon diams = new UPolygon();
diams.addPoint(diamondHalfSize, 0);
diams.addPoint(width - diamondHalfSize, 0);
diams.addPoint(hexagonHalfSize, 0);
diams.addPoint(width - hexagonHalfSize, 0);
diams.addPoint(width, height / 2);
diams.addPoint(width - diamondHalfSize, height);
diams.addPoint(diamondHalfSize, height);
diams.addPoint(width - hexagonHalfSize, height);
diams.addPoint(hexagonHalfSize, height);
diams.addPoint(0, height / 2);
diams.addPoint(diamondHalfSize, 0);
diams.addPoint(hexagonHalfSize, 0);
// if (shadowing) {
// diams.setDeltaShadow(3);
@ -88,9 +88,9 @@ public class Diamond {
private final double getDeltaX(double height, double y) {
final double p = y / height * 2;
if (p <= 1) {
return diamondHalfSize * p;
return hexagonHalfSize * p;
}
return diamondHalfSize * (2 - p);
return hexagonHalfSize * (2 - p);
}
public double getStartingX(StringBounder stringBounder, double y) {

View File

@ -134,7 +134,7 @@ public class Snake implements UShape {
}
public Snake withLabel(TextBlock textBlock, VerticalAlignment verticalAlignment) {
if (textBlock != null) {
if (textBlock != null && textBlock != TextBlockUtils.EMPTY_TEXT_BLOCK) {
this.texts.add(new Text(textBlock, verticalAlignment, null));
}
if (verticalAlignment != VerticalAlignment.CENTER) {
@ -314,9 +314,10 @@ public class Snake implements UShape {
if (this.startDecoration != null || other.startDecoration != null) {
throw new UnsupportedOperationException("Not yet coded: to be done");
}
final ArrayList<Text> mergeTexts = new ArrayList<Text>(this.texts);
mergeTexts.addAll(other.texts);
final Snake result = new Snake(null, color, oneOf, this.worm.merge(other.worm, strategy), strategy,
emphasizeDirection == null ? other.emphasizeDirection : emphasizeDirection, new ArrayList<Text>());
// result.textBlock = oneOf(this.textBlock, other.textBlock, stringBounder);
emphasizeDirection == null ? other.emphasizeDirection : emphasizeDirection, mergeTexts);
return result;
}
if (same(this.getFirst(), other.getLast())) {

View File

@ -55,6 +55,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.FtileSwitch
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.FtileSwitchWithManyLinks;
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.FtileSwitchWithOneLink;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorateInLabel;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorateOutLabel;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.cucadiagram.Display;
@ -106,9 +107,9 @@ public class FtileFactoryDelegatorSwitch extends FtileFactoryDelegator {
final Ftile diamond2 = getDiamond2(swimlane, branches.get(0));
for (Branch branch : branches) {
final Dimension2D dimLabel = branch.getTextBlockPositive().calculateDimension(getStringBounder());
// ftiles.add(new FtileMinWidthCentered(branch.getFtile(), 30));
ftiles.add(new FtileDecorateInLabel(branch.getFtile(), dimLabel.getWidth(), dimLabel.getHeight()));
final Dimension2D dimLabelIn = branch.getTextBlockPositive().calculateDimension(getStringBounder());
final Dimension2D dimLabelOut = branch.getTextBlockSpecial().calculateDimension(getStringBounder());
ftiles.add(new FtileDecorateOutLabel(new FtileDecorateInLabel(branch.getFtile(), dimLabelIn), dimLabelOut));
}
final Rainbow arrowColor;
@ -158,7 +159,7 @@ public class FtileFactoryDelegatorSwitch extends FtileFactoryDelegator {
tbTest = test.create0(fcDiamond, branch0.skinParam().getDefaultTextAlignment(HorizontalAlignment.LEFT),
branch0.skinParam(), lineBreak, CreoleMode.FULL, null, null);
return new FtileDiamondInside(branch0.skinParam(), backColor, borderColor, swimlane, tbTest);
return new FtileDiamondInside(tbTest, branch0.skinParam(), backColor, borderColor, swimlane);
}
private Ftile getDiamond2(Swimlane swimlane, Branch branch0) {
@ -167,8 +168,8 @@ public class FtileFactoryDelegatorSwitch extends FtileFactoryDelegator {
? getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground)
: branch0.getColor();
return new FtileDiamondInside(branch0.skinParam(), backColor, borderColor, swimlane,
TextBlockUtils.empty(0, 0));
return new FtileDiamondInside(TextBlockUtils.empty(0, 0), branch0.skinParam(), backColor, borderColor,
swimlane);
}
// private HColor fontColor(FontParam param) {

View File

@ -44,7 +44,7 @@ import net.sourceforge.plantuml.activitydiagram3.Instruction;
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileBreak;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
@ -124,7 +124,7 @@ public class FtileFactoryDelegatorWhile extends FtileFactoryDelegator {
final Snake snake = Snake.create(arrowColor, Arrows.asToLeft());
snake.addPoint(tr1.getDx(), tr1.getDy());
snake.addPoint(Diamond.diamondHalfSize, tr1.getDy());
snake.addPoint(Hexagon.hexagonHalfSize, tr1.getDy());
ug.draw(snake);
}

View File

@ -51,7 +51,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
@ -134,12 +134,12 @@ class FtileIfAndStop extends AbstractFtile {
final Sheet sheet = Parser.build(fcTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL)
.createSheet(labelTest);
final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding());
final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1),
final TextBlock tbTest = new SheetBlock2(sheetBlock1, Hexagon.asStencil(sheetBlock1),
tileNonStop.getThickness());
final Ftile diamond1;
if (conditionStyle == ConditionStyle.INSIDE_HEXAGON) {
diamond1 = new FtileDiamondInside(tileNonStop.skinParam(), backColor, borderColor, swimlane, tbTest);
diamond1 = new FtileDiamondInside(tbTest, tileNonStop.skinParam(), backColor, borderColor, swimlane);
// .withWest(tb1).withEast(tb2);
} else if (conditionStyle == ConditionStyle.EMPTY_DIAMOND) {
diamond1 = new FtileDiamond(tileNonStop.skinParam(), backColor, borderColor, swimlane).withNorth(tbTest);

View File

@ -50,7 +50,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable;
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileEmpty;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
@ -328,7 +328,7 @@ public class FtileIfDown extends AbstractFtile {
final double y2 = p2.getY();
final FtileGeometry thenGeom = thenBlock.calculateDimension(stringBounder);
final double xmax = Math.max(x1 + Diamond.diamondHalfSize,
final double xmax = Math.max(x1 + Hexagon.hexagonHalfSize,
getTranslateForThen(stringBounder).getDx() + thenGeom.getWidth());
final Snake snake = Snake.create(endInlinkColor, Arrows.asToLeft()).emphasizeDirection(Direction.DOWN);
@ -336,7 +336,7 @@ public class FtileIfDown extends AbstractFtile {
snake.addPoint(xmax, y1);
snake.addPoint(xmax, y2);
snake.addPoint(x2, y2);
ug.apply(new UTranslate(x2, y2 - Diamond.diamondHalfSize)).draw(new UEmpty(5, Diamond.diamondHalfSize));
ug.apply(new UTranslate(x2, y2 - Hexagon.hexagonHalfSize)).draw(new UEmpty(5, Hexagon.hexagonHalfSize));
ug.draw(snake);
}
@ -367,7 +367,7 @@ public class FtileIfDown extends AbstractFtile {
final double y2 = p2.getY();
final FtileGeometry thenGeom = thenBlock.calculateDimension(stringBounder);
final double xmax = Math.max(x1 + Diamond.diamondHalfSize,
final double xmax = Math.max(x1 + Hexagon.hexagonHalfSize,
getTranslateForThen(stringBounder).getDx() + thenGeom.getWidth());
/*
@ -382,7 +382,7 @@ public class FtileIfDown extends AbstractFtile {
snake.addPoint(x1, y1);
snake.addPoint(xmax, y1);
snake.addPoint(xmax, y2);
ug.apply(new UTranslate(xmax, y2 - Diamond.diamondHalfSize)).draw(new UEmpty(5, Diamond.diamondHalfSize));
ug.apply(new UTranslate(xmax, y2 - Hexagon.hexagonHalfSize)).draw(new UEmpty(5, Hexagon.hexagonHalfSize));
ug.draw(snake);
/*
* final Snake snake2 = Snake.create(arrowHorizontalAlignment(),
@ -458,7 +458,7 @@ public class FtileIfDown extends AbstractFtile {
final double y3 = p3.getY();
final FtileGeometry thenGeom = thenBlock.calculateDimension(stringBounder);
final double xmax = Math.max(x1 + Diamond.diamondHalfSize,
final double xmax = Math.max(x1 + Hexagon.hexagonHalfSize,
getTranslateForThen(stringBounder).getDx() + thenGeom.getWidth());
final Snake snake = Snake.create(endInlinkColor).withMerge(MergeStrategy.NONE);
@ -490,9 +490,9 @@ public class FtileIfDown extends AbstractFtile {
final FtileGeometry geoThen = thenBlock.calculateDimension(stringBounder);
final FtileGeometry geoDiamond2 = diamond2.calculateDimension(stringBounder);
final FtileGeometry geo = geoDiamond1.appendBottom(geoThen).appendBottom(geoDiamond2);
final double height = geo.getHeight() + 3 * Diamond.diamondHalfSize
+ Math.max(Diamond.diamondHalfSize * 1, getSouthLabelHeight(stringBounder));
double width = geo.getWidth() + Diamond.diamondHalfSize;
final double height = geo.getHeight() + 3 * Hexagon.hexagonHalfSize
+ Math.max(Hexagon.hexagonHalfSize * 1, getSouthLabelHeight(stringBounder));
double width = geo.getWidth() + Hexagon.hexagonHalfSize;
if (optionalStop != null) {
width += optionalStop.calculateDimension(stringBounder).getWidth() + getAdditionalWidth(stringBounder);
}

View File

@ -163,8 +163,8 @@ class FtileIfLongHorizontal extends AbstractFtile {
ftileFactory.skinParam());
final HColor diamondColor = branch.getColor() == null ? backColor : branch.getColor();
FtileDiamondInside2 diamond = new FtileDiamondInside2(branch.skinParam(), diamondColor, borderColor,
swimlane, tbTest);
FtileDiamondInside2 diamond = new FtileDiamondInside2(tbTest, branch.skinParam(), diamondColor,
borderColor, swimlane);
TextBlock tbInlabel = null;
if (Display.isNull(branch.getInlabel())) {
inlabelSizes.add(0.0);

View File

@ -53,18 +53,20 @@ 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.FtileMargedWest;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMinWidthCentered;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileOverpassing;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
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.FtileDiamondInside3;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside2;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.Rainbow;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.svek.ConditionStyle;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
@ -128,35 +130,39 @@ class FtileIfLongVertical extends AbstractFtile {
static Ftile create(Swimlane swimlane, HColor borderColor, HColor backColor, Rainbow arrowColor,
FtileFactory ftileFactory, ConditionStyle conditionStyle, List<Branch> thens, Branch branch2,
FontConfiguration fc, LinkRendering topInlinkRendering, LinkRendering afterEndwhile) {
final List<Ftile> tiles = new ArrayList<>();
for (Branch branch : thens) {
tiles.add(new FtileMinWidthCentered(branch.getFtile(), 30));
}
final Ftile tile2 = new FtileMinWidthCentered(branch2.getFtile(), 30);
List<Ftile> diamonds = new ArrayList<>();
double west = 10;
for (Branch branch : thens) {
final TextBlock tb1 = branch.getDisplayPositive().create(fc, HorizontalAlignment.LEFT,
ftileFactory.skinParam());
final TextBlock tbTest = branch.getLabelTest().create(fc,
ftileFactory.skinParam().getDefaultTextAlignment(HorizontalAlignment.LEFT),
ftileFactory.skinParam());
FtileDiamondInside3 diamond = new FtileDiamondInside3(branch.skinParam(), backColor, borderColor, swimlane,
tbTest);
FtileDiamondInside2 diamond = new FtileDiamondInside2(tbTest, branch.skinParam(), backColor, borderColor,
swimlane);
diamond = diamond.withEast(tb1);
diamonds.add(diamond);
if (Display.isNull(branch.getInlabel()) == false) {
final TextBlock tbInlabel = branch.getInlabel().create(fc, HorizontalAlignment.LEFT,
ftileFactory.skinParam());
west = Math.max(west, tbInlabel.calculateDimension(ftileFactory.getStringBounder()).getWidth());
}
}
final TextBlock tb2 = branch2.getDisplayPositive().create(fc, HorizontalAlignment.LEFT, ftileFactory.skinParam());
final int last = diamonds.size() - 1;
diamonds.set(last, ((FtileDiamondInside3) diamonds.get(last)).withSouth(tb2));
final List<Ftile> tiles = new ArrayList<>();
// diamonds = alignDiamonds(diamonds, ftileFactory.getStringBounder());
for (Branch branch : thens) {
tiles.add(new FtileMargedWest(branch.getFtile(), west));
}
final Ftile lastDiamond = new FtileDiamond(tiles.get(0).skinParam(), backColor, borderColor, swimlane);
final Ftile tile2 = new FtileMinWidthCentered(branch2.getFtile(), 30);
final FtileIfLongVertical result = new FtileIfLongVertical(diamonds, tiles, tile2, arrowColor, lastDiamond);
final List<Connection> conns = new ArrayList<>();
@ -165,12 +171,17 @@ class FtileIfLongVertical extends AbstractFtile {
final Ftile diam = diamonds.get(i);
final Rainbow color = thens.get(i).getInColor(arrowColor);
conns.add(result.new ConnectionVerticalIn(diam, ftile, color == null ? arrowColor : color));
// conns.add(result.new ConnectionVerticalOut(ftile, arrowColor));
}
for (int i = 0; i < diamonds.size() - 1; i++) {
conns.add(result.new ConnectionVertical(diamonds.get(i), diamonds.get(i + 1), arrowColor));
final Branch branch = thens.get(i + 1);
TextBlock tbInlabel = null;
if (Display.isNull(branch.getInlabel()) == false)
tbInlabel = branch.getInlabel().create(fc, HorizontalAlignment.LEFT, ftileFactory.skinParam());
conns.add(result.new ConnectionVertical(diamonds.get(i), diamonds.get(i + 1), arrowColor, tbInlabel));
}
conns.add(result.new ConnectionThenOut(tiles.get(0), arrowColor));
for (int i = 1; i < tiles.size(); i++) {
@ -179,7 +190,10 @@ class FtileIfLongVertical extends AbstractFtile {
final Rainbow topInColor = topInlinkRendering.getRainbow(arrowColor);
conns.add(result.new ConnectionIn(topInColor));
conns.add(result.new ConnectionLastElse(topInColor));
final TextBlock tb2 = branch2.getDisplayPositive().create(fc, HorizontalAlignment.LEFT,
ftileFactory.skinParam());
conns.add(result.new ConnectionLastElse(topInColor, tb2));
conns.add(result.new ConnectionLastElseOut(arrowColor));
return FtileUtils.addConnection(result, conns);
@ -247,10 +261,12 @@ class FtileIfLongVertical extends AbstractFtile {
class ConnectionVertical extends AbstractConnection {
private final Rainbow color;
private final TextBlock label;
public ConnectionVertical(Ftile diamond1, Ftile diamond2, Rainbow color) {
public ConnectionVertical(Ftile diamond1, Ftile diamond2, Rainbow color, TextBlock label) {
super(diamond1, diamond2);
this.color = color;
this.label = label;
}
public void drawU(UGraphic ug) {
@ -258,7 +274,7 @@ class FtileIfLongVertical extends AbstractFtile {
final Point2D p1 = getP1(stringBounder);
final Point2D p2 = getP2(stringBounder);
final Snake snake = Snake.create(color, Arrows.asToDown());
final Snake snake = Snake.create(color, Arrows.asToDown()).withLabel(label, VerticalAlignment.CENTER);
snake.addPoint(p1);
snake.addPoint(p2);
ug.draw(snake);
@ -279,10 +295,12 @@ class FtileIfLongVertical extends AbstractFtile {
class ConnectionLastElse extends AbstractConnection {
private final Rainbow arrowColor;
private final TextBlock label;
public ConnectionLastElse(Rainbow arrowColor) {
public ConnectionLastElse(Rainbow arrowColor, TextBlock label) {
super(diamonds.get(diamonds.size() - 1), tile2);
this.arrowColor = arrowColor;
this.label = label;
}
public void drawU(UGraphic ug) {
@ -294,7 +312,7 @@ class FtileIfLongVertical extends AbstractFtile {
final Point2D p2 = getTranslate2(stringBounder)
.getTranslated(getFtile2().calculateDimension(stringBounder).getPointIn());
final Snake snake = Snake.create(arrowColor, Arrows.asToDown());
final Snake snake = Snake.create(arrowColor, Arrows.asToDown()).withLabel(label, VerticalAlignment.CENTER);
snake.addPoint(p1);
snake.addPoint(p1.getX(), p2.getY() - 15);
snake.addPoint(p2.getX(), p2.getY() - 15);
@ -480,21 +498,22 @@ class FtileIfLongVertical extends AbstractFtile {
private FtileGeometry calculateDimensionInternal(StringBounder stringBounder) {
double col1 = 0;
double col1overpass = 0;
// double col1overpass = 0;
double col2 = 0;
double height = marginy1;
for (int i = 0; i < tiles.size(); i++) {
final FtileGeometry dim1 = tiles.get(i).calculateDimension(stringBounder);
final FtileGeometry diamondOverpassing = ((FtileOverpassing) diamonds.get(i))
.getOverpassDimension(stringBounder);
// final FtileGeometry diamondOverpassing = ((FtileOverpassing) diamonds.get(i))
// .getOverpassDimension(stringBounder);
final FtileGeometry diamondDim = diamonds.get(i).calculateDimension(stringBounder);
height += diamondDim.getHeight() + dim1.getHeight();
col1 = Math.max(col1, diamondDim.getWidth());
col1overpass = Math.max(col1overpass, diamondOverpassing.getWidth());
// col1overpass = Math.max(col1overpass, diamondOverpassing.getWidth());
col2 = Math.max(col2, dim1.getWidth());
}
final double width = Math.max(col1 + col2, col1overpass);
// final double width = Math.max(col1 + col2, col1overpass);
final double width = col1 + col2;
FtileGeometry result = new FtileGeometry(width, height, width / 2, 0);
final FtileGeometry dimTile2 = tile2.calculateDimension(stringBounder);

View File

@ -54,7 +54,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable;
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileEmpty;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
@ -143,7 +143,7 @@ class FtileRepeat extends AbstractFtile {
if (noOut && Display.isNull(test)) {
diamond2 = new FtileEmpty(repeat.skinParam());
} else {
diamond2 = new FtileDiamondInside(repeat.skinParam(), diamondColor, borderColor, swimlaneOut, tbTest)
diamond2 = new FtileDiamondInside(tbTest, repeat.skinParam(), diamondColor, borderColor, swimlaneOut)
.withEast(yesTb).withSouth(outTb);
}
result = new FtileRepeat(repeat, diamond1, diamond2, TextBlockUtils.empty(0, 0), backward);
@ -152,8 +152,8 @@ class FtileRepeat extends AbstractFtile {
.withEast(tbTest);
result = new FtileRepeat(repeat, diamond1, diamond2, tbTest, backward);
} else if (conditionStyle == ConditionStyle.INSIDE_DIAMOND) {
final Ftile diamond2 = new FtileDiamondSquare(repeat.skinParam(), diamondColor, borderColor, swimlane,
tbTest);
final Ftile diamond2 = new FtileDiamondSquare(tbTest, repeat.skinParam(), diamondColor, borderColor,
swimlane);
result = new FtileRepeat(repeat, diamond1, diamond2, TextBlockUtils.empty(0, 0), backward);
} else {
throw new IllegalStateException();
@ -165,9 +165,12 @@ class FtileRepeat extends AbstractFtile {
: in1.create7(fcArrow, HorizontalAlignment.LEFT, spriteContainer, CreoleMode.SIMPLE_LINE);
conns.add(result.new ConnectionIn(repeat.getInLinkRendering().getRainbow(arrowColor), tbin1));
final TextBlock incomingText = incoming1 == null || incoming1.getDisplay() == null ? null
: incoming1.getDisplay().create7(fcArrow, HorizontalAlignment.LEFT, spriteContainer,
CreoleMode.SIMPLE_LINE);
final TextBlock incomingText;
if (incoming1 == null || incoming1.getDisplay() == null)
incomingText = null;
else
incomingText = incoming1.getDisplay().create7(fcArrow, HorizontalAlignment.LEFT, spriteContainer,
CreoleMode.SIMPLE_LINE);
if (backward != null) {
final Rainbow rainbow1 = incoming1.getRainbow(arrowColor);
@ -326,7 +329,7 @@ class FtileRepeat extends AbstractFtile {
final double x1_a = p1.getX() + dimDiamond2.getWidth();
final double x1_b = p1.getX() + dimDiamond2.getWidth() / 2 + dimRepeat.getWidth() / 2
+ Diamond.diamondHalfSize;
+ Hexagon.hexagonHalfSize;
UPolygon arrow = Arrows.asToLeft();
if (x1_b < x2) {
@ -499,7 +502,7 @@ class FtileRepeat extends AbstractFtile {
final double y2 = p2.getY() + dimDiamond1.getHeight() / 2;
snake.addPoint(x1, y1);
final double xmax = dimTotal.getWidth() - Diamond.diamondHalfSize;
final double xmax = dimTotal.getWidth() - Hexagon.hexagonHalfSize;
snake.addPoint(xmax, y1);
snake.addPoint(xmax, y2);
snake.addPoint(x2, y2);
@ -527,7 +530,7 @@ class FtileRepeat extends AbstractFtile {
snake.addPoint(x1, y1);
final double xmax = p1.getX() + dimDiamond2.getWidth() / 2 + dimRepeat.getWidth() / 2
+ Diamond.diamondHalfSize;
+ Hexagon.hexagonHalfSize;
snake.addPoint(xmax, y1);
snake.addPoint(xmax, y2);
snake.addPoint(x2, y2);
@ -562,13 +565,13 @@ class FtileRepeat extends AbstractFtile {
final double w = tbTest.calculateDimension(stringBounder).getWidth();
double width = getLeft(stringBounder) + getRight(stringBounder);
width = Math.max(width, w + 2 * Diamond.diamondHalfSize);
width = Math.max(width, w + 2 * Hexagon.hexagonHalfSize);
if (backward != null) {
width += backward.calculateDimension(stringBounder).getWidth();
}
final double height = dimDiamond1.getHeight() + dimRepeat.getHeight() + dimDiamond2.getHeight()
+ 8 * Diamond.diamondHalfSize;
return new Dimension2DDouble(width + 2 * Diamond.diamondHalfSize, height);
+ 8 * Hexagon.hexagonHalfSize;
return new Dimension2DDouble(width + 2 * Hexagon.hexagonHalfSize, height);
}

View File

@ -115,8 +115,8 @@ class FtileSwitch extends AbstractFtile {
ftileFactory.skinParam());
final HColor diamondColor = branch.getColor() == null ? backColor : branch.getColor();
FtileDiamondInside2 diamond = new FtileDiamondInside2(branch.skinParam(), diamondColor, borderColor,
swimlane, tbTest);
FtileDiamondInside2 diamond = new FtileDiamondInside2(tbTest, branch.skinParam(), diamondColor,
borderColor, swimlane);
TextBlock tbInlabel = null;
if (Display.isNull(branch.getInlabel())) {
inlabelSizes.add(0.0);

View File

@ -52,7 +52,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable;
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
@ -127,10 +127,10 @@ class FtileWhile extends AbstractFtile {
final Ftile diamond1;
if (conditionStyle == ConditionStyle.INSIDE_HEXAGON) {
diamond1 = new FtileDiamondInside(whileBlock.skinParam(), backColor, borderColor, swimlane, testTb)
diamond1 = new FtileDiamondInside(testTb, whileBlock.skinParam(), backColor, borderColor, swimlane)
.withNorth(yesTb).withWest(outTb);
} else if (conditionStyle == ConditionStyle.INSIDE_DIAMOND) {
diamond1 = new FtileDiamondSquare(whileBlock.skinParam(), backColor, borderColor, swimlane, testTb)
diamond1 = new FtileDiamondSquare(testTb, whileBlock.skinParam(), backColor, borderColor, swimlane)
.withNorth(yesTb).withWest(outTb);
} else if (conditionStyle == ConditionStyle.EMPTY_DIAMOND) {
diamond1 = new FtileDiamond(whileBlock.skinParam(), backColor, borderColor, swimlane).withNorth(testTb)
@ -260,7 +260,7 @@ class FtileWhile extends AbstractFtile {
final Snake snake = Snake.create(endInlinkColor, Arrows.asToLeft()).emphasizeDirection(Direction.UP)
.withLabel(back, arrowHorizontalAlignment());
snake.addPoint(x1, y1);
final double y1bis = Math.max(y1, getBottom(stringBounder)) + Diamond.diamondHalfSize;
final double y1bis = Math.max(y1, getBottom(stringBounder)) + Hexagon.hexagonHalfSize;
snake.addPoint(x1, y1bis);
final double xx = dimTotal.getWidth();
snake.addPoint(xx, y1bis);
@ -268,7 +268,7 @@ class FtileWhile extends AbstractFtile {
snake.addPoint(x2, y2);
ug.draw(snake);
ug.apply(new UTranslate(x1, y1bis)).draw(new UEmpty(5, Diamond.diamondHalfSize));
ug.apply(new UTranslate(x1, y1bis)).draw(new UEmpty(5, Hexagon.hexagonHalfSize));
}
@ -291,15 +291,15 @@ class FtileWhile extends AbstractFtile {
final double y2 = p2.getY() + dimDiamond1.getInY() + half;
snake.addPoint(x1, y1);
snake.addPoint(x1, y1 + Diamond.diamondHalfSize);
snake.addPoint(x1, y1 + Hexagon.hexagonHalfSize);
final double xx = Math.max(translate1.getDx(), translate2.getDx()) + dimTotal.getWidth();
snake.addPoint(xx, y1 + Diamond.diamondHalfSize);
snake.addPoint(xx, y1 + Hexagon.hexagonHalfSize);
snake.addPoint(xx, y2);
snake.addPoint(x2, y2);
ug.draw(snake);
ug.apply(new UTranslate(x1, y1 + Diamond.diamondHalfSize)).draw(new UEmpty(5, Diamond.diamondHalfSize));
ug.apply(new UTranslate(x1, y1 + Hexagon.hexagonHalfSize)).draw(new UEmpty(5, Hexagon.hexagonHalfSize));
ug = ug.apply(endInlinkColor.getColor()).apply(endInlinkColor.getColor().bg());
ug.apply(new UTranslate(xx, (y1 + y2) / 2)).draw(Arrows.asToUp());
@ -352,13 +352,13 @@ class FtileWhile extends AbstractFtile {
final Snake snake = Snake.create(endInlinkColor, Arrows.asToUp()).withLabel(back,
arrowHorizontalAlignment());
snake.addPoint(x1, y1);
final double y1bis = Math.max(y1, getBottom(stringBounder)) + Diamond.diamondHalfSize;
final double y1bis = Math.max(y1, getBottom(stringBounder)) + Hexagon.hexagonHalfSize;
snake.addPoint(x1, y1bis);
snake.addPoint(x2, y1bis);
snake.addPoint(x2, y2);
ug.draw(snake);
ug.apply(new UTranslate(x1, y1bis)).draw(new UEmpty(5, Diamond.diamondHalfSize));
ug.apply(new UTranslate(x1, y1bis)).draw(new UEmpty(5, Hexagon.hexagonHalfSize));
}
}
@ -444,7 +444,7 @@ class FtileWhile extends AbstractFtile {
final double y2 = p2.getY() + dimDiamond1.getInY() + half;
snake.addPoint(x1, y1);
final double y1bis = Math.max(y1, getBottom(stringBounder)) + Diamond.diamondHalfSize;
final double y1bis = Math.max(y1, getBottom(stringBounder)) + Hexagon.hexagonHalfSize;
snake.addPoint(x1, y1bis);
final double xx = dimTotal.getWidth();
snake.addPoint(xx, y1bis);
@ -453,7 +453,7 @@ class FtileWhile extends AbstractFtile {
ug.draw(snake);
ug.apply(new UTranslate(x1, y1bis)).draw(new UEmpty(5, Diamond.diamondHalfSize));
ug.apply(new UTranslate(x1, y1bis)).draw(new UEmpty(5, Hexagon.hexagonHalfSize));
}
@ -493,13 +493,13 @@ class FtileWhile extends AbstractFtile {
final double y2 = p2.getY();
snake.addPoint(x1, y1);
snake.addPoint(Diamond.diamondHalfSize, y1);
snake.addPoint(Diamond.diamondHalfSize, y2);
snake.addPoint(Hexagon.hexagonHalfSize, y1);
snake.addPoint(Hexagon.hexagonHalfSize, y2);
ug.draw(snake);
final Snake snake2 = Snake.create(afterEndwhileColor);
snake2.addPoint(Diamond.diamondHalfSize, y2);
snake2.addPoint(Hexagon.hexagonHalfSize, y2);
snake2.addPoint(x2, y2);
// snake2.goUnmergeable(MergeStrategy.LIMITED);
ug.draw(snake2);
@ -579,14 +579,14 @@ class FtileWhile extends AbstractFtile {
assert false;
}
final FtileGeometry geo = geoDiamond1.appendBottom(geoWhile);
final double height = geo.getHeight() + 4 * Diamond.diamondHalfSize;
final double dx = 2 * Diamond.diamondHalfSize;
final double height = geo.getHeight() + 4 * Hexagon.hexagonHalfSize;
final double dx = 2 * Hexagon.hexagonHalfSize;
double backwardWidth = 0;
if (backward != null) {
backwardWidth += backward.calculateDimension(stringBounder).getWidth();
}
return new FtileGeometry(
xDeltaBecauseSpecial(stringBounder) + geo.getWidth() + dx + Diamond.diamondHalfSize + backwardWidth,
xDeltaBecauseSpecial(stringBounder) + geo.getWidth() + dx + Hexagon.hexagonHalfSize + backwardWidth,
height, xDeltaBecauseSpecial(stringBounder) + geo.getLeft() + dx, geoDiamond1.getInY(), height);
}
@ -635,8 +635,8 @@ class FtileWhile extends AbstractFtile {
private UTranslate getTranslateForSpecial(StringBounder stringBounder) {
final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
final double half = (dimDiamond1.getOutY() - dimDiamond1.getInY()) / 2;
final double y1 = Math.max(3 * half, 4 * Diamond.diamondHalfSize);
final double xWhile = getTranslateForWhile(stringBounder).getDx() - Diamond.diamondHalfSize;
final double y1 = Math.max(3 * half, 4 * Hexagon.hexagonHalfSize);
final double xWhile = getTranslateForWhile(stringBounder).getDx() - Hexagon.hexagonHalfSize;
final double xDiamond = getTranslateDiamond1(stringBounder).getDx();
// final double x1 = xWhile - xDeltaBecauseSpecial(stringBounder);
final double x1 = Math.min(xWhile, xDiamond) - xDeltaBecauseSpecial(stringBounder);

View File

@ -84,7 +84,6 @@ public class FtileWithNoteOpale extends AbstractFtile implements Stencil, Stylea
private final Ftile tile;
private final Opale opale;
// private final HtmlColor arrowColor;
private final NotePosition notePosition;
private final double suppSpace = 20;
private final Swimlane swimlaneNote;
@ -184,6 +183,13 @@ public class FtileWithNoteOpale extends AbstractFtile implements Stencil, Stylea
}
return new UTranslate(marge, yForFtile);
}
@Override
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
if (child == tile)
return new UTranslate();
return super.getTranslateFor(child, stringBounder);
}

View File

@ -42,7 +42,7 @@ import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UseStyle;
import net.sourceforge.plantuml.activitydiagram3.Branch;
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileEmpty;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
@ -180,8 +180,8 @@ public class ConditionalBuilder {
final Ftile tile2 = new FtileMinWidthCentered(branch2.getFtile(), 30);
final TextBlock tb1 = getLabelPositive(branch1);
final TextBlock tb2 = getLabelPositive(branch2);
final Ftile diamond1 = getDiamond1(false, tb1, tb2);
final Ftile diamond2 = getDiamond2(branch1, branch2, true);
final Ftile diamond1 = getShape1(false, tb1, tb2);
final Ftile diamond2 = getShape2(branch1, branch2, true);
if (branch2.isOnlySingleStopOrSpot()) {
return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile1, 10),
arrowColor, conditionEndStyle, ftileFactory, branch2.getFtile(), branch2.getOut());
@ -205,7 +205,7 @@ public class ConditionalBuilder {
private Ftile createWithDiamonds() {
final Ftile diamond1 = getDiamond1(true);
final Ftile diamond2 = getDiamond2(branch1, branch2, false);
final Ftile diamond2 = getShape2(branch1, branch2, false);
final FtileIfWithDiamonds ftile = new FtileIfWithDiamonds(diamond1, tile1, tile2, diamond2, swimlane,
stringBounder);
final Dimension2D label1 = getLabelPositive(branch1).calculateDimension(stringBounder);
@ -223,7 +223,7 @@ public class ConditionalBuilder {
if (url != null) {
diamond1 = new FtileWithUrl(diamond1, url);
}
final Ftile diamond2 = getDiamond2(branch1, branch2, false);
final Ftile diamond2 = getShape2(branch1, branch2, false);
final Ftile tmp1 = FtileUtils.addHorizontalMargin(tile1, 10);
final Ftile tmp2 = FtileUtils.addHorizontalMargin(tile2, 10);
final FtileIfWithLinks ftile = new FtileIfWithLinks(diamond1, tmp1, tmp2, diamond2, swimlane, arrowColor,
@ -240,46 +240,46 @@ public class ConditionalBuilder {
}
private Ftile getDiamond1(boolean eastWest) {
return getDiamond1(eastWest, getLabelPositive(branch1), getLabelPositive(branch2));
return getShape1(eastWest, getLabelPositive(branch1), getLabelPositive(branch2));
}
private Ftile getDiamond1(boolean eastWest, TextBlock tb1, TextBlock tb2) {
private Ftile getShape1(boolean eastWest, TextBlock tb1, TextBlock tb2) {
final Display labelTest = branch1.getLabelTest();
final Sheet sheet = Parser.build(fontTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
skinParam, CreoleMode.FULL).createSheet(labelTest);
final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, diamondLineBreak, skinParam.getPadding());
final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1), tile1.getThickness());
final TextBlock tbTest = new SheetBlock2(sheetBlock1, Hexagon.asStencil(sheetBlock1), tile1.getThickness());
final Ftile diamond1;
final Ftile shape1;
if (conditionStyle == ConditionStyle.INSIDE_HEXAGON) {
if (eastWest) {
diamond1 = new FtileDiamondInside(tile1.skinParam(), backColor, borderColor, swimlane, tbTest)
shape1 = new FtileDiamondInside(tbTest, tile1.skinParam(), backColor, borderColor, swimlane)
.withWestAndEast(tb1, tb2);
} else {
diamond1 = new FtileDiamondInside(tile1.skinParam(), backColor, borderColor, swimlane, tbTest)
shape1 = new FtileDiamondInside(tbTest, tile1.skinParam(), backColor, borderColor, swimlane)
.withSouth(tb1).withEast(tb2);
}
} else if (conditionStyle == ConditionStyle.EMPTY_DIAMOND) {
if (eastWest) {
diamond1 = new FtileDiamond(tile1.skinParam(), backColor, borderColor, swimlane).withNorth(tbTest)
shape1 = new FtileDiamond(tile1.skinParam(), backColor, borderColor, swimlane).withNorth(tbTest)
.withWestAndEast(tb1, tb2);
} else {
diamond1 = new FtileDiamond(tile1.skinParam(), backColor, borderColor, swimlane).withNorth(tbTest)
shape1 = new FtileDiamond(tile1.skinParam(), backColor, borderColor, swimlane).withNorth(tbTest)
.withSouth(tb1).withEast(tb2);
}
} else if (conditionStyle == ConditionStyle.INSIDE_DIAMOND) {
if (eastWest) {
diamond1 = new FtileDiamondSquare(tile1.skinParam(), backColor, borderColor, swimlane, tbTest)
shape1 = new FtileDiamondSquare(tbTest, tile1.skinParam(), backColor, borderColor, swimlane)
.withWestAndEast(tb1, tb2);
} else {
diamond1 = new FtileDiamondSquare(tile1.skinParam(), backColor, borderColor, swimlane, tbTest)
shape1 = new FtileDiamondSquare(tbTest, tile1.skinParam(), backColor, borderColor, swimlane)
.withSouth(tb1).withEast(tb2);
}
} else {
throw new IllegalStateException();
}
return diamond1;
return shape1;
}
private TextBlock getLabelPositive(Branch branch) {
@ -287,10 +287,10 @@ public class ConditionalBuilder {
labelLineBreak, CreoleMode.SIMPLE_LINE, null, null);
}
private Ftile getDiamond2(Branch branch1, Branch branch2, boolean useNorth) {
final Ftile diamond2;
private Ftile getShape2(Branch branch1, Branch branch2, boolean useNorth) {
final Ftile shape2;
if (conditionEndStyle == ConditionEndStyle.HLINE) {
return new FtileEmpty(tile1.skinParam(), 0, Diamond.diamondHalfSize, swimlane, swimlane);
return new FtileEmpty(tile1.skinParam(), 0, Hexagon.hexagonHalfSize, swimlane, swimlane);
}
// else use default ConditionEndStyle.DIAMOND
if (hasTwoBranches()) {
@ -305,11 +305,11 @@ public class ConditionalBuilder {
FtileDiamond tmp = new FtileDiamond(tile1.skinParam(), backColor, borderColor, swimlane);
tmp = useNorth ? tmp.withNorth(tbout1) : tmp.withWest(tbout1);
tmp = tmp.withEast(tbout2);
diamond2 = tmp;
shape2 = tmp;
} else {
diamond2 = new FtileEmpty(tile1.skinParam(), 0, Diamond.diamondHalfSize / 2, swimlane, swimlane);
shape2 = new FtileEmpty(tile1.skinParam(), 0, Hexagon.hexagonHalfSize / 2, swimlane, swimlane);
}
return diamond2;
return shape2;
}
public boolean hasTwoBranches() {

View File

@ -46,7 +46,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable;
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
@ -145,7 +145,7 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds {
p2 = translate2.getTranslated(p2);
final Direction newDirection = Direction.leftOrRight(p1, p2);
if (originalDirection != newDirection) {
final double delta = (originalDirection == Direction.RIGHT ? -1 : 1) * Diamond.diamondHalfSize;
final double delta = (originalDirection == Direction.RIGHT ? -1 : 1) * Hexagon.hexagonHalfSize;
final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
final Snake small = Snake.create(color);
small.addPoint(p1);
@ -242,7 +242,7 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds {
final Direction newDirection = Direction.leftOrRight(mp1a, mp2b);
final UPolygon arrow = x2 > x1 ? Arrows.asToRight() : Arrows.asToLeft();
if (originalDirection == newDirection) {
final double delta = (x2 > x1 ? -1 : 1) * 1.5 * Diamond.diamondHalfSize;
final double delta = (x2 > x1 ? -1 : 1) * 1.5 * Hexagon.hexagonHalfSize;
final Point2D mp2bc = new Point2D.Double(mp2b.getX() + delta, mp2b.getY());
final Snake snake = Snake.create(myArrowColor).withMerge(MergeStrategy.LIMITED);
final double middle = (mp1a.getY() + mp2b.getY()) / 2.0;
@ -257,9 +257,9 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds {
small.addPoint(mp2b);
ug.draw(small);
} else {
final double delta = (x2 > x1 ? -1 : 1) * 1.5 * Diamond.diamondHalfSize;
final double delta = (x2 > x1 ? -1 : 1) * 1.5 * Hexagon.hexagonHalfSize;
final Point2D mp2bb = new Point2D.Double(mp2b.getX() + delta,
mp2b.getY() - 1.5 * Diamond.diamondHalfSize);
mp2b.getY() - 1.5 * Hexagon.hexagonHalfSize);
final Snake snake = Snake.create(myArrowColor).withMerge(MergeStrategy.LIMITED);
snake.addPoint(mp1a);
snake.addPoint(mp1a.getX(), mp2bb.getY());
@ -325,7 +325,7 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds {
return;
}
final Point2D p1 = geo.translate(translate(stringBounder)).getPointOut();
final Point2D p2 = new Point2D.Double(dimTotal.getLeft(), dimTotal.getHeight() - Diamond.diamondHalfSize);
final Point2D p2 = new Point2D.Double(dimTotal.getLeft(), dimTotal.getHeight() - Hexagon.hexagonHalfSize);
final Point2D mp1a = translate1.getTranslated(p1);
final Point2D mp2b = translate2.getTranslated(p2);

View File

@ -41,6 +41,7 @@ import java.util.List;
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.activitydiagram3.Branch;
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
@ -49,8 +50,10 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.Rainbow;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UPolygon;
@ -85,8 +88,8 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds {
final double x2 = p2.getX();
final double y2 = p2.getY();
final Snake snake = Snake.create(null, arrowColor, Arrows.asToDown()).withLabel(branch.getTextBlockPositive(),
arrowHorizontalAlignment());
final Snake snake = Snake.create(null, arrowColor, Arrows.asToDown())
.withLabel(branch.getTextBlockPositive(), arrowHorizontalAlignment());
snake.addPoint(x1, y1);
snake.addPoint(x2, y1);
snake.addPoint(x2, y2);
@ -116,8 +119,11 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds {
class ConnectionVerticalThenHorizontal extends AbstractConnection {
public ConnectionVerticalThenHorizontal(Ftile tile) {
private final TextBlock outLabel;
public ConnectionVerticalThenHorizontal(Ftile tile, TextBlock outLabel) {
super(tile, diamond2);
this.outLabel = outLabel;
}
public void drawU(UGraphic ug) {
@ -154,7 +160,7 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds {
final double x2 = p2.getX();
final double y2 = p2.getY();
final Snake snake = Snake.create(arrowColor, arrow);
final Snake snake = Snake.create(arrowColor, arrow).withLabel(outLabel, VerticalAlignment.CENTER);
snake.addPoint(x1, y1);
if (direction == Direction.LEFT && x2 > x1 - 10) {
snake.addPoint(x1, y2 - 8);
@ -195,8 +201,8 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds {
final double x2 = p2.getX();
final double y2 = p2.getY();
final Snake snake = Snake.create(null, arrowColor, Arrows.asToDown()).withLabel(branch.getTextBlockPositive(),
VerticalAlignment.CENTER);
final Snake snake = Snake.create(null, arrowColor, Arrows.asToDown())
.withLabel(branch.getTextBlockPositive(), VerticalAlignment.CENTER);
if (x2 < p1d.getX() - margin || x2 > p1b.getX() + margin) {
snake.addPoint(x2, p1d.getY());
snake.addPoint(x2, y2);
@ -222,8 +228,11 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds {
class ConnectionVerticalBottom extends AbstractConnection {
public ConnectionVerticalBottom(Ftile tile) {
final private TextBlock outLabel;
public ConnectionVerticalBottom(Ftile tile, TextBlock textBlock) {
super(tile, diamond2);
this.outLabel = textBlock;
}
public void drawU(UGraphic ug) {
@ -248,7 +257,8 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds {
final double ym = (y1 + y2) / 2;
final Snake snake = Snake.create(null, arrowColor, Arrows.asToDown());
final Snake snake = Snake.create(null, arrowColor, Arrows.asToDown()).withLabel(outLabel,
VerticalAlignment.CENTER);
if (x1 < p1d.getX() - margin || x1 > p1b.getX() + margin) {
snake.addPoint(x1, y1);
@ -303,13 +313,15 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds {
final int firstOutgoingArrow = getFirstOutgoingArrow(stringBounder);
final int lastOutgoingArrow = getLastOutgoingArrow(stringBounder);
if (firstOutgoingArrow < tiles.size())
conns.add(new ConnectionVerticalThenHorizontal(tiles.get(firstOutgoingArrow)));
conns.add(new ConnectionVerticalThenHorizontal(tiles.get(firstOutgoingArrow),
branches.get(firstOutgoingArrow).getTextBlockSpecial()));
if (lastOutgoingArrow > 0)
conns.add(new ConnectionVerticalThenHorizontal(tiles.get(lastOutgoingArrow)));
conns.add(new ConnectionVerticalThenHorizontal(tiles.get(lastOutgoingArrow),
branches.get(lastOutgoingArrow).getTextBlockSpecial()));
for (int i = firstOutgoingArrow + 1; i < lastOutgoingArrow; i++) {
final Ftile tile = tiles.get(i);
if (tile.calculateDimension(stringBounder).hasPointOut()) {
conns.add(new ConnectionVerticalBottom(tile));
conns.add(new ConnectionVerticalBottom(tile, branches.get(i).getTextBlockSpecial()));
}
}
}

View File

@ -73,7 +73,6 @@ import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleBuilder;
import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UStroke;

View File

@ -73,7 +73,6 @@ import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleBuilder;
import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.ugraphic.UEmpty;
import net.sourceforge.plantuml.ugraphic.UGraphic;

View File

@ -35,6 +35,8 @@
*/
package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.graphic.StringBounder;
@ -46,7 +48,11 @@ public class FtileDecorateInLabel extends FtileDecorate {
final private double xl;
final private double yl;
public FtileDecorateInLabel(final Ftile ftile, double xl, double yl) {
public FtileDecorateInLabel(Ftile ftile, Dimension2D dim) {
this(ftile, dim.getWidth(), dim.getHeight());
}
private FtileDecorateInLabel(final Ftile ftile, double xl, double yl) {
super(ftile);
this.xl = xl;
this.yl = yl;

View File

@ -0,0 +1,76 @@
/* ========================================================================
* 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.ftile.vertical;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class FtileDecorateOutLabel extends FtileDecorate {
final private double xl;
final private double yl;
public FtileDecorateOutLabel(Ftile ftile, Dimension2D dim) {
this(ftile, dim.getWidth(), dim.getHeight());
}
private FtileDecorateOutLabel(Ftile ftile, double xl, double yl) {
super(ftile);
this.xl = xl;
this.yl = yl;
}
@Override
public FtileGeometry calculateDimension(StringBounder stringBounder) {
FtileGeometry result = super.calculateDimension(stringBounder);
result = result.addBottom(yl);
final double missing = xl - result.getRight();
if (missing > 0)
result = result.incRight(missing);
return result;
}
@Override
public void drawU(UGraphic ug) {
super.drawU(ug);
}
}

View File

@ -36,136 +36,81 @@
package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
import java.awt.geom.Dimension2D;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.UseStyle;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class FtileDiamond extends AbstractFtile {
private final HColor backColor;
private final HColor borderColor;
private final Swimlane swimlane;
private final TextBlock north;
private final TextBlock south;
private final TextBlock west1;
private final TextBlock east1;
private final double shadowing;
public class FtileDiamond extends FtileDiamondWIP {
public FtileDiamond(ISkinParam skinParam, HColor backColor, HColor borderColor, Swimlane swimlane) {
this(skinParam, backColor, borderColor, swimlane, TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0),
TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
}
public StyleSignature getDefaultStyleDefinitionDiamond() {
return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.diamond);
}
@Override
public Collection<Ftile> getMyChildren() {
return Collections.emptyList();
}
public FtileDiamond withNorth(TextBlock north) {
return new FtileDiamond(skinParam(), backColor, borderColor, swimlane, north, south, east1, west1);
return new FtileDiamond(skinParam(), backColor, borderColor, swimlane, north, south, east, west);
}
public FtileDiamond withWest(TextBlock west1) {
if (west1 == null) {
return this;
}
return new FtileDiamond(skinParam(), backColor, borderColor, swimlane, north, south, east1, west1);
return new FtileDiamond(skinParam(), backColor, borderColor, swimlane, north, south, east, west1);
}
public FtileDiamond withEast(TextBlock east1) {
if (east1 == null) {
return this;
}
return new FtileDiamond(skinParam(), backColor, borderColor, swimlane, north, south, east1, west1);
return new FtileDiamond(skinParam(), backColor, borderColor, swimlane, north, south, east1, west);
}
public FtileDiamond withSouth(TextBlock south) {
return new FtileDiamond(skinParam(), backColor, borderColor, swimlane, north, south, east1, west1);
return new FtileDiamond(skinParam(), backColor, borderColor, swimlane, north, south, east, west);
}
private FtileDiamond(ISkinParam skinParam, HColor backColor, HColor borderColor, Swimlane swimlane,
TextBlock north, TextBlock south, TextBlock east1, TextBlock west1) {
super(skinParam);
if (UseStyle.useBetaStyle()) {
Style style = getDefaultStyleDefinitionDiamond().getMergedStyle(skinParam.getCurrentStyleBuilder());
shadowing = style.value(PName.Shadowing).asDouble();
} else {
shadowing = skinParam().shadowing(null) ? 3 : 0;
}
this.backColor = backColor;
this.swimlane = swimlane;
this.borderColor = borderColor;
this.north = north;
this.west1 = west1;
this.east1 = east1;
this.south = south;
}
public Set<Swimlane> getSwimlanes() {
if (swimlane == null) {
return Collections.emptySet();
}
return Collections.singleton(swimlane);
}
public Swimlane getSwimlaneIn() {
return swimlane;
}
public Swimlane getSwimlaneOut() {
return swimlane;
private FtileDiamond(ISkinParam skinParam, HColor backColor, HColor borderColor, Swimlane swimlane, TextBlock north,
TextBlock south, TextBlock east, TextBlock west) {
super(null, skinParam, backColor, borderColor, swimlane, north, south, east, west);
}
public void drawU(UGraphic ug) {
final double suppY1 = north.calculateDimension(ug.getStringBounder()).getHeight();
ug = ug.apply(UTranslate.dy(suppY1));
ug.apply(borderColor).apply(getThickness()).apply(backColor.bg())
.draw(Diamond.asPolygon(shadowing));
ug.apply(borderColor).apply(getThickness()).apply(backColor.bg()).draw(Hexagon.asPolygon(shadowing));
// final Dimension2D dimNorth = north.calculateDimension(ug.getStringBounder());
north.drawU(ug.apply(new UTranslate(Diamond.diamondHalfSize * 1.5, -suppY1)));
north.drawU(ug.apply(new UTranslate(Hexagon.hexagonHalfSize * 1.5, -suppY1)));
// final Dimension2D dimSouth = south.calculateDimension(ug.getStringBounder());
south.drawU(ug.apply(new UTranslate(Diamond.diamondHalfSize * 1.5, 2 * Diamond.diamondHalfSize)));
// south.drawU(ug.apply(new UTranslate(-(dimSouth.getWidth() - 2 * Diamond.diamondHalfSize) / 2,
south.drawU(ug.apply(new UTranslate(Hexagon.hexagonHalfSize * 1.5, 2 * Hexagon.hexagonHalfSize)));
// south.drawU(ug.apply(new UTranslate(-(dimSouth.getWidth() - 2 *
// Diamond.diamondHalfSize) / 2,
// 2 * Diamond.diamondHalfSize)));
final Dimension2D dimWeat1 = west1.calculateDimension(ug.getStringBounder());
west1.drawU(ug.apply(new UTranslate(-dimWeat1.getWidth(), -dimWeat1.getHeight() + Diamond.diamondHalfSize)));
final Dimension2D dimWeat1 = west.calculateDimension(ug.getStringBounder());
west.drawU(ug.apply(new UTranslate(-dimWeat1.getWidth(), -dimWeat1.getHeight() + Hexagon.hexagonHalfSize)));
final Dimension2D dimEast1 = east1.calculateDimension(ug.getStringBounder());
east1.drawU(ug.apply(new UTranslate(Diamond.diamondHalfSize * 2, -dimEast1.getHeight()
+ Diamond.diamondHalfSize)));
final Dimension2D dimEast1 = east.calculateDimension(ug.getStringBounder());
east.drawU(
ug.apply(new UTranslate(Hexagon.hexagonHalfSize * 2, -dimEast1.getHeight() + Hexagon.hexagonHalfSize)));
}
@Override
protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder) {
final double suppY1 = north.calculateDimension(stringBounder).getHeight();
final Dimension2D dim = new Dimension2DDouble(Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2 + suppY1);
final Dimension2D dim = new Dimension2DDouble(Hexagon.hexagonHalfSize * 2,
Hexagon.hexagonHalfSize * 2 + suppY1);
return new FtileGeometry(dim, dim.getWidth() / 2, suppY1, dim.getHeight());
}
@ -174,7 +119,7 @@ public class FtileDiamond extends AbstractFtile {
}
public double getEastLabelWidth(StringBounder stringBounder) {
final Dimension2D dimEast = east1.calculateDimension(stringBounder);
final Dimension2D dimEast = east.calculateDimension(stringBounder);
return dimEast.getWidth();
}

View File

@ -36,67 +36,38 @@
package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
import java.awt.geom.Dimension2D;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.UseStyle;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.style.Styleable;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class FtileDiamondInside extends AbstractFtile implements Styleable {
public class FtileDiamondInside extends FtileDiamondWIP {
private final HColor backColor;
private final HColor borderColor;
private final Swimlane swimlane;
private final TextBlock label;
private final TextBlock west;
private final TextBlock east;
private final TextBlock north;
private final TextBlock south;
private final double shadowing;
@Override
public Collection<Ftile> getMyChildren() {
return Collections.emptyList();
}
public StyleSignature getDefaultStyleDefinition() {
return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity, SName.diamond);
}
public FtileDiamondInside(ISkinParam skinParam, HColor backColor, HColor borderColor, Swimlane swimlane,
TextBlock label) {
this(skinParam, backColor, borderColor, swimlane, label, TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0),
public FtileDiamondInside(TextBlock label, ISkinParam skinParam, HColor backColor, HColor borderColor,
Swimlane swimlane) {
this(label, skinParam, backColor, borderColor, swimlane, TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0),
TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
}
public FtileDiamondInside withNorth(TextBlock north) {
return new FtileDiamondInside(skinParam(), backColor, borderColor, swimlane, label, north, south, west, east);
return new FtileDiamondInside(label, skinParam(), backColor, borderColor, swimlane, north, south, west, east);
}
public FtileDiamondInside withWest(TextBlock west) {
return new FtileDiamondInside(skinParam(), backColor, borderColor, swimlane, label, north, south, west, east);
return new FtileDiamondInside(label, skinParam(), backColor, borderColor, swimlane, north, south, west, east);
}
public FtileDiamondInside withEast(TextBlock east) {
return new FtileDiamondInside(skinParam(), backColor, borderColor, swimlane, label, north, south, west, east);
return new FtileDiamondInside(label, skinParam(), backColor, borderColor, swimlane, north, south, west, east);
}
public Ftile withWestAndEast(TextBlock tb1, TextBlock tb2) {
@ -104,43 +75,12 @@ public class FtileDiamondInside extends AbstractFtile implements Styleable {
}
public FtileDiamondInside withSouth(TextBlock south) {
return new FtileDiamondInside(skinParam(), backColor, borderColor, swimlane, label, north, south, west, east);
return new FtileDiamondInside(label, skinParam(), backColor, borderColor, swimlane, north, south, west, east);
}
private FtileDiamondInside(ISkinParam skinParam, HColor backColor, HColor borderColor, Swimlane swimlane,
TextBlock label, TextBlock north, TextBlock south, TextBlock west, TextBlock east) {
super(skinParam);
if (UseStyle.useBetaStyle()) {
final Style style = getDefaultStyleDefinition().getMergedStyle(skinParam.getCurrentStyleBuilder());
this.borderColor = style.value(PName.LineColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet());
this.backColor = style.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet());
this.shadowing = style.value(PName.Shadowing).asDouble();
} else {
this.backColor = backColor;
this.borderColor = borderColor;
this.shadowing = skinParam().shadowing(null) ? 3 : 0;
}
this.swimlane = swimlane;
this.label = label;
this.west = west;
this.east = east;
this.north = north;
this.south = south;
}
public Set<Swimlane> getSwimlanes() {
if (swimlane == null) {
return Collections.emptySet();
}
return Collections.singleton(swimlane);
}
public Swimlane getSwimlaneIn() {
return swimlane;
}
public Swimlane getSwimlaneOut() {
return swimlane;
private FtileDiamondInside(TextBlock label, ISkinParam skinParam, HColor backColor, HColor borderColor,
Swimlane swimlane, TextBlock north, TextBlock south, TextBlock west, TextBlock east) {
super(label, skinParam, backColor, borderColor, swimlane, north, south, east, west);
}
public void drawU(UGraphic ug) {
@ -148,7 +88,7 @@ public class FtileDiamondInside extends AbstractFtile implements Styleable {
final Dimension2D dimLabel = label.calculateDimension(stringBounder);
final Dimension2D dimTotal = calculateDimensionAlone(stringBounder);
ug = ug.apply(borderColor).apply(getThickness()).apply(backColor.bg());
ug.draw(Diamond.asPolygon(shadowing, dimTotal.getWidth(), dimTotal.getHeight()));
ug.draw(Hexagon.asPolygon(shadowing, dimTotal.getWidth(), dimTotal.getHeight()));
north.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
south.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
@ -169,11 +109,11 @@ public class FtileDiamondInside extends AbstractFtile implements Styleable {
final Dimension2D dimLabel = label.calculateDimension(stringBounder);
final Dimension2D dim;
if (dimLabel.getWidth() == 0 || dimLabel.getHeight() == 0) {
dim = new Dimension2DDouble(Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2);
dim = new Dimension2DDouble(Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2);
} else {
dim = Dimension2DDouble.delta(
Dimension2DDouble.atLeast(dimLabel, Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2),
Diamond.diamondHalfSize * 2, 0);
Dimension2DDouble.atLeast(dimLabel, Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2),
Hexagon.hexagonHalfSize * 2, 0);
}
return new FtileGeometry(dim, dim.getWidth() / 2, 0, dim.getHeight());
}
@ -185,8 +125,6 @@ public class FtileDiamondInside extends AbstractFtile implements Styleable {
final Dimension2D dimEast = east.calculateDimension(stringBounder);
final double northHeight = north.calculateDimension(stringBounder).getHeight();
return dimDiamonAlone.incHeight(northHeight);
// return dimDiamonAlone.incHeight(northHeight).addMarginX(dimWest.getWidth(),
// dimEast.getWidth());
}
public double getEastLabelWidth(StringBounder stringBounder) {

View File

@ -36,97 +36,46 @@
package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
import java.awt.geom.Dimension2D;
import java.util.Collections;
import java.util.Set;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.UseStyle;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class FtileDiamondInside2 extends AbstractFtile {
public class FtileDiamondInside2 extends FtileDiamondWIP {
private final HColor backColor;
private final HColor borderColor;
private final Swimlane swimlane;
private final TextBlock label;
private final TextBlock west;
private final TextBlock east;
private final TextBlock north;
private final TextBlock south;
private final double shadowing;
public FtileDiamondInside2(ISkinParam skinParam, HColor backColor, HColor borderColor, Swimlane swimlane,
TextBlock label) {
this(skinParam, backColor, borderColor, swimlane, label, TextBlockUtils.empty(0, 0),
TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
public FtileDiamondInside2(TextBlock label, ISkinParam skinParam, HColor backColor, HColor borderColor,
Swimlane swimlane) {
this(label, skinParam, backColor, borderColor, swimlane, TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0),
TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
}
public FtileDiamondInside2 withNorth(TextBlock north) {
return new FtileDiamondInside2(skinParam(), backColor, borderColor, swimlane, label, north, south, west, east);
return new FtileDiamondInside2(label, skinParam(), backColor, borderColor, swimlane, north, south, west, east);
}
public FtileDiamondInside2 withWest(TextBlock west) {
return new FtileDiamondInside2(skinParam(), backColor, borderColor, swimlane, label, north, south, west, east);
return new FtileDiamondInside2(label, skinParam(), backColor, borderColor, swimlane, north, south, west, east);
}
public FtileDiamondInside2 withEast(TextBlock east) {
return new FtileDiamondInside2(skinParam(), backColor, borderColor, swimlane, label, north, south, west, east);
return new FtileDiamondInside2(label, skinParam(), backColor, borderColor, swimlane, north, south, west, east);
}
public FtileDiamondInside2 withSouth(TextBlock south) {
return new FtileDiamondInside2(skinParam(), backColor, borderColor, swimlane, label, north, south, west, east);
}
public StyleSignature getDefaultStyleDefinition() {
return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity, SName.diamond);
return new FtileDiamondInside2(label, skinParam(), backColor, borderColor, swimlane, north, south, west, east);
}
private FtileDiamondInside2(ISkinParam skinParam, HColor backColor, HColor borderColor, Swimlane swimlane,
TextBlock label, TextBlock north, TextBlock south, TextBlock west, TextBlock east) {
super(skinParam);
if (UseStyle.useBetaStyle()) {
final Style style = getDefaultStyleDefinition().getMergedStyle(skinParam.getCurrentStyleBuilder());
this.shadowing = style.value(PName.Shadowing).asDouble();
} else {
this.shadowing = skinParam().shadowing(null) ? 3 : 0;
}
this.backColor = backColor;
this.swimlane = swimlane;
this.borderColor = borderColor;
this.label = label;
this.west = west;
this.east = east;
this.north = north;
this.south = south;
}
public Set<Swimlane> getSwimlanes() {
if (swimlane == null) {
return Collections.emptySet();
}
return Collections.singleton(swimlane);
}
public Swimlane getSwimlaneIn() {
return swimlane;
}
public Swimlane getSwimlaneOut() {
return swimlane;
private FtileDiamondInside2(TextBlock label, ISkinParam skinParam, HColor backColor, HColor borderColor,
Swimlane swimlane, TextBlock north, TextBlock south, TextBlock west, TextBlock east) {
super(label, skinParam, backColor, borderColor, swimlane, north, south, east, west);
}
public void drawU(UGraphic ug) {
@ -134,7 +83,7 @@ public class FtileDiamondInside2 extends AbstractFtile {
final Dimension2D dimLabel = label.calculateDimension(stringBounder);
final Dimension2D dimTotal = calculateDimensionAlone(stringBounder);
ug = ug.apply(borderColor).apply(getThickness()).apply(backColor.bg());
ug.draw(Diamond.asPolygon(shadowing, dimTotal.getWidth(), dimTotal.getHeight()));
ug.draw(Hexagon.asPolygon(shadowing, dimTotal.getWidth(), dimTotal.getHeight()));
north.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
south.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
@ -155,11 +104,11 @@ public class FtileDiamondInside2 extends AbstractFtile {
final Dimension2D dimLabel = label.calculateDimension(stringBounder);
final Dimension2D dim;
if (dimLabel.getWidth() == 0 || dimLabel.getHeight() == 0) {
dim = new Dimension2DDouble(Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2);
dim = new Dimension2DDouble(Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2);
} else {
dim = Dimension2DDouble.delta(
Dimension2DDouble.atLeast(dimLabel, Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2),
Diamond.diamondHalfSize * 2, 0);
Dimension2DDouble.atLeast(dimLabel, Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2),
Hexagon.hexagonHalfSize * 2, 0);
}
return new FtileGeometry(dim, dim.getWidth() / 2, 0, dim.getHeight());
}

View File

@ -1,178 +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.ftile.vertical;
import java.awt.geom.Dimension2D;
import java.util.Collections;
import java.util.Set;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileOverpassing;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.utils.MathUtils;
public class FtileDiamondInside3 extends AbstractFtile implements FtileOverpassing {
private final HColor backColor;
private final HColor borderColor;
private final Swimlane swimlane;
private final TextBlock label;
private final TextBlock west;
private final TextBlock east;
private final TextBlock north;
private final TextBlock south;
public FtileDiamondInside3(ISkinParam skinParam, HColor backColor, HColor borderColor, Swimlane swimlane,
TextBlock label) {
this(skinParam, backColor, borderColor, swimlane, label, TextBlockUtils.empty(0, 0),
TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
}
public FtileDiamondInside3 withNorth(TextBlock north) {
return new FtileDiamondInside3(skinParam(), backColor, borderColor, swimlane, label, north, south, west, east);
}
public FtileDiamondInside3 withWest(TextBlock west) {
return new FtileDiamondInside3(skinParam(), backColor, borderColor, swimlane, label, north, south, west, east);
}
public FtileDiamondInside3 withEast(TextBlock east) {
return new FtileDiamondInside3(skinParam(), backColor, borderColor, swimlane, label, north, south, west, east);
}
public FtileDiamondInside3 withSouth(TextBlock south) {
return new FtileDiamondInside3(skinParam(), backColor, borderColor, swimlane, label, north, south, west, east);
}
private FtileDiamondInside3(ISkinParam skinParam, HColor backColor, HColor borderColor, Swimlane swimlane,
TextBlock label, TextBlock north, TextBlock south, TextBlock west, TextBlock east) {
super(skinParam);
this.backColor = backColor;
this.swimlane = swimlane;
this.borderColor = borderColor;
this.label = label;
this.west = west;
this.east = east;
this.north = north;
this.south = south;
}
public Set<Swimlane> getSwimlanes() {
if (swimlane == null) {
return Collections.emptySet();
}
return Collections.singleton(swimlane);
}
public Swimlane getSwimlaneIn() {
return swimlane;
}
public Swimlane getSwimlaneOut() {
return swimlane;
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Dimension2D dimLabel = label.calculateDimension(stringBounder);
final Dimension2D dimTotal = calculateDimensionAlone(stringBounder);
ug = ug.apply(borderColor).apply(getThickness()).apply(backColor.bg());
final double shadowing = skinParam().shadowing(null) ? 3 : 0;
ug.draw(Diamond.asPolygon(shadowing, dimTotal.getWidth(), dimTotal.getHeight()));
north.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
south.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
final double lx = (dimTotal.getWidth() - dimLabel.getWidth()) / 2;
final double ly = (dimTotal.getHeight() - dimLabel.getHeight()) / 2;
label.drawU(ug.apply(new UTranslate(lx, ly)));
final Dimension2D dimWeat = west.calculateDimension(stringBounder);
west.drawU(ug.apply(new UTranslate(-dimWeat.getWidth(), -dimWeat.getHeight() + dimTotal.getHeight() / 2)));
final Dimension2D dimEast = east.calculateDimension(stringBounder);
east.drawU(ug.apply(new UTranslate(dimTotal.getWidth(), -dimEast.getHeight() + dimTotal.getHeight() / 2)));
}
private FtileGeometry calculateDimensionAlone(StringBounder stringBounder) {
final Dimension2D dimLabel = label.calculateDimension(stringBounder);
final Dimension2D dim;
if (dimLabel.getWidth() == 0 || dimLabel.getHeight() == 0) {
dim = new Dimension2DDouble(Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2);
} else {
dim = Dimension2DDouble.delta(
Dimension2DDouble.atLeast(dimLabel, Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2),
Diamond.diamondHalfSize * 2, 0);
}
return new FtileGeometry(dim, dim.getWidth() / 2, 0, dim.getHeight());
}
@Override
protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder) {
final Dimension2D diamond = calculateDimensionAlone(stringBounder);
final Dimension2D north = this.north.calculateDimension(stringBounder);
final double height = diamond.getHeight() + north.getHeight();
final double left = diamond.getWidth() / 2;
// final double width = north.getWidth() > left ? left + north.getWidth() : diamond.getWidth();
final double width = diamond.getWidth();
return new FtileGeometry(width, height, left, 0, diamond.getHeight());
}
public FtileGeometry getOverpassDimension(StringBounder stringBounder) {
final Dimension2D total = calculateDimension(stringBounder);
final Dimension2D north = this.north.calculateDimension(stringBounder);
final Dimension2D east = this.east.calculateDimension(stringBounder);
final Dimension2D west = this.west.calculateDimension(stringBounder);
final double height = total.getHeight(); // + north.getHeight();
final double left = total.getWidth() / 2;
final double supp = MathUtils.max(north.getWidth(), east.getWidth(), west.getWidth());
// final double width = supp > left ? left + supp : diamond.getWidth();
final double width = total.getWidth() + supp;
return new FtileGeometry(width, height, left, 0, total.getHeight());
}
}

View File

@ -36,16 +36,12 @@
package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
import java.awt.geom.Dimension2D;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
@ -54,74 +50,37 @@ import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class FtileDiamondSquare extends AbstractFtile {
public class FtileDiamondSquare extends FtileDiamondWIP {
private final HColor backColor;
private final HColor borderColor;
private final Swimlane swimlane;
private final TextBlock label;
private final TextBlock west;
private final TextBlock east;
private final TextBlock north;
private final TextBlock south;
public FtileDiamondSquare(ISkinParam skinParam, HColor backColor, HColor borderColor, Swimlane swimlane,
TextBlock label) {
this(skinParam, backColor, borderColor, swimlane, label, TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0),
public FtileDiamondSquare(TextBlock label, ISkinParam skinParam, HColor backColor, HColor borderColor,
Swimlane swimlane) {
this(label, skinParam, backColor, borderColor, swimlane, TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0),
TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
}
@Override
public Collection<Ftile> getMyChildren() {
return Collections.emptyList();
}
public FtileDiamondSquare withNorth(TextBlock north) {
return new FtileDiamondSquare(skinParam(), backColor, borderColor, swimlane, label, north, west, east, south);
return new FtileDiamondSquare(label, skinParam(), backColor, borderColor, swimlane, north, west, east, south);
}
public FtileDiamondSquare withWest(TextBlock west) {
return new FtileDiamondSquare(skinParam(), backColor, borderColor, swimlane, label, north, west, east, south);
return new FtileDiamondSquare(label, skinParam(), backColor, borderColor, swimlane, north, west, east, south);
}
public FtileDiamondSquare withEast(TextBlock east) {
return new FtileDiamondSquare(skinParam(), backColor, borderColor, swimlane, label, north, west, east, south);
return new FtileDiamondSquare(label, skinParam(), backColor, borderColor, swimlane, north, west, east, south);
}
public FtileDiamondSquare withSouth(TextBlock south) {
return new FtileDiamondSquare(skinParam(), backColor, borderColor, swimlane, label, north, west, east, south);
return new FtileDiamondSquare(label, skinParam(), backColor, borderColor, swimlane, north, west, east, south);
}
public Ftile withWestAndEast(TextBlock tb1, TextBlock tb2) {
return withWest(tb1).withEast(tb2);
}
private FtileDiamondSquare(ISkinParam skinParam, HColor backColor, HColor borderColor, Swimlane swimlane,
TextBlock label, TextBlock north, TextBlock west, TextBlock east, TextBlock south) {
super(skinParam);
this.backColor = backColor;
this.swimlane = swimlane;
this.borderColor = borderColor;
this.label = label;
this.west = west;
this.east = east;
this.north = north;
this.south = south;
}
public Set<Swimlane> getSwimlanes() {
if (swimlane == null) {
return Collections.emptySet();
}
return Collections.singleton(swimlane);
}
public Swimlane getSwimlaneIn() {
return swimlane;
}
public Swimlane getSwimlaneOut() {
return swimlane;
private FtileDiamondSquare(TextBlock label, ISkinParam skinParam, HColor backColor, HColor borderColor,
Swimlane swimlane, TextBlock north, TextBlock west, TextBlock east, TextBlock south) {
super(label, skinParam, backColor, borderColor, swimlane, north, south, east, west);
}
public void drawU(UGraphic ug) {
@ -129,7 +88,7 @@ public class FtileDiamondSquare extends AbstractFtile {
final Dimension2D dimLabel = label.calculateDimension(stringBounder);
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
ug = ug.apply(borderColor).apply(getThickness()).apply(backColor.bg());
ug.draw(Diamond.asPolygonSquare(skinParam().shadowing(null), dimTotal.getWidth(), dimTotal.getHeight()));
ug.draw(Hexagon.asPolygonSquare(skinParam().shadowing(null), dimTotal.getWidth(), dimTotal.getHeight()));
// Fix why north and south are the same
north.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
@ -140,10 +99,10 @@ public class FtileDiamondSquare extends AbstractFtile {
label.drawU(ug.apply(new UTranslate(lx, ly)));
final Dimension2D dimWeat = west.calculateDimension(stringBounder);
west.drawU(ug.apply(new UTranslate(-dimWeat.getWidth(), -dimWeat.getHeight() + Diamond.diamondHalfSize)));
west.drawU(ug.apply(new UTranslate(-dimWeat.getWidth(), -dimWeat.getHeight() + Hexagon.hexagonHalfSize)));
final Dimension2D dimEast = east.calculateDimension(stringBounder);
east.drawU(ug.apply(new UTranslate(dimTotal.getWidth(), -dimEast.getHeight() + Diamond.diamondHalfSize)));
east.drawU(ug.apply(new UTranslate(dimTotal.getWidth(), -dimEast.getHeight() + Hexagon.hexagonHalfSize)));
}
@ -156,10 +115,10 @@ public class FtileDiamondSquare extends AbstractFtile {
private Dimension2D calculateDimensionInternal(StringBounder stringBounder) {
final Dimension2D dimLabel = label.calculateDimension(stringBounder);
if (dimLabel.getWidth() == 0 || dimLabel.getHeight() == 0) {
return new Dimension2DDouble(Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2);
return new Dimension2DDouble(Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2);
}
Dimension2D result = dimLabel;
result = Dimension2DDouble.delta(result, Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2);
result = Dimension2DDouble.delta(result, Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2);
return result;
}

View File

@ -0,0 +1,117 @@
/* ========================================================================
* 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.ftile.vertical;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.UseStyle;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.style.Styleable;
import net.sourceforge.plantuml.ugraphic.color.HColor;
abstract class FtileDiamondWIP extends AbstractFtile implements Styleable {
protected final HColor backColor;
protected final HColor borderColor;
protected final Swimlane swimlane;
protected final TextBlock label;
protected final TextBlock north;
protected final TextBlock south;
protected final TextBlock west;
protected final TextBlock east;
protected final double shadowing;
final public StyleSignature getDefaultStyleDefinition() {
return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity, SName.diamond);
}
@Override
final public Collection<Ftile> getMyChildren() {
return Collections.emptyList();
}
protected FtileDiamondWIP(TextBlock label, ISkinParam skinParam, HColor backColor, HColor borderColor,
Swimlane swimlane, TextBlock north, TextBlock south, TextBlock east, TextBlock west) {
super(skinParam);
if (UseStyle.useBetaStyle()) {
Style style = getDefaultStyleDefinition().getMergedStyle(skinParam.getCurrentStyleBuilder());
this.borderColor = style.value(PName.LineColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet());
this.backColor = style.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet());
this.shadowing = style.value(PName.Shadowing).asDouble();
} else {
this.backColor = backColor;
this.borderColor = borderColor;
this.shadowing = skinParam().shadowing(null) ? 3 : 0;
}
this.swimlane = swimlane;
this.label = label;
this.north = north;
this.west = west;
this.east = east;
this.south = south;
}
final public Set<Swimlane> getSwimlanes() {
if (swimlane == null) {
return Collections.emptySet();
}
return Collections.singleton(swimlane);
}
final public Swimlane getSwimlaneIn() {
return swimlane;
}
final public Swimlane getSwimlaneOut() {
return swimlane;
}
}

View File

@ -50,8 +50,8 @@ import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.security.SImageIO;
import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.sprite.Sprite;
import net.sourceforge.plantuml.sprite.SpriteImage;
import net.sourceforge.plantuml.sprite.SpriteSvg;

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml.creole.legacy;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@ -111,7 +112,7 @@ public class StripeCode implements Stripe, Atom {
}
public List<Atom> splitInTwo(StringBounder stringBounder, double width) {
throw new UnsupportedOperationException();
return Arrays.asList((Atom) this);
}
}

View File

@ -35,9 +35,9 @@
*/
package net.sourceforge.plantuml.png;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import javax.imageio.ImageReader;
@ -52,7 +52,7 @@ import net.sourceforge.plantuml.security.SFile;
public class MetadataTag {
private final Object source;
private final File source;
private final String tag;
public MetadataTag(SFile file, String tag) throws FileNotFoundException {
@ -65,11 +65,6 @@ public class MetadataTag {
this.tag = tag;
}
public MetadataTag(InputStream is, String tag) {
this.source = is;
this.tag = tag;
}
public String getData() throws IOException {
final ImageInputStream iis = SImageIO.createImageInputStream(source);
final Iterator<ImageReader> readers = SImageIO.getImageReaders(iis);

View File

@ -38,6 +38,7 @@ package net.sourceforge.plantuml.security;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -58,10 +59,6 @@ public class SImageIO {
javax.imageio.ImageIO.write(image, format, os);
}
public static void write(RenderedImage image, String format, java.io.File file) throws IOException {
javax.imageio.ImageIO.write(image, format, file);
}
public static void write(RenderedImage image, String format, SFile file) throws IOException {
javax.imageio.ImageIO.write(image, format, file.conv());
}
@ -77,23 +74,19 @@ public class SImageIO {
public static BufferedImage read(InputStream is) throws IOException {
return javax.imageio.ImageIO.read(is);
}
public static BufferedImage read(byte[] bytes) throws IOException {
return javax.imageio.ImageIO.read(new ByteArrayInputStream(bytes));
}
public static ImageInputStream createImageInputStream(java.io.File file) throws IOException {
return javax.imageio.ImageIO.createImageInputStream(file);
}
public static ImageInputStream createImageInputStream(SFile file) throws IOException {
return javax.imageio.ImageIO.createImageInputStream(file.conv());
}
public static ImageInputStream createImageInputStream(Object obj) throws IOException {
if (obj instanceof SFile) {
obj = ((SFile) obj).conv();
}
public static ImageInputStream createImageInputStream(File obj) throws IOException {
// if (obj instanceof SFile) {
// obj = ((SFile) obj).conv();
// }
return javax.imageio.ImageIO.createImageInputStream(obj);
}

View File

@ -72,6 +72,7 @@ public abstract class AbstractMessage implements EventWithDeactivate, WithStyle
private Url url;
private final String messageNumber;
private boolean parallel = false;
private AbstractMessage parallelBrother;
private final StyleBuilder styleBuilder;
private List<Note> noteOnMessages = new ArrayList<>();
@ -93,6 +94,10 @@ public abstract class AbstractMessage implements EventWithDeactivate, WithStyle
this.parallel = true;
}
public void setParallelBrother(AbstractMessage brother) {
this.parallelBrother = brother;
}
public boolean isParallel() {
return parallel;
}
@ -262,4 +267,5 @@ public abstract class AbstractMessage implements EventWithDeactivate, WithStyle
public abstract Participant getParticipant1();
public abstract Participant getParticipant2();
}

View File

@ -151,6 +151,9 @@ public class SequenceDiagram extends UmlDiagram {
}
public String addMessage(AbstractMessage m) {
if (m.isParallel()) {
m.setParallelBrother(getLastAbstractMessage());
}
lastEventWithDeactivate = m;
lastDelay = null;
events.add(m);
@ -164,6 +167,14 @@ public class SequenceDiagram extends UmlDiagram {
return null;
}
private AbstractMessage getLastAbstractMessage() {
for (int i = events.size() - 1; i > 0; i--)
if (events.get(i) instanceof AbstractMessage)
return (AbstractMessage) events.get(i);
return null;
}
public void addNote(Note n, boolean tryMerge) {
// this.lastEventWithDeactivate = null;
if (tryMerge && events.size() > 0) {

View File

@ -80,7 +80,7 @@ public class Version {
}
public static int beta() {
final int beta = 3;
final int beta = 7;
return beta;
}