diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa966d1c4..9ca3f3269 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,11 +9,18 @@ on: - master workflow_dispatch: +defaults: + run: + shell: bash + jobs: - CI: + workflow_config: runs-on: ubuntu-latest + outputs: + do_release: ${{ steps.config.outputs.do_release }} + pom_version: ${{ steps.config.outputs.pom_version }} steps: - - name: Configure job + - name: Configure workflow id: config env: ACTOR: ${{ github.actor }} @@ -47,13 +54,28 @@ jobs: echo "This run will NOT make a release" fi + # We run the tests on many OS / Java combinations but also the Compile step because some users build + # their own jars from source, so it is good for CI to check that is working on all combinations. + build: + needs: workflow_config + strategy: + fail-fast: false + matrix: + java_version: [ 8, 11, 17 ] + os: [ macos-10.15, macos-11, ubuntu-18.04, ubuntu-20.04, windows-2016, windows-2019, windows-2022 ] + include: + - release_from_this_build: true + os: ubuntu-20.04 + java_version: 8 + runs-on: ${{ matrix.os }} + steps: - name: Checkout the repository uses: actions/checkout@v2 - name: Set up java - uses: actions/setup-java@v2.3.0 + uses: actions/setup-java@v2.3.1 with: - java-version: 8 + java-version: ${{ matrix.java_version }} distribution: temurin cache: maven @@ -63,9 +85,9 @@ jobs: # POM version is usually a -SNAPSHOT at this point, if this is a release then we use the version derived from the tag - name: Set POM version - if: steps.config.outputs.do_release == 'true' + if: needs.workflow_config.outputs.do_release == 'true' env: - POM_VERSION: ${{ steps.config.outputs.pom_version }} + POM_VERSION: ${{ needs.workflow_config.outputs.pom_version }} run: | mvn --batch-mode versions:set "-DnewVersion=${POM_VERSION}" @@ -77,24 +99,37 @@ jobs: run: mvn --batch-mode test - name: Package + if: ${{ matrix.release_from_this_build }} run: mvn --batch-mode -Dmaven.test.skip=true package - name: Upload jar artifacts - if: ${{ always() }} + if: ${{ matrix.release_from_this_build }} uses: actions/upload-artifact@v2 with: # Using github.run_number here to reduce confusion when downloading & comparing artifacts from several builds name: ${{ github.run_number }}-jars path: target/*.jar + release: + needs: [ workflow_config, build ] + if: needs.workflow_config.outputs.do_release == 'true' + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v2 + + - name: Download jar artifacts + uses: actions/download-artifact@v2 + with: + name: ${{ github.run_number }}-jars + - name: Create release in GitHub - if: steps.config.outputs.do_release == 'true' env: GITHUB_TOKEN: ${{ github.token }} - POM_VERSION: ${{ steps.config.outputs.pom_version }} + POM_VERSION: ${{ needs.workflow_config.outputs.pom_version }} TAG: ${{ github.event.ref }} run: | gh release create "${TAG}" \ - "target/plantuml-${POM_VERSION}.jar" \ - "target/plantuml-${POM_VERSION}-javadoc.jar" \ - "target/plantuml-${POM_VERSION}-sources.jar" + "plantuml-${POM_VERSION}.jar" \ + "plantuml-${POM_VERSION}-javadoc.jar" \ + "plantuml-${POM_VERSION}-sources.jar" diff --git a/pom.xml b/pom.xml index 2615dd94f..c74569606 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ net.sourceforge.plantuml plantuml - 1.2021.11-SNAPSHOT + 1.2021.13-SNAPSHOT jar PlantUML @@ -57,12 +57,19 @@ 7 + + 1.7 + 1.7 + 1.8 + 1.8 + + org.junit junit-bom - 5.8.0 + 5.8.1 pom import @@ -74,7 +81,7 @@ org.apache.ant ant - 1.10.11 + 1.10.12 provided @@ -156,8 +163,6 @@ maven-compiler-plugin 3.8.1 - 1.7 - 1.7 true @@ -179,7 +184,7 @@ maven-javadoc-plugin - 3.3.1 + 3.2.0 attach-javadocs @@ -234,4 +239,24 @@ + + + + + intellij + + false + + idea.maven.embedder.version + + + + 1.8 + 1.8 + + + diff --git a/skin/plantuml.skin b/skin/plantuml.skin index 54219342d..b7b9e874e 100644 --- a/skin/plantuml.skin +++ b/skin/plantuml.skin @@ -64,6 +64,9 @@ stereotype { element { Shadowing 4.0 + title { + FontStyle bold + } } group { @@ -95,6 +98,18 @@ classDiagram { } +stateDiagram { + state { + RoundCorner 25 + } + element { + title { + FontStyle plain + } + } +} + + destroy { } diff --git a/src/ext/plantuml/com/ctreber/acearth/gui/PixelCanvas.java b/src/ext/plantuml/com/ctreber/acearth/gui/PixelCanvas.java index f06dff741..ab4b3deaa 100644 --- a/src/ext/plantuml/com/ctreber/acearth/gui/PixelCanvas.java +++ b/src/ext/plantuml/com/ctreber/acearth/gui/PixelCanvas.java @@ -7,7 +7,7 @@ import java.io.IOException; import java.io.OutputStream; import ext.plantuml.com.ctreber.acearth.renderer.RenderTarget; -import net.sourceforge.plantuml.security.ImageIO; +import net.sourceforge.plantuml.security.SImageIO; /** *

@@ -58,7 +58,7 @@ public class PixelCanvas implements RenderTarget { } public void saveToImage(OutputStream os) throws IOException { - ImageIO.write(fEarthImage2, "png", os); + SImageIO.write(fEarthImage2, "png", os); } } diff --git a/src/net/sourceforge/plantuml/ClipboardLoop.java b/src/net/sourceforge/plantuml/ClipboardLoop.java index cd0da6723..160408e5c 100644 --- a/src/net/sourceforge/plantuml/ClipboardLoop.java +++ b/src/net/sourceforge/plantuml/ClipboardLoop.java @@ -45,7 +45,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import net.sourceforge.plantuml.core.DiagramDescription; -import net.sourceforge.plantuml.security.ImageIO; +import net.sourceforge.plantuml.security.SImageIO; public class ClipboardLoop { @@ -88,7 +88,7 @@ public class ClipboardLoop { } else { Log.info("Image ok " + desc.getDescription()); baos.close(); - final BufferedImage image = ImageIO.read(baos.toByteArray()); + final BufferedImage image = SImageIO.read(baos.toByteArray()); setClipboardImage(image); Log.info("Image copied in clipboard"); } diff --git a/src/net/sourceforge/plantuml/Dimension2DDouble.java b/src/net/sourceforge/plantuml/Dimension2DDouble.java index f9f7293c1..08ec8aa3f 100644 --- a/src/net/sourceforge/plantuml/Dimension2DDouble.java +++ b/src/net/sourceforge/plantuml/Dimension2DDouble.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml; import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; import net.sourceforge.plantuml.utils.MathUtils; @@ -52,6 +53,10 @@ public class Dimension2DDouble extends Dimension2D { this.height = height; } + public Dimension2DDouble(Point2D point) { + this(point.getX(), point.getY()); + } + @Override public String toString() { return "[" + width + "," + height + "]"; diff --git a/src/net/sourceforge/plantuml/EmbeddedDiagram.java b/src/net/sourceforge/plantuml/EmbeddedDiagram.java index 2733cd458..547ded584 100644 --- a/src/net/sourceforge/plantuml/EmbeddedDiagram.java +++ b/src/net/sourceforge/plantuml/EmbeddedDiagram.java @@ -50,7 +50,7 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.Line; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.preproc.Defines; -import net.sourceforge.plantuml.security.ImageIO; +import net.sourceforge.plantuml.security.SImageIO; import net.sourceforge.plantuml.ugraphic.AffineTransformType; import net.sourceforge.plantuml.ugraphic.PixelImage; import net.sourceforge.plantuml.ugraphic.UGraphic; @@ -186,7 +186,7 @@ public class EmbeddedDiagram implements CharSequence { final ByteArrayOutputStream os = new ByteArrayOutputStream(); system.exportDiagram(os, 0, new FileFormatOption(FileFormat.PNG)); os.close(); - return ImageIO.read(os.toByteArray()); + return SImageIO.read(os.toByteArray()); } public HorizontalAlignment getHorizontalAlignment() { diff --git a/src/net/sourceforge/plantuml/EmptyImageBuilder.java b/src/net/sourceforge/plantuml/EmptyImageBuilder.java index f3fd01cfe..70b60e731 100644 --- a/src/net/sourceforge/plantuml/EmptyImageBuilder.java +++ b/src/net/sourceforge/plantuml/EmptyImageBuilder.java @@ -46,6 +46,7 @@ import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils; +import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.ugraphic.UAntiAliasing; import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity; import net.sourceforge.plantuml.ugraphic.color.HColor; @@ -57,12 +58,13 @@ public class EmptyImageBuilder { private final BufferedImage im; private final Graphics2D g2d; private final Color background; + private final StringBounder stringBounder; - public EmptyImageBuilder(String watermark, double width, double height, Color background) { - this(watermark, (int) width, (int) height, background); + public EmptyImageBuilder(String watermark, double width, double height, Color background, StringBounder stringBounder) { + this(watermark, (int) width, (int) height, background, stringBounder); } - public EmptyImageBuilder(String watermark, int width, int height, Color background) { + public EmptyImageBuilder(String watermark, int width, int height, Color background, StringBounder stringBounder) { if (width > GraphvizUtils.getenvImageLimit()) { Log.info("Width too large " + width + ". You should set PLANTUML_LIMIT_SIZE"); width = GraphvizUtils.getenvImageLimit(); @@ -72,6 +74,7 @@ public class EmptyImageBuilder { height = GraphvizUtils.getenvImageLimit(); } this.background = background; + this.stringBounder = stringBounder; Log.info("Creating image " + width + "x" + height); im = new BufferedImage(width, height, getType(background)); g2d = im.createGraphics(); @@ -149,8 +152,8 @@ public class EmptyImageBuilder { return result; } - public EmptyImageBuilder(String watermark, int width, int height, Color background, double dpiFactor) { - this(watermark, width * dpiFactor, height * dpiFactor, background); + public EmptyImageBuilder(String watermark, int width, int height, Color background, StringBounder stringBounder, double dpiFactor) { + this(watermark, width * dpiFactor, height * dpiFactor, background, stringBounder); if (dpiFactor != 1.0) { g2d.setTransform(AffineTransform.getScaleInstance(dpiFactor, dpiFactor)); } @@ -166,7 +169,7 @@ public class EmptyImageBuilder { public UGraphicG2d getUGraphicG2d() { final HColor back = new HColorSimple(background, false); - final UGraphicG2d result = new UGraphicG2d(back, new ColorMapperIdentity(), g2d, 1.0); + final UGraphicG2d result = new UGraphicG2d(back, new ColorMapperIdentity(), stringBounder, g2d, 1.0); result.setBufferedImage(im); return result; } diff --git a/src/net/sourceforge/plantuml/FileFormat.java b/src/net/sourceforge/plantuml/FileFormat.java index f31a3ff4c..f6199e906 100644 --- a/src/net/sourceforge/plantuml/FileFormat.java +++ b/src/net/sourceforge/plantuml/FileFormat.java @@ -132,10 +132,6 @@ public enum FileFormat { return getDefaultStringBounder(TikzFontDistortion.getDefault(), SvgCharSizeHack.NO_HACK); } - public StringBounder getDefaultStringBounder(TikzFontDistortion tikzFontDistortion) { - return getDefaultStringBounder(tikzFontDistortion, SvgCharSizeHack.NO_HACK); - } - public StringBounder getDefaultStringBounder(TikzFontDistortion tikzFontDistortion, SvgCharSizeHack charSizeHack) { if (this == LATEX || this == LATEX_NO_PREAMBLE) { return getTikzStringBounder(tikzFontDistortion); @@ -201,6 +197,11 @@ public enum FileFormat { final double width = 3 * nb * quanta + 1; return new Dimension2DDouble(width, height); } + + @Override + public double getDescent(UFont font, String text) { + return UGraphicBraille.QUANTA; + } }; } diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index 3b935a0c1..10a5da484 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -63,7 +63,7 @@ import net.sourceforge.plantuml.ftp.FtpServer; import net.sourceforge.plantuml.picoweb.PicoWebServer; import net.sourceforge.plantuml.png.MetadataTag; import net.sourceforge.plantuml.preproc.Stdlib; -import net.sourceforge.plantuml.security.ImageIO; +import net.sourceforge.plantuml.security.SImageIO; import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SecurityUtils; import net.sourceforge.plantuml.sprite.SpriteGrayLevel; @@ -299,7 +299,7 @@ public class Run { final BufferedImage im; try (InputStream stream = source.openStream()) { - im = ImageIO.read(stream); + im = SImageIO.read(stream); } final String name = getSpriteName(fileName); final String s = compressed ? SpriteUtils.encodeCompressed(im, name, level) diff --git a/src/net/sourceforge/plantuml/StringUtils.java b/src/net/sourceforge/plantuml/StringUtils.java index 4db4f0331..50dafe0aa 100644 --- a/src/net/sourceforge/plantuml/StringUtils.java +++ b/src/net/sourceforge/plantuml/StringUtils.java @@ -5,12 +5,12 @@ * (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 @@ -119,16 +119,22 @@ public class StringUtils { return result; } - public static boolean isNotEmpty(String input) { - return input != null && trin(input).length() > 0; + public static boolean isNotEmpty(CharSequence s) { + return !isEmpty(s); } public static boolean isNotEmpty(List input) { return input != null && input.size() > 0; } - public static boolean isEmpty(String input) { - return input == null || trin(input).length() == 0; + public static boolean isEmpty(CharSequence s) { + if (s == null) return true; + final int length = s.length(); + if (length == 0) return true; + for (int i = 0; i < length; i++) { + if (!isSpaceOrTabOrNull(s.charAt(i))) return false; + } + return true; } public static String manageHtml(String s) { diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java index a372e25f2..dcf13e15a 100644 --- a/src/net/sourceforge/plantuml/UmlDiagram.java +++ b/src/net/sourceforge/plantuml/UmlDiagram.java @@ -66,7 +66,7 @@ import net.sourceforge.plantuml.graphic.GraphicStrings; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.mjpeg.MJPEGGenerator; import net.sourceforge.plantuml.pdf.PdfConverter; -import net.sourceforge.plantuml.security.ImageIO; +import net.sourceforge.plantuml.security.SImageIO; import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SecurityUtils; import net.sourceforge.plantuml.style.NoStyleAvailableException; @@ -269,7 +269,7 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot // exportDiagramTOxxBEREMOVED(baos, null, 0, new // FileFormatOption(FileFormat.PNG, at)); baos.close(); - final BufferedImage im = ImageIO.read(baos.toByteArray()); + final BufferedImage im = SImageIO.read(baos.toByteArray()); m.addImage(im); } m.finishAVI(); diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java index 0ec71fd60..dbcbd1904 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java @@ -129,7 +129,7 @@ public class CommandLinkActivity extends SingleLineCommand2 { return CommandExecutionResult.error("No such activity"); } if (arg.get("STEREOTYPE", 0) != null) { - entity1.setStereotype(new Stereotype(arg.get("STEREOTYPE", 0))); + entity1.setStereotype(Stereotype.build(arg.get("STEREOTYPE", 0))); } if (arg.get("BACKCOLOR", 0) != null) { String s = arg.get("BACKCOLOR", 0); @@ -147,7 +147,7 @@ public class CommandLinkActivity extends SingleLineCommand2 { diagram.getSkinParam().getIHtmlColorSet().getColor(diagram.getSkinParam().getThemeStyle(), s)); } if (arg.get("STEREOTYPE2", 0) != null) { - entity2.setStereotype(new Stereotype(arg.get("STEREOTYPE2", 0))); + entity2.setStereotype(Stereotype.build(arg.get("STEREOTYPE2", 0))); } final Display linkLabel = Display.getWithNewlines(arg.get("BRACKET", 0)); diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java index 335eb8cf6..9372d9ff8 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java @@ -126,7 +126,7 @@ public class CommandLinkLongActivity extends CommandMultilines2 } if (line0.get("STEREOTYPE", 0) != null) { - entity1.setStereotype(new Stereotype(line0.get("STEREOTYPE", 0))); + entity1.setStereotype(Stereotype.build(line0.get("STEREOTYPE", 0))); } final String stringColor = line0.get("BACKCOLOR", 0); if (stringColor != null) { @@ -196,7 +196,7 @@ public class CommandLinkLongActivity extends CommandMultilines2 } if (lineLast.get(2) != null) { - entity2.setStereotype(new Stereotype(lineLast.get(2))); + entity2.setStereotype(Stereotype.build(lineLast.get(2))); } if (lineLast.get(4) != null) { String s = lineLast.get(4); diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java index 66630899c..d8918b920 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java @@ -101,7 +101,7 @@ public class CommandPartition extends SingleLineCommand2 { p.setColors(colors); } if (arg.get("STEREOTYPE", 0) != null) { - p.setStereotype(new Stereotype(arg.get("STEREOTYPE", 0))); + p.setStereotype(Stereotype.build(arg.get("STEREOTYPE", 0))); } return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/ugraphic/html5/DriverNopHtml5.java b/src/net/sourceforge/plantuml/activitydiagram3/AbstractInstruction.java similarity index 74% rename from src/net/sourceforge/plantuml/ugraphic/html5/DriverNopHtml5.java rename to src/net/sourceforge/plantuml/activitydiagram3/AbstractInstruction.java index 46b12cf64..355c3d41a 100644 --- a/src/net/sourceforge/plantuml/ugraphic/html5/DriverNopHtml5.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/AbstractInstruction.java @@ -31,16 +31,18 @@ * * Original Author: Arnaud Roques * + * */ -package net.sourceforge.plantuml.ugraphic.html5; +package net.sourceforge.plantuml.activitydiagram3; -import net.sourceforge.plantuml.ugraphic.UDriver; -import net.sourceforge.plantuml.ugraphic.UParam; -import net.sourceforge.plantuml.ugraphic.UShape; -import net.sourceforge.plantuml.ugraphic.color.ColorMapper; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; +import net.sourceforge.plantuml.graphic.StringBounder; -public class DriverNopHtml5 implements UDriver { +abstract class AbstractInstruction { - public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Html5Drawer html) { + public Gtile createGtile(ISkinParam skinParam, StringBounder stringBounder) { + throw new UnsupportedOperationException("" + getClass()); } + } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java index 5faf9be9f..20fa7c20e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java @@ -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()); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/Branch.java b/src/net/sourceforge/plantuml/activitydiagram3/Branch.java index 7c09ef19f..7e645663d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/Branch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/Branch.java @@ -38,15 +38,24 @@ package net.sourceforge.plantuml.activitydiagram3; import java.util.Collection; import java.util.Objects; +import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint; +import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.creole.CreoleMode; 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.TextBlockUtils; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; @@ -71,6 +80,7 @@ public class Branch { private final HColor color; private Ftile ftile; + private Gtile gtile; public StyleSignature getDefaultStyleDefinitionArrow() { return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow); @@ -127,16 +137,12 @@ public class Branch { this.ftile = factory.decorateOut(list.createFtile(factory), inlinkRendering); } - public Collection getSwimlanes() { - return list.getSwimlanes(); + public void updateGtile(ISkinParam skinParam, StringBounder stringBounder) { + this.gtile = list.createGtile(skinParam, stringBounder); } - public final Display getLabelPositive() { - final LinkRendering in = ftile.getInLinkRendering(); - if (in != null && Display.isNull(in.getDisplay()) == false) { - return in.getDisplay(); - } - return labelPositive.getDisplay(); + public Collection getSwimlanes() { + return list.getSwimlanes(); } public final Display getLabelTest() { @@ -187,6 +193,10 @@ public class Branch { return ftile; } + public Gtile getGtile() { + return gtile; + } + public ISkinParam skinParam() { return ftile.skinParam(); } @@ -215,4 +225,45 @@ public class Branch { return special; } + public final Display getDisplayPositive() { + final LinkRendering in = ftile.getInLinkRendering(); + if (in != null && Display.isNull(in.getDisplay()) == false) { + return in.getDisplay(); + } + return labelPositive.getDisplay(); + } + + 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()) { + final Style style = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam().getCurrentStyleBuilder()); + lineBreak = style.wrapWidth(); + fcArrow = style.getFontConfiguration(skinParam().getThemeStyle(), skinParam().getIHtmlColorSet()); + } else { + fcArrow = new FontConfiguration(skinParam(), FontParam.ARROW, 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()); + } + } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/Instruction.java b/src/net/sourceforge/plantuml/activitydiagram3/Instruction.java index aa85025d3..ed1e2db6a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/Instruction.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/Instruction.java @@ -35,12 +35,15 @@ */ package net.sourceforge.plantuml.activitydiagram3; +import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimable; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; @@ -49,6 +52,8 @@ public interface Instruction extends Swimable { public Ftile createFtile(FtileFactory factory); + public Gtile createGtile(ISkinParam skinParam, StringBounder stringBounder); + public CommandExecutionResult add(Instruction other); public boolean kill(); @@ -56,7 +61,7 @@ public interface Instruction extends Swimable { public LinkRendering getInLinkRendering(); public boolean addNote(Display note, NotePosition position, NoteType type, Colors colors, Swimlane swimlaneNote); - + public boolean containsBreak(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java index f64e06a97..d7827801b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java @@ -50,7 +50,7 @@ import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; import net.sourceforge.plantuml.ugraphic.color.HColor; -public class InstructionGroup implements Instruction, InstructionCollection { +public class InstructionGroup extends AbstractInstruction implements Instruction, InstructionCollection { private final InstructionList list; private final Instruction parent; @@ -68,8 +68,8 @@ public class InstructionGroup implements Instruction, InstructionCollection { return list.containsBreak(); } - public InstructionGroup(Instruction parent, Display test, HColor backColor, HColor titleColor, - Swimlane swimlane, HColor borderColor, LinkRendering linkRendering, USymbol type, double roundCorner) { + public InstructionGroup(Instruction parent, Display test, HColor backColor, HColor titleColor, Swimlane swimlane, + HColor borderColor, LinkRendering linkRendering, USymbol type, double roundCorner) { this.list = new InstructionList(swimlane); this.type = type; this.linkRendering = linkRendering; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java index d751d5155..13a756cfb 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java @@ -50,8 +50,11 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale; +import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; +import net.sourceforge.plantuml.activitydiagram3.gtile.GtileIfHexagon; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; @@ -73,6 +76,7 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC private final Swimlane swimlane; + @Override public boolean containsBreak() { for (Branch branch : thens) { if (branch.containsBreak()) { @@ -97,18 +101,40 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC this.current = this.thens.get(0); } + @Override public CommandExecutionResult add(Instruction ins) { return current.add(ins); } + @Override + public Gtile createGtile(ISkinParam skinParam, StringBounder stringBounder) { + for (Branch branch : thens) + branch.updateGtile(skinParam, stringBounder); + + final List gtiles = new ArrayList<>(); + final List branches = new ArrayList<>(); + for (Branch branch : thens) { + gtiles.add(branch.getGtile()); + branches.add(branch); + } + if (elseBranch != null && elseBranch.isEmpty() == false) { + elseBranch.updateGtile(skinParam, stringBounder); + gtiles.add(elseBranch.getGtile()); + branches.add(elseBranch); + } + + return new GtileIfHexagon(swimlane, gtiles, branches); + } + + @Override public Ftile createFtile(FtileFactory factory) { for (Branch branch : thens) { branch.updateFtile(factory); } - if (elseBranch == null) { + if (elseBranch == null) this.elseBranch = new Branch(skinParam.getCurrentStyleBuilder(), swimlane, LinkRendering.none(), Display.NULL, null, LinkRendering.none()); - } + elseBranch.updateFtile(factory); Ftile result = factory.createIf(swimlane, thens, elseBranch, outColor, topInlinkRendering, url); if (getPositionedNotes().size() > 0) { @@ -163,6 +189,7 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC this.current.setInlinkRendering(nextLinkRenderer); } + @Override final public boolean kill() { if (endifCalled) { for (Branch branch : thens) { @@ -178,6 +205,7 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC return current.kill(); } + @Override public LinkRendering getInLinkRendering() { return topInlinkRendering; } @@ -191,6 +219,7 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC } } + @Override public Set getSwimlanes() { final Set result = new HashSet<>(); if (swimlane != null) { @@ -205,14 +234,17 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC return Collections.unmodifiableSet(result); } + @Override public Swimlane getSwimlaneIn() { return swimlane; } + @Override public Swimlane getSwimlaneOut() { return swimlane; } + @Override public Instruction getLast() { if (elseBranch == null) { return thens.get(thens.size() - 1).getLast(); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java index 69d5835bd..58f3c098a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java @@ -41,14 +41,19 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileDecorateWelding; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileEmpty; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint; +import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; +import net.sourceforge.plantuml.activitydiagram3.gtile.GtileAssembly; +import net.sourceforge.plantuml.activitydiagram3.gtile.GtileEmpty; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; @@ -58,6 +63,7 @@ public class InstructionList extends WithNote implements Instruction, Instructio private final List all = new ArrayList<>(); private final Swimlane defaultSwimlane; + @Override public boolean containsBreak() { for (Instruction ins : all) { if (ins.containsBreak()) { @@ -89,11 +95,31 @@ public class InstructionList extends WithNote implements Instruction, Instructio this.defaultSwimlane = defaultSwimlane; } + @Override public CommandExecutionResult add(Instruction ins) { all.add(ins); return CommandExecutionResult.ok(); } + @Override + public Gtile createGtile(ISkinParam skinParam, StringBounder stringBounder) { + if (all.size() == 0) { + return new GtileEmpty(stringBounder, skinParam, defaultSwimlane); + } + Gtile result = null; + for (Instruction ins : all) { + final Gtile cur = ins.createGtile(skinParam, stringBounder); + + if (result == null) { + result = cur; + } else { + result = new GtileAssembly(result, cur, ins.getInLinkRendering()); + } + } + return result; + } + + @Override public Ftile createFtile(FtileFactory factory) { if (all.size() == 0) { return new FtileEmpty(factory.skinParam(), defaultSwimlane); @@ -126,6 +152,7 @@ public class InstructionList extends WithNote implements Instruction, Instructio return result; } + @Override final public boolean kill() { if (all.size() == 0) { return false; @@ -133,10 +160,12 @@ public class InstructionList extends WithNote implements Instruction, Instructio return getLast().kill(); } + @Override public LinkRendering getInLinkRendering() { return all.iterator().next().getInLinkRendering(); } + @Override public Instruction getLast() { if (all.size() == 0) { return null; @@ -144,6 +173,7 @@ public class InstructionList extends WithNote implements Instruction, Instructio return all.get(all.size() - 1); } + @Override public boolean addNote(Display note, NotePosition position, NoteType type, Colors colors, Swimlane swimlaneNote) { if (getLast() == null) { return super.addNote(note, position, type, colors, swimlaneNote); @@ -151,14 +181,17 @@ public class InstructionList extends WithNote implements Instruction, Instructio return getLast().addNote(note, position, type, colors, swimlaneNote); } + @Override public Set getSwimlanes() { return getSwimlanes2(all); } + @Override public Swimlane getSwimlaneIn() { return defaultSwimlane; } + @Override public Swimlane getSwimlaneOut() { final Set swimlanes = getSwimlanes(); if (swimlanes.size() == 0) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionPartition.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionPartition.java index b847e8c7c..a931cb6ad 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionPartition.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionPartition.java @@ -46,7 +46,7 @@ import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; -public class InstructionPartition implements Instruction { +public class InstructionPartition extends AbstractInstruction implements Instruction { private final InstructionList list = new InstructionList(); private final Instruction parent; @@ -54,7 +54,7 @@ public class InstructionPartition implements Instruction { public InstructionPartition(Instruction parent, String partitionTitle) { this.parent = parent; } - + public Instruction getParent() { return parent; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java index 19d356e4d..ca0df0aba 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java @@ -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; @@ -52,12 +53,13 @@ import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; import net.sourceforge.plantuml.ugraphic.color.HColor; -public class InstructionRepeat implements Instruction { +public class InstructionRepeat extends AbstractInstruction implements Instruction { private final InstructionList repeatList; 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) { @@ -131,9 +136,9 @@ public class InstructionRepeat implements Instruction { if (Display.isNull(backward)) { return null; } - Ftile result = factory.activity(backward, swimlane, boxStyle, Colors.empty(), null); + Ftile result = factory.activity(backward, swimlaneOut, boxStyle, Colors.empty(), null); if (backwardNotes.size() > 0) { - result = factory.addNote(result, swimlane, backwardNotes); + result = factory.addNote(result, swimlaneOut, backwardNotes); } return result; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java index 18e2a70ab..3975a5c9e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java @@ -35,17 +35,23 @@ */ package net.sourceforge.plantuml.activitydiagram3; +import java.util.Collection; import java.util.Objects; +import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; 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.gtile.Gtile; +import net.sourceforge.plantuml.activitydiagram3.gtile.GtileBox; +import net.sourceforge.plantuml.activitydiagram3.gtile.GtileWithNoteOpale; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Stereotype; +import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.color.Colors; public class InstructionSimple extends MonoSwimable implements Instruction { @@ -58,6 +64,7 @@ public class InstructionSimple extends MonoSwimable implements Instruction { private final Url url; private final Stereotype stereotype; + @Override public boolean containsBreak() { return false; } @@ -73,6 +80,21 @@ public class InstructionSimple extends MonoSwimable implements Instruction { this.colors = Objects.requireNonNull(colors); } + @Override + public Gtile createGtile(ISkinParam skinParam, StringBounder stringBounder) { + GtileBox result = GtileBox.create(stringBounder, colors.mute(skinParam), label, getSwimlaneIn(), style, + stereotype); + if (hasNotes()) { + final Collection notes = getPositionedNotes(); + if (notes.size() != 1) + throw new UnsupportedOperationException("wip"); + return new GtileWithNoteOpale(result, notes.iterator().next(), skinParam, false); + + } + return result; + } + + @Override public Ftile createFtile(FtileFactory factory) { Ftile result = factory.activity(label, getSwimlaneIn(), style, colors, stereotype); if (url != null) { @@ -85,15 +107,18 @@ public class InstructionSimple extends MonoSwimable implements Instruction { return result; } + @Override public CommandExecutionResult add(Instruction other) { throw new UnsupportedOperationException(); } + @Override final public boolean kill() { this.killed = true; return true; } + @Override public LinkRendering getInLinkRendering() { return inlinkRendering; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java index 8818d0b8e..c1ff730f1 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java @@ -49,7 +49,7 @@ import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; -public class InstructionSplit implements Instruction { +public class InstructionSplit extends AbstractInstruction implements Instruction { private final List splits = new ArrayList<>(); private final Instruction parent; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionStart.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionStart.java index 39b7e8325..d3e11e254 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionStart.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionStart.java @@ -37,10 +37,15 @@ package net.sourceforge.plantuml.activitydiagram3; import java.util.Objects; +import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; +import net.sourceforge.plantuml.activitydiagram3.gtile.GtileCircleStart; import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.color.HColorUtils; public class InstructionStart extends MonoSwimable implements Instruction { @@ -50,26 +55,35 @@ public class InstructionStart extends MonoSwimable implements Instruction { super(swimlane); this.inlinkRendering = Objects.requireNonNull(inlinkRendering); } - + + @Override public boolean containsBreak() { return false; } + @Override + public Gtile createGtile(ISkinParam skinParam, StringBounder stringBounder) { + return new GtileCircleStart(stringBounder, skinParam, HColorUtils.BLACK, getSwimlaneIn(), null); + } + @Override public Ftile createFtile(FtileFactory factory) { Ftile result = factory.start(getSwimlaneIn()); result = eventuallyAddNote(factory, result, result.getSwimlaneIn()); return result; } + @Override public CommandExecutionResult add(Instruction other) { throw new UnsupportedOperationException(); } + @Override final public boolean kill() { return false; } + @Override public LinkRendering getInLinkRendering() { return inlinkRendering; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java index 2e38e731a..38bc06664 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java @@ -37,10 +37,15 @@ package net.sourceforge.plantuml.activitydiagram3; import java.util.Objects; +import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; +import net.sourceforge.plantuml.activitydiagram3.gtile.GtileCircleStart; import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.color.HColorUtils; public class InstructionStop extends MonoSwimable implements Instruction { @@ -50,26 +55,35 @@ public class InstructionStop extends MonoSwimable implements Instruction { super(swimlane); this.inlinkRendering = Objects.requireNonNull(inlinkRendering); } - + + @Override public boolean containsBreak() { return false; } + @Override + public Gtile createGtile(ISkinParam skinParam, StringBounder stringBounder) { + return new GtileCircleStart(stringBounder, skinParam, HColorUtils.BLACK, getSwimlaneIn(), null); + } + @Override public Ftile createFtile(FtileFactory factory) { Ftile result = factory.stop(getSwimlaneIn()); result = eventuallyAddNote(factory, result, result.getSwimlaneIn()); return result; } + @Override public CommandExecutionResult add(Instruction other) { throw new UnsupportedOperationException(); } + @Override final public boolean kill() { return false; } + @Override public LinkRendering getInLinkRendering() { return inlinkRendering; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java index ad7a01778..55fd6f9b7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java @@ -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)); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/MonoSwimable.java b/src/net/sourceforge/plantuml/activitydiagram3/MonoSwimable.java index 8ad641ce0..bf1ca775b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/MonoSwimable.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/MonoSwimable.java @@ -41,7 +41,7 @@ import java.util.Set; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimable; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; -public class MonoSwimable extends WithNote implements Swimable { +abstract class MonoSwimable extends WithNote implements Swimable { private final Swimlane swimlane; @@ -50,7 +50,7 @@ public class MonoSwimable extends WithNote implements Swimable { } final public Set getSwimlanes() { - return swimlane == null ? Collections. emptySet() : Collections. singleton(swimlane); + return swimlane == null ? Collections.emptySet() : Collections.singleton(swimlane); } final public Swimlane getSwimlaneIn() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/WithNote.java b/src/net/sourceforge/plantuml/activitydiagram3/WithNote.java index e5b7b7bf7..204fd1a48 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/WithNote.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/WithNote.java @@ -47,7 +47,7 @@ import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; -public class WithNote { +abstract class WithNote extends AbstractInstruction { private final Collection notes = new ArrayList<>(); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java index 1974bcc4e..833086306 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java @@ -118,7 +118,7 @@ public class CommandActivity3 extends SingleLineCommand2 { final String stereo = arg.get("STEREO", 0); Stereotype stereotype = null; if (stereo != null) { - stereotype = new Stereotype(stereo); + stereotype = Stereotype.build(stereo); colors = colors.applyStereotype(stereotype, diagram.getSkinParam(), ColorParam.activityBackground); } final BoxStyle style = BoxStyle.fromChar(arg.get("STYLE", 0).charAt(0)); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java index 48b462c85..03e1a628e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java @@ -129,7 +129,7 @@ public class CommandPartition3 extends SingleLineCommand2 { final USymbol symbol = getUSymbol(arg.get("TYPE", 0)); final String stereo = arg.get("STEREO", 0); - final Stereotype stereotype = stereo == null ? null : new Stereotype(stereo); + final Stereotype stereotype = stereo == null ? null : Stereotype.build(stereo); final HColor backColorInSkinparam = diagram.getSkinParam().getHtmlColor(getColorParamBack(symbol), stereotype, false); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java index 349ce431d..dfae89a2a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java @@ -94,7 +94,7 @@ public class CommandRepeat3 extends SingleLineCommand2 { diagram.getSkinParam().getIHtmlColorSet()); final String stereo = arg.get("STEREO", 0); if (stereo != null) { - final Stereotype stereotype = new Stereotype(stereo); + final Stereotype stereotype = Stereotype.build(stereo); colors = colors.applyStereotype(stereotype, diagram.getSkinParam(), ColorParam.activityBackground); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileEmpty.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileEmpty.java index 78e98455e..bbfff0259 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileEmpty.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileEmpty.java @@ -48,8 +48,7 @@ public class FtileEmpty extends AbstractFtile { private final double width; private final double height; - private final Swimlane swimlaneIn; - private final Swimlane swimlaneOut; + private final Swimlane swimlane; @Override public Collection getMyChildren() { @@ -57,24 +56,23 @@ public class FtileEmpty extends AbstractFtile { } public FtileEmpty(ISkinParam skinParam, double width, double height) { - this(skinParam, width, height, null, null); + this(skinParam, width, height, null); } - public FtileEmpty(ISkinParam skinParam, double width, double height, Swimlane swimlaneIn, Swimlane swimlaneOut) { + public FtileEmpty(ISkinParam skinParam, double width, double height, Swimlane swimlane) { super(skinParam); this.width = width; this.height = height; - this.swimlaneIn = swimlaneIn; - this.swimlaneOut = swimlaneOut; + this.swimlane = swimlane; } public FtileEmpty(ISkinParam skinParam) { - this(skinParam, 0, 0, null, null); + this(skinParam, 0, 0, null); } public FtileEmpty(ISkinParam skinParam, Swimlane swimlane) { - this(skinParam, 0, 0, swimlane, swimlane); + this(skinParam, 0, 0, swimlane); } @Override @@ -95,20 +93,17 @@ public class FtileEmpty extends AbstractFtile { } public Swimlane getSwimlaneIn() { - return swimlaneIn; + return swimlane; } public Swimlane getSwimlaneOut() { - return swimlaneOut; + return swimlane; } public Set getSwimlanes() { final Set result = new HashSet<>(); - if (swimlaneIn != null) { - result.add(swimlaneIn); - } - if (swimlaneOut != null) { - result.add(swimlaneOut); + if (swimlane != null) { + result.add(swimlane); } return Collections.unmodifiableSet(result); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java index 2711439ac..f3351f9c5 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java @@ -114,9 +114,30 @@ public class FtileGeometry extends Dimension2D { return new FtileGeometry(width, height + northHeight, left, inY, outY); } -// public FtileGeometry incInnerHeight(double northHeight) { -// return new FtileGeometry(width, height + northHeight, left, inY, outY + northHeight); -// } + public FtileGeometry addTop(double northHeight) { + if (hasPointOut()) + return new FtileGeometry(width, height + northHeight, left, inY + northHeight, outY + northHeight); + 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 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); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedVertically.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedVertically.java index 9c10f91b9..def1a2446 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedVertically.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedVertically.java @@ -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); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedWest.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedWest.java new file mode 100644 index 000000000..0a805884a --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedWest.java @@ -0,0 +1,63 @@ +/* ======================================================================== + * 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; + +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 class FtileMargedWest extends FtileDecorate { + + 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; + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Diamond.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Hexagon.java similarity index 83% rename from src/net/sourceforge/plantuml/activitydiagram3/ftile/Diamond.java rename to src/net/sourceforge/plantuml/activitydiagram3/ftile/Hexagon.java index 80315d919..65a098d92 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Diamond.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Hexagon.java @@ -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) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java index 70517c9f8..2882c51f3 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java @@ -134,10 +134,10 @@ 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.BOTTOM) { + if (verticalAlignment != VerticalAlignment.CENTER) { throw new UnsupportedOperationException(); } return this; @@ -254,6 +254,10 @@ public class Snake implements UShape { double y = (pt1.getY() + pt2.getY()) / 2 - dim.getHeight() / 2; if (text.verticalAlignment == VerticalAlignment.BOTTOM) { x = worm.getLast().getX(); + throw new AssertionError(); + } else if (text.verticalAlignment == VerticalAlignment.CENTER) { + x = worm.getMinX(); + y = (worm.getFirst().getY() + worm.getLast().getY() - 10) / 2 - dim.getHeight() / 2; } else if (text.horizontalAlignment == HorizontalAlignment.CENTER && zigzag) { final Point2D pt3 = worm.get(2); x = (pt2.getX() + pt3.getX()) / 2 - dim.getWidth() / 2; @@ -310,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 mergeTexts = new ArrayList(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()); - // result.textBlock = oneOf(this.textBlock, other.textBlock, stringBounder); + emphasizeDirection == null ? other.emphasizeDirection : emphasizeDirection, mergeTexts); return result; } if (same(this.getFirst(), other.getLast())) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java index 511f8fb93..8edd4f9aa 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java @@ -61,6 +61,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDele import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorWhile; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.UGraphicInterceptorOneSwimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.VCompactFactory; +import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -213,6 +214,11 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock, Styleable } public final void drawU(UGraphic ug) { + if (Gtile.USE_GTILE) { + drawGtile(ug); + return; + } + TextBlock full = root.createFtile(getFtileFactory(ug.getStringBounder())); ug = new UGraphicForSnake(ug); @@ -226,6 +232,16 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock, Styleable } } + private void drawGtile(UGraphic ug) { + TextBlock full = root.createGtile(skinParam, ug.getStringBounder()); + + ug = new UGraphicForSnake(ug); + full = new TextBlockInterceptorUDrawable(full); + full.drawU(ug); + ug.flushUg(); + + } + private TextBlock getTitle(Swimlane swimlane) { final HorizontalAlignment horizontalAlignment = HorizontalAlignment.LEFT; FontConfiguration fontConfiguration = new FontConfiguration(skinParam, FontParam.SWIMLANE_TITLE, null); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/TextBlockInterceptorUDrawable.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/TextBlockInterceptorUDrawable.java index 406639820..142d314c3 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/TextBlockInterceptorUDrawable.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/TextBlockInterceptorUDrawable.java @@ -53,12 +53,11 @@ public class TextBlockInterceptorUDrawable extends AbstractTextBlock implements } public void drawU(UGraphic ug) { - textBlock.drawU(new UGraphicInterceptorUDrawable2(ug, new HashMap())); + new UGraphicInterceptorUDrawable2(ug, new HashMap()).draw(textBlock); ug.flushUg(); } public Dimension2D calculateDimension(StringBounder stringBounder) { - // return TextBlockUtils.getMinMax(this, stringBounder).getDimension(); throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/UGraphicInterceptorUDrawable2.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/UGraphicInterceptorUDrawable2.java index be7257e84..ad9ee2f6d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/UGraphicInterceptorUDrawable2.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/UGraphicInterceptorUDrawable2.java @@ -38,6 +38,8 @@ package net.sourceforge.plantuml.activitydiagram3.ftile; import java.awt.geom.Point2D; import java.util.Map; +import net.sourceforge.plantuml.activitydiagram3.gtile.GConnection; +import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UGraphicDelegator; import net.sourceforge.plantuml.svek.UGraphicForSnake; @@ -60,7 +62,15 @@ public class UGraphicInterceptorUDrawable2 extends UGraphicDelegator { } public void draw(UShape shape) { - if (shape instanceof Ftile) { + if (shape instanceof Gtile) { + final Gtile gtile = (Gtile) shape; + // System.err.println("gtile=" + gtile); + gtile.drawU(this); + // FtileWithConnection + for (GConnection c : gtile.getInnerConnections()) { + this.draw(c); + } + } else if (shape instanceof Ftile) { final Ftile ftile = (Ftile) shape; // System.err.println("ftile=" + ftile); ftile.drawU(this); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Worm.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Worm.java index e8553c216..3f09e58c8 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Worm.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Worm.java @@ -309,7 +309,7 @@ public class Worm implements Iterable { this.points.add(i, pt); } - private Point2D getFirst() { + public Point2D getFirst() { return points.get(0); } @@ -317,6 +317,13 @@ public class Worm implements Iterable { return points.get(points.size() - 1); } + public double getMinX() { + double result = points.get(0).getX(); + for (Point2D.Double pt : points) + result = Math.min(result, pt.getX()); + return result; + } + public Worm merge(Worm other, MergeStrategy merge) { if (Snake.same(this.getLast(), other.getFirst()) == false) { throw new IllegalArgumentException(); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/ZadBuilder.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/ZadBuilder.java index a1cdf3c4d..913e5c115 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/ZadBuilder.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/ZadBuilder.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.activitydiagram3.ftile; import static net.sourceforge.plantuml.utils.ObjectUtils.instanceOfAny; + import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.UBackground; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ConnectionVerticalDown.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ConnectionVerticalDown.java index d125ae253..300dbfdd9 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ConnectionVerticalDown.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ConnectionVerticalDown.java @@ -76,16 +76,15 @@ public class ConnectionVerticalDown extends AbstractConnection implements Connec } private Snake getSimpleSnake() { - final Snake snake = Snake.create(color, Arrows.asToDown()).withLabel(textBlock, - arrowHorizontalAlignment()); + final Snake snake = Snake.create(color, Arrows.asToDown()).withLabel(textBlock, arrowHorizontalAlignment()); snake.addPoint(p1); snake.addPoint(p2); return snake; } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { - final Snake snake = Snake.create(color, Arrows.asToDown()).withLabel(textBlock, - arrowHorizontalAlignment()); + final Snake snake = Snake.create(color, Arrows.asToDown()).withLabel(textBlock, arrowHorizontalAlignment()); final Point2D mp1a = translate1.getTranslated(p1); final Point2D mp2b = translate2.getTranslated(p2); final double middle = (mp1a.getY() + mp2b.getY()) / 2.0; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java index 68a64d106..0b8ce2049 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java @@ -114,7 +114,7 @@ public class FtileFactoryDelegatorRepeat extends FtileFactoryDelegator { final LinkRendering endRepeatLinkRendering = repeat.getOutLinkRendering(); final Rainbow endRepeatLinkColor = endRepeatLinkRendering == null ? null : endRepeatLinkRendering.getRainbow(); - final Ftile entry = getEntry(swimlane, startLabel, colors, boxStyleIn); + final Ftile entry = getEntry(repeat.getSwimlaneIn(), startLabel, colors, boxStyleIn); Ftile result = FtileRepeat.create(swimlane, swimlaneOut, entry, repeat, test, yes, out, borderColor, diamondColor, arrowColor, endRepeatLinkColor, conditionStyle, this.skinParam(), fcDiamond, fcArrow, diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorSwitch.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorSwitch.java index 66580a104..1eaa644ba 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorSwitch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorSwitch.java @@ -35,11 +35,13 @@ */ package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact; +import java.awt.geom.Dimension2D; import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.activitydiagram3.Branch; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; @@ -52,13 +54,17 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.FtileSwitch import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.FtileSwitchWithDiamonds; 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; 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.style.PName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.color.HColor; @@ -99,9 +105,13 @@ public class FtileFactoryDelegatorSwitch extends FtileFactoryDelegator { final List ftiles = new ArrayList<>(); final Ftile diamond1 = getDiamond1(swimlane, branches.get(0), labelTest); final Ftile diamond2 = getDiamond2(swimlane, branches.get(0)); + for (Branch branch : branches) { - ftiles.add(new FtileMinWidthCentered(branch.getFtile(), 30)); + 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; if (UseStyle.useBetaStyle()) { final Style style = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam().getCurrentStyleBuilder()); @@ -121,18 +131,35 @@ public class FtileFactoryDelegatorSwitch extends FtileFactoryDelegator { } private Ftile getDiamond1(Swimlane swimlane, Branch branch0, Display test) { - final HColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder); - final HColor backColor = branch0.getColor() == null - ? getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground) - : branch0.getColor(); - final FontConfiguration fcDiamond = new FontConfiguration(skinParam(), FontParam.ACTIVITY_DIAMOND, null); + LineBreakStrategy lineBreak = LineBreakStrategy.NONE; + final FontConfiguration fcDiamond; + final HColor borderColor; + final HColor backColor; + if (UseStyle.useBetaStyle()) { + final Style style = getDefaultStyleDefinitionDiamond().getMergedStyle(skinParam().getCurrentStyleBuilder()); + lineBreak = style.wrapWidth(); + fcDiamond = style.getFontConfiguration(skinParam().getThemeStyle(), skinParam().getIHtmlColorSet()); + borderColor = style.value(PName.LineColor).asColor(skinParam().getThemeStyle(), + skinParam().getIHtmlColorSet()); + backColor = branch0.getColor() == null ? style.value(PName.BackGroundColor) + .asColor(skinParam().getThemeStyle(), skinParam().getIHtmlColorSet()) : branch0.getColor(); + } else { + fcDiamond = new FontConfiguration(skinParam(), FontParam.ACTIVITY_DIAMOND, null); + borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder); + backColor = branch0.getColor() == null + ? getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground) + : branch0.getColor(); + } - final TextBlock tbTest = (Display.isNull(test) || test.isWhite()) ? TextBlockUtils.empty(0, 0) - : test.create(fcDiamond, branch0.skinParam().getDefaultTextAlignment(HorizontalAlignment.LEFT), - branch0.skinParam()); + final TextBlock tbTest; + if (Display.isNull(test) || test.isWhite()) + tbTest = TextBlockUtils.empty(0, 0); + else + 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) { @@ -141,12 +168,12 @@ 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) { - return skinParam().getFontHtmlColor(null, param); - } +// private HColor fontColor(FontParam param) { +// return skinParam().getFontHtmlColor(null, param); +// } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java index 08c61136f..367cc6f5f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java @@ -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); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java index 02af5fe27..86b2969ab 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java @@ -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); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java index 4f29cd953..1bdb50b1c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java @@ -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; @@ -205,6 +205,7 @@ public class FtileIfDown extends AbstractFtile { ug.draw(snake); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { final StringBounder stringBounder = ug.getStringBounder(); final Point2D p1 = getP1(stringBounder); @@ -266,6 +267,7 @@ public class FtileIfDown extends AbstractFtile { ug.draw(snake); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { if (getFtile1().calculateDimension(ug.getStringBounder()).hasPointOut() == false) { @@ -326,16 +328,15 @@ 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); + final Snake snake = Snake.create(endInlinkColor, Arrows.asToLeft()).emphasizeDirection(Direction.DOWN); snake.addPoint(x1, y1); 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); } @@ -366,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()); /* @@ -381,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(), @@ -457,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); @@ -489,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); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java index 23b79357b..2307a2837 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java @@ -156,15 +156,15 @@ class FtileIfLongHorizontal extends AbstractFtile { List diamonds = new ArrayList<>(); List inlabelSizes = new ArrayList<>(); for (Branch branch : thens) { - final TextBlock tb1 = branch.getLabelPositive().create(fcArrow, HorizontalAlignment.LEFT, + final TextBlock tb1 = branch.getDisplayPositive().create(fcArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam()); final TextBlock tbTest = branch.getLabelTest().create(fcTest, ftileFactory.skinParam().getDefaultTextAlignment(HorizontalAlignment.LEFT), 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); @@ -177,7 +177,7 @@ class FtileIfLongHorizontal extends AbstractFtile { diamonds.add(diamond); } - final TextBlock tb2 = branch2.getLabelPositive().create(fcArrow, HorizontalAlignment.LEFT, + final TextBlock tb2 = branch2.getDisplayPositive().create(fcArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam()); final int last = diamonds.size() - 1; diamonds.set(last, ((FtileDiamondInside2) diamonds.get(last)).withEast(tb2)); @@ -402,6 +402,7 @@ class FtileIfLongHorizontal extends AbstractFtile { return getTranslate1(getFtile2(), stringBounder).getTranslated(p); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { final Point2D p1 = getP1(ug.getStringBounder()); final Point2D p2 = getP2(ug.getStringBounder()); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongVertical.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongVertical.java index 59ec89099..6234a025d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongVertical.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongVertical.java @@ -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 thens, Branch branch2, FontConfiguration fc, LinkRendering topInlinkRendering, LinkRendering afterEndwhile) { - final List tiles = new ArrayList<>(); - - for (Branch branch : thens) { - tiles.add(new FtileMinWidthCentered(branch.getFtile(), 30)); - } - - final Ftile tile2 = new FtileMinWidthCentered(branch2.getFtile(), 30); List diamonds = new ArrayList<>(); + + double west = 10; for (Branch branch : thens) { - final TextBlock tb1 = branch.getLabelPositive().create(fc, HorizontalAlignment.LEFT, + 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.getLabelPositive().create(fc, HorizontalAlignment.LEFT, ftileFactory.skinParam()); - final int last = diamonds.size() - 1; - diamonds.set(last, ((FtileDiamondInside3) diamonds.get(last)).withSouth(tb2)); + final List 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 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); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java index 1e4c9d734..4817a8179 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java @@ -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; @@ -121,7 +121,8 @@ class FtileRepeat extends AbstractFtile { FontConfiguration fcDiamond, FontConfiguration fcArrow, Ftile backward, boolean noOut, LinkRendering incoming1, LinkRendering incoming2) { - final FontConfiguration fontConfiguration1 = conditionStyle == ConditionStyle.INSIDE_HEXAGON ? fcDiamond : fcArrow; + final FontConfiguration fontConfiguration1 = conditionStyle == ConditionStyle.INSIDE_HEXAGON ? fcDiamond + : fcArrow; final TextBlock tbTest = (Display.isNull(test) || test.isWhite()) ? TextBlockUtils.empty(0, 0) : test.create(fontConfiguration1, repeat.skinParam().getDefaultTextAlignment(HorizontalAlignment.LEFT), @@ -142,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); @@ -151,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(); @@ -164,26 +165,24 @@ 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 (repeat.getSwimlaneIn() == null || repeat.getSwimlaneIn() == swimlaneOut) { - if (backward == null) { - conns.add(result.new ConnectionBackSimple(incoming1.getRainbow(arrowColor), incomingText)); - } else { - final Rainbow rainbow1 = incoming1.getRainbow(arrowColor); - conns.add(result.new ConnectionBackBackward1(rainbow1, incomingText)); - final TextBlock backArrowLabel = incoming2 == null || incoming2.getDisplay() == null ? null - : incoming2.getDisplay().create(fcArrow, HorizontalAlignment.LEFT, spriteContainer); - final Rainbow rainbow2 = incoming2.getRainbow(arrowColor); - conns.add(result.new ConnectionBackBackward2(rainbow2, backArrowLabel)); - } + if (backward != null) { + final Rainbow rainbow1 = incoming1.getRainbow(arrowColor); + conns.add(result.new ConnectionBackBackward1(rainbow1, incomingText)); + final TextBlock backArrowLabel = incoming2 == null || incoming2.getDisplay() == null ? null + : incoming2.getDisplay().create(fcArrow, HorizontalAlignment.LEFT, spriteContainer); + final Rainbow rainbow2 = incoming2.getRainbow(arrowColor); + conns.add(result.new ConnectionBackBackward2(rainbow2, backArrowLabel)); + } else if (repeat.getSwimlaneIn() == null || repeat.getSwimlaneIn() == swimlaneOut) { + conns.add(result.new ConnectionBackSimple(incoming1.getRainbow(arrowColor), incomingText)); } else { conns.add(result.new ConnectionBackComplex1(incoming1.getRainbow(arrowColor))); - // conns.add(result.new - // ConnectionBackComplexHorizontalOnly(incoming1.getRainbow(arrowColor), - // incomingText)); } final Display out1 = repeat.getOutLinkRendering().getDisplay(); @@ -219,8 +218,15 @@ class FtileRepeat extends AbstractFtile { final StringBounder stringBounder = ug.getStringBounder(); final Snake snake = Snake.create(arrowColor, Arrows.asToDown()).withLabel(tbin, arrowHorizontalAlignment()); - snake.addPoint(getP1(stringBounder)); - snake.addPoint(getP2(stringBounder)); + final Point2D p1 = getP1(stringBounder); + final Point2D p2 = getP2(stringBounder); + snake.addPoint(p1); + if (p1.getX() != p2.getX()) { + final double my = (p1.getY() + p2.getY()) / 2; + snake.addPoint(new Point2D.Double(p1.getX(), my)); + snake.addPoint(new Point2D.Double(p2.getX(), my)); + } + snake.addPoint(p2); ug.draw(snake); } @@ -260,6 +266,7 @@ class FtileRepeat extends AbstractFtile { ug.draw(snake); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { final StringBounder stringBounder = ug.getStringBounder(); if (getFtile1().calculateDimension(stringBounder).hasPointOut() == false) { @@ -304,6 +311,7 @@ class FtileRepeat extends AbstractFtile { // throw new UnsupportedOperationException(); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { final StringBounder stringBounder = ug.getStringBounder(); final Dimension2D dimRepeat = repeat.calculateDimension(stringBounder); @@ -321,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) { @@ -345,39 +353,6 @@ class FtileRepeat extends AbstractFtile { } -// class ConnectionBackComplexHorizontalOnly extends AbstractConnection { -// private final Rainbow arrowColor; -// private final TextBlock tbback; -// -// public ConnectionBackComplexHorizontalOnly(Rainbow arrowColor, TextBlock tbback) { -// super(diamond2, diamond2); -// this.arrowColor = arrowColor; -// this.tbback = tbback; -// } -// -// private Point2D getP1(final StringBounder stringBounder) { -// return getTranslateDiamond2(stringBounder).getTranslated(new Point2D.Double(0, 0)); -// } -// -// public void drawU(UGraphic ug) { -// final StringBounder stringBounder = ug.getStringBounder(); -// -// final Snake snake = Snake.create(arrowColor, null).withLabel(tbback, arrowHorizontalAlignment()); -// final Dimension2D dimRepeat = repeat.calculateDimension(stringBounder); -// final Point2D p1 = getP1(stringBounder); -// final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder); -// final double x1 = p1.getX() + dimDiamond2.getWidth(); -// final double y1 = p1.getY() + dimDiamond2.getHeight() / 2; -// -// snake.addPoint(x1, y1); -// final double xmax = p1.getX() + dimDiamond2.getWidth() / 2 + dimRepeat.getWidth() / 2 -// + Diamond.diamondHalfSize; -// snake.addPoint(xmax, y1); -// ug.draw(snake); -// } -// -// } - class ConnectionBackBackward1 extends AbstractConnection { private final Rainbow arrowColor; private final TextBlock tbback; @@ -400,7 +375,6 @@ class FtileRepeat extends AbstractFtile { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final Snake snake = Snake.create(arrowColor, Arrows.asToUp()).withLabel(tbback, arrowHorizontalAlignment()); final Point2D p1 = getP1(stringBounder); final Point2D p2 = getP2(stringBounder); final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder); @@ -409,6 +383,8 @@ class FtileRepeat extends AbstractFtile { final double x2 = p2.getX(); final double y2 = p2.getY(); + final Snake snake = Snake.create(arrowColor, Arrows.asToUp()).withLabel(tbback, arrowHorizontalAlignment()); + snake.addPoint(x1, y1); snake.addPoint(x2, y1); snake.addPoint(x2, y2); @@ -418,7 +394,7 @@ class FtileRepeat extends AbstractFtile { } - class ConnectionBackBackward2 extends AbstractConnection { + class ConnectionBackBackward2 extends AbstractConnection implements ConnectionTranslatable { private final Rainbow arrowColor; private final TextBlock label; @@ -437,11 +413,41 @@ class FtileRepeat extends AbstractFtile { return getTranslateDiamond1(stringBounder).getTranslated(new Point2D.Double(0, 0)); } + @Override + public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { + final StringBounder stringBounder = ug.getStringBounder(); + + Point2D p1 = getP1(stringBounder); + Point2D p2 = getP2(stringBounder); + p1 = translate1.getTranslated(p1); + p2 = translate2.getTranslated(p2); + + final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder); + + final double x1 = p1.getX(); + final double y1 = p1.getY(); + double x2 = p2.getX(); + if (x2 < x1) + x2 += dimDiamond1.getWidth(); + final double y2 = p2.getY() + dimDiamond1.getHeight() / 2; + + Snake snake = Snake.create(arrowColor, x2 < x1 ? Arrows.asToLeft() : Arrows.asToRight()); + if (label != null) { + snake = snake.withLabel(label, arrowHorizontalAlignment()); + } + + snake.addPoint(x1, y1); + snake.addPoint(x1, y2); + snake.addPoint(x2, y2); + + ug.draw(snake); + + } + public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); Snake snake = Snake.create(arrowColor, Arrows.asToLeft()); - // .emphasizeDirection(Direction.UP); if (label != null) { snake = snake.withLabel(label, arrowHorizontalAlignment()); } @@ -496,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); @@ -504,6 +510,7 @@ class FtileRepeat extends AbstractFtile { ug.draw(snake); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { final StringBounder stringBounder = ug.getStringBounder(); final Snake snake = Snake.create(arrowColor, Arrows.asToLeft()).emphasizeDirection(Direction.UP) @@ -523,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); @@ -558,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); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSwitch.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSwitch.java index 92164a709..b03afb24d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSwitch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSwitch.java @@ -108,15 +108,15 @@ class FtileSwitch extends AbstractFtile { List inlabelSizes = new ArrayList<>(); for (Branch branch : thens) { - final TextBlock tb1 = branch.getLabelPositive().create(fcArrow, HorizontalAlignment.LEFT, + final TextBlock tb1 = branch.getDisplayPositive().create(fcArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam()); final TextBlock tbTest = branch.getLabelTest().create(fcTest, ftileFactory.skinParam().getDefaultTextAlignment(HorizontalAlignment.LEFT), 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); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java index ae02c0ecf..be9a20aa3 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java @@ -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) @@ -196,6 +196,7 @@ class FtileWhile extends AbstractFtile { ug.draw(snake); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { final StringBounder stringBounder = ug.getStringBounder(); final Point2D p1 = getP1(stringBounder); @@ -259,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); @@ -267,10 +268,11 @@ 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)); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { final StringBounder stringBounder = ug.getStringBounder(); final Snake snake = Snake.create(endInlinkColor, Arrows.asToLeft()).withMerge(MergeStrategy.LIMITED); @@ -289,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()); @@ -350,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)); } } @@ -442,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); @@ -451,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)); } @@ -491,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); @@ -577,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); } @@ -633,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); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java index 5939a05b5..be311770e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java @@ -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); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java index 597bcbf3b..7c4a5b4e7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java @@ -244,6 +244,7 @@ public class ParallelBuilderFork extends AbstractParallelFtilesBuilder { ug.draw(snake); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { ug = ug.apply(UTranslate.dx(x)); final FtileGeometry geo2 = getFtile2().calculateDimension(getStringBounder()); @@ -297,6 +298,7 @@ public class ParallelBuilderFork extends AbstractParallelFtilesBuilder { ug.draw(snake); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { ug = ug.apply(UTranslate.dx(x)); final FtileGeometry geo = getFtile1().calculateDimension(getStringBounder()); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderMerge.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderMerge.java index 230710e90..68c087466 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderMerge.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderMerge.java @@ -225,6 +225,7 @@ public class ParallelBuilderMerge extends AbstractParallelFtilesBuilder { ug.draw(snake); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { ug = ug.apply(UTranslate.dx(x)); final FtileGeometry geo = getFtile2().calculateDimension(getStringBounder()); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit.java index 4578c1cd2..2f3c0794e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit.java @@ -236,6 +236,7 @@ public class ParallelBuilderSplit extends AbstractParallelFtilesBuilder { ug.draw(snake); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { ug = ug.apply(UTranslate.dx(x)); final FtileGeometry geo = getFtile2().calculateDimension(getStringBounder()); @@ -292,6 +293,7 @@ public class ParallelBuilderSplit extends AbstractParallelFtilesBuilder { ug.draw(snake); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { ug = ug.apply(UTranslate.dx(x)); final FtileGeometry geo = getFtile1().calculateDimension(getStringBounder()); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java index e830a976c..474d6bb6f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java @@ -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; @@ -78,6 +78,8 @@ public class ConditionalBuilder { private final Swimlane swimlane; private final HColor borderColor; private final HColor backColor; + private final LineBreakStrategy diamondLineBreak; + private final LineBreakStrategy labelLineBreak; private final Rainbow arrowColor; private final FtileFactory ftileFactory; private final ConditionStyle conditionStyle; @@ -110,6 +112,8 @@ public class ConditionalBuilder { .getMergedStyle(skinParam.getCurrentStyleBuilder()); final Style styleDiamond = getDefaultStyleDefinitionDiamond() .getMergedStyle(skinParam.getCurrentStyleBuilder()); + this.diamondLineBreak = styleDiamond.wrapWidth(); + this.labelLineBreak = styleArrow.wrapWidth(); this.borderColor = styleDiamond.value(PName.LineColor).asColor(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet()); this.backColor = styleDiamond.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(), @@ -120,6 +124,8 @@ public class ConditionalBuilder { this.fontTest = styleDiamond.getFontConfiguration(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet()); this.fontArrow = styleArrow.getFontConfiguration(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet()); } else { + this.diamondLineBreak = LineBreakStrategy.NONE; + this.labelLineBreak = LineBreakStrategy.NONE; this.borderColor = borderColor; this.backColor = backColor; this.arrowColor = arrowColor; @@ -174,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()); @@ -199,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); @@ -217,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, @@ -234,57 +240,57 @@ 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, LineBreakStrategy.NONE, skinParam.getPadding()); - final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1), tile1.getThickness()); + final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, diamondLineBreak, skinParam.getPadding()); + 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) { - return branch.getLabelPositive().create7(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam(), - CreoleMode.SIMPLE_LINE); + return branch.getDisplayPositive().create0(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam(), + 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); } // else use default ConditionEndStyle.DIAMOND if (hasTwoBranches()) { @@ -299,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); } - return diamond2; + return shape2; } public boolean hasTwoBranches() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithDiamonds.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithDiamonds.java index 8b277349b..73da00734 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithDiamonds.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithDiamonds.java @@ -65,16 +65,13 @@ public class FtileIfWithDiamonds extends FtileIfNude { } public int getYdelta1a(StringBounder stringBounder) { - // if (getSwimlanes().size() > 1 && hasTwoBranches(stringBounder)) { if (getSwimlanes().size() > 1) { return 20; } return 10; - // return hasTwoBranches(stringBounder) ? 6 : 6; } public int getYdelta1b(StringBounder stringBounder) { - // if (getSwimlanes().size() > 1 && hasTwoBranches(stringBounder)) { if (getSwimlanes().size() > 1) { return 10; } @@ -98,9 +95,6 @@ public class FtileIfWithDiamonds extends FtileIfNude { return all.addDim(0, getYdelta1a(stringBounder) + getYdelta1b(stringBounder)); - // final double height = dimNude.getHeight() + dim1.getHeight() + dim2.getHeight() + getYdelta1a(stringBounder) - // + getYdelta1b(stringBounder); - // return new Dimension2DDouble(width, height); } @Override @@ -115,22 +109,21 @@ public class FtileIfWithDiamonds extends FtileIfNude { @Override protected UTranslate getTranslate1(StringBounder stringBounder) { final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder); - return super.getTranslate1(stringBounder).compose( - UTranslate.dy(dimDiamond1.getHeight() + getYdelta1a(stringBounder))); + return super.getTranslate1(stringBounder) + .compose(UTranslate.dy(dimDiamond1.getHeight() + getYdelta1a(stringBounder))); } @Override protected UTranslate getTranslate2(StringBounder stringBounder) { final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder); - return super.getTranslate2(stringBounder).compose( - UTranslate.dy(dimDiamond1.getHeight() + getYdelta1a(stringBounder))); + return super.getTranslate2(stringBounder) + .compose(UTranslate.dy(dimDiamond1.getHeight() + getYdelta1a(stringBounder))); } protected UTranslate getTranslateDiamond1(StringBounder stringBounder) { final double y1 = 0; final FtileGeometry dimTotal = calculateDimensionInternal(stringBounder); final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder); - // final double x1 = getLeft(stringBounder) - dimDiamond1.getWidth() / 2; final double x1 = dimTotal.getLeft() - dimDiamond1.getLeft(); return new UTranslate(x1, y1); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java index 74bec1163..939248473 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileIfWithLinks.java @@ -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; @@ -135,6 +135,7 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { throw new IllegalStateException(); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { final StringBounder stringBounder = ug.getStringBounder(); Point2D p1 = getP1(stringBounder); @@ -144,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); @@ -223,6 +224,7 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { throw new IllegalStateException(); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { final StringBounder stringBounder = ug.getStringBounder(); final FtileGeometry geo = getFtile1().calculateDimension(stringBounder); @@ -240,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; @@ -255,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()); @@ -313,6 +315,7 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { ug.draw(snake); } + @Override public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { final StringBounder stringBounder = ug.getStringBounder(); final FtileGeometry dimTotal = calculateDimensionInternal(stringBounder); @@ -322,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); @@ -416,7 +419,7 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { super(null, null); this.arrowColor = arrowColor; } - + public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); final Dimension2D totalDim = calculateDimensionInternal(stringBounder); @@ -446,7 +449,7 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { s.addPoint(maxX, totalDim.getHeight()); ug.draw(s); } - + private double[] getMinmax(StringBounder stringBounder, double width, List allTiles, Swimlane intoSw, List allSwimlanes) { final int current = allSwimlanes.indexOf(intoSw); @@ -499,7 +502,7 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { } return new double[] { minX, maxX }; } - + private int getFirstSwimlane(StringBounder stringBounder, List allTiles, List allSwimlanes) { for (int i = 0; i < allSwimlanes.size(); i++) { if (atLeastOne(stringBounder, allSwimlanes.get(i), allTiles)) { @@ -529,7 +532,6 @@ public class FtileIfWithLinks extends FtileIfWithDiamonds { return ftile.getSwimlaneOut() == swimlane && ftile.getSwimlanes().contains(swimlane); } - } public Ftile addLinks(Branch branch1, Branch branch2, StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithDiamonds.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithDiamonds.java index 49ceb1854..e35cbee81 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithDiamonds.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithDiamonds.java @@ -41,6 +41,8 @@ import java.util.Collections; import java.util.List; import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.activitydiagram3.Branch; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; @@ -50,6 +52,10 @@ import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; 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.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -64,7 +70,7 @@ public class FtileSwitchWithDiamonds extends FtileSwitchNude { protected final Ftile diamond1; protected final Ftile diamond2; protected final List branches; - private Mode mode; + protected final Mode mode; private final double w13; private final double w9; @@ -95,18 +101,18 @@ public class FtileSwitchWithDiamonds extends FtileSwitchNude { } @Override - public Collection getMyChildren() { + final public Collection getMyChildren() { final Collection result = new ArrayList<>(super.getMyChildren()); result.add(diamond1); result.add(diamond2); return Collections.unmodifiableCollection(result); } - public double getYdelta1a(StringBounder stringBounder) { + protected double getYdelta1a(StringBounder stringBounder) { return 20; } - public double getYdelta1b(StringBounder stringBounder) { + final protected double getYdelta1b(StringBounder stringBounder) { return 10; } @@ -134,7 +140,7 @@ public class FtileSwitchWithDiamonds extends FtileSwitchNude { } @Override - public void drawU(UGraphic ug) { + final public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1); @@ -151,7 +157,7 @@ public class FtileSwitchWithDiamonds extends FtileSwitchNude { } } - protected UTranslate getTranslateOf(Ftile tile, StringBounder stringBounder) { + final protected UTranslate getTranslateOf(Ftile tile, StringBounder stringBounder) { final UTranslate main = getTranslateMain(stringBounder); if (mode == Mode.BIG_DIAMOND) { double dx = 0; @@ -173,13 +179,13 @@ public class FtileSwitchWithDiamonds extends FtileSwitchNude { return getTranslateNude(tile, stringBounder).compose(main); } - protected UTranslate getTranslateMain(StringBounder stringBounder) { + final protected UTranslate getTranslateMain(StringBounder stringBounder) { final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder); final double dy1 = dimDiamond1.getHeight() + getYdelta1a(stringBounder); return UTranslate.dy(dy1); } - protected UTranslate getTranslateDiamond1(StringBounder stringBounder) { + final protected UTranslate getTranslateDiamond1(StringBounder stringBounder) { final double y1 = 0; final FtileGeometry dimTotal = calculateDimensionInternal(stringBounder); final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder); @@ -187,7 +193,7 @@ public class FtileSwitchWithDiamonds extends FtileSwitchNude { return new UTranslate(x1, y1); } - protected UTranslate getTranslateDiamond2(StringBounder stringBounder) { + final protected UTranslate getTranslateDiamond2(StringBounder stringBounder) { final FtileGeometry dimTotal = calculateDimensionInternal(stringBounder); final FtileGeometry dimDiamond2 = diamond2.calculateDimension(stringBounder); final double y2 = dimTotal.getHeight() - dimDiamond2.getHeight(); @@ -195,10 +201,4 @@ public class FtileSwitchWithDiamonds extends FtileSwitchNude { return new UTranslate(x2, y2); } - protected TextBlock getLabelPositive(Branch branch) { - final FontConfiguration fcArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null); - return branch.getLabelPositive().create7(fcArrow, HorizontalAlignment.LEFT, skinParam(), - CreoleMode.SIMPLE_LINE); - } - } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithManyLinks.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithManyLinks.java index 9b475149a..44f61b9eb 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithManyLinks.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithManyLinks.java @@ -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(getLabelPositive(branch), - 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(getLabelPositive(branch), - VerticalAlignment.BOTTOM); + 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); @@ -270,10 +280,15 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds { } - public double getYdelta1a(StringBounder stringBounder) { + @Override + protected double getYdelta1a(StringBounder stringBounder) { double max = 10; for (Branch branch : branches) { - max = Math.max(max, getLabelPositive(branch).calculateDimension(stringBounder).getHeight()); + max = Math.max(max, branch.getTextBlockPositive().calculateDimension(stringBounder).getHeight()); + } + if (mode == Mode.BIG_DIAMOND) { + final double diamondHeight = diamond1.calculateDimension(stringBounder).getHeight(); + max += diamondHeight / 2; } return max + 10; } @@ -298,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())); } } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithOneLink.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithOneLink.java index 3d942bf2c..cae0831d8 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithOneLink.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/FtileSwitchWithOneLink.java @@ -80,7 +80,7 @@ public class FtileSwitchWithOneLink extends FtileSwitchWithDiamonds { final double x2 = p2.getX(); final double y2 = p2.getY(); - final Snake snake = Snake.create(null, arrowColor, Arrows.asToDown()).withLabel(getLabelPositive(branch), + final Snake snake = Snake.create(null, arrowColor, Arrows.asToDown()).withLabel(branch.getTextBlockPositive(), arrowHorizontalAlignment()); // snake.addPoint(x1, y1); snake.addPoint(x2, y1); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java index a3e919c4f..7e113cb27 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java @@ -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; @@ -152,32 +151,6 @@ public class FtileBox extends AbstractFtile { return new FtileBox(skinParam, label, swimlane, boxStyle, style, styleArrow); } -// public static TextBlock createWbs(StyleBuilder styleBuilder, ISkinParam skinParam, Display label, -// StyleSignature styleDefinition) { -// Style style = null; -// Style styleArrow = null; -// if (UseStyle.useBetaStyle()) { -// style = styleDefinition.getMergedStyle(styleBuilder); -// styleArrow = style; -// } -// return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); -// } -// -// public static TextBlock createWbs(Style style, ISkinParam skinParam, Display label) { -// Style styleArrow = null; -// if (UseStyle.useBetaStyle()) { -// styleArrow = style; -// } -// return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); -// } -// -// public static TextBlock createMindMap(StyleBuilder styleBuilder, ISkinParam skinParam, Display label, -// StyleSignature styleDefinition) { -// final Style style = styleDefinition.getMergedStyle(styleBuilder); -// final Style styleArrow = style; -// return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); -// } - private FtileBox(ISkinParam skinParam, Display label, Swimlane swimlane, BoxStyle boxStyle, Style style, Style styleArrow) { super(skinParam); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox2.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox2.java index a4172342f..e4ab32bfb 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox2.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox2.java @@ -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; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorateInLabel.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorateInLabel.java new file mode 100644 index 000000000..4fb285dcd --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorateInLabel.java @@ -0,0 +1,77 @@ +/* ======================================================================== + * 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; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class FtileDecorateInLabel extends FtileDecorate { + + final private double xl; + final private 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; + } + + @Override + public FtileGeometry calculateDimension(StringBounder stringBounder) { + FtileGeometry result = super.calculateDimension(stringBounder); + result = result.addTop(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.apply(UTranslate.dy(yl))); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorateOutLabel.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorateOutLabel.java new file mode 100644 index 000000000..d3edfcaec --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorateOutLabel.java @@ -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); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamond.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamond.java index b1416cb89..dfefb03c8 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamond.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamond.java @@ -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 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 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(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java index 316332c5d..3c4a0fab7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java @@ -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 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 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) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java index 0d54095f4..3f8d25a5e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java @@ -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 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()); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside3.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside3.java deleted file mode 100644 index f2698d7e1..000000000 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside3.java +++ /dev/null @@ -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 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()); - } - -} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondSquare.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondSquare.java index d24596724..27ae55252 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondSquare.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondSquare.java @@ -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 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 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; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondWIP.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondWIP.java new file mode 100644 index 000000000..8be6a526b --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondWIP.java @@ -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 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 getSwimlanes() { + if (swimlane == null) { + return Collections.emptySet(); + } + return Collections.singleton(swimlane); + } + + final public Swimlane getSwimlaneIn() { + return swimlane; + } + + final public Swimlane getSwimlaneOut() { + return swimlane; + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/AbstractGtile.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/AbstractGtile.java new file mode 100644 index 000000000..6b87c04b0 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/AbstractGtile.java @@ -0,0 +1,191 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.awt.geom.Dimension2D; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineParam; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.graphic.AbstractTextBlock; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.skin.rose.Rose; +import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.color.HColorSet; + +public abstract class AbstractGtile extends AbstractTextBlock implements Gtile { + + protected final StringBounder stringBounder; + private final ISkinParam skinParam; + private final Swimlane singleSwimlane; + + public AbstractGtile(StringBounder stringBounder, ISkinParam skinParam, Swimlane singleSwimlane) { + this.stringBounder = stringBounder; + this.skinParam = skinParam; + this.singleSwimlane = singleSwimlane; + } + + public StringBounder getStringBounder() { + return stringBounder; + } + + public AbstractGtile(StringBounder stringBounder, ISkinParam skinParam) { + this(stringBounder, skinParam, null); + } + + final public ISkinParam skinParam() { + if (skinParam == null) { + throw new IllegalStateException(); + } + return skinParam; + } + + final public HColorSet getIHtmlColorSet() { + return skinParam.getIHtmlColorSet(); + } + +// @Override +// public UTranslate getTranslateFor(Gtile child) { +// throw new UnsupportedOperationException(); +// } + +// @Override +// public Collection getMyChildren() { +// return Collections.emptySet(); +// } + + @Override + public UTranslate getCoord(String name) { + final Dimension2D dim = calculateDimension(stringBounder); + if (name.equals(GPoint.NORTH_HOOK)) + return new UTranslate(dim.getWidth() / 2, 0); + if (name.equals(GPoint.SOUTH_HOOK)) + return new UTranslate(dim.getWidth() / 2, dim.getHeight()); + if (name.equals(GPoint.WEST_HOOK)) + return new UTranslate(0, dim.getHeight() / 2); + if (name.equals(GPoint.EAST_HOOK)) + return new UTranslate(dim.getWidth(), dim.getHeight() / 2); + throw new UnsupportedOperationException(); + } + + @Override + public GPoint getGPoint(String name) { + if (name.equals(GPoint.NORTH_HOOK) || name.equals(GPoint.SOUTH_HOOK) || name.equals(GPoint.WEST_HOOK) + || name.equals(GPoint.EAST_HOOK)) + return new GPoint(this, name); + throw new UnsupportedOperationException(); + } + + @Override + public Set getSwimlanes() { + if (singleSwimlane == null) + return Collections.emptySet(); + return Collections.singleton(singleSwimlane); + } + + @Override + public Swimlane getSwimlane(String point) { + return singleSwimlane; + } + +// public LinkRendering getInLinkRendering() { +// return LinkRendering.none(); +// } +// +// public LinkRendering getOutLinkRendering() { +// return LinkRendering.none(); +// } + + public Collection getInnerConnections() { + return Collections.emptyList(); + } + +// public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) { +// throw new UnsupportedOperationException("" + getClass()); +// } + + public final UStroke getThickness() { + UStroke thickness = skinParam.getThickness(LineParam.activityBorder, null); + if (thickness == null) { + thickness = new UStroke(1.5); + } + return thickness; + } + + private final Rose rose = new Rose(); + + protected final Rose getRose() { + return rose; + } + +// public List getWeldingPoints() { +// return Collections.emptyList(); +// } +// +// public Collection getMyChildren() { +// throw new UnsupportedOperationException("" + getClass()); +// } +// +// public HorizontalAlignment arrowHorizontalAlignment() { +// return skinParam.getHorizontalAlignment(AlignmentParam.arrowMessageAlignment, null, false, null); +// } +// +// private FtileGeometry cachedGeometry; +// +// final public FtileGeometry calculateDimension(StringBounder stringBounder) { +// if (cachedGeometry == null) { +// cachedGeometry = calculateDimensionFtile(stringBounder); +// } +// return cachedGeometry; +// } +// +// abstract protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder); +// +// @Override +// final public MinMax getMinMax(StringBounder stringBounder) { +// throw new UnsupportedOperationException(); +// // return getMinMaxFtile(stringBounder); +// } +// +// // protected MinMax getMinMaxFtile(StringBounder stringBounder) { +// // throw new UnsupportedOperationException(); +// // } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/UScale.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GAbstractConnection.java similarity index 72% rename from src/net/sourceforge/plantuml/ugraphic/UScale.java rename to src/net/sourceforge/plantuml/activitydiagram3/gtile/GAbstractConnection.java index 937994080..0edd17fe9 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UScale.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GAbstractConnection.java @@ -30,34 +30,32 @@ * * * Original Author: Arnaud Roques - * + * * */ -package net.sourceforge.plantuml.ugraphic; +package net.sourceforge.plantuml.activitydiagram3.gtile; +import java.util.Arrays; +import java.util.List; -public class UScale implements UChange { +public abstract class GAbstractConnection implements GConnection { - private final double scale; + protected final GPoint gpoint1; + protected final GPoint gpoint2; + + public GAbstractConnection(GPoint gpoint1, GPoint gpoint2) { + this.gpoint1 = gpoint1; + this.gpoint2 = gpoint2; + } @Override public String toString() { - return "scale scale=" + scale; + return "[" + gpoint1 + "]->[" + gpoint2 + "]"; } - public UScale(double scale) { - this.scale = scale; + @Override + final public List getHooks() { + return Arrays.asList(gpoint1, gpoint2); } - public double getScale() { - return scale; - } - -// public Point2D getTranslated(Point2D p) { -// if (p == null) { -// return null; -// } -// return new Point2D.Double(p.getX() + dx, p.getY() + dy); -// } - } diff --git a/src/net/sourceforge/plantuml/braille/DriverNoneBraille.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnection.java similarity index 77% rename from src/net/sourceforge/plantuml/braille/DriverNoneBraille.java rename to src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnection.java index 6e132b68a..34a5a92e4 100644 --- a/src/net/sourceforge/plantuml/braille/DriverNoneBraille.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnection.java @@ -31,17 +31,17 @@ * * Original Author: Arnaud Roques * + * */ -package net.sourceforge.plantuml.braille; +package net.sourceforge.plantuml.activitydiagram3.gtile; -import net.sourceforge.plantuml.ugraphic.UDriver; -import net.sourceforge.plantuml.ugraphic.UParam; +import java.util.List; + +import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.ugraphic.UShape; -import net.sourceforge.plantuml.ugraphic.color.ColorMapper; -public class DriverNoneBraille implements UDriver { +public interface GConnection extends UDrawable, UShape { - public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, BrailleGrid object) { - } + public List getHooks(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionHorizontalThenVerticalDown.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionHorizontalThenVerticalDown.java new file mode 100644 index 000000000..b26f410ca --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionHorizontalThenVerticalDown.java @@ -0,0 +1,130 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; +import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class GConnectionHorizontalThenVerticalDown extends GAbstractConnection implements GConnectionTranslatable { + + private final TextBlock textBlock; + private final UTranslate pos1; + private final UTranslate pos2; + + public GConnectionHorizontalThenVerticalDown(UTranslate pos1, GPoint gpoint1, UTranslate pos2, GPoint gpoint2, + TextBlock textBlock) { + super(gpoint1, gpoint2); + this.textBlock = textBlock; + this.pos1 = pos1; + this.pos2 = pos2; + // See FtileFactoryDelegatorAssembly + } + + @Override + public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { + throw new UnsupportedOperationException(); + + } + + @Override + public void drawU(UGraphic ug) { + ug.draw(getSimpleSnake()); + } + +// public double getMaxX(StringBounder stringBounder) { +// return getSimpleSnake().getMaxX(stringBounder); +// } + + private Rainbow getInLinkRenderingColor() { + Rainbow color; + color = Rainbow.build(gpoint1.getGtile().skinParam()); +// final LinkRendering linkRendering = tile.getInLinkRendering(); +// if (linkRendering == null) { +// if (UseStyle.useBetaStyle()) { +// final Style style = getDefaultStyleDefinitionArrow() +// .getMergedStyle(skinParam().getCurrentStyleBuilder()); +// return Rainbow.build(style, skinParam().getIHtmlColorSet(), skinParam().getThemeStyle()); +// } else { +// color = Rainbow.build(skinParam()); +// } +// } else { +// color = linkRendering.getRainbow(); +// } +// if (color.size() == 0) { +// if (UseStyle.useBetaStyle()) { +// final Style style = getDefaultStyleDefinitionArrow() +// .getMergedStyle(skinParam().getCurrentStyleBuilder()); +// return Rainbow.build(style, skinParam().getIHtmlColorSet(), skinParam().getThemeStyle()); +// } else { +// color = Rainbow.build(skinParam()); +// } +// } + return color; + } + + private Snake getSimpleSnake() { + final Snake snake = Snake.create(getInLinkRenderingColor(), Arrows.asToDown()).withLabel(textBlock, + HorizontalAlignment.LEFT); + final Point2D p1 = pos1.getTranslated(gpoint1.getPoint2D()); + final Point2D p2 = pos2.getTranslated(gpoint2.getPoint2D()); + snake.addPoint(p1); + snake.addPoint(new Point2D.Double(p2.getX(), p1.getY())); + snake.addPoint(p2); + return snake; + } + +// @Override +// public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { +// final Snake snake = Snake.create(color, Arrows.asToDown()).withLabel(textBlock, HorizontalAlignment.LEFT); +// final Point2D mp1a = translate1.getTranslated(p1); +// final Point2D mp2b = translate2.getTranslated(p2); +// final double middle = (mp1a.getY() + mp2b.getY()) / 2.0; +// snake.addPoint(mp1a); +// snake.addPoint(mp1a.getX(), middle); +// snake.addPoint(mp2b.getX(), middle); +// snake.addPoint(mp2b); +// ug.draw(snake); +// +// } + +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionLeftThenDownThenRight.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionLeftThenDownThenRight.java new file mode 100644 index 000000000..3d957a829 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionLeftThenDownThenRight.java @@ -0,0 +1,137 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; +import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class GConnectionLeftThenDownThenRight extends GAbstractConnection implements GConnectionTranslatable { + + private final TextBlock textBlock; + private final UTranslate pos1; + private final UTranslate pos2; + + private final double xright; + + public GConnectionLeftThenDownThenRight(UTranslate pos1, GPoint gpoint1, UTranslate pos2, GPoint gpoint2, + double xright, TextBlock textBlock) { + super(gpoint1, gpoint2); + this.textBlock = textBlock; + this.pos1 = pos1; + this.pos2 = pos2; + this.xright = xright; + // See FtileFactoryDelegatorAssembly + } + + @Override + public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { + throw new UnsupportedOperationException(); + + } + + @Override + public void drawU(UGraphic ug) { + ug.draw(getSimpleSnake()); + } + +// public double getMaxX(StringBounder stringBounder) { +// return getSimpleSnake().getMaxX(stringBounder); +// } + + private Rainbow getInLinkRenderingColor() { + Rainbow color; + color = Rainbow.build(gpoint1.getGtile().skinParam()); +// final LinkRendering linkRendering = tile.getInLinkRendering(); +// if (linkRendering == null) { +// if (UseStyle.useBetaStyle()) { +// final Style style = getDefaultStyleDefinitionArrow() +// .getMergedStyle(skinParam().getCurrentStyleBuilder()); +// return Rainbow.build(style, skinParam().getIHtmlColorSet(), skinParam().getThemeStyle()); +// } else { +// color = Rainbow.build(skinParam()); +// } +// } else { +// color = linkRendering.getRainbow(); +// } +// if (color.size() == 0) { +// if (UseStyle.useBetaStyle()) { +// final Style style = getDefaultStyleDefinitionArrow() +// .getMergedStyle(skinParam().getCurrentStyleBuilder()); +// return Rainbow.build(style, skinParam().getIHtmlColorSet(), skinParam().getThemeStyle()); +// } else { +// color = Rainbow.build(skinParam()); +// } +// } + return color; + } + + private Snake getSimpleSnake() { + final Snake snake = Snake.create(getInLinkRenderingColor(), Arrows.asToLeft()) + .emphasizeDirection(Direction.DOWN).withLabel(textBlock, HorizontalAlignment.LEFT); + final Point2D p1 = pos1.getTranslated(gpoint1.getPoint2D()); + final Point2D p2 = pos2.getTranslated(gpoint2.getPoint2D()); + // final double maxX = Math.max(p1.getX(), p2.getX()); + final double maxX = xright; + snake.addPoint(p1); + snake.addPoint(new Point2D.Double(maxX, p1.getY())); + snake.addPoint(new Point2D.Double(maxX, p2.getY())); + snake.addPoint(p2); + return snake; + } + +// @Override +// public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { +// final Snake snake = Snake.create(color, Arrows.asToDown()).withLabel(textBlock, HorizontalAlignment.LEFT); +// final Point2D mp1a = translate1.getTranslated(p1); +// final Point2D mp2b = translate2.getTranslated(p2); +// final double middle = (mp1a.getY() + mp2b.getY()) / 2.0; +// snake.addPoint(mp1a); +// snake.addPoint(mp1a.getX(), middle); +// snake.addPoint(mp2b.getX(), middle); +// snake.addPoint(mp2b); +// ug.draw(snake); +// +// } + +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionTranslatable.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionTranslatable.java new file mode 100644 index 000000000..8c6b3c5fa --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionTranslatable.java @@ -0,0 +1,45 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public interface GConnectionTranslatable extends GConnection { + + public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2); + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDown.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDown.java new file mode 100644 index 000000000..8ee4d2996 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDown.java @@ -0,0 +1,129 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; +import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class GConnectionVerticalDown extends GAbstractConnection implements GConnectionTranslatable { + + private final TextBlock textBlock; + private final UTranslate pos1; + private final UTranslate pos2; + + public GConnectionVerticalDown(UTranslate pos1, GPoint gpoint1, UTranslate pos2, GPoint gpoint2, + TextBlock textBlock) { + super(gpoint1, gpoint2); + this.textBlock = textBlock; + this.pos1 = pos1; + this.pos2 = pos2; + // See FtileFactoryDelegatorAssembly + } + + @Override + public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { + throw new UnsupportedOperationException(); + + } + + @Override + public void drawU(UGraphic ug) { + ug.draw(getSimpleSnake()); + } + +// public double getMaxX(StringBounder stringBounder) { +// return getSimpleSnake().getMaxX(stringBounder); +// } + + private Rainbow getInLinkRenderingColor() { + Rainbow color; + color = Rainbow.build(gpoint1.getGtile().skinParam()); +// final LinkRendering linkRendering = tile.getInLinkRendering(); +// if (linkRendering == null) { +// if (UseStyle.useBetaStyle()) { +// final Style style = getDefaultStyleDefinitionArrow() +// .getMergedStyle(skinParam().getCurrentStyleBuilder()); +// return Rainbow.build(style, skinParam().getIHtmlColorSet(), skinParam().getThemeStyle()); +// } else { +// color = Rainbow.build(skinParam()); +// } +// } else { +// color = linkRendering.getRainbow(); +// } +// if (color.size() == 0) { +// if (UseStyle.useBetaStyle()) { +// final Style style = getDefaultStyleDefinitionArrow() +// .getMergedStyle(skinParam().getCurrentStyleBuilder()); +// return Rainbow.build(style, skinParam().getIHtmlColorSet(), skinParam().getThemeStyle()); +// } else { +// color = Rainbow.build(skinParam()); +// } +// } + return color; + } + + private Snake getSimpleSnake() { + final Snake snake = Snake.create(getInLinkRenderingColor(), Arrows.asToDown()).withLabel(textBlock, + HorizontalAlignment.LEFT); + final Point2D p1 = pos1.getTranslated(gpoint1.getPoint2D()); + final Point2D p2 = pos2.getTranslated(gpoint2.getPoint2D()); + snake.addPoint(p1); + snake.addPoint(p2); + return snake; + } + +// @Override +// public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { +// final Snake snake = Snake.create(color, Arrows.asToDown()).withLabel(textBlock, HorizontalAlignment.LEFT); +// final Point2D mp1a = translate1.getTranslated(p1); +// final Point2D mp2b = translate2.getTranslated(p2); +// final double middle = (mp1a.getY() + mp2b.getY()) / 2.0; +// snake.addPoint(mp1a); +// snake.addPoint(mp1a.getX(), middle); +// snake.addPoint(mp2b.getX(), middle); +// snake.addPoint(mp2b); +// ug.draw(snake); +// +// } + +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDownThenHorizontal.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDownThenHorizontal.java new file mode 100644 index 000000000..42ae4c1a7 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GConnectionVerticalDownThenHorizontal.java @@ -0,0 +1,132 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; +import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UPolygon; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class GConnectionVerticalDownThenHorizontal extends GAbstractConnection implements GConnectionTranslatable { + + private final TextBlock textBlock; + private final UTranslate pos1; + private final UTranslate pos2; + + public GConnectionVerticalDownThenHorizontal(UTranslate pos1, GPoint gpoint1, UTranslate pos2, GPoint gpoint2, + TextBlock textBlock) { + super(gpoint1, gpoint2); + this.textBlock = textBlock; + this.pos1 = pos1; + this.pos2 = pos2; + // See FtileFactoryDelegatorAssembly + } + + @Override + public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { + throw new UnsupportedOperationException(); + + } + + @Override + public void drawU(UGraphic ug) { + ug.draw(getSimpleSnake()); + } + +// public double getMaxX(StringBounder stringBounder) { +// return getSimpleSnake().getMaxX(stringBounder); +// } + + private Rainbow getInLinkRenderingColor() { + Rainbow color; + color = Rainbow.build(gpoint1.getGtile().skinParam()); +// final LinkRendering linkRendering = tile.getInLinkRendering(); +// if (linkRendering == null) { +// if (UseStyle.useBetaStyle()) { +// final Style style = getDefaultStyleDefinitionArrow() +// .getMergedStyle(skinParam().getCurrentStyleBuilder()); +// return Rainbow.build(style, skinParam().getIHtmlColorSet(), skinParam().getThemeStyle()); +// } else { +// color = Rainbow.build(skinParam()); +// } +// } else { +// color = linkRendering.getRainbow(); +// } +// if (color.size() == 0) { +// if (UseStyle.useBetaStyle()) { +// final Style style = getDefaultStyleDefinitionArrow() +// .getMergedStyle(skinParam().getCurrentStyleBuilder()); +// return Rainbow.build(style, skinParam().getIHtmlColorSet(), skinParam().getThemeStyle()); +// } else { +// color = Rainbow.build(skinParam()); +// } +// } + return color; + } + + private Snake getSimpleSnake() { + final Point2D p1 = pos1.getTranslated(gpoint1.getPoint2D()); + final Point2D p2 = pos2.getTranslated(gpoint2.getPoint2D()); + final UPolygon arrow = p1.getX() < p2.getX() ? Arrows.asToRight() : Arrows.asToLeft(); + final Snake snake = Snake.create(getInLinkRenderingColor(), arrow).withLabel(textBlock, + HorizontalAlignment.LEFT); + snake.addPoint(p1); + snake.addPoint(new Point2D.Double(p1.getX(), p2.getY())); + snake.addPoint(p2); + return snake; + } + +// @Override +// public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { +// final Snake snake = Snake.create(color, Arrows.asToDown()).withLabel(textBlock, HorizontalAlignment.LEFT); +// final Point2D mp1a = translate1.getTranslated(p1); +// final Point2D mp2b = translate2.getTranslated(p2); +// final double middle = (mp1a.getY() + mp2b.getY()) / 2.0; +// snake.addPoint(mp1a); +// snake.addPoint(mp1a.getX(), middle); +// snake.addPoint(mp2b.getX(), middle); +// snake.addPoint(mp2b); +// ug.draw(snake); +// +// } + +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GPoint.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GPoint.java new file mode 100644 index 000000000..fcb4e17f1 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GPoint.java @@ -0,0 +1,89 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.activitydiagram3.LinkRendering; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class GPoint { + + public static final String NORTH_HOOK = "NORTH_HOOK"; + public static final String SOUTH_HOOK = "SOUTH_HOOK"; + public static final String WEST_HOOK = "WEST_HOOK"; + public static final String EAST_HOOK = "EAST_HOOK"; + + public static final String NORTH_BORDER = "NORTH_BORDER"; + public static final String SOUTH_BORDER = "SOUTH_BORDER"; + public static final String WEST_BORDER = "WEST_BORDER"; + public static final String EAST_BORDER = "EAST_BORDER"; + + private final Gtile gtile; + private final String name; + private final LinkRendering linkRendering; + + public GPoint(Gtile gtile, String name, LinkRendering linkRendering) { + this.gtile = gtile; + this.name = name; + this.linkRendering = linkRendering; + } + + public GPoint(Gtile gtile, String name) { + this(gtile, name, LinkRendering.none()); + } + + public Gtile getGtile() { + return gtile; + } + + public String getName() { + return name; + } + + public UTranslate getCoord() { + return gtile.getCoord(name); + } + + public Point2D getPoint2D() { + return getCoord().getPosition(); + } + + public LinkRendering getLinkRendering() { + return linkRendering; + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/Scalable.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/Gluon.java similarity index 91% rename from src/net/sourceforge/plantuml/ugraphic/Scalable.java rename to src/net/sourceforge/plantuml/activitydiagram3/gtile/Gluon.java index f4b4ea011..7c6633077 100644 --- a/src/net/sourceforge/plantuml/ugraphic/Scalable.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/Gluon.java @@ -30,12 +30,11 @@ * * * Original Author: Arnaud Roques - * + * * */ -package net.sourceforge.plantuml.ugraphic; +package net.sourceforge.plantuml.activitydiagram3.gtile; -public interface Scalable { +public interface Gluon { - public UShape getScaled(double scale); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/Gtile.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/Gtile.java new file mode 100644 index 000000000..0b74b6d01 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/Gtile.java @@ -0,0 +1,67 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.util.Collection; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public interface Gtile extends Swimable2, TextBlock { + + public static final boolean USE_GTILE = false; + + public ISkinParam skinParam(); + + public StringBounder getStringBounder(); + + // public UTranslate getTranslateFor(Gtile child); + + // public Collection getMyChildren(); + + public UTranslate getCoord(String name); + + public GPoint getGPoint(String name); + + public Collection getInnerConnections(); + +// public List getWeldingPoints(); +// +// public HorizontalAlignment arrowHorizontalAlignment(); + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileAssembly.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileAssembly.java new file mode 100644 index 000000000..c0c18b731 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileAssembly.java @@ -0,0 +1,97 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.util.Collection; +import java.util.Collections; + +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.UseStyle; +import net.sourceforge.plantuml.activitydiagram3.LinkRendering; +import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class GtileAssembly extends GtileAssemblySimple { + + private final TextBlock textBlock; + + public GtileAssembly(Gtile tile1, Gtile tile2, LinkRendering linkRendering) { + super(tile1, tile2); + this.textBlock = getTextBlock(linkRendering.getDisplay()); + // See FtileFactoryDelegatorAssembly + } + + @Override + protected UTranslate supplementaryMove() { + final double height = 30 + textBlock.calculateDimension(stringBounder).getHeight(); + return new UTranslate(0, height); + } + + final public StyleSignature getDefaultStyleDefinitionArrow() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow); + } + + protected final TextBlock getTextBlock(Display display) { + // DUP3945 + if (Display.isNull(display)) { + return TextBlockUtils.EMPTY_TEXT_BLOCK; + } + final FontConfiguration fontConfiguration; + if (UseStyle.useBetaStyle()) { + final Style style = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam().getCurrentStyleBuilder()); + fontConfiguration = style.getFontConfiguration(skinParam().getThemeStyle(), skinParam().getIHtmlColorSet()); + } else { + fontConfiguration = new FontConfiguration(skinParam(), FontParam.ARROW, null); + } + return display.create7(fontConfiguration, HorizontalAlignment.LEFT, skinParam(), CreoleMode.SIMPLE_LINE); + } + + @Override + public Collection getInnerConnections() { + final GConnection arrow = new GConnectionVerticalDown(getPos1(), tile1.getGPoint(GPoint.SOUTH_HOOK), getPos2(), + tile2.getGPoint(GPoint.NORTH_HOOK), textBlock); + return Collections.singletonList(arrow); + } + +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileAssemblySimple.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileAssemblySimple.java new file mode 100644 index 000000000..408f584bf --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileAssemblySimple.java @@ -0,0 +1,138 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.utils.MathUtils; + +public class GtileAssemblySimple extends AbstractGtile { + + protected final Gtile tile1; + protected final Gtile tile2; + + private final Dimension2D dim1; + private final Dimension2D dim2; + + private final UTranslate pos1; + private final UTranslate pos2; + + @Override + public String toString() { + return "GtileAssemblySimple " + tile1 + " && " + tile2; + } + + public GtileAssemblySimple(Gtile tile1, Gtile tile2) { + super(tile1.getStringBounder(), tile1.skinParam()); + this.tile1 = tile1; + this.tile2 = tile2; + + this.dim1 = tile1.calculateDimension(stringBounder); + this.dim2 = tile2.calculateDimension(stringBounder); + + final UTranslate vector1 = tile1.getCoord(GPoint.SOUTH_HOOK); + final UTranslate vector2 = tile2.getCoord(GPoint.NORTH_HOOK); + +// final UTranslate diff = vector1.compose(vector2.reverse()); +// this.pos1 = diff.getDx() > 0 ? UTranslate.none() : UTranslate.dx(-diff.getDx()); +// this.pos2 = diff.compose(this.pos1); + + final double maxDx = Math.max(vector1.getDx(), vector2.getDx()); + this.pos1 = UTranslate.dx(maxDx - vector1.getDx()); + this.pos2 = new UTranslate(maxDx - vector2.getDx(), dim1.getHeight()); + } + + protected UTranslate supplementaryMove() { + return new UTranslate(); + } + +// @Override +// public List getHooks() { +// return Arrays.asList(tile1.getGPoint(GPoint.SOUTH), tile2.getGPoint(GPoint.NORTH)); +// } + + @Override + public UTranslate getCoord(String name) { + if (name.equals(GPoint.NORTH_HOOK)) + return getPos1().compose(tile1.getCoord(name)); + if (name.equals(GPoint.SOUTH_HOOK)) + return getPos2().compose(tile2.getCoord(name)); + throw new UnsupportedOperationException(); + } + + protected UTranslate getPos1() { + return pos1; + } + + protected UTranslate getPos2() { + return pos2.compose(supplementaryMove()); + } + + public void drawU(UGraphic ug) { + ug.apply(getPos1()).draw(tile1); + ug.apply(getPos2()).draw(tile2); + } + + @Override + public Dimension2D calculateDimension(StringBounder stringBounder) { + final Point2D corner1 = getPos1().getTranslated(dim1); + final Point2D corner2 = getPos2().getTranslated(dim2); + return new Dimension2DDouble(MathUtils.max(corner1, corner2)); + } + + public Set getSwimlanes() { + final Set result = new HashSet<>(); + result.addAll(tile1.getSwimlanes()); + result.addAll(tile2.getSwimlanes()); + return Collections.unmodifiableSet(result); + } + + public Collection getMyChildren() { + return Arrays.asList(tile1, tile2); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileBox.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileBox.java new file mode 100644 index 000000000..21ff6d7a3 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileBox.java @@ -0,0 +1,237 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.ColorParam; +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.SkinParamColors; +import net.sourceforge.plantuml.SkinParamUtils; +import net.sourceforge.plantuml.UseStyle; +import net.sourceforge.plantuml.activitydiagram3.LinkRendering; +import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.creole.Parser; +import net.sourceforge.plantuml.creole.Sheet; +import net.sourceforge.plantuml.creole.SheetBlock1; +import net.sourceforge.plantuml.creole.SheetBlock2; +import net.sourceforge.plantuml.creole.Stencil; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.Stereotype; +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.UDrawable; +import net.sourceforge.plantuml.graphic.color.Colors; +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.StyleSignature; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.HColorNone; + +public class GtileBox extends AbstractGtile { + + private final ClockwiseTopRightBottomLeft padding; + private final ClockwiseTopRightBottomLeft margin; + + private final TextBlock tb; + private double roundCorner = 25; + private final double shadowing; + private final HorizontalAlignment horizontalAlignment; + private double minimumWidth = 0; + + private final LinkRendering inRendering; + private final Swimlane swimlane; + private final BoxStyle boxStyle; + + private final HColor borderColor; + private final HColor backColor; + private final Style style; + + static public StyleSignature getDefaultStyleDefinitionActivity() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity); + } + + static public StyleSignature getDefaultStyleDefinitionArrow() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow); + } + + final public LinkRendering getInLinkRendering() { + return inRendering; + } + + class MyStencil implements Stencil { + + public double getStartingX(StringBounder stringBounder, double y) { + return -padding.getLeft(); + } + + public double getEndingX(StringBounder stringBounder, double y) { + final Dimension2D dim = calculateDimension(stringBounder); + return dim.getWidth() - padding.getRight(); + } + + } + + public static GtileBox create(StringBounder stringBounder, ISkinParam skinParam, Display label, Swimlane swimlane, + BoxStyle boxStyle, Stereotype stereotype) { + Style style = null; + Style styleArrow = null; + if (UseStyle.useBetaStyle()) { + style = getDefaultStyleDefinitionActivity().with(stereotype) + .getMergedStyle(skinParam.getCurrentStyleBuilder()); + styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam.getCurrentStyleBuilder()); + } + return new GtileBox(stringBounder, skinParam, label, swimlane, boxStyle, style, styleArrow); + } + + private GtileBox(StringBounder stringBounder, ISkinParam skinParam, Display label, Swimlane swimlane, + BoxStyle boxStyle, Style style, Style styleArrow) { + super(stringBounder, skinParam); + this.style = style; + this.boxStyle = boxStyle; + this.swimlane = swimlane; + final FontConfiguration fc; + final LineBreakStrategy wrapWidth; + if (UseStyle.useBetaStyle()) { + this.inRendering = new LinkRendering( + Rainbow.build(styleArrow, getIHtmlColorSet(), skinParam.getThemeStyle())); + Colors specBack = null; + if (skinParam instanceof SkinParamColors) { + specBack = ((SkinParamColors) skinParam).getColors(); + } + style = style.eventuallyOverride(specBack); + this.borderColor = style.value(PName.LineColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet()); + this.backColor = style.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet()); + fc = style.getFontConfiguration(skinParam.getThemeStyle(), getIHtmlColorSet()); + this.horizontalAlignment = style.getHorizontalAlignment(); + this.padding = style.getPadding(); + this.margin = style.getMargin(); + this.roundCorner = style.value(PName.RoundCorner).asDouble(); + this.shadowing = style.value(PName.Shadowing).asDouble(); + wrapWidth = style.wrapWidth(); + this.minimumWidth = style.value(PName.MinimumWidth).asDouble(); + } else { + this.padding = ClockwiseTopRightBottomLeft.same(10); + this.margin = ClockwiseTopRightBottomLeft.same(0); + this.inRendering = new LinkRendering(Rainbow.build(skinParam)); + this.borderColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBorder); + this.backColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBackground); + fc = new FontConfiguration(skinParam, FontParam.ACTIVITY, null); + this.horizontalAlignment = HorizontalAlignment.LEFT; + this.shadowing = skinParam().shadowing(null) ? 3.0 : 0.0; + wrapWidth = skinParam.wrapWidth(); + + } + final Sheet sheet = Parser + .build(fc, skinParam.getDefaultTextAlignment(horizontalAlignment), skinParam, CreoleMode.FULL) + .createSheet(label); + this.tb = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, skinParam.getPadding()), new MyStencil(), + new UStroke(1)); + this.print = label.toString(); + + } + + final private String print; + + @Override + public String toString() { + return print; + } + + public void drawU(UGraphic ug) { + final Dimension2D dimTotal = calculateDimension(ug.getStringBounder()); + final double widthTotal = dimTotal.getWidth(); + final double heightTotal = dimTotal.getHeight(); + final UDrawable shape = boxStyle.getUDrawable(widthTotal, heightTotal, shadowing, roundCorner); + + final UStroke thickness; + if (UseStyle.useBetaStyle()) { + thickness = style.getStroke(); + } else { + thickness = getThickness(); + } + + if (borderColor == null) { + ug = ug.apply(new HColorNone()); + } else { + ug = ug.apply(borderColor); + } + if (backColor == null) { + ug = ug.apply(new HColorNone().bg()); + } else { + ug = ug.apply(backColor.bg()); + } + + ug = ug.apply(thickness); + shape.drawU(ug); + + if (horizontalAlignment == HorizontalAlignment.LEFT) { + tb.drawU(ug.apply(new UTranslate(padding.getLeft(), padding.getTop()))); + } else if (horizontalAlignment == HorizontalAlignment.RIGHT) { + final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); + tb.drawU(ug.apply( + new UTranslate(dimTotal.getWidth() - dimTb.getWidth() - padding.getRight(), padding.getBottom()))); + } else if (horizontalAlignment == HorizontalAlignment.CENTER) { + final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); + tb.drawU(ug.apply(new UTranslate((dimTotal.getWidth() - dimTb.getWidth()) / 2, padding.getBottom()))); + } + } + + @Override + public final Dimension2D calculateDimension(StringBounder stringBounder) { + Dimension2D dimRaw = tb.calculateDimension(stringBounder); + dimRaw = Dimension2DDouble.delta(dimRaw, padding.getLeft() + padding.getRight(), + padding.getBottom() + padding.getTop()); + dimRaw = Dimension2DDouble.atLeast(dimRaw, minimumWidth, 0); + return new FtileGeometry(dimRaw.getWidth() + boxStyle.getShield(), dimRaw.getHeight(), dimRaw.getWidth() / 2, 0, + dimRaw.getHeight()); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileCircleStart.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileCircleStart.java new file mode 100644 index 000000000..ad6c349ec --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileCircleStart.java @@ -0,0 +1,84 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.UseStyle; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.ugraphic.UEllipse; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.HColorNone; + +public class GtileCircleStart extends AbstractGtile { + + private static final int SIZE = 20; + + private final HColor backColor; + private double shadowing; + + public GtileCircleStart(StringBounder stringBounder, ISkinParam skinParam, HColor backColor, Swimlane swimlane, + Style style) { + super(stringBounder, skinParam, swimlane); + this.backColor = backColor; + if (UseStyle.useBetaStyle()) { + this.shadowing = style.value(PName.Shadowing).asDouble(); + } else { + if (skinParam().shadowing(null)) { + this.shadowing = 3; + } + } + + } + + public void drawU(UGraphic ug) { + final UEllipse circle = new UEllipse(SIZE, SIZE); + circle.setDeltaShadow(shadowing); + ug.apply(new HColorNone()).apply(backColor.bg()).draw(circle); + } + + @Override + public Dimension2D calculateDimension(StringBounder stringBounder) { + return new Dimension2DDouble(SIZE, SIZE); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileDiamondInside.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileDiamondInside.java new file mode 100644 index 000000000..31c5b88e8 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileDiamondInside.java @@ -0,0 +1,115 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.UseStyle; +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.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 GtileDiamondInside extends AbstractGtile { + + protected final HColor backColor; + protected final HColor borderColor; + + protected final TextBlock label; + protected final Dimension2D dimLabel; + + protected final double shadowing; + + final public StyleSignature getDefaultStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity, SName.diamond); + } + + // FtileDiamondInside + public GtileDiamondInside(StringBounder stringBounder, TextBlock label, ISkinParam skinParam, HColor backColor, + HColor borderColor, Swimlane swimlane) { + super(stringBounder, skinParam, swimlane); + 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.label = label; + this.dimLabel = label.calculateDimension(stringBounder); + + } + + @Override + public Dimension2D calculateDimension(StringBounder stringBounder) { + final Dimension2D dim; + if (dimLabel.getWidth() == 0 || dimLabel.getHeight() == 0) { + dim = new Dimension2DDouble(Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2); + } else { + dim = Dimension2DDouble.delta( + Dimension2DDouble.atLeast(dimLabel, Hexagon.hexagonHalfSize * 2, Hexagon.hexagonHalfSize * 2), + Hexagon.hexagonHalfSize * 2, 0); + } + return dim; + } + + @Override + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final Dimension2D dimTotal = calculateDimension(stringBounder); + ug = ug.apply(borderColor).apply(getThickness()).apply(backColor.bg()); + ug.draw(Hexagon.asPolygon(shadowing, dimTotal.getWidth(), 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))); + + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileEmpty.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileEmpty.java new file mode 100644 index 000000000..9d7508ffa --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileEmpty.java @@ -0,0 +1,107 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.UGraphic; + +public class GtileEmpty extends AbstractGtile { + + private final double width; + private final double height; + + public GtileEmpty(StringBounder stringBounder, ISkinParam skinParam, double width, double height) { + this(stringBounder, skinParam, width, height, null); + } + + public GtileEmpty(StringBounder stringBounder, ISkinParam skinParam) { + this(stringBounder, skinParam, 0, 0, null); + } + + public GtileEmpty(StringBounder stringBounder, ISkinParam skinParam, Swimlane swimlane) { + this(stringBounder, skinParam, 0, 0, swimlane); + } + + public GtileEmpty(StringBounder stringBounder, ISkinParam skinParam, double width, double height, Swimlane swimlane) { + super(stringBounder, skinParam, swimlane); + this.width = width; + this.height = height; + } + + @Override + public String toString() { + return "FtileEmpty"; + } + + public void drawU(UGraphic ug) { + } + + @Override + public Dimension2D calculateDimension(StringBounder stringBounder) { + return new Dimension2DDouble(width, height); + } + +// @Override +// protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder) { +// return calculateDimensionEmpty(); +// } +// +// final protected FtileGeometry calculateDimensionEmpty() { +// return new FtileGeometry(width, height, width / 2, 0, height); +// } +// +// public Swimlane getSwimlaneIn() { +// return swimlane; +// } +// +// public Swimlane getSwimlaneOut() { +// return swimlane; +// } +// +// public Set getSwimlanes() { +// final Set result = new HashSet<>(); +// if (swimlane != null) { +// result.add(swimlane); +// } +// return Collections.unmodifiableSet(result); +// } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfHexagon.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfHexagon.java new file mode 100644 index 000000000..13c6491d9 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfHexagon.java @@ -0,0 +1,247 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.awt.geom.Dimension2D; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.ListIterator; + +import net.sourceforge.plantuml.ColorParam; +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.UseStyle; +import net.sourceforge.plantuml.activitydiagram3.Branch; +import net.sourceforge.plantuml.activitydiagram3.ftile.Hexagon; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.creole.Parser; +import net.sourceforge.plantuml.creole.Sheet; +import net.sourceforge.plantuml.creole.SheetBlock1; +import net.sourceforge.plantuml.creole.SheetBlock2; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +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.svek.ConditionEndStyle; +import net.sourceforge.plantuml.svek.ConditionStyle; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.color.HColor; + +public class GtileIfHexagon extends GtileIfSimple { + + private final List branches; + private final Gtile shape1; + private final Gtile shape2; + + private final UTranslate positionShape1; + private final UTranslate positionShape2; + + @Override + public String toString() { + return "GtileIfHexagon " + gtiles; + } + + // ConditionalBuilder + // FtileFactoryDelegatorIf + + public GtileIfHexagon(Swimlane swimlane, List gtiles, List branches) { + super(gtiles); + + final ConditionStyle conditionStyle = skinParam().getConditionStyle(); + final ConditionEndStyle conditionEndStyle = skinParam().getConditionEndStyle(); + + this.branches = branches; + + final Branch branch0 = branches.get(0); + + final HColor borderColor; + final HColor backColor; + final FontConfiguration fcTest; + + if (UseStyle.useBetaStyle()) { + final Style styleArrow = getDefaultStyleDefinitionArrow() + .getMergedStyle(skinParam().getCurrentStyleBuilder()); + final Style styleDiamond = getDefaultStyleDefinitionDiamond() + .getMergedStyle(skinParam().getCurrentStyleBuilder()); + borderColor = styleDiamond.value(PName.LineColor).asColor(skinParam().getThemeStyle(), + skinParam().getIHtmlColorSet()); + backColor = branch0.getColor() == null ? styleDiamond.value(PName.BackGroundColor) + .asColor(skinParam().getThemeStyle(), skinParam().getIHtmlColorSet()) : branch0.getColor(); +// arrowColor = Rainbow.build(styleArrow, skinParam().getIHtmlColorSet(), skinParam().getThemeStyle()); + fcTest = styleDiamond.getFontConfiguration(skinParam().getThemeStyle(), skinParam().getIHtmlColorSet()); +// fcArrow = styleArrow.getFontConfiguration(skinParam().getThemeStyle(), skinParam().getIHtmlColorSet()); + } else { + final FontParam testParam = conditionStyle == ConditionStyle.INSIDE_HEXAGON ? FontParam.ACTIVITY_DIAMOND + : FontParam.ARROW; + + borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder); + backColor = branch0.getColor() == null + ? getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground) + : branch0.getColor(); +// arrowColor = Rainbow.build(skinParam()); + fcTest = new FontConfiguration(skinParam(), testParam, null) + .changeColor(fontColor(FontParam.ACTIVITY_DIAMOND)); +// fcArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null); + } + + final Sheet sheet = Parser.build(fcTest, skinParam().getDefaultTextAlignment(HorizontalAlignment.LEFT), + skinParam(), CreoleMode.FULL).createSheet(branch0.getLabelTest()); + final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam().getPadding()); + final TextBlock tbTest = new SheetBlock2(sheetBlock1, Hexagon.asStencil(sheetBlock1), new UStroke()); + + this.shape1 = new GtileDiamondInside(getStringBounder(), tbTest, skinParam(), backColor, borderColor, swimlane); + this.shape2 = new GtileDiamondInside(getStringBounder(), TextBlockUtils.EMPTY_TEXT_BLOCK, skinParam(), + backColor, borderColor, swimlane); + + final double height1 = shape1.calculateDimension(stringBounder).getHeight() + getSuppHeightMargin(); + +// public GtileDiamondInside(StringBounder stringBounder, TextBlock label, ISkinParam skinParam, HColor backColor, +// HColor borderColor, Swimlane swimlane) { + + for (ListIterator it = positions.listIterator(); it.hasNext();) { + final UTranslate tmp = it.next(); + it.set(tmp.compose(UTranslate.dy(height1))); + } + + if (branches.size() == 1) { + final UTranslate tmp = positions.get(0); + positions.set(0, tmp.compose(UTranslate.dx(missingSpace()))); + } + + this.positionShape1 = this.getCoord(GPoint.NORTH_HOOK).compose(shape1.getCoord(GPoint.NORTH_HOOK).reverse()); + this.positionShape2 = this.getCoord(GPoint.SOUTH_HOOK).compose(shape2.getCoord(GPoint.SOUTH_HOOK).reverse()); + + } + + private double missingSpace() { + if (branches.size() != 1) + throw new IllegalStateException(); + return 25; + } + + private double getSuppHeightMargin() { + if (branches.size() == 1) + return 30; + return 10; + } + + @Override + public Dimension2D calculateDimension(StringBounder stringBounder) { + final double height2 = shape2.calculateDimension(stringBounder).getHeight() + getSuppHeightMargin(); + final Dimension2D nude = super.calculateDimension(stringBounder); + if (branches.size() > 1) + return Dimension2DDouble.delta(nude, 0, height2); + return Dimension2DDouble.delta(nude, missingSpace(), height2); + } + + @Override + public UTranslate getCoord(String name) { + final UTranslate result = super.getCoord(name); + return result; + } + + private HColor fontColor(FontParam param) { + return skinParam().getFontHtmlColor(null, param); + } + + final public StyleSignature getDefaultStyleDefinitionActivity() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity); + } + + final public StyleSignature getDefaultStyleDefinitionDiamond() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity, SName.diamond); + } + + final public StyleSignature getDefaultStyleDefinitionArrow() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow); + } + + @Override + public void drawU(UGraphic ug) { + super.drawU(ug); + + shape1.drawU(ug.apply(positionShape1)); + shape2.drawU(ug.apply(positionShape2)); + } + + @Override + public Collection getInnerConnections() { + if (branches.size() == 1) { + final GConnection arrow1 = new GConnectionVerticalDown(positionShape1, shape1.getGPoint(GPoint.SOUTH_HOOK), + positions.get(0), gtiles.get(0).getGPoint(GPoint.NORTH_HOOK), TextBlockUtils.EMPTY_TEXT_BLOCK); + final GConnection arrow2 = new GConnectionVerticalDown(positions.get(0), + gtiles.get(0).getGPoint(GPoint.SOUTH_HOOK), positionShape2, shape2.getGPoint(GPoint.NORTH_HOOK), + TextBlockUtils.EMPTY_TEXT_BLOCK); + + final Dimension2D totalDim = calculateDimension(stringBounder); + + final GConnection arrow3 = new GConnectionLeftThenDownThenRight(positionShape1, + shape1.getGPoint(GPoint.EAST_HOOK), positionShape2, shape2.getGPoint(GPoint.EAST_HOOK), totalDim.getWidth(), + TextBlockUtils.EMPTY_TEXT_BLOCK); + return Arrays.asList(arrow1, arrow2, arrow3); + // return Arrays.asList(arrow3); + } else if (branches.size() == 2) { + final GConnection arrow1 = new GConnectionHorizontalThenVerticalDown(positionShape1, + shape1.getGPoint(GPoint.WEST_HOOK), positions.get(0), gtiles.get(0).getGPoint(GPoint.NORTH_HOOK), + TextBlockUtils.EMPTY_TEXT_BLOCK); + final GConnection arrow2 = new GConnectionHorizontalThenVerticalDown(positionShape1, + shape1.getGPoint(GPoint.EAST_HOOK), positions.get(1), gtiles.get(1).getGPoint(GPoint.NORTH_HOOK), + TextBlockUtils.EMPTY_TEXT_BLOCK); + + final GConnection arrow3 = new GConnectionVerticalDownThenHorizontal(positions.get(0), + gtiles.get(0).getGPoint(GPoint.SOUTH_HOOK), positionShape2, shape2.getGPoint(GPoint.WEST_HOOK), + TextBlockUtils.EMPTY_TEXT_BLOCK); + final GConnection arrow4 = new GConnectionVerticalDownThenHorizontal(positions.get(1), + gtiles.get(1).getGPoint(GPoint.SOUTH_HOOK), positionShape2, shape2.getGPoint(GPoint.EAST_HOOK), + TextBlockUtils.EMPTY_TEXT_BLOCK); + + return Arrays.asList(arrow1, arrow2, arrow3, arrow4); + } + return super.getInnerConnections(); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfSimple.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfSimple.java new file mode 100644 index 000000000..77187e3af --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileIfSimple.java @@ -0,0 +1,114 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.utils.MathUtils; + +public class GtileIfSimple extends AbstractGtile { + + protected final List gtiles; + private final List dims = new ArrayList<>(); + protected final List positions = new ArrayList<>(); + + @Override + public String toString() { + return "GtileIfSimple " + gtiles; + } + + public GtileIfSimple(List gtiles) { + super(gtiles.get(0).getStringBounder(), gtiles.get(0).skinParam()); + this.gtiles = gtiles; + + double dx = 0; + for (Gtile tile : gtiles) { + final Dimension2D dim = tile.calculateDimension(getStringBounder()); + final UTranslate pos = UTranslate.dx(dx); + dx += dim.getWidth() + getMargin(); + dims.add(dim); + positions.add(pos); + } + } + + private double getMargin() { + return 20; + } + + public void drawU(UGraphic ug) { + for (int i = 0; i < gtiles.size(); i++) { + final Gtile tile = gtiles.get(i); + final UTranslate pos = positions.get(i); + ug.apply(pos).draw(tile); + } + } + + @Override + public Dimension2D calculateDimension(StringBounder stringBounder) { + Point2D result = new Point2D.Double(); + for (int i = 0; i < dims.size(); i++) { + final Dimension2D dim = dims.get(i); + final UTranslate pos = positions.get(i); + final Point2D corner = pos.getTranslated(dim); + result = MathUtils.max(result, corner); + } + return new Dimension2DDouble(result); + } + + public Set getSwimlanes() { + final Set result = new HashSet<>(); + for (Gtile tile : gtiles) + result.addAll(tile.getSwimlanes()); + return Collections.unmodifiableSet(result); + } + + public Collection getMyChildren() { + return Collections.unmodifiableCollection(gtiles); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithNoteOpale.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithNoteOpale.java new file mode 100644 index 000000000..9fce797e8 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/GtileWithNoteOpale.java @@ -0,0 +1,173 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.AlignmentParam; +import net.sourceforge.plantuml.ColorParam; +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.UseStyle; +import net.sourceforge.plantuml.activitydiagram3.PositionedNote; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.creole.Parser; +import net.sourceforge.plantuml.creole.Sheet; +import net.sourceforge.plantuml.creole.SheetBlock1; +import net.sourceforge.plantuml.creole.SheetBlock2; +import net.sourceforge.plantuml.creole.Stencil; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.sequencediagram.NotePosition; +import net.sourceforge.plantuml.sequencediagram.NoteType; +import net.sourceforge.plantuml.skin.rose.Rose; +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.svek.image.Opale; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.color.HColor; + +public class GtileWithNoteOpale extends AbstractGtile implements Stencil, Styleable { + + private final Gtile tile; + private final Opale opale; + + private final NotePosition notePosition; + private final double suppSpace = 20; + private final Swimlane swimlaneNote; + + private final UTranslate positionNote; + private final UTranslate positionTile; + + private final Dimension2D dimNote; + private final Dimension2D dimTile; + + public StyleSignature getDefaultStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.note); + } + + public GtileWithNoteOpale(Gtile tile, PositionedNote note, ISkinParam skinParam, boolean withLink) { + super(tile.getStringBounder(), tile.skinParam()); + this.swimlaneNote = note.getSwimlaneNote(); + if (note.getColors() != null) { + skinParam = note.getColors().mute(skinParam); + } + this.tile = tile; + this.notePosition = note.getNotePosition(); + if (note.getType() == NoteType.FLOATING_NOTE) { + withLink = false; + } + + final Rose rose = new Rose(); + + final HColor noteBackgroundColor; + final HColor borderColor; + final FontConfiguration fc; + + final double shadowing; + final LineBreakStrategy wrapWidth; + if (UseStyle.useBetaStyle()) { + final Style style = getDefaultStyleDefinition().getMergedStyle(skinParam.getCurrentStyleBuilder()) + .eventuallyOverride(note.getColors()); + noteBackgroundColor = style.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(), + getIHtmlColorSet()); + borderColor = style.value(PName.LineColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet()); + fc = style.getFontConfiguration(skinParam.getThemeStyle(), getIHtmlColorSet()); + shadowing = style.value(PName.Shadowing).asDouble(); + wrapWidth = style.wrapWidth(); + } else { + noteBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.noteBackground); + borderColor = rose.getHtmlColor(skinParam, ColorParam.noteBorder); + fc = new FontConfiguration(skinParam, FontParam.NOTE, null); + shadowing = skinParam.shadowing(null) ? 4 : 0; + wrapWidth = skinParam.wrapWidth(); + } + + final HorizontalAlignment align = skinParam.getHorizontalAlignment(AlignmentParam.noteTextAlignment, null, + false, null); + final Sheet sheet = Parser.build(fc, align, skinParam, CreoleMode.FULL).createSheet(note.getDisplay()); + final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, skinParam.getPadding()), this, + new UStroke(1)); + this.opale = new Opale(shadowing, borderColor, noteBackgroundColor, text, withLink); + + this.dimNote = opale.calculateDimension(stringBounder); + this.dimTile = tile.calculateDimension(stringBounder); + + final Dimension2D dimTotal = calculateDimension(stringBounder); + + this.positionNote = new UTranslate(0, (dimTotal.getHeight() - dimNote.getHeight()) / 2); + this.positionTile = new UTranslate(dimNote.getWidth() + suppSpace, + (dimTotal.getHeight() - dimTile.getHeight()) / 2); + } + + @Override + public UTranslate getCoord(String name) { + return tile.getCoord(name).compose(positionTile); + } + + @Override + public Dimension2D calculateDimension(StringBounder stringBounder) { + final double height = Math.max(dimNote.getHeight(), dimTile.getHeight()); + return new Dimension2DDouble(dimTile.getWidth() + dimNote.getWidth() + suppSpace, height); + } + + @Override + public void drawU(UGraphic ug) { + ug.apply(positionNote).draw(opale); + ug.apply(positionTile).draw(tile); + } + + @Override + public double getStartingX(StringBounder stringBounder, double y) { + return -opale.getMarginX1(); + } + + @Override + public double getEndingX(StringBounder stringBounder, double y) { + return opale.calculateDimension(stringBounder).getWidth() - opale.getMarginX1(); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/gtile/Swimable2.java b/src/net/sourceforge/plantuml/activitydiagram3/gtile/Swimable2.java new file mode 100644 index 000000000..983f034e1 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/gtile/Swimable2.java @@ -0,0 +1,48 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.activitydiagram3.gtile; + +import java.util.Set; + +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; + +public interface Swimable2 { + + public Set getSwimlanes(); + + public Swimlane getSwimlane(String point); + +} diff --git a/src/net/sourceforge/plantuml/braille/DriverCenteredCharacterBraille.java b/src/net/sourceforge/plantuml/braille/DriverCenteredCharacterBraille.java index e83b04771..f3e0956a5 100644 --- a/src/net/sourceforge/plantuml/braille/DriverCenteredCharacterBraille.java +++ b/src/net/sourceforge/plantuml/braille/DriverCenteredCharacterBraille.java @@ -38,14 +38,11 @@ package net.sourceforge.plantuml.braille; import net.sourceforge.plantuml.ugraphic.UCenteredCharacter; import net.sourceforge.plantuml.ugraphic.UDriver; import net.sourceforge.plantuml.ugraphic.UParam; -import net.sourceforge.plantuml.ugraphic.UShape; import net.sourceforge.plantuml.ugraphic.color.ColorMapper; -public class DriverCenteredCharacterBraille implements UDriver { - - public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, BrailleGrid grid) { - final UCenteredCharacter characterCircled = (UCenteredCharacter) ushape; +public class DriverCenteredCharacterBraille implements UDriver { + public void draw(UCenteredCharacter characterCircled, double x, double y, ColorMapper mapper, UParam param, BrailleGrid grid) { final double xpos = x; final double ypos = y; diff --git a/src/net/sourceforge/plantuml/braille/DriverDotPathBraille.java b/src/net/sourceforge/plantuml/braille/DriverDotPathBraille.java index 6fcb3f8e8..b75f1625e 100644 --- a/src/net/sourceforge/plantuml/braille/DriverDotPathBraille.java +++ b/src/net/sourceforge/plantuml/braille/DriverDotPathBraille.java @@ -38,14 +38,11 @@ package net.sourceforge.plantuml.braille; import net.sourceforge.plantuml.posimo.DotPath; import net.sourceforge.plantuml.ugraphic.UDriver; import net.sourceforge.plantuml.ugraphic.UParam; -import net.sourceforge.plantuml.ugraphic.UShape; import net.sourceforge.plantuml.ugraphic.color.ColorMapper; -public class DriverDotPathBraille implements UDriver { - - public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, BrailleGrid grid) { - final DotPath shape = (DotPath) ushape; +public class DriverDotPathBraille implements UDriver { + public void draw(DotPath shape, double x, double y, ColorMapper mapper, UParam param, BrailleGrid grid) { if (param.getColor() != null) { grid.drawDotPath(x, y, shape); } diff --git a/src/net/sourceforge/plantuml/braille/DriverLineBraille.java b/src/net/sourceforge/plantuml/braille/DriverLineBraille.java index 002924241..48c738ae2 100644 --- a/src/net/sourceforge/plantuml/braille/DriverLineBraille.java +++ b/src/net/sourceforge/plantuml/braille/DriverLineBraille.java @@ -41,10 +41,9 @@ import net.sourceforge.plantuml.ugraphic.UClip; import net.sourceforge.plantuml.ugraphic.UDriver; import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UParam; -import net.sourceforge.plantuml.ugraphic.UShape; import net.sourceforge.plantuml.ugraphic.color.ColorMapper; -public class DriverLineBraille implements UDriver { +public class DriverLineBraille implements UDriver { private final ClipContainer clipContainer; @@ -52,9 +51,7 @@ public class DriverLineBraille implements UDriver { this.clipContainer = clipContainer; } - public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, BrailleGrid grid) { - final ULine shape = (ULine) ushape; - + public void draw(ULine shape , double x, double y, ColorMapper mapper, UParam param, BrailleGrid grid) { double x2 = x + shape.getDX(); double y2 = y + shape.getDY(); diff --git a/src/net/sourceforge/plantuml/braille/DriverPolygonBraille.java b/src/net/sourceforge/plantuml/braille/DriverPolygonBraille.java index 7b5bdea2b..1fb8be370 100644 --- a/src/net/sourceforge/plantuml/braille/DriverPolygonBraille.java +++ b/src/net/sourceforge/plantuml/braille/DriverPolygonBraille.java @@ -43,11 +43,10 @@ import net.sourceforge.plantuml.ugraphic.UClip; import net.sourceforge.plantuml.ugraphic.UDriver; import net.sourceforge.plantuml.ugraphic.UParam; import net.sourceforge.plantuml.ugraphic.UPolygon; -import net.sourceforge.plantuml.ugraphic.UShape; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.ColorMapper; -public class DriverPolygonBraille implements UDriver { +public class DriverPolygonBraille implements UDriver { private final ClipContainer clipContainer; @@ -55,9 +54,7 @@ public class DriverPolygonBraille implements UDriver { this.clipContainer = clipContainer; } - public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, BrailleGrid grid) { - final UPolygon shape = (UPolygon) ushape; - + public void draw(UPolygon shape, double x, double y, ColorMapper mapper, UParam param, BrailleGrid grid) { final List points = new ArrayList<>(); int i = 0; diff --git a/src/net/sourceforge/plantuml/braille/DriverRectangleBraille.java b/src/net/sourceforge/plantuml/braille/DriverRectangleBraille.java index 37fa98977..e1967898e 100644 --- a/src/net/sourceforge/plantuml/braille/DriverRectangleBraille.java +++ b/src/net/sourceforge/plantuml/braille/DriverRectangleBraille.java @@ -41,10 +41,9 @@ import net.sourceforge.plantuml.ugraphic.UClip; import net.sourceforge.plantuml.ugraphic.UDriver; import net.sourceforge.plantuml.ugraphic.UParam; import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UShape; import net.sourceforge.plantuml.ugraphic.color.ColorMapper; -public class DriverRectangleBraille implements UDriver { +public class DriverRectangleBraille implements UDriver { private final ClipContainer clipContainer; @@ -52,9 +51,7 @@ public class DriverRectangleBraille implements UDriver { this.clipContainer = clipContainer; } - public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, BrailleGrid grid) { - final URectangle rect = (URectangle) ushape; - + public void draw(URectangle rect, double x, double y, ColorMapper mapper, UParam param, BrailleGrid grid) { // final double rx = rect.getRx(); // final double ry = rect.getRy(); double width = rect.getWidth(); diff --git a/src/net/sourceforge/plantuml/braille/DriverTextBraille.java b/src/net/sourceforge/plantuml/braille/DriverTextBraille.java index e20f090c3..37327cd2d 100644 --- a/src/net/sourceforge/plantuml/braille/DriverTextBraille.java +++ b/src/net/sourceforge/plantuml/braille/DriverTextBraille.java @@ -36,18 +36,15 @@ package net.sourceforge.plantuml.braille; import net.sourceforge.plantuml.ugraphic.UDriver; import net.sourceforge.plantuml.ugraphic.UParam; -import net.sourceforge.plantuml.ugraphic.UShape; import net.sourceforge.plantuml.ugraphic.UText; import net.sourceforge.plantuml.ugraphic.color.ColorMapper; -public class DriverTextBraille implements UDriver { +public class DriverTextBraille implements UDriver { public DriverTextBraille() { } - public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, BrailleGrid grid) { - final UText text = (UText) ushape; - + public void draw(UText text, double x, double y, ColorMapper mapper, UParam param, BrailleGrid grid) { y -= grid.getQuanta() * 3; x += grid.getQuanta(); diff --git a/src/net/sourceforge/plantuml/braille/UGraphicBraille.java b/src/net/sourceforge/plantuml/braille/UGraphicBraille.java index 7eaee354e..680da8881 100644 --- a/src/net/sourceforge/plantuml/braille/UGraphicBraille.java +++ b/src/net/sourceforge/plantuml/braille/UGraphicBraille.java @@ -39,7 +39,7 @@ import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainPngBuilder; import java.io.IOException; import java.io.OutputStream; -import net.sourceforge.plantuml.FileFormat; +import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.posimo.DotPath; import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic; import net.sourceforge.plantuml.ugraphic.AbstractUGraphic; @@ -59,20 +59,19 @@ import net.sourceforge.plantuml.ugraphic.color.HColor; public class UGraphicBraille extends AbstractUGraphic implements ClipContainer { public static final int QUANTA = 4; - private final BrailleGrid grid; @Override protected AbstractCommonUGraphic copyUGraphic() { return new UGraphicBraille(this); } - public UGraphicBraille(HColor defaultBackground, ColorMapper colorMapper) { - this(defaultBackground, colorMapper, new BrailleGrid(QUANTA)); + public UGraphicBraille(HColor defaultBackground, ColorMapper colorMapper, StringBounder stringBounder) { + super(defaultBackground, colorMapper, stringBounder, new BrailleGrid(QUANTA)); + register(); } private UGraphicBraille(UGraphicBraille other) { super(other); - this.grid = other.grid; register(); } @@ -96,21 +95,15 @@ public class UGraphicBraille extends AbstractUGraphic implements Cl // svg.paintBackcolorGradient(mapper, gr); // } - private UGraphicBraille(HColor defaultBackground, ColorMapper colorMapper, BrailleGrid grid) { - super(defaultBackground, colorMapper, FileFormat.BRAILLE_PNG.getDefaultStringBounder(), grid); - this.grid = grid; - register(); - } - private void register() { - registerDriver(URectangle.class, new DriverNoneBraille()); + ignoreShape(URectangle.class); registerDriver(URectangle.class, new DriverRectangleBraille(this)); registerDriver(UText.class, new DriverTextBraille()); registerDriver(ULine.class, new DriverLineBraille(this)); registerDriver(UPolygon.class, new DriverPolygonBraille(this)); - registerDriver(UEllipse.class, new DriverNoneBraille()); - registerDriver(UImage.class, new DriverNoneBraille()); - registerDriver(UPath.class, new DriverNoneBraille()); + ignoreShape(UEllipse.class); + ignoreShape(UImage.class); + ignoreShape(UPath.class); registerDriver(DotPath.class, new DriverDotPathBraille()); registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterBraille()); } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java index e95e912fa..01d8baf3b 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java @@ -133,7 +133,7 @@ public class CommandCreateClass extends SingleLineCommand2 { final String genericOption = arg.getLazzy("DISPLAY", 1); final String generic = genericOption != null ? genericOption : arg.get("GENERIC", 0); - final String stereotype = arg.get("STEREO", 0); + final String stereo = arg.get("STEREO", 0); final ILeaf entity; final Ident idNewLong = diagram.buildLeafIdent(idShort); if (diagram.V1972()) { @@ -156,10 +156,11 @@ public class CommandCreateClass extends SingleLineCommand2 { entity = diagram.createLeaf(idNewLong, code, Display.getWithNewlines(display), type, null); } } - if (stereotype != null) { - entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), + if (stereo != null) { + entity.setStereotype(Stereotype.build(stereo, diagram.getSkinParam().getCircledCharacterRadius(), diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam().getIHtmlColorSet())); + entity.setStereostyle(stereo); } if (generic != null) { entity.setGeneric(generic); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java index 44177fc1d..a844f65f1 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java @@ -264,7 +264,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2 entity.setDisplay(Display.getWithNewlines(display)); entity.setUSymbol(usymbol); if (stereotype != null) { - entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), + entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam().getIHtmlColorSet())); } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java index 458c54a67..f9c1ed2bd 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java @@ -71,7 +71,7 @@ public class CommandStereotype extends SingleLineCommand2 { final Code code = diagram.V1972() ? ident : diagram.buildCode(name); final String stereotype = arg.get("STEREO", 0); final IEntity entity = diagram.getOrCreateLeaf(ident, code, null, null); - entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram + entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram .getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam() .getIHtmlColorSet())); return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/command/CommandNamespace.java b/src/net/sourceforge/plantuml/command/CommandNamespace.java index f83d9963f..e84f6cc47 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespace.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespace.java @@ -98,7 +98,7 @@ public class CommandNamespace extends SingleLineCommand2 { final IEntity p = diagram.getCurrentGroup(); final String stereotype = arg.get("STEREOTYPE", 0); if (stereotype != null) { - p.setStereotype(new Stereotype(stereotype)); + p.setStereotype(Stereotype.build(stereotype)); } final String urlString = arg.get("URL", 0); diff --git a/src/net/sourceforge/plantuml/command/CommandNamespace2.java b/src/net/sourceforge/plantuml/command/CommandNamespace2.java index 83393d62f..c1fb4e84b 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespace2.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespace2.java @@ -98,7 +98,7 @@ public class CommandNamespace2 extends SingleLineCommand2 { final IEntity p = diagram.getCurrentGroup(); final String stereotype = arg.get("STEREOTYPE", 0); if (stereotype != null) { - p.setStereotype(new Stereotype(stereotype)); + p.setStereotype(Stereotype.build(stereotype)); } final String urlString = arg.get("URL", 0); diff --git a/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java b/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java index 168c80672..8262332b9 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java @@ -92,7 +92,7 @@ public class CommandNamespaceEmpty extends SingleLineCommand2 { final IEntity p = diagram.getCurrentGroup(); final String stereotype = arg.get("STEREOTYPE", 0); if (stereotype != null) { - p.setStereotype(new Stereotype(stereotype)); + p.setStereotype(Stereotype.build(stereotype)); } final String urlString = arg.get("URL", 0); diff --git a/src/net/sourceforge/plantuml/command/CommandPackage.java b/src/net/sourceforge/plantuml/command/CommandPackage.java index d7fd97d6a..e051d0d9d 100644 --- a/src/net/sourceforge/plantuml/command/CommandPackage.java +++ b/src/net/sourceforge/plantuml/command/CommandPackage.java @@ -141,7 +141,7 @@ public class CommandPackage extends SingleLineCommand2 { final USymbol usymbol = USymbol.fromString(stereotype, diagram.getSkinParam().actorStyle(), diagram.getSkinParam().componentStyle(), diagram.getSkinParam().packageStyle()); if (usymbol == null) { - p.setStereotype(new Stereotype(stereotype)); + p.setStereotype(Stereotype.build(stereotype)); } else { p.setUSymbol(usymbol); } diff --git a/src/net/sourceforge/plantuml/command/CommandSpriteFile.java b/src/net/sourceforge/plantuml/command/CommandSpriteFile.java index b6f79380f..f8e096596 100644 --- a/src/net/sourceforge/plantuml/command/CommandSpriteFile.java +++ b/src/net/sourceforge/plantuml/command/CommandSpriteFile.java @@ -50,7 +50,7 @@ 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.ImageIO; +import net.sourceforge.plantuml.security.SImageIO; import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.sprite.Sprite; import net.sourceforge.plantuml.sprite.SpriteImage; @@ -83,7 +83,7 @@ public class CommandSpriteFile extends SingleLineCommand2 { if (is == null) { return CommandExecutionResult.error("No such internal sprite: " + inner); } - sprite = new SpriteImage(ImageIO.read(is)); + sprite = new SpriteImage(SImageIO.read(is)); } else if (src.contains("~")) { final int idx = src.lastIndexOf("~"); final SFile f = FileSystem.getInstance().getFile(src.substring(0, idx)); @@ -139,7 +139,7 @@ public class CommandSpriteFile extends SingleLineCommand2 { if (isSvg(name)) { return new SpriteSvg(FileUtils.readSvg(zis)); } else { - return new SpriteImage(ImageIO.read(zis)); + return new SpriteImage(SImageIO.read(zis)); } } ze = zis.getNextEntry(); diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java index 47ab4fe40..b1d28437c 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java @@ -242,7 +242,7 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma final String stereotypeString = line0.get("STEREO", 0); if (stereotypeString != null) { - final Stereotype stereotype = new Stereotype(stereotypeString); + final Stereotype stereotype = Stereotype.build(stereotypeString); colors = colors.applyStereotypeForNote(stereotype, diagram.getSkinParam(), FontParam.NOTE, ColorParam.noteBackground, ColorParam.noteBorder); note.setStereotype(stereotype); diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java index bcfb3baf9..e9f25f3f1 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java @@ -159,7 +159,7 @@ public final class FactorySequenceNoteAcrossCommand implements SingleMultiFactor diagram.getSkinParam().getIHtmlColorSet()); final String stereotypeString = line0.get("STEREO", 0); if (stereotypeString != null) { - final Stereotype stereotype = new Stereotype(stereotypeString); + final Stereotype stereotype = Stereotype.build(stereotypeString); colors = colors.applyStereotypeForNote(stereotype, diagram.getSkinParam(), FontParam.NOTE, ColorParam.noteBackground, ColorParam.noteBorder); note.setStereotype(stereotype); diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java index a5928fdf7..5b89d37f6 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java @@ -158,7 +158,7 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma diagram.getSkinParam().getIHtmlColorSet()); final String stereotypeString = arg.get("STEREO", 0); if (stereotypeString != null) { - final Stereotype stereotype = new Stereotype(stereotypeString); + final Stereotype stereotype = Stereotype.build(stereotypeString); colors = colors.applyStereotypeForNote(stereotype, diagram.getSkinParam(), FontParam.NOTE, ColorParam.noteBackground, ColorParam.noteBorder); note.setStereotype(stereotype); diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java index 91520773d..9f0ebffac 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java @@ -153,7 +153,7 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto final Note note = new Note(display, position, style, diagram.getSkinParam().getCurrentStyleBuilder()); final String stereotypeString = line0.get("STEREO", 0); if (stereotypeString != null) { - final Stereotype stereotype = new Stereotype(stereotypeString); + final Stereotype stereotype = Stereotype.build(stereotypeString); colors = colors.applyStereotypeForNote(stereotype, diagram.getSkinParam(), FontParam.NOTE, ColorParam.noteBackground, ColorParam.noteBorder); note.setStereotype(stereotype); diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java index b8928fce3..4f852cbcb 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java @@ -169,7 +169,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF diagram.getSkinParam().getIHtmlColorSet()); final String stereotypeString = line0.get("STEREO", 0); if (stereotypeString != null) { - final Stereotype stereotype = new Stereotype(stereotypeString); + final Stereotype stereotype = Stereotype.build(stereotypeString); colors = colors.applyStereotypeForNote(stereotype, diagram.getSkinParam(), FontParam.NOTE, ColorParam.noteBackground, ColorParam.noteBorder); note.setStereotype(stereotype); diff --git a/src/net/sourceforge/plantuml/creole/atom/AtomImg.java b/src/net/sourceforge/plantuml/creole/atom/AtomImg.java index 6a4e5b240..7aacb664d 100644 --- a/src/net/sourceforge/plantuml/creole/atom/AtomImg.java +++ b/src/net/sourceforge/plantuml/creole/atom/AtomImg.java @@ -54,7 +54,7 @@ import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.ImgValign; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TileImageSvg; -import net.sourceforge.plantuml.security.ImageIO; +import net.sourceforge.plantuml.security.SImageIO; import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SURL; import net.sourceforge.plantuml.security.SecurityProfile; @@ -158,7 +158,7 @@ public class AtomImg extends AbstractAtom implements Atom { private static Atom buildRasterFromData(String source, final FontConfiguration fc, final byte[] data, double scale, Url url) throws IOException { - final BufferedImage read = ImageIO.read(data); + final BufferedImage read = SImageIO.read(data); if (read == null) { return AtomTextUtils.createLegacy("(Cannot decode: " + source + ")", fc); } diff --git a/src/net/sourceforge/plantuml/creole/command/CommandCreoleColorChange.java b/src/net/sourceforge/plantuml/creole/command/CommandCreoleColorChange.java index f4830fd29..43b09ff9e 100644 --- a/src/net/sourceforge/plantuml/creole/command/CommandCreoleColorChange.java +++ b/src/net/sourceforge/plantuml/creole/command/CommandCreoleColorChange.java @@ -49,8 +49,7 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorRuntimeException; public class CommandCreoleColorChange implements Command { - private static final Pattern2 pattern = MyPattern - .cmpile("^(" + Splitter.fontColorPattern2 + "(.*?)\\)"); + private static final Pattern2 pattern = MyPattern.cmpile("^(" + Splitter.fontColorPattern2 + "(.*?)\\)"); private static final Pattern2 patternEol = MyPattern.cmpile("^(" + Splitter.fontColorPattern2 + "(.*)$)"); @@ -90,12 +89,13 @@ public class CommandCreoleColorChange implements Command { final HColor color = HColorSet.instance().getColor(themeStyle, s); final FontConfiguration fc2 = fc1.changeColor(color); stripe.setActualFontConfiguration(fc2); - stripe.analyzeAndAdd(m.group(3)); - stripe.setActualFontConfiguration(fc1); - return line.substring(m.group(1).length()); } catch (NoSuchColorException e) { - throw new NoSuchColorRuntimeException(); + // Too late for parsing error + // So we just ignore } + stripe.analyzeAndAdd(m.group(3)); + stripe.setActualFontConfiguration(fc1); + return line.substring(m.group(1).length()); } } diff --git a/src/net/sourceforge/plantuml/creole/legacy/AtomText.java b/src/net/sourceforge/plantuml/creole/legacy/AtomText.java index f14e606ea..0353e1dcb 100644 --- a/src/net/sourceforge/plantuml/creole/legacy/AtomText.java +++ b/src/net/sourceforge/plantuml/creole/legacy/AtomText.java @@ -228,16 +228,16 @@ public final class AtomText extends AbstractAtom implements Atom { final List result = new ArrayList<>(); for (int i = 0; i < text.length(); i++) { final char ch = text.charAt(i); - if (isOfWord(ch)) { + if (isSeparator(ch)) { + result.add("" + text.charAt(i)); + } else { final StringBuilder tmp = new StringBuilder(); tmp.append(ch); - while (i + 1 < text.length() && isOfWord(text.charAt(i + 1))) { + while (i + 1 < text.length() && isSeparator(text.charAt(i + 1)) == false) { i++; tmp.append(text.charAt(i)); } result.add(tmp.toString()); - } else { - result.add("" + text.charAt(i)); } } return result; @@ -289,8 +289,16 @@ public final class AtomText extends AbstractAtom implements Atom { return Collections.singletonList((Atom) this); } - private boolean isOfWord(char ch) { - return Character.isWhitespace(ch) == false; + private boolean isSeparator(char ch) { + return Character.isWhitespace(ch) // + || ch == '\uFF01' // U+FF01 FULLWIDTH EXCLAMATION MARK (!) + || ch == '\uFF08' // U+FF08 FULLWIDTH LEFT PARENTHESIS + || ch == '\uFF09' // U+FF09 FULLWIDTH RIGHT PARENTHESIS + || ch == '\uFF0C' // U+FF0C FULLWIDTH COMMA + || ch == '\uFF1A' // U+FF1A FULLWIDTH COLON (:) + || ch == '\uFF1B' // U+FF1B FULLWIDTH SEMICOLON (;) + || ch == '\uFF1F' // U+FF1F FULLWIDTH QUESTION MARK (?) + || ch == '\u3002'; // U+3002 IDEOGRAPHIC FULL STOP (.) } public final String getText() { diff --git a/src/net/sourceforge/plantuml/creole/legacy/StripeCode.java b/src/net/sourceforge/plantuml/creole/legacy/StripeCode.java index 177b278b2..fe26c3039 100644 --- a/src/net/sourceforge/plantuml/creole/legacy/StripeCode.java +++ b/src/net/sourceforge/plantuml/creole/legacy/StripeCode.java @@ -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 splitInTwo(StringBounder stringBounder, double width) { - throw new UnsupportedOperationException(); + return Arrays.asList((Atom) this); } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Bodier.java b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java index 0e0f763e4..55df29b66 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Bodier.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java @@ -39,6 +39,7 @@ import java.util.List; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; @@ -54,7 +55,7 @@ public interface Bodier { public void addFieldOrMethod(String s) throws NoSuchColorException; public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields, - Stereotype stereotype, Style style); + Stereotype stereotype, Style style, FontConfiguration fontConfiguration); public List getRawBody(); diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java b/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java index dc959865c..75c91d50e 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.creole.legacy.CreoleParser; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockLineBefore; @@ -62,6 +63,7 @@ public class BodierLikeClassOrObject implements Bodier { private List fieldsToDisplay; private ILeaf leaf; + @Override public void muteClassToObject() { methodsToDisplay = null; fieldsToDisplay = null; @@ -77,11 +79,13 @@ public class BodierLikeClassOrObject implements Bodier { this.hides = hides; } + @Override public void setLeaf(ILeaf leaf) { this.leaf = Objects.requireNonNull(leaf); } + @Override public void addFieldOrMethod(String s) { // Empty cache methodsToDisplay = null; @@ -109,6 +113,7 @@ public class BodierLikeClassOrObject implements Bodier { return purged.contains("(") || purged.contains(")"); } + @Override public Display getMethodsToDisplay() { if (methodsToDisplay == null) { methodsToDisplay = new ArrayList<>(); @@ -138,6 +143,7 @@ public class BodierLikeClassOrObject implements Bodier { return isMethod(rawBody.get(i)); } + @Override public Display getFieldsToDisplay() { if (fieldsToDisplay == null) { fieldsToDisplay = new ArrayList<>(); @@ -164,6 +170,7 @@ public class BodierLikeClassOrObject implements Bodier { } } + @Override public boolean hasUrl() { for (CharSequence cs : getFieldsToDisplay()) { if (cs instanceof Member) { @@ -201,8 +208,9 @@ public class BodierLikeClassOrObject implements Bodier { return result; } + @Override public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields, - Stereotype stereotype, Style style) { + Stereotype stereotype, Style style, FontConfiguration fontConfiguration) { if (BodyFactory.BODY3) { return new Body3(rawBody, fontParam, skinParam, stereotype, style); @@ -245,6 +253,7 @@ public class BodierLikeClassOrObject implements Bodier { return TextBlockUtils.mergeTB(bb1, bb2, HorizontalAlignment.LEFT); } + @Override public List getRawBody() { return Collections.unmodifiableList(rawBody); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java b/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java index 5b1c60b1f..0476b7432 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java @@ -46,6 +46,7 @@ import java.util.regex.Pattern; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.style.Style; @@ -55,6 +56,7 @@ public class BodierMap implements Bodier { private final Map map = new LinkedHashMap(); private ILeaf leaf; + @Override public void muteClassToObject() { throw new UnsupportedOperationException(); } @@ -62,6 +64,7 @@ public class BodierMap implements Bodier { public BodierMap() { } + @Override public void setLeaf(ILeaf leaf) { this.leaf = Objects.requireNonNull(leaf); @@ -76,6 +79,7 @@ public class BodierMap implements Bodier { return null; } + @Override public void addFieldOrMethod(String s) { if (s.contains("=>")) { final int x = s.indexOf("=>"); @@ -87,23 +91,28 @@ public class BodierMap implements Bodier { } } + @Override public Display getMethodsToDisplay() { throw new UnsupportedOperationException(); } + @Override public Display getFieldsToDisplay() { throw new UnsupportedOperationException(); } + @Override public boolean hasUrl() { return false; } + @Override public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, final boolean showMethods, - final boolean showFields, Stereotype stereotype, Style style) { - return new TextBlockMap(fontParam, skinParam, map); + final boolean showFields, Stereotype stereotype, Style style, FontConfiguration fontConfiguration) { + return new TextBlockMap(fontConfiguration, fontParam, skinParam, map); } + @Override public List getRawBody() { return Collections.unmodifiableList(rawBody); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java b/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java index b86e67785..45042b987 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java @@ -42,6 +42,7 @@ import java.util.Objects; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.style.Style; @@ -52,6 +53,7 @@ public class BodierSimple implements Bodier { private final List rawBody = new ArrayList<>(); private ILeaf leaf; + @Override public void muteClassToObject() { throw new UnsupportedOperationException(); } @@ -59,33 +61,40 @@ public class BodierSimple implements Bodier { BodierSimple() { } + @Override public void setLeaf(ILeaf leaf) { this.leaf = Objects.requireNonNull(leaf); } + @Override public void addFieldOrMethod(String s) throws NoSuchColorException { final Display display = Display.getWithNewlines2(s); rawBody.addAll(display.asList()); } + @Override public Display getMethodsToDisplay() { throw new UnsupportedOperationException(); } + @Override public Display getFieldsToDisplay() { throw new UnsupportedOperationException(); } + @Override public boolean hasUrl() { return false; } + @Override public List getRawBody() { return Collections.unmodifiableList(rawBody); } + @Override public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields, - Stereotype stereotype, Style style) { + Stereotype stereotype, Style style, FontConfiguration fontConfiguration) { return BodyFactory.create1(skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), rawBody, fontParam, skinParam, stereotype, leaf, style); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java b/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java index 56cdad0f9..714358510 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java +++ b/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java @@ -66,6 +66,7 @@ public class GroupRoot implements IGroup { this.entityFactory = entityFactory; } + @Override public Collection getLeafsDirect() { final List result = new ArrayList<>(); for (ILeaf ent : entityFactory.leafs()) { @@ -82,71 +83,79 @@ public class GroupRoot implements IGroup { return "ROOT"; } + @Override public boolean isGroup() { return true; } + @Override public Display getDisplay() { throw new UnsupportedOperationException(); } + @Override public void setDisplay(Display display) { throw new UnsupportedOperationException(); } + @Override public LeafType getLeafType() { throw new UnsupportedOperationException(); } + @Override public String getUid() { throw new UnsupportedOperationException(); } + @Override public Url getUrl99() { return null; } + @Override public Stereotype getStereotype() { throw new UnsupportedOperationException(); } + @Override public void setStereotype(Stereotype stereotype) { throw new UnsupportedOperationException(); - - } - - public TextBlock getBody(PortionShower portionShower, FontParam fontParam, ISkinParam skinParam) { - throw new UnsupportedOperationException(); - } + @Override public Code getCode() { return CodeImpl.of("__ROOT__"); } + @Override public String getCodeGetName() { return getCode().getName(); } + @Override public void addUrl(Url url) { throw new UnsupportedOperationException(); } + @Override public IGroup getParentContainer() { return null; } + @Override public boolean containsLeafRecurse(ILeaf entity) { throw new UnsupportedOperationException(); } + @Override public Collection getChildren() { final List result = new ArrayList<>(); if (entityFactory.namespaceSeparator.V1972()) { @@ -166,93 +175,105 @@ public class GroupRoot implements IGroup { return Collections.unmodifiableCollection(result); } + @Override public void moveEntitiesTo(IGroup dest) { throw new UnsupportedOperationException(); } + @Override public int size() { throw new UnsupportedOperationException(); } + @Override public GroupType getGroupType() { return null; } + @Override public Code getNamespace() { throw new UnsupportedOperationException(); } + @Override public PackageStyle getPackageStyle() { throw new UnsupportedOperationException(); } + @Override public void overrideImage(IEntityImage img, LeafType state) { throw new UnsupportedOperationException(); } + @Override public boolean isHidden() { return false; } + @Override public USymbol getUSymbol() { return null; // throw new UnsupportedOperationException(); } + @Override public void setUSymbol(USymbol symbol) { throw new UnsupportedOperationException(); } + @Override public SingleStrategy getSingleStrategy() { return SingleStrategy.SQUARE; } + @Override public boolean isRemoved() { return false; } + @Override public boolean hasUrl() { return false; } - public int getHectorLayer() { - throw new UnsupportedOperationException(); - } - - public void setHectorLayer(int layer) { - throw new UnsupportedOperationException(); - } - + @Override public int getRawLayout() { throw new UnsupportedOperationException(); } + @Override public char getConcurrentSeparator() { throw new UnsupportedOperationException(); } + @Override public void setConcurrentSeparator(char separator) { // throw new UnsupportedOperationException(); } + @Override public void putTip(String member, Display display) { throw new UnsupportedOperationException(); } + @Override public Map getTips() { throw new UnsupportedOperationException(); } + @Override public Bodier getBodier() { throw new UnsupportedOperationException(); } + @Override public Colors getColors(ISkinParam skinParam) { return Colors.empty(); } + @Override public void setColors(Colors colors) { throw new UnsupportedOperationException(); } @@ -277,31 +298,48 @@ public class GroupRoot implements IGroup { throw new UnsupportedOperationException(); } + @Override public void setLegend(DisplayPositionned legend) { throw new UnsupportedOperationException(); } + @Override public DisplayPositionned getLegend() { throw new UnsupportedOperationException(); } + @Override public Ident getIdent() { return Ident.empty(); } + @Override public boolean isAloneAndUnlinked() { throw new UnsupportedOperationException(); } + @Override public void setThisIsTogether() { throw new UnsupportedOperationException(); } + @Override public String getCodeLine() { throw new UnsupportedOperationException(); } + @Override public void setCodeLine(LineLocation codeLine) { throw new UnsupportedOperationException(); } + + @Override + public void setStereostyle(String stereo) { + throw new UnsupportedOperationException(); + } + + @Override + public Stereostyles getStereostyles() { + throw new UnsupportedOperationException(); + } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/IEntity.java b/src/net/sourceforge/plantuml/cucadiagram/IEntity.java index d2a15f430..383211eef 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/IEntity.java +++ b/src/net/sourceforge/plantuml/cucadiagram/IEntity.java @@ -82,10 +82,6 @@ public interface IEntity extends SpecificBackcolorable, Hideable, Removeable, Li public boolean hasUrl(); - public int getHectorLayer(); - - public void setHectorLayer(int layer); - public int getRawLayout(); public void putTip(String member, Display display); @@ -104,4 +100,8 @@ public interface IEntity extends SpecificBackcolorable, Hideable, Removeable, Li public void setCodeLine(LineLocation codeLine); + public void setStereostyle(String stereo); + + public Stereostyles getStereostyles(); + } diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverNoneTikz.java b/src/net/sourceforge/plantuml/cucadiagram/Stereostyles.java similarity index 56% rename from src/net/sourceforge/plantuml/ugraphic/tikz/DriverNoneTikz.java rename to src/net/sourceforge/plantuml/cucadiagram/Stereostyles.java index 63435a6fe..fc93e86b1 100644 --- a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverNoneTikz.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Stereostyles.java @@ -30,19 +30,45 @@ * * * Original Author: Arnaud Roques + * * */ -package net.sourceforge.plantuml.ugraphic.tikz; +package net.sourceforge.plantuml.cucadiagram; -import net.sourceforge.plantuml.tikz.TikzGraphics; -import net.sourceforge.plantuml.ugraphic.UDriver; -import net.sourceforge.plantuml.ugraphic.UParam; -import net.sourceforge.plantuml.ugraphic.UShape; -import net.sourceforge.plantuml.ugraphic.color.ColorMapper; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; -public class DriverNoneTikz implements UDriver { +import net.sourceforge.plantuml.command.regex.Matcher2; +import net.sourceforge.plantuml.command.regex.MyPattern; +import net.sourceforge.plantuml.command.regex.Pattern2; - public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics object) { +public class Stereostyles { + + public static final Stereostyles NONE = new Stereostyles(); + + private final Set names = new LinkedHashSet(); + + private Stereostyles() { + } + + public boolean isEmpty() { + return names.isEmpty(); + } + + public static Stereostyles build(String label) { + final Stereostyles result = new Stereostyles(); + final Pattern2 p = MyPattern.cmpile("\\<{3}(.*?)\\>{3}"); + final Matcher2 m = p.matcher(label); + while (m.find()) { + result.names.add(m.group(1)); + } + return result; + } + + public Collection getStyleNames() { + return Collections.unmodifiableCollection(names); } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java b/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java index 14a39fbd1..8b8d1f17e 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java @@ -45,191 +45,100 @@ import java.util.regex.Pattern; import net.sourceforge.plantuml.Guillemet; import net.sourceforge.plantuml.SpriteContainer; -import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.command.regex.Matcher2; -import net.sourceforge.plantuml.command.regex.MyPattern; -import net.sourceforge.plantuml.command.regex.Pattern2; -import net.sourceforge.plantuml.command.regex.RegexComposed; -import net.sourceforge.plantuml.command.regex.RegexConcat; -import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexOptional; -import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.sprite.Sprite; -import net.sourceforge.plantuml.sprite.SpriteUtils; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.svek.PackageStyle; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; -import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class Stereotype implements CharSequence { - private final static RegexComposed circleChar = new RegexConcat( // - new RegexLeaf("\\<\\<"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("\\(?"), // - new RegexLeaf("CHAR", "(\\S)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf(","), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("COLOR", "(#[0-9a-fA-F]{6}|\\w+)"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexOptional(new RegexLeaf("LABEL", "[),](.*?)")), // - new RegexLeaf("\\>\\>") // - ); - - private final static RegexComposed circleSprite = new RegexConcat( // - new RegexLeaf("\\<\\<"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("\\(?\\$"), // - new RegexLeaf("NAME", "(" + SpriteUtils.SPRITE_NAME + ")"), // - new RegexLeaf("SCALE", "((?:\\{scale=|\\*)([0-9.]+)\\}?)?"), // - RegexLeaf.spaceZeroOrMore(), // - new RegexOptional( // - new RegexConcat( // - new RegexLeaf(","), // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("COLOR", "(#[0-9a-fA-F]{6}|\\w+)") // - )), // - RegexLeaf.spaceZeroOrMore(), // - new RegexOptional(new RegexLeaf("LABEL", "[),](.*?)")), // - new RegexLeaf("\\>\\>") // - ); private final double radius; private final UFont circledFont; private final boolean automaticPackageStyle; + private final StereotypeDecoration decoration; - private String label; - private HColor htmlColor; - private char character; - private String spriteName; - private double spriteScale; - - public Stereotype(String label, double radius, UFont circledFont, HColorSet htmlColorSet) throws NoSuchColorException { - this(label, radius, circledFont, true, htmlColorSet); - } - - public Stereotype(String label, boolean automaticPackageStyle) { - this.automaticPackageStyle = automaticPackageStyle; - this.label = label; - this.htmlColor = null; - this.character = '\0'; - this.radius = 0; - this.circledFont = null; - if (label.startsWith("<<$") && label.endsWith(">>")) { - final RegexResult mCircleSprite = circleSprite.matcher(label); - this.spriteName = mCircleSprite.get("NAME", 0); - this.spriteScale = Parser.getScale(mCircleSprite.get("SCALE", 0), 1); - } else { - this.spriteName = null; - } - } - - public Stereotype(String label, double radius, UFont circledFont, boolean automaticPackageStyle, - HColorSet htmlColorSet) throws NoSuchColorException { - Objects.requireNonNull(label); - if (label.startsWith("<<") == false || label.endsWith(">>") == false) { - throw new IllegalArgumentException(label); - } + private Stereotype(boolean automaticPackageStyle, String label, StereotypeDecoration decoration, double radius, + UFont circledFont) { this.automaticPackageStyle = automaticPackageStyle; this.radius = radius; this.circledFont = circledFont; + this.decoration = decoration; - final StringBuilder tmpLabel = new StringBuilder(); + } - final List list = cutLabels(label, Guillemet.DOUBLE_COMPARATOR); - for (String local : list) { - final RegexResult mCircleChar = circleChar.matcher(local); - final RegexResult mCircleSprite = circleSprite.matcher(local); - if (mCircleSprite != null) { - if (StringUtils.isNotEmpty(mCircleSprite.get("LABEL", 0))) { - local = "<<" + mCircleSprite.get("LABEL", 0) + ">>"; - } else { - local = null; - } - final String colName = mCircleSprite.get("COLOR", 0); - final HColor col = colName == null ? null : htmlColorSet.getColorLEGACY(colName); - this.htmlColor = col == null ? HColorUtils.BLACK : col; - this.spriteName = mCircleSprite.get("NAME", 0); - this.character = '\0'; - this.spriteScale = Parser.getScale(mCircleSprite.get("SCALE", 0), 1); - } else if (mCircleChar != null) { - if (StringUtils.isNotEmpty(mCircleChar.get("LABEL", 0))) { - local = "<<" + mCircleChar.get("LABEL", 0) + ">>"; - } else { - local = null; - } - final String colName = mCircleChar.get("COLOR", 0); - this.htmlColor = colName == null ? null : htmlColorSet.getColorLEGACY(colName); - this.character = mCircleChar.get("CHAR", 0).charAt(0); - this.spriteName = null; - } - if (local != null) { - tmpLabel.append(local); - } - } - if (tmpLabel.length() > 0) { - this.label = tmpLabel.toString(); + private static void checkLabel(String label) { + if (label.startsWith("<<") == false || label.endsWith(">>") == false) { + throw new IllegalArgumentException(label); } } - public Stereotype(String label) { - this(label, true); + public static Stereotype build(String label) { + return build(label, true); + } + + public static Stereotype build(String label, boolean automaticPackageStyle) { + checkLabel(label); + final StereotypeDecoration decoration = StereotypeDecoration.buildSimple(label); + return new Stereotype(automaticPackageStyle, label, decoration, 0, null); + } + + public static Stereotype build(String label, double radius, UFont circledFont, HColorSet htmlColorSet) + throws NoSuchColorException { + checkLabel(label); + final StereotypeDecoration decoration = StereotypeDecoration.buildComplex(label, htmlColorSet); + return new Stereotype(true, label, decoration, radius, circledFont); } public HColor getHtmlColor() { - return htmlColor; + return decoration.htmlColor; } public char getCharacter() { - return character; + return decoration.character; } public final TextBlock getSprite(SpriteContainer container) { - if (spriteName == null || container == null) { + if (decoration.spriteName == null || container == null) { return null; } - final Sprite tmp = container.getSprite(spriteName); + final Sprite tmp = container.getSprite(decoration.spriteName); if (tmp == null) { return null; } - return tmp.asTextBlock(getHtmlColor(), spriteScale); + return tmp.asTextBlock(getHtmlColor(), decoration.spriteScale); } public boolean isWithOOSymbol() { - return "<>".equalsIgnoreCase(label); + return "<>".equalsIgnoreCase(decoration.label); } public List getMultipleLabels() { final List result = new ArrayList<>(); - if (label != null) { - final Pattern p = Pattern.compile("\\<\\<\\s?((?:\\<&\\w+\\>|[^<>])+?)\\s?\\>\\>"); - final Matcher m = p.matcher(label); - while (m.find()) { - result.add(m.group(1)); - } + + final Pattern p = Pattern.compile("\\<\\<\\s?((?:\\<&\\w+\\>|[^<>])+?)\\s?\\>\\>"); + final Matcher m = p.matcher(decoration.label); + while (m.find()) { + result.add(m.group(1)); } + return Collections.unmodifiableList(result); } public boolean isSpotted() { - return character != 0; + return decoration.character != 0; } @Override public String toString() { - if (label == null) { - return "" + character; + if (decoration.character == 0) { + return decoration.label; } - if (character == 0) { - return label; - } - return character + " " + label; + return decoration.character + " " + decoration.label; } public char charAt(int arg0) { @@ -253,14 +162,13 @@ public class Stereotype implements CharSequence { } public String getLabel(Guillemet guillemet) { - assert label == null || label.length() > 0; if (isWithOOSymbol()) { return null; } - if (spriteName != null && spriteName.startsWith("archimate/")) { - return guillemet.manageGuillemet("<<" + spriteName.substring("archimate/".length()) + ">>"); + if (decoration.spriteName != null && decoration.spriteName.startsWith("archimate/")) { + return guillemet.manageGuillemet("<<" + decoration.spriteName.substring("archimate/".length()) + ">>"); } - return guillemet.manageGuillemet(label); + return guillemet.manageGuillemet(decoration.label); } public List getLabels(Guillemet guillemet) { @@ -268,7 +176,7 @@ public class Stereotype implements CharSequence { if (labelLocal == null) { return Collections.emptyList(); } - return cutLabels(labelLocal, guillemet); + return StereotypeDecoration.cutLabels(labelLocal, guillemet); } public List