From f0048de5b7c98886ecefe7f23a987cb7df7b4a97 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Wed, 5 Oct 2022 22:32:57 +0200 Subject: [PATCH] wip --- skin/plantuml.skin | 10 +- skin/rose.skin | 1 + .../plantuml/AnnotatedBuilder.java | 212 ++++++++++++++++++ .../sourceforge/plantuml/AnnotatedWorker.java | 160 ++----------- src/net/sourceforge/plantuml/ISkinParam.java | 2 +- .../sourceforge/plantuml/LineLocation.java | 4 +- src/net/sourceforge/plantuml/SkinParam.java | 6 +- .../plantuml/SkinParamDelegator.java | 2 +- .../sourceforge/plantuml/UmlDiagramType.java | 67 +++--- .../activitydiagram/command/CommandIf.java | 2 +- .../plantuml/asciiart/TextSkin.java | 2 +- .../sourceforge/plantuml/bpm/BpmElement.java | 2 +- .../command/CommandCreateClass.java | 4 +- .../command/CommandCreateClassMultilines.java | 11 +- .../command/CommandLinkClass.java | 6 +- .../command/CommandLinkLollipop.java | 2 +- .../plantuml/cucadiagram/Bodier.java | 5 +- .../plantuml/cucadiagram/BodierJSon.java | 7 +- .../cucadiagram/BodierLikeClassOrObject.java | 7 +- .../plantuml/cucadiagram/BodierMap.java | 9 +- .../plantuml/cucadiagram/BodierSimple.java | 5 +- .../plantuml/cucadiagram/Body3.java | 24 +- .../plantuml/cucadiagram/Link.java | 10 +- .../plantuml/cucadiagram/LinkArg.java | 28 +-- .../cucadiagram/TextBlockCucaJSon.java | 69 +++--- .../plantuml/cucadiagram/TextBlockMap.java | 39 ++-- .../definition/PSystemDefinition.java | 2 +- .../command/CommandLinkElement.java | 2 +- .../plantuml/ebnf/CommandEBnfSingleLine.java | 65 ++++++ .../plantuml/ebnf/CommandEbnfMultiline.java | 75 +++++++ .../plantuml/ebnf/CornerCurved.java | 28 ++- src/net/sourceforge/plantuml/ebnf/ETile.java | 115 +++++++++- .../plantuml/ebnf/ETileAlternation.java | 122 ++++++---- .../sourceforge/plantuml/ebnf/ETileBox.java | 24 +- .../plantuml/ebnf/ETileConcatenation.java | 57 +++-- ...ileRepetition.java => ETileOneOrMore.java} | 59 ++--- .../plantuml/ebnf/ETileOptional.java | 61 +++-- .../plantuml/ebnf/ETileWithCircles.java | 49 ++-- .../plantuml/ebnf/ETileZeroOrMore.java | 122 ++++++++++ .../sourceforge/plantuml/ebnf/EbnfEngine.java | 34 ++- .../plantuml/ebnf/EbnfExpressions.java | 14 +- .../plantuml/ebnf/EbnfSingleExpression.java | 83 ++++--- .../plantuml/ebnf/PSystemEbnf.java | 16 +- .../plantuml/ebnf/PSystemEbnfFactory.java | 25 ++- .../plantuml/ebnf/ShuntingYard.java | 35 ++- src/net/sourceforge/plantuml/ebnf/Symbol.java | 8 +- src/net/sourceforge/plantuml/ebnf/Token.java | 2 + .../ebnf/{VLineCurved.java => ZigZag.java} | 26 +-- .../plantuml/eggs/PSystemColors.java | 3 +- .../plantuml/elk/CucaDiagramFileMakerElk.java | 14 +- .../plantuml/emoji/SvgNanoParser.java | 2 +- .../plantuml/error/PSystemError.java | 4 +- .../sourceforge/plantuml/gitlog/MagicBox.java | 4 +- .../plantuml/graphic/BigFrame.java | 113 ++++++++++ .../plantuml/graphic/FontConfiguration.java | 108 ++++----- .../plantuml/graphic/GraphicStrings.java | 9 +- .../plantuml/graphic/HtmlCommandFactory.java | 47 ++-- .../plantuml/graphic/QuoteUtils.java | 5 +- .../plantuml/graphic/USymbolFrame.java | 20 +- .../plantuml/html/LinkHtmlPrinter.java | 12 +- .../AbstractClassOrObjectDiagram.java | 16 +- .../openiconic/PSystemListOpenIconic.java | 4 +- .../sourceforge/plantuml/posimo/DotPath.java | 20 +- .../sourceforge/plantuml/preproc/Stdlib.java | 4 +- .../plantuml/project/GanttDiagram.java | 18 +- .../plantuml/project/GanttDiagramFactory.java | 8 +- .../sourceforge/plantuml/project/Load.java | 5 + ...x.java => CommandHideResourceFootbox.java} | 10 +- ...Name.java => CommandHideResourceName.java} | 10 +- .../plantuml/project/core/TaskImpl.java | 9 +- .../plantuml/project/draw/ResourceDraw.java | 2 +- .../plantuml/project/draw/TimeHeader.java | 2 +- .../plantuml/project/lang/Verbs.java | 2 +- .../project/solver/AbstractSolver.java | 16 +- .../sourceforge/plantuml/real/RealLine.java | 16 +- .../sdot/CucaDiagramFileMakerSmetana.java | 12 +- .../plantuml/sdot/SmetanaPath.java | 2 + .../plantuml/security/SecurityProfile.java | 2 +- .../plantuml/sequencediagram/Doll.java | 3 +- .../plantuml/sequencediagram/Reference.java | 13 +- .../graphic/DrawableSetInitializer.java | 2 +- .../graphic/SequenceDiagramArea.java | 4 +- .../SequenceDiagramFileMakerPuma2.java | 14 +- .../sequencediagram/teoz/ElseTile.java | 9 +- .../sequencediagram/teoz/GroupingTile.java | 36 ++- .../teoz/SequenceDiagramFileMakerTeoz.java | 15 +- .../plantuml/skin/ComponentType.java | 2 +- .../skin/rose/ComponentRoseGroupingElse.java | 14 +- .../sourceforge/plantuml/skin/rose/Rose.java | 16 +- .../sprite/PSystemListInternalSprites.java | 4 +- ...ssourcesUtils.java => ResourcesUtils.java} | 2 +- .../style/ClockwiseTopRightBottomLeft.java | 15 ++ src/net/sourceforge/plantuml/style/PName.java | 2 + src/net/sourceforge/plantuml/style/SName.java | 2 + src/net/sourceforge/plantuml/style/Style.java | 16 +- .../svek/CucaDiagramFileMakerSvek.java | 4 +- .../plantuml/svek/DecorateEntityImage.java | 22 +- src/net/sourceforge/plantuml/svek/Kal.java | 8 +- .../sourceforge/plantuml/svek/SvekLine.java | 16 +- .../plantuml/svek/extremity/Extremity.java | 11 +- .../svek/extremity/ExtremityDiamond.java | 8 + .../extremity/ExtremityFactoryDoubleLine.java | 6 + .../ExtremityFactoryLineCrowfoot.java | 6 + .../image/EntityImageAssociationPoint.java | 16 +- .../plantuml/svek/image/EntityImageClass.java | 10 +- .../plantuml/svek/image/EntityImageJson.java | 4 +- .../plantuml/svek/image/EntityImageMap.java | 9 +- .../svek/image/EntityImageObject.java | 9 +- .../plantuml/theme/ThemeUtils.java | 4 +- .../plantuml/tim/expression/ShuntingYard.java | 4 +- .../timingdiagram/graphic/TimeArrow.java | 2 +- .../ugraphic/AbstractCommonUGraphic.java | 2 + .../plantuml/ugraphic/AbstractUGraphic.java | 23 +- .../CopyForegroundColorToBackgroundColor.java | 40 ++++ .../plantuml/ugraphic/ImageBuilder.java | 5 +- .../plantuml/ugraphic/LimitFinder.java | 6 +- .../plantuml/ugraphic/UPolygon.java | 4 + .../plantuml/ugraphic/UStroke.java | 8 +- .../plantuml/ugraphic/eps/DriverTextEps.java | 59 +++-- .../plantuml/ugraphic/g2d/DriverLineG2d.java | 5 +- .../ugraphic/g2d/DriverTextAsPathG2d.java | 18 +- .../plantuml/ugraphic/g2d/DriverTextG2d.java | 35 +-- .../plantuml/ugraphic/svg/DriverTextSvg.java | 18 +- .../plantuml/utils/ObjectUtils.java | 7 +- .../sourceforge/plantuml/version/Version.java | 2 +- src/net/sourceforge/plantuml/wire/WBlock.java | 2 +- .../plantuml/xmi/XmiClassDiagramArgo.java | 8 +- .../plantuml/xmi/XmiClassDiagramStar.java | 8 +- .../plantuml/xmi/XmiDescriptionDiagram.java | 8 +- .../plantuml/xmi/XmiStateDiagram.java | 8 +- .../sourceforge/plantuml/SkinParamTest.java | 116 +++------- test/nonreg/simple/A0005_TestResult.java | 134 +++++------ test/nonreg/simple/A0006_TestResult.java | 32 +-- 133 files changed, 1942 insertions(+), 1133 deletions(-) create mode 100644 src/net/sourceforge/plantuml/AnnotatedBuilder.java create mode 100644 src/net/sourceforge/plantuml/ebnf/CommandEBnfSingleLine.java create mode 100644 src/net/sourceforge/plantuml/ebnf/CommandEbnfMultiline.java rename src/net/sourceforge/plantuml/ebnf/{ETileRepetition.java => ETileOneOrMore.java} (55%) create mode 100644 src/net/sourceforge/plantuml/ebnf/ETileZeroOrMore.java rename src/net/sourceforge/plantuml/ebnf/{VLineCurved.java => ZigZag.java} (73%) create mode 100644 src/net/sourceforge/plantuml/graphic/BigFrame.java rename src/net/sourceforge/plantuml/project/command/{CommandHideRessourceFootbox.java => CommandHideResourceFootbox.java} (87%) rename src/net/sourceforge/plantuml/project/command/{CommandHideRessourceName.java => CommandHideResourceName.java} (88%) rename src/net/sourceforge/plantuml/sprite/{RessourcesUtils.java => ResourcesUtils.java} (99%) create mode 100644 src/net/sourceforge/plantuml/ugraphic/CopyForegroundColorToBackgroundColor.java diff --git a/skin/plantuml.skin b/skin/plantuml.skin index 4b791e181..a99142a1a 100644 --- a/skin/plantuml.skin +++ b/skin/plantuml.skin @@ -5,6 +5,7 @@ root { FontName SansSerif HyperLinkColor blue + HyperLinkUnderlineThickness 1 FontColor black FontSize 14 FontStyle plain @@ -47,8 +48,8 @@ document { BackGroundColor #D FontSize 14 RoundCorner 15 - Padding 6 - Margin 8 + Padding 5 + Margin 12 } caption { HorizontalAlignment center @@ -69,6 +70,11 @@ stereotype { } +mainframe { + Padding 1 5 + LineThickness 1.5 + Margin 10 5 +} element { Shadowing 0.0 diff --git a/skin/rose.skin b/skin/rose.skin index 95b559cb4..0ec9589b7 100644 --- a/skin/rose.skin +++ b/skin/rose.skin @@ -1,6 +1,7 @@ root { FontName SansSerif HyperLinkColor blue + HyperLinkUnderlineThickness 1 FontColor black FontSize 14 FontStyle plain diff --git a/src/net/sourceforge/plantuml/AnnotatedBuilder.java b/src/net/sourceforge/plantuml/AnnotatedBuilder.java new file mode 100644 index 000000000..300df872c --- /dev/null +++ b/src/net/sourceforge/plantuml/AnnotatedBuilder.java @@ -0,0 +1,212 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, 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; + +import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; +import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.awt.geom.XRectangle2D; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; +import net.sourceforge.plantuml.cucadiagram.DisplaySection; +import net.sourceforge.plantuml.graphic.BigFrame; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.InnerStrategy; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.SymbolContext; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignatureBasic; +import net.sourceforge.plantuml.svek.DecorateEntityImage; +import net.sourceforge.plantuml.svek.TextBlockBackcolored; +import net.sourceforge.plantuml.ugraphic.MinMax; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.color.HColor; + +public class AnnotatedBuilder { + + private final Annotated annotated; + private final ISkinParam skinParam; + private final StringBounder stringBounder; + + public AnnotatedBuilder(Annotated annotated, ISkinParam skinParam, StringBounder stringBounder) { + this.annotated = annotated; + this.skinParam = skinParam; + this.stringBounder = stringBounder; + } + + public boolean hasMainFrame() { + return annotated.getMainFrame() != null; + } + + public double mainFrameSuppHeight() { + final Display mainFrame = annotated.getMainFrame(); + final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.mainframe) + .getMergedStyle(skinParam.getCurrentStyleBuilder()); + final FontConfiguration fontConfiguration = FontConfiguration.create(getSkinParam(), style); + final TextBlock title = mainFrame.create(fontConfiguration, HorizontalAlignment.CENTER, getSkinParam()); + final XDimension2D dimTitle = title.calculateDimension(stringBounder); + + final ClockwiseTopRightBottomLeft margin = style.getMargin(); + final ClockwiseTopRightBottomLeft padding = style.getPadding().incTop(dimTitle.getHeight() + 10); + + return margin.getBottom() + margin.getTop() + padding.getTop() + padding.getBottom() + 10; + } + + public TextBlock decoreWithFrame(final TextBlock original) { + final Display mainFrame = annotated.getMainFrame(); + if (mainFrame == null) + return original; + +// final double x1 = 5; +// final double x2 = 7; +// final double y1 = 10; +// final double y2 = 10; + + final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.mainframe) + .getMergedStyle(skinParam.getCurrentStyleBuilder()); + final FontConfiguration fontConfiguration = FontConfiguration.create(getSkinParam(), style); + final TextBlock title = mainFrame.create(fontConfiguration, HorizontalAlignment.CENTER, getSkinParam()); + final XDimension2D dimTitle = title.calculateDimension(stringBounder); + + final SymbolContext symbolContext = style.getSymbolContext(skinParam.getIHtmlColorSet()); + final ClockwiseTopRightBottomLeft margin = style.getMargin(); + final ClockwiseTopRightBottomLeft padding = style.getPadding().incTop(dimTitle.getHeight() + 10); + + final MinMax originalMinMax = TextBlockUtils.getMinMax(original, stringBounder, false); + + final double ww = originalMinMax.getMinX() >= 0 ? originalMinMax.getMaxX() : originalMinMax.getWidth(); + final double hh = originalMinMax.getMinY() >= 0 ? originalMinMax.getMaxY() : originalMinMax.getHeight(); + final double dx = originalMinMax.getMinX() < 0 ? -originalMinMax.getMinX() : 0; + final double dy = originalMinMax.getMinY() < 0 ? -originalMinMax.getMinY() : 0; + final UTranslate delta = new UTranslate(dx, dy); + + final double width = padding.getLeft() + Math.max(ww + 12, dimTitle.getWidth() + 10) + padding.getRight(); + final double height = padding.getTop() + dimTitle.getHeight() + hh + padding.getBottom(); + + final TextBlock frame = new BigFrame(title, width, height, symbolContext); + + return new TextBlockBackcolored() { + + public void drawU(UGraphic ug) { + frame.drawU(ug.apply(margin.getTranslate())); + original.drawU(ug.apply(margin.getTranslate().compose(padding.getTranslate().compose(delta)))); + } + + public MinMax getMinMax(StringBounder stringBounder) { + throw new UnsupportedOperationException(); + } + + public XRectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) { + final XRectangle2D rect = original.getInnerPosition(member, stringBounder, strategy); + return new XRectangle2D(dx + rect.getX() + margin.getLeft() + padding.getLeft(), + dy + rect.getY() + margin.getTop() + padding.getTop() + dimTitle.getHeight(), rect.getWidth(), + rect.getHeight()); + } + + public XDimension2D calculateDimension(StringBounder stringBounder) { + final XDimension2D dim1 = original.calculateDimension(stringBounder); + final XDimension2D dim2 = padding.apply(dim1); + final XDimension2D dim3 = margin.apply(dim2); + return dim3; + } + + public HColor getBackcolor() { + return symbolContext.getBackColor(); + } + }; + } + + private ISkinParam getSkinParam() { + return skinParam; + } + + public TextBlock getLegend() { + final DisplayPositioned legend = annotated.getLegend(); + return EntityImageLegend.create(legend.getDisplay(), getSkinParam()); + } + + public TextBlock getTitle() { + final DisplayPositioned title = (DisplayPositioned) annotated.getTitle(); + final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.title) + .getMergedStyle(skinParam.getCurrentStyleBuilder()); + final TextBlock block = style.createTextBlockBordered(title.getDisplay(), skinParam.getIHtmlColorSet(), + skinParam, Style.ID_TITLE); + return block; + } + + public TextBlock getCaption() { + final DisplayPositioned caption = annotated.getCaption(); + if (caption.isNull()) + return TextBlockUtils.empty(0, 0); + + final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.caption) + .getMergedStyle(skinParam.getCurrentStyleBuilder()); + return style.createTextBlockBordered(caption.getDisplay(), skinParam.getIHtmlColorSet(), skinParam, + Style.ID_CAPTION); + + } + + public TextBlock addHeaderAndFooter(TextBlock original) { + final DisplaySection footer = annotated.getFooter(); + final DisplaySection header = annotated.getHeader(); + if (footer.isNull() && header.isNull()) + return original; + + TextBlock textFooter = null; + if (footer.isNull() == false) { + final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.footer) + .getMergedStyle(skinParam.getCurrentStyleBuilder()); + textFooter = footer.createRibbon(FontConfiguration.create(getSkinParam(), FontParam.FOOTER, null), + getSkinParam(), style); + } + TextBlock textHeader = null; + if (header.isNull() == false) { + final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.header) + .getMergedStyle(skinParam.getCurrentStyleBuilder()); + textHeader = header.createRibbon(FontConfiguration.create(getSkinParam(), FontParam.HEADER, null), + getSkinParam(), style); + } + + return DecorateEntityImage.addTopAndBottom(original, textHeader, header.getHorizontalAlignment(), textFooter, + footer.getHorizontalAlignment()); + } + +} diff --git a/src/net/sourceforge/plantuml/AnnotatedWorker.java b/src/net/sourceforge/plantuml/AnnotatedWorker.java index fe2aff27c..8a4be381f 100644 --- a/src/net/sourceforge/plantuml/AnnotatedWorker.java +++ b/src/net/sourceforge/plantuml/AnnotatedWorker.java @@ -35,130 +35,52 @@ */ package net.sourceforge.plantuml; -import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; -import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.awt.geom.XRectangle2D; -import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; -import net.sourceforge.plantuml.cucadiagram.DisplaySection; -import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; -import net.sourceforge.plantuml.graphic.USymbols; -import net.sourceforge.plantuml.style.PName; -import net.sourceforge.plantuml.style.SName; -import net.sourceforge.plantuml.style.Style; -import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.svek.DecorateEntityImage; import net.sourceforge.plantuml.svek.TextBlockBackcolored; -import net.sourceforge.plantuml.ugraphic.MinMax; -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 AnnotatedWorker { private final Annotated annotated; private final ISkinParam skinParam; private final StringBounder stringBounder; + private final AnnotatedBuilder builder; - public AnnotatedWorker(Annotated annotated, ISkinParam skinParam, StringBounder stringBounder) { + public AnnotatedWorker(Annotated annotated, ISkinParam skinParam, StringBounder stringBounder, + AnnotatedBuilder builder) { this.annotated = annotated; this.skinParam = skinParam; this.stringBounder = stringBounder; + this.builder = builder; } public TextBlockBackcolored addAdd(TextBlock result) { - result = addFrame(result); + result = builder.decoreWithFrame(result); result = addLegend(result); result = addTitle(result); result = addCaption(result); - result = addHeaderAndFooter(result); + result = builder.addHeaderAndFooter(result); return (TextBlockBackcolored) result; } - public boolean hasMainFrame() { - return annotated.getMainFrame() != null; - } - - public TextBlock addFrame(final TextBlock original) { - final Display mainFrame = annotated.getMainFrame(); - if (mainFrame == null) - return original; - - final double x1 = 5; - final double x2 = 7; - final double y1 = 10; - final double y2 = 10; - - final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.frame) - .getMergedStyle(skinParam.getCurrentStyleBuilder()); - final double deltaShadow = style.value(PName.Shadowing).asDouble(); - final FontConfiguration fontConfiguration = FontConfiguration.create(getSkinParam(), style); - final UStroke stroke = style.getStroke(); - final HColor borderColor = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); - - final SymbolContext symbolContext = new SymbolContext(getBackgroundColor(), borderColor).withShadow(deltaShadow) - .withStroke(stroke); - final MinMax originalMinMax = TextBlockUtils.getMinMax(original, stringBounder, false); - - final TextBlock title = mainFrame.create(fontConfiguration, HorizontalAlignment.CENTER, getSkinParam()); - final XDimension2D dimTitle = title.calculateDimension(stringBounder); - - final double width = x1 + Math.max(originalMinMax.getWidth(), dimTitle.getWidth()) + x2; - final double height = dimTitle.getHeight() + y1 + originalMinMax.getHeight() + y2; - final TextBlock frame = USymbols.FRAME.asBig(title, HorizontalAlignment.LEFT, TextBlockUtils.empty(0, 0), width, - height, symbolContext, skinParam.getStereotypeAlignment()); - - return new TextBlockBackcolored() { - - public void drawU(UGraphic ug) { - frame.drawU(ug.apply(UTranslate.dx(originalMinMax.getMinX()))); - original.drawU(ug.apply(new UTranslate(x1, y1 + dimTitle.getHeight()))); - // original.drawU(ug); - } - - public MinMax getMinMax(StringBounder stringBounder) { - return TextBlockUtils.getMinMax(this, stringBounder, false); - } - - public XRectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) { - final XRectangle2D rect = original.getInnerPosition(member, stringBounder, strategy); - return new XRectangle2D(rect.getX() + x1, rect.getY() + y1 + dimTitle.getHeight(), - rect.getWidth(), rect.getHeight()); - } - - public XDimension2D calculateDimension(StringBounder stringBounder) { - return original.calculateDimension(stringBounder); - } - - public HColor getBackcolor() { - return symbolContext.getBackColor(); - } - }; - } - - private HColor getBackgroundColor() { - return getSkinParam().getBackgroundColor(); - } - - private TextBlock addLegend(TextBlock original) { + public TextBlock addLegend(TextBlock original) { final DisplayPositioned legend = annotated.getLegend(); if (legend.isNull()) return original; - final TextBlock text = EntityImageLegend.create(legend.getDisplay(), getSkinParam()); - - return DecorateEntityImage.add(original, text, legend.getHorizontalAlignment(), legend.getVerticalAlignment()); + return DecorateEntityImage.add(original, builder.getLegend(), legend.getHorizontalAlignment(), + legend.getVerticalAlignment()); } - private ISkinParam getSkinParam() { - return skinParam; + public TextBlock addTitle(TextBlock original) { + final DisplayPositioned title = (DisplayPositioned) annotated.getTitle(); + if (title.isNull()) + return original; + + return DecorateEntityImage.addTop(original, builder.getTitle(), HorizontalAlignment.CENTER); } private TextBlock addCaption(TextBlock original) { @@ -166,57 +88,7 @@ public class AnnotatedWorker { if (caption.isNull()) return original; - final TextBlock text = getCaption(); - return DecorateEntityImage.addBottom(original, text, HorizontalAlignment.CENTER); + return DecorateEntityImage.addBottom(original, builder.getCaption(), HorizontalAlignment.CENTER); } - public TextBlock getCaption() { - final DisplayPositioned caption = annotated.getCaption(); - if (caption.isNull()) - return TextBlockUtils.empty(0, 0); - - final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.caption) - .getMergedStyle(skinParam.getCurrentStyleBuilder()); - return style.createTextBlockBordered(caption.getDisplay(), skinParam.getIHtmlColorSet(), skinParam, - Style.ID_CAPTION); - - } - - private TextBlock addTitle(TextBlock original) { - final DisplayPositioned title = (DisplayPositioned) annotated.getTitle(); - if (title.isNull()) - return original; - - final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.title) - .getMergedStyle(skinParam.getCurrentStyleBuilder()); - final TextBlock block = style.createTextBlockBordered(title.getDisplay(), skinParam.getIHtmlColorSet(), - skinParam, Style.ID_TITLE); - - return DecorateEntityImage.addTop(original, block, HorizontalAlignment.CENTER); - } - - private TextBlock addHeaderAndFooter(TextBlock original) { - final DisplaySection footer = annotated.getFooter(); - final DisplaySection header = annotated.getHeader(); - if (footer.isNull() && header.isNull()) - return original; - - TextBlock textFooter = null; - if (footer.isNull() == false) { - final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.footer) - .getMergedStyle(skinParam.getCurrentStyleBuilder()); - textFooter = footer.createRibbon(FontConfiguration.create(getSkinParam(), FontParam.FOOTER, null), - getSkinParam(), style); - } - TextBlock textHeader = null; - if (header.isNull() == false) { - final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.header) - .getMergedStyle(skinParam.getCurrentStyleBuilder()); - textHeader = header.createRibbon(FontConfiguration.create(getSkinParam(), FontParam.HEADER, null), - getSkinParam(), style); - } - - return DecorateEntityImage.addTopAndBottom(original, textHeader, header.getHorizontalAlignment(), textFooter, - footer.getHorizontalAlignment()); - } } diff --git a/src/net/sourceforge/plantuml/ISkinParam.java b/src/net/sourceforge/plantuml/ISkinParam.java index cc8f2e5fd..fb50acb15 100644 --- a/src/net/sourceforge/plantuml/ISkinParam.java +++ b/src/net/sourceforge/plantuml/ISkinParam.java @@ -62,7 +62,7 @@ public interface ISkinParam extends ISkinSimple { public HColor getHyperlinkColor(); - public boolean useUnderlineForHyperlink(); + public UStroke useUnderlineForHyperlink(); public HColor getBackgroundColor(); diff --git a/src/net/sourceforge/plantuml/LineLocation.java b/src/net/sourceforge/plantuml/LineLocation.java index fbd66ebda..86fa281ee 100644 --- a/src/net/sourceforge/plantuml/LineLocation.java +++ b/src/net/sourceforge/plantuml/LineLocation.java @@ -48,8 +48,8 @@ public interface LineLocation extends Comparable { public int getPosition(); /** - * A description of the ressource. - * If the ressource is a file, this is the complete path of the file. + * A description of the resource. + * If the resource is a file, this is the complete path of the file. */ public String getDescription(); diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index 40a67718a..3889a2ac0 100644 --- a/src/net/sourceforge/plantuml/SkinParam.java +++ b/src/net/sourceforge/plantuml/SkinParam.java @@ -925,8 +925,10 @@ public class SkinParam implements ISkinParam { return htmlColorSet; } - public boolean useUnderlineForHyperlink() { - return !valueIs("hyperlinkunderline", "false"); + public UStroke useUnderlineForHyperlink() { + if (valueIs("hyperlinkunderline", "false") == false) + return new UStroke(); + return null; } public int groupInheritance() { diff --git a/src/net/sourceforge/plantuml/SkinParamDelegator.java b/src/net/sourceforge/plantuml/SkinParamDelegator.java index 58dc841d3..b30a4d04c 100644 --- a/src/net/sourceforge/plantuml/SkinParamDelegator.java +++ b/src/net/sourceforge/plantuml/SkinParamDelegator.java @@ -234,7 +234,7 @@ public class SkinParamDelegator implements ISkinParam { } @Override - public boolean useUnderlineForHyperlink() { + public UStroke useUnderlineForHyperlink() { return skinParam.useUnderlineForHyperlink(); } diff --git a/src/net/sourceforge/plantuml/UmlDiagramType.java b/src/net/sourceforge/plantuml/UmlDiagramType.java index ff77b4ea5..092916032 100644 --- a/src/net/sourceforge/plantuml/UmlDiagramType.java +++ b/src/net/sourceforge/plantuml/UmlDiagramType.java @@ -42,54 +42,57 @@ public enum UmlDiagramType { HELP, GANTT, SALT, JSON, GIT, BOARD, YAML, HCL, EBNF; public SName getStyleName() { - if (this == SEQUENCE) { + if (this == SEQUENCE) return SName.sequenceDiagram; - } - if (this == STATE) { + + if (this == STATE) return SName.stateDiagram; - } - if (this == CLASS) { + + if (this == CLASS) return SName.classDiagram; - } - if (this == OBJECT) { + + if (this == OBJECT) return SName.objectDiagram; - } - if (this == ACTIVITY) { + + if (this == ACTIVITY) return SName.activityDiagram; - } - if (this == DESCRIPTION) { + + if (this == DESCRIPTION) return SName.componentDiagram; - } - if (this == COMPOSITE) { + + if (this == COMPOSITE) return SName.componentDiagram; - } - if (this == MINDMAP) { + + if (this == MINDMAP) return SName.mindmapDiagram; - } - if (this == WBS) { + + if (this == WBS) return SName.wbsDiagram; - } - if (this == GANTT) { + + if (this == GANTT) return SName.ganttDiagram; - } - if (this == SALT) { + + if (this == SALT) return SName.saltDiagram; - } - if (this == YAML) { + + if (this == YAML) return SName.yamlDiagram; - } - if (this == HCL) { + + if (this == HCL) return SName.yamlDiagram; - } - if (this == JSON) { + + if (this == JSON) return SName.jsonDiagram; - } - if (this == TIMING) { + + if (this == TIMING) return SName.timingDiagram; - } - if (this == NWDIAG) { + + if (this == NWDIAG) return SName.nwdiagDiagram; - } + + if (this == EBNF) + return SName.ebnf; + return SName.activityDiagram; } } diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java index 776ab3bfb..0bd523e76 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java @@ -126,7 +126,7 @@ public class CommandIf extends SingleLineCommand2 { final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(arg.get("BRACKET", 0)), lenght); Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, branch, - new LinkType(LinkDecor.ARROW, LinkDecor.NONE), linkArg.withQualifier(null, ifLabel) + new LinkType(LinkDecor.ARROW, LinkDecor.NONE), linkArg.withQuantifier(null, ifLabel) .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); if (arg.get("ARROW", 0) != null) { final Direction direction = StringUtils.getArrowDirection(arg.get("ARROW", 0)); diff --git a/src/net/sourceforge/plantuml/asciiart/TextSkin.java b/src/net/sourceforge/plantuml/asciiart/TextSkin.java index 443dff23d..e6d9daf53 100644 --- a/src/net/sourceforge/plantuml/asciiart/TextSkin.java +++ b/src/net/sourceforge/plantuml/asciiart/TextSkin.java @@ -141,7 +141,7 @@ public class TextSkin extends Rose { if (type == ComponentType.GROUPING_SPACE) return new ComponentRoseGroupingSpace(1); - if (type == ComponentType.GROUPING_ELSE) + if (type == ComponentType.GROUPING_ELSE_LEGACY || type == ComponentType.GROUPING_ELSE_TEOZ) return new ComponentTextGroupingElse(type, stringsToDisplay, fileFormat); if (type == ComponentType.DELAY_TEXT) diff --git a/src/net/sourceforge/plantuml/bpm/BpmElement.java b/src/net/sourceforge/plantuml/bpm/BpmElement.java index 236a77c8c..022b9a8a9 100644 --- a/src/net/sourceforge/plantuml/bpm/BpmElement.java +++ b/src/net/sourceforge/plantuml/bpm/BpmElement.java @@ -159,7 +159,7 @@ public class BpmElement extends AbstractConnectorPuzzle implements ConnectorPuzz return FtileBox.create(skinParam, display, null, BoxStyle.PLAIN, null); } final UFont font = UFont.serif(14); - final FontConfiguration fc = FontConfiguration.create(font, HColors.RED, HColors.RED, false); + final FontConfiguration fc = FontConfiguration.create(font, HColors.RED, HColors.RED, null); if (Display.isNull(display)) { return Display.getWithNewlines(type.toString()).create(fc, HorizontalAlignment.LEFT, skinParam); } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java index a56655002..13010c4e0 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java @@ -111,9 +111,9 @@ public class CommandCreateClass extends SingleLineCommand2 { new RegexOptional(new RegexConcat(new RegexLeaf("##"), new RegexLeaf("LINECOLOR", "(?:\\[(dotted|dashed|bold)\\])?(\\w+)?"))), // new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(), - new RegexLeaf("EXTENDS", "(extends)[%s]+(" + CommandCreateClassMultilines.CODES + ")"))), // + new RegexLeaf("EXTENDS", "(extends)[%s]+(" + CommandCreateClassMultilines.CODES + "|[%g]([^%g]+)[%g])"))), // new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(), - new RegexLeaf("IMPLEMENTS", "(implements)[%s]+(" + CommandCreateClassMultilines.CODES + ")"))), // + new RegexLeaf("IMPLEMENTS", "(implements)[%s]+(" + CommandCreateClassMultilines.CODES + "|[%g]([^%g]+)[%g])"))), // new RegexOptional(new RegexConcat(RegexLeaf.spaceZeroOrMore(), new RegexLeaf("\\{"), RegexLeaf.spaceZeroOrMore(), new RegexLeaf("\\}"))), // RegexLeaf.end()); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java index b4918d0a9..547d408fc 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java @@ -126,9 +126,9 @@ public class CommandCreateClassMultilines extends CommandMultilines2 0) - .withQualifier(labels.getFirstLabel(), labels.getSecondLabel()) + .withQuantifier(labels.getFirstLabel(), labels.getSecondLabel()) .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()).withKal(kal1, kal2); Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, linkArg); @@ -379,7 +379,7 @@ final public class CommandLinkClass extends SingleLineCommand2 0); final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, - linkArg.withQualifier(firstLabel, secondLabel).withDistanceAngle(diagram.getLabeldistance(), + linkArg.withQuantifier(firstLabel, secondLabel).withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet())); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java index 04990def6..082725f3c 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java @@ -190,7 +190,7 @@ final public class CommandLinkLollipop extends SingleLineCommand2 0); final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, - linkArg.withQualifier(firstLabel, secondLabel).withDistanceAngle(diagram.getLabeldistance(), + linkArg.withQuantifier(firstLabel, secondLabel).withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); diagram.resetPragmaLabel(); addLink(diagram, link, arg.get("HEADER", 0)); diff --git a/src/net/sourceforge/plantuml/cucadiagram/Bodier.java b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java index 922ce596c..55111b6d9 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Bodier.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java @@ -37,7 +37,6 @@ package net.sourceforge.plantuml.cucadiagram; 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; @@ -54,8 +53,8 @@ public interface Bodier { public boolean addFieldOrMethod(String s) throws NoSuchColorException; - public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields, - Stereotype stereotype, Style style, FontConfiguration fontConfiguration); + public TextBlock getBody(ISkinParam skinParam, boolean showMethods, boolean showFields, Stereotype stereotype, + Style style, FontConfiguration fontConfiguration); public List getRawBody(); diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierJSon.java b/src/net/sourceforge/plantuml/cucadiagram/BodierJSon.java index b31cb49e5..823f78f69 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierJSon.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierJSon.java @@ -38,7 +38,6 @@ package net.sourceforge.plantuml.cucadiagram; import java.util.List; 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.TextBlock; @@ -81,9 +80,9 @@ public class BodierJSon implements Bodier { } @Override - public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, final boolean showMethods, - final boolean showFields, Stereotype stereotype, Style style, FontConfiguration fontConfiguration) { - return new TextBlockCucaJSon(fontConfiguration, fontParam, skinParam, json); + public TextBlock getBody(ISkinParam skinParam, final boolean showMethods, final boolean showFields, + Stereotype stereotype, Style style, FontConfiguration fontConfiguration) { + return new TextBlockCucaJSon(fontConfiguration, skinParam, json, style.wrapWidth()); } @Override diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java b/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java index d2b6a43ea..56a56c60a 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierLikeClassOrObject.java @@ -41,7 +41,6 @@ import java.util.List; import java.util.Objects; import java.util.Set; -import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UrlBuilder; @@ -210,11 +209,11 @@ public class BodierLikeClassOrObject implements Bodier { } @Override - public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields, - Stereotype stereotype, Style style, FontConfiguration fontConfiguration) { + public TextBlock getBody(ISkinParam skinParam, boolean showMethods, boolean showFields, Stereotype stereotype, + Style style, FontConfiguration fontConfiguration) { if (BodyFactory.BODY3) - return new Body3(rawBody, fontParam, skinParam, stereotype, style); + return new Body3(rawBody, skinParam, stereotype, style); if (type.isLikeClass() && isBodyEnhanced()) { if (showMethods || showFields) diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java b/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java index 249a0b540..96e583ba3 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierMap.java @@ -44,8 +44,8 @@ import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; -import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.style.Style; @@ -110,9 +110,10 @@ public class BodierMap implements Bodier { } @Override - public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, final boolean showMethods, - final boolean showFields, Stereotype stereotype, Style style, FontConfiguration fontConfiguration) { - return new TextBlockMap(fontConfiguration, fontParam, skinParam, map); + public TextBlock getBody(ISkinParam skinParam, final boolean showMethods, final boolean showFields, + Stereotype stereotype, Style style, FontConfiguration fontConfiguration) { + final LineBreakStrategy wordWrap = style.wrapWidth(); + return new TextBlockMap(fontConfiguration, skinParam, map, wordWrap); } @Override diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java b/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java index 1724a807b..ff8055c63 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierSimple.java @@ -40,7 +40,6 @@ import java.util.Collections; import java.util.List; 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; @@ -94,8 +93,8 @@ public class BodierSimple implements Bodier { } @Override - public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields, - Stereotype stereotype, Style style, FontConfiguration fontConfiguration) { + public TextBlock getBody(ISkinParam skinParam, boolean showMethods, boolean showFields, Stereotype stereotype, + Style style, FontConfiguration fontConfiguration) { return BodyFactory.create1(skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), rawBody, skinParam, stereotype, leaf, style); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Body3.java b/src/net/sourceforge/plantuml/cucadiagram/Body3.java index 0992a9c69..da7896e8b 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Body3.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Body3.java @@ -38,7 +38,6 @@ package net.sourceforge.plantuml.cucadiagram; import java.util.ArrayList; import java.util.List; -import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.graphic.AbstractTextBlock; @@ -55,17 +54,14 @@ import net.sourceforge.plantuml.ugraphic.UGraphic; public class Body3 extends AbstractTextBlock implements TextBlock, WithPorts { private final List rawBody = new ArrayList<>(); - private final FontParam fontParam; private final ISkinParam skinParam; private final Stereotype stereotype; private final Style style; - public Body3(List rawBody_, FontParam fontParam, ISkinParam skinParam, Stereotype stereotype, - Style style) { - for (CharSequence s : rawBody_) { + public Body3(List rawBody_, ISkinParam skinParam, Stereotype stereotype, Style style) { + for (CharSequence s : rawBody_) this.rawBody.add(VisibilityModifier.replaceVisibilityModifierByUnicodeChar(s.toString(), true)); - } - this.fontParam = fontParam; + this.skinParam = skinParam; this.stereotype = stereotype; this.style = style; @@ -77,17 +73,9 @@ public class Body3 extends AbstractTextBlock implements TextBlock, WithPorts { } private TextBlock getTextBlock() { - Display display = Display.create(rawBody); - - FontConfiguration config; - if (style != null) { - config = FontConfiguration.create(skinParam, style); - } else { - config = FontConfiguration.create(skinParam, fontParam, stereotype); - } - - TextBlock foo = display.create(config, HorizontalAlignment.LEFT, skinParam); - return foo; + final Display display = Display.create(rawBody); + final FontConfiguration config = FontConfiguration.create(skinParam, style); + return display.create(config, HorizontalAlignment.LEFT, skinParam); } @Override diff --git a/src/net/sourceforge/plantuml/cucadiagram/Link.java b/src/net/sourceforge/plantuml/cucadiagram/Link.java index 5802a961d..9827cee5c 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Link.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Link.java @@ -278,12 +278,12 @@ public class Link extends WithLinkType implements Hideable, Removeable { this.getLinkArg().setLength(length); } - public String getQualifier1() { - return getLinkArg().getQualifier1(); + public String getQuantifier1() { + return getLinkArg().getQuantifier1(); } - public String getQualifier2() { - return getLinkArg().getQualifier2(); + public String getQuantifier2() { + return getLinkArg().getQuantifier2(); } public final double getWeight() { @@ -356,7 +356,7 @@ public class Link extends WithLinkType implements Hideable, Removeable { // return decor.getMargin() + q; // } - private double getQualifierMargin(StringBounder stringBounder, UFont fontQualif, String qualif, + private double getQuantifierMargin(StringBounder stringBounder, UFont fontQualif, String qualif, ISkinSimple spriteContainer) { if (qualif != null) { final TextBlock b = Display.create(qualif).create(FontConfiguration.blackBlueTrue(fontQualif), diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkArg.java b/src/net/sourceforge/plantuml/cucadiagram/LinkArg.java index 15cc3132f..39760d646 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/LinkArg.java +++ b/src/net/sourceforge/plantuml/cucadiagram/LinkArg.java @@ -40,8 +40,8 @@ import net.sourceforge.plantuml.skin.VisibilityModifier; public class LinkArg { private final Display label; - private final String qualifier1; - private final String qualifier2; + private final String quantifier1; + private final String quantifier2; private final String labeldistance; private final String labelangle; @@ -72,29 +72,29 @@ public class LinkArg { return new LinkArg(newLabel, length, null, null, null, null, visibilityModifier, null, null); } - public LinkArg withQualifier(String qualifier1, String qualifier2) { - return new LinkArg(label, length, qualifier1, qualifier2, labeldistance, labelangle, visibilityModifier, kal1, + public LinkArg withQuantifier(String quantifier1, String quantifier2) { + return new LinkArg(label, length, quantifier1, quantifier2, labeldistance, labelangle, visibilityModifier, kal1, kal2); } public LinkArg withKal(String kal1, String kal2) { - return new LinkArg(label, length, qualifier1, qualifier2, labeldistance, labelangle, visibilityModifier, kal1, + return new LinkArg(label, length, quantifier1, quantifier2, labeldistance, labelangle, visibilityModifier, kal1, kal2); } public LinkArg withDistanceAngle(String labeldistance, String labelangle) { - return new LinkArg(label, length, qualifier1, qualifier2, labeldistance, labelangle, visibilityModifier, kal1, + return new LinkArg(label, length, quantifier1, quantifier2, labeldistance, labelangle, visibilityModifier, kal1, kal2); } - private LinkArg(Display label, int length, String qualifier1, String qualifier2, String labeldistance, + private LinkArg(Display label, int length, String quantifier1, String quantifier2, String labeldistance, String labelangle, VisibilityModifier visibilityModifier, String kal1, String kal2) { this.label = label; this.visibilityModifier = visibilityModifier; this.length = length; - this.qualifier1 = qualifier1; - this.qualifier2 = qualifier2; + this.quantifier1 = quantifier1; + this.quantifier2 = quantifier2; this.labeldistance = labeldistance; this.labelangle = labelangle; this.kal1 = kal1; @@ -102,7 +102,7 @@ public class LinkArg { } public LinkArg getInv() { - return new LinkArg(label, length, qualifier2, qualifier1, labeldistance, labelangle, visibilityModifier, kal1, + return new LinkArg(label, length, quantifier2, quantifier1, labeldistance, labelangle, visibilityModifier, kal1, kal2); } @@ -114,12 +114,12 @@ public class LinkArg { return length; } - public final String getQualifier1() { - return qualifier1; + public final String getQuantifier1() { + return quantifier1; } - public final String getQualifier2() { - return qualifier2; + public final String getQuantifier2() { + return quantifier2; } public final String getLabeldistance() { diff --git a/src/net/sourceforge/plantuml/cucadiagram/TextBlockCucaJSon.java b/src/net/sourceforge/plantuml/cucadiagram/TextBlockCucaJSon.java index c9cb9368a..e53af4180 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/TextBlockCucaJSon.java +++ b/src/net/sourceforge/plantuml/cucadiagram/TextBlockCucaJSon.java @@ -35,9 +35,10 @@ */ package net.sourceforge.plantuml.cucadiagram; -import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -55,26 +56,26 @@ import net.sourceforge.plantuml.ugraphic.UTranslate; public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts { - private final FontParam fontParam; private final ISkinParam skinParam; private final FontConfiguration fontConfiguration; private final JsonValue json; private TextBlockJson jsonTextBlock; - private double totalWidth; + private double mainTotalWidth; + private final LineBreakStrategy wordWrap; - public TextBlockCucaJSon(FontConfiguration fontConfiguration, FontParam fontParam, ISkinParam skinParam, - JsonValue json) { - this.fontParam = fontParam; + public TextBlockCucaJSon(FontConfiguration fontConfiguration, ISkinParam skinParam, JsonValue json, + LineBreakStrategy wordWrap) { this.skinParam = skinParam; this.json = json; this.fontConfiguration = fontConfiguration; + this.wordWrap = wordWrap; } private TextBlockJson getJsonTextBlock() { if (jsonTextBlock == null) this.jsonTextBlock = new TextBlockJson(json, 0); - jsonTextBlock.totalWidth = totalWidth; + jsonTextBlock.jsonTotalWidth = mainTotalWidth; return jsonTextBlock; } @@ -94,11 +95,11 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts { class TextBlockJson extends AbstractTextBlock { private final JsonObject obj; - private double totalWidth; + private double jsonTotalWidth; public TextBlockJson(JsonValue json, double totalWidth) { this.obj = json.asObject(); - this.totalWidth = totalWidth; + this.jsonTotalWidth = totalWidth; } @Override @@ -109,7 +110,7 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts { private double getWidth1(StringBounder stringBounder) { double result = 0; for (JsonObject.Member s : obj) { - final TextBlock tb1 = getTextBlockKey(s.getName()); + final TextBlock tb1 = getTextBlock(s.getName()); result = Math.max(result, tb1.calculateDimension(stringBounder).getWidth()); } return result; @@ -118,7 +119,7 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts { private double getWidth2(StringBounder stringBounder) { double result = 0; for (JsonObject.Member s : obj) { - final TextBlock tb2 = getTextBlockValue(s.getValue(), totalWidth); + final TextBlock tb2 = getTextBlockValue(s.getValue(), jsonTotalWidth); result = Math.max(result, tb2.calculateDimension(stringBounder).getWidth()); } return result; @@ -127,8 +128,8 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts { private double getHeight(StringBounder stringBounder) { double result = 0; for (JsonObject.Member s : obj) { - final TextBlock tb1 = getTextBlockKey(s.getName()); - final TextBlock tb2 = getTextBlockValue(s.getValue(), totalWidth); + final TextBlock tb1 = getTextBlock(s.getName()); + final TextBlock tb2 = getTextBlockValue(s.getValue(), jsonTotalWidth); final XDimension2D dim1 = tb1.calculateDimension(stringBounder); final XDimension2D dim2 = tb2.calculateDimension(stringBounder); result += Math.max(dim1.getHeight(), dim2.getHeight()); @@ -140,13 +141,12 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts { public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); final double width1 = getWidth1(stringBounder); - final double width2 = getWidth2(stringBounder); final double height = getHeight(stringBounder); ug.apply(UTranslate.dx(width1)).draw(ULine.vline(height)); - final ULine hline = ULine.hline(this.totalWidth); + final ULine hline = ULine.hline(this.jsonTotalWidth); for (JsonObject.Member s : obj) { - final TextBlock tb1 = getTextBlockKey(s.getName()); - final TextBlock tb2 = getTextBlockValue(s.getValue(), width2); + final TextBlock tb1 = getTextBlock(s.getName()); + final TextBlock tb2 = getTextBlockValue(s.getValue(), this.jsonTotalWidth - width1); final XDimension2D dim1 = tb1.calculateDimension(stringBounder); final XDimension2D dim2 = tb2.calculateDimension(stringBounder); ug.draw(hline); @@ -162,10 +162,7 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts { private TextBlock getTextBlockValue(JsonValue value, double width2) { if (value.isString() || value.isNull() || value.isTrue() || value.isFalse() || value.isNumber()) { final String tmp = value.isString() ? value.asString() : value.toString(); - final Display display = Display.getWithNewlines(tmp); - TextBlock result = display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam); - result = TextBlockUtils.withMargin(result, 5, 2); - return result; + return getTextBlock(tmp); } if (value.isArray()) return new TextBlockArray(value.asArray(), width2); @@ -173,8 +170,13 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts { return new TextBlockJson(value, width2); final String tmp = value.getClass().getSimpleName(); - final Display display = Display.getWithNewlines(tmp); - TextBlock result = display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam); + return getTextBlock(tmp); + } + + private TextBlock getTextBlock(String key) { + final Display display = Display.getWithNewlines(key); + TextBlock result = display.create0(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam, wordWrap, + CreoleMode.FULL, null, null); result = TextBlockUtils.withMargin(result, 5, 2); return result; } @@ -182,18 +184,18 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts { class TextBlockArray extends AbstractTextBlock { private final JsonArray array; - private final double totalWidth; + private final double arrayTotalWidth; public TextBlockArray(JsonArray array, double totalWidth) { this.array = array; - this.totalWidth = totalWidth; + this.arrayTotalWidth = totalWidth; } @Override public XDimension2D calculateDimension(StringBounder stringBounder) { XDimension2D result = new XDimension2D(0, 0); for (JsonValue element : array) { - final TextBlock tb = getTextBlockValue(element, totalWidth); + final TextBlock tb = getTextBlockValue(element, arrayTotalWidth); final XDimension2D dim = tb.calculateDimension(stringBounder); result = XDimension2D.mergeTB(result, dim); } @@ -202,10 +204,10 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts { @Override public void drawU(UGraphic ug) { - final ULine hline = ULine.hline(this.totalWidth); + final ULine hline = ULine.hline(this.arrayTotalWidth); int nb = 0; for (JsonValue element : array) { - final TextBlock tb = getTextBlockValue(element, totalWidth); + final TextBlock tb = getTextBlockValue(element, arrayTotalWidth); if (nb > 0) ug.draw(hline); nb++; @@ -216,21 +218,12 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts { } - private TextBlock getTextBlockKey(String key) { - final Display display = Display.getWithNewlines(key); - TextBlock result = display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam); - result = TextBlockUtils.withMargin(result, 5, 2); - return result; - } - private FontConfiguration getFontConfiguration() { - if (fontConfiguration == null) - return FontConfiguration.create(skinParam, fontParam, null); return fontConfiguration; } public void setTotalWidth(double totalWidth) { - this.totalWidth = totalWidth; + this.mainTotalWidth = totalWidth; } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/TextBlockMap.java b/src/net/sourceforge/plantuml/cucadiagram/TextBlockMap.java index 86e705a5c..d13f5a047 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/TextBlockMap.java +++ b/src/net/sourceforge/plantuml/cucadiagram/TextBlockMap.java @@ -41,9 +41,10 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -62,16 +63,14 @@ import net.sourceforge.plantuml.ugraphic.color.HColor; public class TextBlockMap extends AbstractTextBlock implements WithPorts { - private final FontParam fontParam; private final ISkinParam skinParam; private final FontConfiguration fontConfiguration; private final Map blocksMap = new LinkedHashMap<>(); private final List keys = new ArrayList<>(); private double totalWidth; - public TextBlockMap(FontConfiguration fontConfiguration, FontParam fontParam, ISkinParam skinParam, - Map map) { - this.fontParam = fontParam; + public TextBlockMap(FontConfiguration fontConfiguration, ISkinParam skinParam, Map map, + LineBreakStrategy wordWrap) { this.skinParam = skinParam; this.fontConfiguration = fontConfiguration; for (Map.Entry ent : map.entrySet()) { @@ -80,8 +79,8 @@ public class TextBlockMap extends AbstractTextBlock implements WithPorts { key = key.substring(1); this.keys.add(key); final String value = ent.getValue(); - final TextBlock block1 = getTextBlock(key); - final TextBlock block2 = getTextBlock(value); + final TextBlock block1 = getTextBlock(key, wordWrap); + final TextBlock block2 = getTextBlock(value, wordWrap); this.blocksMap.put(block1, block2); } } @@ -117,9 +116,9 @@ public class TextBlockMap extends AbstractTextBlock implements WithPorts { private double getMaxWidth(StringBounder stringBounder, Collection blocks) { double width = 0; - for (TextBlock block : blocks) { + for (TextBlock block : blocks) width = Math.max(width, block.calculateDimension(stringBounder).getWidth()); - } + return width; } @@ -137,10 +136,6 @@ public class TextBlockMap extends AbstractTextBlock implements WithPorts { ugline.draw(ULine.hline(trueWidth)); final double heightOfRow = getHeightOfRow(stringBounder, key, value); if (value instanceof Point) { -// final Dimension2D dimPoint = value.calculateDimension(stringBounder); -// final double xp = widthColA + (widthColB - dimPoint.getWidth()) / 2; -// final double yp = (heightOfRow - dimPoint.getHeight()) / 2; -// value.drawU(ugline.apply(new UTranslate(xp, yp))); final double posColA = (trueWidth - key.calculateDimension(stringBounder).getWidth()) / 2; key.drawU(ugline.apply(UTranslate.dx(posColA))); } else { @@ -151,7 +146,6 @@ public class TextBlockMap extends AbstractTextBlock implements WithPorts { } y += heightOfRow; } - // ug.apply(UTranslate.dx(widthColA)).draw(ULine.vline(fullDim.getHeight())); } private double getTotalHeight(StringBounder stringBounder) { @@ -169,12 +163,13 @@ public class TextBlockMap extends AbstractTextBlock implements WithPorts { value.calculateDimension(stringBounder).getHeight()); } - private TextBlock getTextBlock(String key) { - if (key.equals("\0")) { - return new Point(getFontConfiguration().getColor()); - } + private TextBlock getTextBlock(String key, LineBreakStrategy wordWrap) { + if (key.equals("\0")) + return new Point(fontConfiguration.getColor()); + final Display display = Display.getWithNewlines(key); - TextBlock result = display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam); + TextBlock result = display.create0(fontConfiguration, HorizontalAlignment.LEFT, skinParam, wordWrap, + CreoleMode.FULL, null, null); result = TextBlockUtils.withMargin(result, 5, 2); return result; } @@ -203,12 +198,6 @@ public class TextBlockMap extends AbstractTextBlock implements WithPorts { } - private FontConfiguration getFontConfiguration() { - if (fontConfiguration == null) - return FontConfiguration.create(skinParam, fontParam, null); - return fontConfiguration; - } - public void setTotalWidth(double totalWidth) { this.totalWidth = totalWidth; } diff --git a/src/net/sourceforge/plantuml/definition/PSystemDefinition.java b/src/net/sourceforge/plantuml/definition/PSystemDefinition.java index bb4517665..f54a60ca2 100644 --- a/src/net/sourceforge/plantuml/definition/PSystemDefinition.java +++ b/src/net/sourceforge/plantuml/definition/PSystemDefinition.java @@ -73,7 +73,7 @@ public class PSystemDefinition extends PlainDiagram implements UDrawable { public void drawU(UGraphic ug) { final UFont font = UFont.sansSerif(14); - final FontConfiguration fc = FontConfiguration.create(font, HColors.BLACK, HColors.BLACK, false); + final FontConfiguration fc = FontConfiguration.create(font, HColors.BLACK, HColors.BLACK, null); Display.getWithNewlines(startLine).create(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty()).drawU(ug); } diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java index 63abec4dc..f659b7220 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java @@ -262,7 +262,7 @@ public class CommandLinkElement extends SingleLineCommand2 { final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(labels.getLabelLink()), queue.length(), diagram.getSkinParam().classAttributeIconSize() > 0); Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, - linkArg.withQualifier(labels.getFirstLabel(), labels.getSecondLabel()) + linkArg.withQuantifier(labels.getFirstLabel(), labels.getSecondLabel()) .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle())); link.setLinkArrow(labels.getLinkArrow()); if (dir == Direction.LEFT || dir == Direction.UP) diff --git a/src/net/sourceforge/plantuml/ebnf/CommandEBnfSingleLine.java b/src/net/sourceforge/plantuml/ebnf/CommandEBnfSingleLine.java new file mode 100644 index 000000000..ebc3a06f3 --- /dev/null +++ b/src/net/sourceforge/plantuml/ebnf/CommandEBnfSingleLine.java @@ -0,0 +1,65 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, 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.ebnf; + +import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +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.ugraphic.color.NoSuchColorException; + +public class CommandEBnfSingleLine extends SingleLineCommand2 { + + public CommandEBnfSingleLine() { + super(true, getRegexConcat()); + } + + static IRegex getRegexConcat() { + return RegexConcat.build(CommandEBnfSingleLine.class.getName(), RegexLeaf.start(), // + new RegexLeaf("LINE", "(\\w[-\\w]*[%s]*=.*;)"), // + RegexLeaf.end()); + } + + @Override + protected CommandExecutionResult executeArg(PSystemEbnf diagram, LineLocation location, RegexResult arg) + throws NoSuchColorException { + diagram.addLine(arg.get("LINE", 0)); + return CommandExecutionResult.ok(); + } +} diff --git a/src/net/sourceforge/plantuml/ebnf/CommandEbnfMultiline.java b/src/net/sourceforge/plantuml/ebnf/CommandEbnfMultiline.java new file mode 100644 index 000000000..012e93b87 --- /dev/null +++ b/src/net/sourceforge/plantuml/ebnf/CommandEbnfMultiline.java @@ -0,0 +1,75 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, 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.ebnf; + +import net.sourceforge.plantuml.StringLocated; +import net.sourceforge.plantuml.command.BlocLines; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.CommandMultilines2; +import net.sourceforge.plantuml.command.MultilinesStrategy; +import net.sourceforge.plantuml.command.Trim; +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.ugraphic.color.NoSuchColorException; + +public class CommandEbnfMultiline extends CommandMultilines2 { + + public CommandEbnfMultiline() { + super(getRegexConcat(), MultilinesStrategy.KEEP_STARTING_QUOTE, Trim.BOTH); + } + + static IRegex getRegexConcat() { + return RegexConcat.build(CommandEbnfMultiline.class.getName(), RegexLeaf.start(), // + new RegexLeaf("LINE", "(\\w[-\\w]*[%s]*=.*)"), // + RegexLeaf.end()); + } + + @Override + public String getPatternEnd() { + return "^(.*);$"; + } + + @Override + protected CommandExecutionResult executeNow(PSystemEbnf diagram, BlocLines lines) throws NoSuchColorException { + for (StringLocated s : lines) + diagram.addLine(s.getString()); + + return CommandExecutionResult.ok(); + + } + +} diff --git a/src/net/sourceforge/plantuml/ebnf/CornerCurved.java b/src/net/sourceforge/plantuml/ebnf/CornerCurved.java index bf1c0eb8a..a67a9d6e1 100644 --- a/src/net/sourceforge/plantuml/ebnf/CornerCurved.java +++ b/src/net/sourceforge/plantuml/ebnf/CornerCurved.java @@ -36,8 +36,10 @@ package net.sourceforge.plantuml.ebnf; import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.ugraphic.CopyForegroundColorToBackgroundColor; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPath; +import net.sourceforge.plantuml.ugraphic.UTranslate; enum CornerType { NW, NE, SE, SW; @@ -47,28 +49,38 @@ public class CornerCurved implements UDrawable { private final double delta; private final CornerType type; + private final boolean withArrow; - private CornerCurved(CornerType type, double delta) { + private CornerCurved(CornerType type, double delta, boolean withArrow) { this.delta = delta; this.type = type; + this.withArrow = withArrow; if (delta <= 0) throw new IllegalArgumentException(); } public static UDrawable createSW(double delta) { - return new CornerCurved(CornerType.SW, delta); + return new CornerCurved(CornerType.SW, delta, false); } public static UDrawable createSE(double delta) { - return new CornerCurved(CornerType.SE, delta); + return new CornerCurved(CornerType.SE, delta, false); } public static UDrawable createNE(double delta) { - return new CornerCurved(CornerType.NE, delta); + return new CornerCurved(CornerType.NE, delta, false); + } + + public static UDrawable createNE_arrow(double delta) { + return new CornerCurved(CornerType.NE, delta, true); } public static UDrawable createNW(double delta) { - return new CornerCurved(CornerType.NW, delta); + return new CornerCurved(CornerType.NW, delta, false); + } + + public static UDrawable createNW_arrow(double delta) { + return new CornerCurved(CornerType.NW, delta, true); } @Override @@ -88,10 +100,16 @@ public class CornerCurved implements UDrawable { case NE: path.moveTo(-delta, 0); path.cubicTo(-a, 0, 0, a, 0, delta); + if (withArrow) + ug.apply(new CopyForegroundColorToBackgroundColor()).apply(UTranslate.dy(delta - 5)) + .draw(ETile.getArrowToBottom()); break; case NW: path.moveTo(0, delta); path.cubicTo(0, a, a, 0, delta, 0); + if (withArrow) + ug.apply(new CopyForegroundColorToBackgroundColor()).apply(UTranslate.dy(delta)) + .draw(ETile.getArrowToTop()); break; } diff --git a/src/net/sourceforge/plantuml/ebnf/ETile.java b/src/net/sourceforge/plantuml/ebnf/ETile.java index b71cb4a7f..6397891a6 100644 --- a/src/net/sourceforge/plantuml/ebnf/ETile.java +++ b/src/net/sourceforge/plantuml/ebnf/ETile.java @@ -35,13 +35,120 @@ */ package net.sourceforge.plantuml.ebnf; +import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.StyleSignatureBasic; +import net.sourceforge.plantuml.ugraphic.CopyForegroundColorToBackgroundColor; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UPath; +import net.sourceforge.plantuml.ugraphic.UTranslate; -public interface ETile extends TextBlock { +public abstract class ETile extends AbstractTextBlock { - public double linePos(StringBounder stringBounder); + protected final boolean TRACE = false; - public void push(ETile tile); + public static StyleSignatureBasic getStyleSignature() { + return StyleSignatureBasic.of(SName.root, SName.element, SName.ebnf); + } + + public abstract void push(ETile tile); + + @Override + final public XDimension2D calculateDimension(StringBounder stringBounder) { + final double width = getWidth(stringBounder); + final double h1 = getH1(stringBounder); + final double h2 = getH2(stringBounder); + return new XDimension2D(width, h1 + h2); + } + + public abstract double getWidth(StringBounder stringBounder); + + public abstract double getH1(StringBounder stringBounder); + + public abstract double getH2(StringBounder stringBounder); + + protected final void drawHline(UGraphic ug, double y, double x1, double x2) { + ug.apply(new UTranslate(x1, y)).draw(ULine.hline(x2 - x1)); + } + + protected final void drawHlineDirected(UGraphic ug, double y, double x1, double x2, double coef) { + ug.apply(new UTranslate(x1, y)).draw(ULine.hline(x2 - x1)); + if (x2 > x1 + 20) + ug.apply(new CopyForegroundColorToBackgroundColor()) + .apply(new UTranslate(x1 * (1 - coef) + x2 * coef - 2, y)).draw(getArrowToRight()); + + } + + protected final void drawHlineAntiDirected(UGraphic ug, double y, double x1, double x2, double coef) { + ug.apply(new UTranslate(x1, y)).draw(ULine.hline(x2 - x1)); + ug.apply(new CopyForegroundColorToBackgroundColor()).apply(new UTranslate(x1 * (1 - coef) + x2 * coef - 2, y)) + .draw(getArrowToLeft()); + + } + + protected final void drawVline(UGraphic ug, double x, double y1, double y2) { + ug.apply(new UTranslate(x, y1)).draw(ULine.vline(y2 - y1)); + } + + protected final void drawVlineDirected(UGraphic ug, double x, double y1, double y2) { + ug.apply(new UTranslate(x, y1)).draw(ULine.vline(y2 - y1)); + ug.apply(new CopyForegroundColorToBackgroundColor()).apply(new UTranslate(x, y1 * .5 + y2 * .5 - 2)) + .draw(getArrowToBottom()); + + } + + protected final void drawVlineAntiDirected(UGraphic ug, double x, double y1, double y2) { + ug.apply(new UTranslate(x, y1)).draw(ULine.vline(y2 - y1)); + ug.apply(new CopyForegroundColorToBackgroundColor()).apply(new UTranslate(x, y1 * .5 + y2 * .5 + 2)) + .draw(getArrowToTop()); + + } + + static UPath getArrowToLeft() { + final UPath arrow = new UPath(); + arrow.moveTo(0, 0); + arrow.lineTo(0, -3); + arrow.lineTo(-6, 0); + arrow.lineTo(0, 3); + arrow.lineTo(0, 0); + arrow.closePath(); + return arrow; + } + + static UPath getArrowToRight() { + final UPath arrow = new UPath(); + arrow.moveTo(0, 0); + arrow.lineTo(0, -3); + arrow.lineTo(6, 0); + arrow.lineTo(0, 3); + arrow.lineTo(0, 0); + arrow.closePath(); + return arrow; + } + + static UPath getArrowToBottom() { + final UPath arrow = new UPath(); + arrow.moveTo(0, 0); + arrow.lineTo(3, 0); + arrow.lineTo(0, 6); + arrow.lineTo(-3, 0); + arrow.lineTo(0, 0); + arrow.closePath(); + return arrow; + } + + static UPath getArrowToTop() { + final UPath arrow = new UPath(); + arrow.moveTo(0, 0); + arrow.lineTo(3, 0); + arrow.lineTo(0, -6); + arrow.lineTo(-3, 0); + arrow.lineTo(0, 0); + arrow.closePath(); + return arrow; + } } diff --git a/src/net/sourceforge/plantuml/ebnf/ETileAlternation.java b/src/net/sourceforge/plantuml/ebnf/ETileAlternation.java index e7930a835..9af35f688 100644 --- a/src/net/sourceforge/plantuml/ebnf/ETileAlternation.java +++ b/src/net/sourceforge/plantuml/ebnf/ETileAlternation.java @@ -39,18 +39,15 @@ import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.style.SName; -import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.ugraphic.color.HColors; -public class ETileAlternation extends AbstractTextBlock implements ETile { +public class ETileAlternation extends ETile { private final List tiles = new ArrayList<>(); private final double marginx = 12; + private boolean inZeroOrMore; @Override public void push(ETile tile) { @@ -58,14 +55,37 @@ public class ETileAlternation extends AbstractTextBlock implements ETile { } @Override - public double linePos(StringBounder stringBounder) { - return tiles.get(0).linePos(stringBounder); + public double getH1(StringBounder stringBounder) { + return tiles.get(0).getH1(stringBounder); + } + + @Override + public double getH2(StringBounder stringBounder) { + double height = tiles.get(0).getH2(stringBounder); + for (int i = 1; i < tiles.size(); i++) { + final ETile tile = tiles.get(i); + height += tile.getH1(stringBounder); + height += tile.getH2(stringBounder); + height += 10; + } + return height; + } + + @Override + public double getWidth(StringBounder stringBounder) { + double width = 0; + for (ETile tile : tiles) { + final XDimension2D dim = tile.calculateDimension(stringBounder); + width = Math.max(width, dim.getWidth()); + } + width += 2 * 2 * marginx; + return width; } @Override public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - ug = ug.apply(HColors.BLACK); + double y = 0; double lastLinePos = 0; @@ -79,53 +99,65 @@ public class ETileAlternation extends AbstractTextBlock implements ETile { final double q = r - marginx; final double p = q - marginx; - for (int i = 0; i < tiles.size(); i++) { - final ETile tile = tiles.get(i); - final XDimension2D dim = tile.calculateDimension(stringBounder); - lastLinePos = y + tile.linePos(stringBounder); - tile.drawU(ug.apply(new UTranslate(c, y))); + final double linePos = getH1(stringBounder); + + if (inZeroOrMore) { + for (int i = 0; i < tiles.size(); i++) { + final ETile tile = tiles.get(i); + final XDimension2D dim = tile.calculateDimension(stringBounder); + lastLinePos = y + tile.getH1(stringBounder); + tile.drawU(ug.apply(new UTranslate(c, y))); - if (i == 0) { - ETileConcatenation.drawHline(ug, lastLinePos, a, c); - ETileConcatenation.drawHline(ug, lastLinePos, c + dim.getWidth(), r); - } else if (i > 0 && i < tiles.size() - 1) { CornerCurved.createSW(marginx).drawU(ug.apply(new UTranslate(b, lastLinePos))); - ETileConcatenation.drawHline(ug, lastLinePos, c + dim.getWidth(), p); + drawHlineDirected(ug, lastLinePos, c + dim.getWidth(), p, 0.3); CornerCurved.createSE(marginx).drawU(ug.apply(new UTranslate(q, lastLinePos))); - } else if (i == tiles.size() - 1) { - ETileConcatenation.drawHline(ug, lastLinePos, c + dim.getWidth(), p); + + y += dim.getHeight() + 10; } - y += dim.getHeight() + 10; + drawVline(ug, b, 0, lastLinePos - marginx); + drawVline(ug, q, 0, lastLinePos - marginx); + + } else { + for (int i = 0; i < tiles.size(); i++) { + final ETile tile = tiles.get(i); + final XDimension2D dim = tile.calculateDimension(stringBounder); + lastLinePos = y + tile.getH1(stringBounder); + tile.drawU(ug.apply(new UTranslate(c, y))); + + if (i == 0) { + drawHline(ug, lastLinePos, a, c); + drawHline(ug, lastLinePos, c + dim.getWidth(), r); + } else if (i > 0 && i < tiles.size() - 1) { + CornerCurved.createSW(marginx).drawU(ug.apply(new UTranslate(b, lastLinePos))); + drawHlineDirected(ug, lastLinePos, c + dim.getWidth(), p, 0.5); + CornerCurved.createSE(marginx).drawU(ug.apply(new UTranslate(q, lastLinePos))); + } else if (i == tiles.size() - 1) { + drawHlineDirected(ug, lastLinePos, c + dim.getWidth(), p, 0.5); + + } + y += dim.getHeight() + 10; + } + + final double height42 = lastLinePos - linePos; + final UGraphic ug_b = ug.apply(new UTranslate(b, linePos)); + final UGraphic ug_q = ug.apply(new UTranslate(q, linePos)); + + CornerCurved.createSW(marginx).drawU(ug_b.apply(UTranslate.dy(height42))); + drawVline(ug_b, 0, marginx, height42 - marginx); + CornerCurved.createNE(marginx).drawU(ug_b); + + CornerCurved.createSE(marginx).drawU(ug_q.apply(UTranslate.dy(height42))); + drawVline(ug_q, 0, marginx, height42 - marginx); + CornerCurved.createNW(marginx).drawU(ug_q); + } - final double linePos = linePos(stringBounder); - - final VLineCurved hlineIn = new VLineCurved(lastLinePos - linePos, marginx, CornerCurved.createNE(marginx), - CornerCurved.createSW(marginx)); - hlineIn.drawU(ug.apply(new UTranslate(b, linePos))); - - final VLineCurved hlineOut = new VLineCurved(lastLinePos - linePos, marginx, CornerCurved.createNW(marginx), - CornerCurved.createSE(marginx)); - hlineOut.drawU(ug.apply(new UTranslate(q, linePos))); } - @Override - public XDimension2D calculateDimension(StringBounder stringBounder) { - double width = 0; - double height = 0; - for (ETile tile : tiles) { - final XDimension2D dim = tile.calculateDimension(stringBounder); - height += dim.getHeight(); - height += 10; - width = Math.max(width, dim.getWidth()); - } - width += 2 * 2 * marginx; - return new XDimension2D(width, height); - } + public void setInZeroOrMore(boolean inZeroOrMore) { + this.inZeroOrMore = true; - private StyleSignatureBasic getStyleSignature() { - return StyleSignatureBasic.of(SName.root, SName.element, SName.activityDiagram, SName.activity); } } diff --git a/src/net/sourceforge/plantuml/ebnf/ETileBox.java b/src/net/sourceforge/plantuml/ebnf/ETileBox.java index 0719dca71..7eb0ecad5 100644 --- a/src/net/sourceforge/plantuml/ebnf/ETileBox.java +++ b/src/net/sourceforge/plantuml/ebnf/ETileBox.java @@ -36,7 +36,6 @@ package net.sourceforge.plantuml.ebnf; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.style.PName; @@ -49,7 +48,7 @@ import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; -public class ETileBox extends AbstractTextBlock implements ETile { +public class ETileBox extends ETile { private final String value; private final FontConfiguration fc; @@ -68,8 +67,19 @@ public class ETileBox extends AbstractTextBlock implements ETile { } @Override - public XDimension2D calculateDimension(StringBounder stringBounder) { - return XDimension2D.delta(getTextDim(stringBounder), 10); + public double getH1(StringBounder stringBounder) { + final double height = getTextDim(stringBounder).getHeight() + 10; + return height / 2; + } + + @Override + public double getH2(StringBounder stringBounder) { + return getH1(stringBounder); + } + + @Override + public double getWidth(StringBounder stringBounder) { + return getTextDim(stringBounder).getWidth() + 10; } private XDimension2D getTextDim(StringBounder stringBounder) { @@ -94,12 +104,6 @@ public class ETileBox extends AbstractTextBlock implements ETile { ug.apply(new UTranslate(5, 5 + dimText.getHeight() - utext.getDescent(ug.getStringBounder()))).draw(utext); } - @Override - public double linePos(StringBounder stringBounder) { - final double height = calculateDimension(stringBounder).getHeight(); - return height / 2; - } - @Override public void push(ETile tile) { throw new UnsupportedOperationException(); diff --git a/src/net/sourceforge/plantuml/ebnf/ETileConcatenation.java b/src/net/sourceforge/plantuml/ebnf/ETileConcatenation.java index ce47fca00..25cb56300 100644 --- a/src/net/sourceforge/plantuml/ebnf/ETileConcatenation.java +++ b/src/net/sourceforge/plantuml/ebnf/ETileConcatenation.java @@ -38,17 +38,13 @@ package net.sourceforge.plantuml.ebnf; import java.util.ArrayList; import java.util.List; -import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.ugraphic.color.HColors; -public class ETileConcatenation extends AbstractTextBlock implements ETile { +public class ETileConcatenation extends ETile { - private final double marginx = 16; + private final double marginx = 20; private final List tiles = new ArrayList<>(); @Override @@ -56,59 +52,56 @@ public class ETileConcatenation extends AbstractTextBlock implements ETile { tiles.add(0, tile); } - @Override - public double linePos(StringBounder stringBounder) { - double result = 0; - - for (ETile tile : tiles) - result = Math.max(result, tile.linePos(stringBounder)); - - return result; - } - @Override public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - ug = ug.apply(HColors.BLACK); - final double fullLinePos = linePos(stringBounder); + final double fullLinePos = getH1(stringBounder); double x = 0; drawHline(ug, fullLinePos, 0, x); for (int i = 0; i < tiles.size(); i++) { final ETile tile = tiles.get(i); - final double linePos = tile.linePos(stringBounder); + final double linePos = tile.getH1(stringBounder); tile.drawU(ug.apply(new UTranslate(x, fullLinePos - linePos))); x += tile.calculateDimension(stringBounder).getWidth(); if (i != tiles.size() - 1) { - drawHline(ug, fullLinePos, x, x + marginx); + drawHlineDirected(ug, fullLinePos, x, x + marginx, 0.5); x += marginx; } } } - public static void drawHline(UGraphic ug, double y, double x1, double x2) { - ug.apply(new UTranslate(x1, y)).draw(ULine.hline(x2 - x1)); - } + @Override + public double getH1(StringBounder stringBounder) { + double result = 0; - public static void drawVline(UGraphic ug, double x, double y1, double y2) { - ug.apply(new UTranslate(x, y1)).draw(ULine.vline(y2 - y1)); + for (ETile tile : tiles) + result = Math.max(result, tile.getH1(stringBounder)); + + return result; } @Override - public XDimension2D calculateDimension(StringBounder stringBounder) { - double width = 0; - double height = 0; + public double getH2(StringBounder stringBounder) { + double result = 0; + for (ETile tile : tiles) + result = Math.max(result, tile.getH2(stringBounder)); + + return result; + } + + @Override + public double getWidth(StringBounder stringBounder) { + double width = 0; for (int i = 0; i < tiles.size(); i++) { final ETile tile = tiles.get(i); - final XDimension2D dim = tile.calculateDimension(stringBounder); - height = Math.max(height, dim.getHeight()); - width += dim.getWidth(); + width += tile.getWidth(stringBounder); if (i != tiles.size() - 1) width += marginx; } - return new XDimension2D(width, height); + return width; } } diff --git a/src/net/sourceforge/plantuml/ebnf/ETileRepetition.java b/src/net/sourceforge/plantuml/ebnf/ETileOneOrMore.java similarity index 55% rename from src/net/sourceforge/plantuml/ebnf/ETileRepetition.java rename to src/net/sourceforge/plantuml/ebnf/ETileOneOrMore.java index c68a66c3a..ab5d742b8 100644 --- a/src/net/sourceforge/plantuml/ebnf/ETileRepetition.java +++ b/src/net/sourceforge/plantuml/ebnf/ETileOneOrMore.java @@ -36,57 +36,58 @@ package net.sourceforge.plantuml.ebnf; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColors; -public class ETileRepetition extends AbstractTextBlock implements ETile { +public class ETileOneOrMore extends ETile { - private final double deltax = 20; - private final double deltay = 10; + private final double deltax = 15; + private final double deltay = 12; private final ETile orig; - public ETileRepetition(ETile orig) { + public ETileOneOrMore(ETile orig) { this.orig = orig; } @Override - public XDimension2D calculateDimension(StringBounder stringBounder) { - return XDimension2D.delta(orig.calculateDimension(stringBounder), 2 * deltax, deltay); + public double getH1(StringBounder stringBounder) { + return deltay + orig.getH1(stringBounder); + } + + @Override + public double getH2(StringBounder stringBounder) { + return orig.getH2(stringBounder); + } + + @Override + public double getWidth(StringBounder stringBounder) { + return orig.getWidth(stringBounder) + 2 * deltax; } @Override public void drawU(UGraphic ug) { final XDimension2D fullDim = calculateDimension(ug.getStringBounder()); - ug = ug.apply(HColors.BLACK); - final double linePos = linePos(ug.getStringBounder()); + if (TRACE) + ug.apply(HColors.RED).draw(new URectangle(fullDim)); - final double posA = 7; - final double posB = fullDim.getWidth() - 7; - - final double corner = 12; + final double linePos = getH1(ug.getStringBounder()); + CornerCurved.createSW(8).drawU(ug.apply(new UTranslate(8, linePos))); + drawVline(ug, 8, 8 + 5, linePos - 8); + CornerCurved.createNW(8).drawU(ug.apply(new UTranslate(8, 5))); - CornerCurved.createNW(corner).drawU(ug.apply(new UTranslate(posA, linePos))); - ETileConcatenation.drawVline(ug, posA, linePos + corner, fullDim.getHeight() - 1 - corner); - CornerCurved.createSW(corner).drawU(ug.apply(new UTranslate(posA, fullDim.getHeight() - 1))); + drawHlineAntiDirected(ug, 5, deltax, fullDim.getWidth() - deltax, 0.6); - CornerCurved.createNE(corner).drawU(ug.apply(new UTranslate(posB, linePos))); - ETileConcatenation.drawVline(ug, posB, linePos + corner, fullDim.getHeight() - 1 - corner); - CornerCurved.createSE(corner).drawU(ug.apply(new UTranslate(posB, fullDim.getHeight() - 1))); + CornerCurved.createSE(8).drawU(ug.apply(new UTranslate(fullDim.getWidth() - 8, linePos))); + drawVline(ug, fullDim.getWidth() - 8, 8 + 5, linePos - 8); + CornerCurved.createNE(8).drawU(ug.apply(new UTranslate(fullDim.getWidth() - 8, 5))); - ETileConcatenation.drawHline(ug, fullDim.getHeight() - 1, posA + corner, posB - corner); + drawHline(ug, linePos, 0, deltax); + drawHline(ug, linePos, fullDim.getWidth() - deltax, fullDim.getWidth()); - ETileConcatenation.drawHline(ug, linePos, 0, deltax); - ETileConcatenation.drawHline(ug, linePos, fullDim.getWidth() - deltax, fullDim.getWidth()); - - orig.drawU(ug.apply(new UTranslate(deltax, 0))); - } - - @Override - public double linePos(StringBounder stringBounder) { - return orig.linePos(stringBounder); + orig.drawU(ug.apply(new UTranslate(deltax, deltay))); } @Override diff --git a/src/net/sourceforge/plantuml/ebnf/ETileOptional.java b/src/net/sourceforge/plantuml/ebnf/ETileOptional.java index 1fecf2949..771da476a 100644 --- a/src/net/sourceforge/plantuml/ebnf/ETileOptional.java +++ b/src/net/sourceforge/plantuml/ebnf/ETileOptional.java @@ -36,54 +36,69 @@ package net.sourceforge.plantuml.ebnf; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColors; -public class ETileOptional extends AbstractTextBlock implements ETile { +public class ETileOptional extends ETile { - private final double posLineTop = 21; - private final double deltax = 15; - private final double deltay = 24; + private final double deltax; + private final double deltay = 16; private final ETile orig; + private final boolean specialForAlternate; + public ETileOptional(ETile orig) { this.orig = orig; + this.specialForAlternate = orig instanceof ETileAlternation; + this.deltax = this.specialForAlternate ? 0 : 15; } @Override - public XDimension2D calculateDimension(StringBounder stringBounder) { - return XDimension2D.delta(orig.calculateDimension(stringBounder), 2 * deltax, deltay); + public double getH1(StringBounder stringBounder) { + return deltay + orig.getH1(stringBounder); + } + + @Override + public double getH2(StringBounder stringBounder) { + return orig.getH2(stringBounder); + } + + @Override + public double getWidth(StringBounder stringBounder) { + return orig.getWidth(stringBounder) + 2 * deltax; } @Override public void drawU(UGraphic ug) { final XDimension2D fullDim = calculateDimension(ug.getStringBounder()); - ug = ug.apply(HColors.BLACK); - final double linePos = linePos(ug.getStringBounder()); - CornerCurved.createSE(8).drawU(ug.apply(new UTranslate(8, linePos))); - ETileConcatenation.drawVline(ug, 8, linePos - posLineTop + 8, linePos - 8); - CornerCurved.createNW(8).drawU(ug.apply(new UTranslate(8, linePos - posLineTop))); + if (TRACE) + ug.apply(HColors.BLUE).draw(new URectangle(fullDim)); - ETileConcatenation.drawHline(ug, linePos - posLineTop, deltax, fullDim.getWidth() - deltax); + final double linePos = getH1(ug.getStringBounder()); - CornerCurved.createSW(8).drawU(ug.apply(new UTranslate(fullDim.getWidth() - 8, linePos))); - ETileConcatenation.drawVline(ug, fullDim.getWidth() - 8, linePos - posLineTop + 8, linePos - 8); - CornerCurved.createNE(8).drawU(ug.apply(new UTranslate(fullDim.getWidth() - 8, linePos - posLineTop))); + final double posA = specialForAlternate ? 12 : 8; + final double corner = specialForAlternate ? 12 : 8; + final double posB = fullDim.getWidth() - posA; - ETileConcatenation.drawHline(ug, linePos, 0, deltax); - ETileConcatenation.drawHline(ug, linePos, fullDim.getWidth() - deltax, fullDim.getWidth()); + CornerCurved.createSE(corner).drawU(ug.apply(new UTranslate(posA, linePos))); + drawVline(ug, posA, corner + 5, linePos - corner); + CornerCurved.createNW(corner).drawU(ug.apply(new UTranslate(posA, 5))); + + drawHlineDirected(ug, 5, posA + corner, posB - corner, 0.4); + + CornerCurved.createSW(corner).drawU(ug.apply(new UTranslate(posB, linePos))); + drawVline(ug, posB, corner + 5, linePos - corner); + CornerCurved.createNE(corner).drawU(ug.apply(new UTranslate(posB, 5))); + + drawHline(ug, linePos, 0, deltax); + drawHline(ug, linePos, fullDim.getWidth() - deltax, fullDim.getWidth()); orig.drawU(ug.apply(new UTranslate(deltax, deltay))); } - @Override - public double linePos(StringBounder stringBounder) { - return deltay + orig.linePos(stringBounder); - } - @Override public void push(ETile tile) { throw new UnsupportedOperationException(); diff --git a/src/net/sourceforge/plantuml/ebnf/ETileWithCircles.java b/src/net/sourceforge/plantuml/ebnf/ETileWithCircles.java index f824f0145..bc5debb64 100644 --- a/src/net/sourceforge/plantuml/ebnf/ETileWithCircles.java +++ b/src/net/sourceforge/plantuml/ebnf/ETileWithCircles.java @@ -36,45 +36,58 @@ package net.sourceforge.plantuml.ebnf; import net.sourceforge.plantuml.awt.geom.XDimension2D; -import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.CopyForegroundColorToBackgroundColor; import net.sourceforge.plantuml.ugraphic.UEllipse; import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.ugraphic.color.HColors; +import net.sourceforge.plantuml.ugraphic.color.HColor; -public class ETileWithCircles extends AbstractTextBlock implements ETile { +public class ETileWithCircles extends ETile { private static final double SIZE = 8; - private final double deltax = 15; + private final double deltax = 30; private final ETile orig; + private final HColor lineColor; - public ETileWithCircles(ETile orig) { + public ETileWithCircles(ETile orig, HColor lineColor) { this.orig = orig; + this.lineColor = lineColor; } @Override - public XDimension2D calculateDimension(StringBounder stringBounder) { - return XDimension2D.delta(orig.calculateDimension(stringBounder), 2 * deltax, 0); + public double getWidth(StringBounder stringBounder) { + return orig.getWidth(stringBounder) + 2 * deltax; + } + + @Override + public double getH1(StringBounder stringBounder) { + return orig.getH1(stringBounder); + } + + @Override + public double getH2(StringBounder stringBounder) { + return orig.getH2(stringBounder); } @Override public void drawU(UGraphic ug) { - final double linePos = linePos(ug.getStringBounder()); + final double linePos = getH1(ug.getStringBounder()); final XDimension2D fullDim = calculateDimension(ug.getStringBounder()); + ug = ug.apply(lineColor).apply(new UStroke(1.5)); orig.drawU(ug.apply(UTranslate.dx(deltax))); - ug = ug.apply(HColors.BLACK).apply(HColors.BLACK.bg()); - final UEllipse circle = new UEllipse(SIZE, SIZE); - ug.apply(new UTranslate(0, linePos - SIZE / 2)).draw(circle); - ug.apply(new UTranslate(fullDim.getWidth() - SIZE / 2, linePos - SIZE / 2)).draw(circle); - ETileConcatenation.drawHline(ug, linePos, SIZE / 2, deltax); - ETileConcatenation.drawHline(ug, linePos, fullDim.getWidth() - deltax, fullDim.getWidth() - SIZE / 2); - } - @Override - public double linePos(StringBounder stringBounder) { - return orig.linePos(stringBounder); + final UEllipse circle = new UEllipse(SIZE, SIZE); + + ug.apply(new UStroke(2)).apply(new UTranslate(0, linePos - SIZE / 2)).draw(circle); + ug.apply(new UStroke(1)).apply(new CopyForegroundColorToBackgroundColor()) + .apply(new UTranslate(fullDim.getWidth() - SIZE / 2, linePos - SIZE / 2)).draw(circle); + + ug = ug.apply(new UStroke(1.5)); + drawHlineDirected(ug, linePos, SIZE, deltax, 0.5); + drawHlineDirected(ug, linePos, fullDim.getWidth() - deltax, fullDim.getWidth() - SIZE / 2, 0.5); } @Override diff --git a/src/net/sourceforge/plantuml/ebnf/ETileZeroOrMore.java b/src/net/sourceforge/plantuml/ebnf/ETileZeroOrMore.java new file mode 100644 index 000000000..7a927212e --- /dev/null +++ b/src/net/sourceforge/plantuml/ebnf/ETileZeroOrMore.java @@ -0,0 +1,122 @@ +/* ======================================================================== + * 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.ebnf; + +import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.URectangle; +import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.color.HColors; + +public class ETileZeroOrMore extends ETile { + + private final double deltax; + private final double deltay = 20; + private final ETile orig; + private final boolean specialForAlternate; + + public ETileZeroOrMore(ETile orig) { + this.orig = orig; + this.specialForAlternate = orig instanceof ETileAlternation; + this.deltax = this.specialForAlternate ? 0 : 20; + if (this.specialForAlternate) + ((ETileAlternation) orig).setInZeroOrMore(true); + } + + @Override + public double getH1(StringBounder stringBounder) { + return 10; + } + + @Override + public double getH2(StringBounder stringBounder) { + return 10 + orig.getH1(stringBounder) + orig.getH2(stringBounder); + } + + @Override + public double getWidth(StringBounder stringBounder) { + return orig.getWidth(stringBounder) + 2 * deltax; + } + + @Override + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final XDimension2D fullDim = calculateDimension(stringBounder); + if (TRACE) { + if (specialForAlternate) + ug.apply(HColors.COL_B38D22).draw(new URectangle(fullDim)); + else + ug.apply(HColors.GREEN).draw(new URectangle(fullDim)); + } + + final double linePos = getH1(stringBounder); + + drawHline(ug, linePos, 0, fullDim.getWidth()); + final double corner = 12; + + if (specialForAlternate) { + CornerCurved.createNE_arrow(corner).drawU(ug.apply(new UTranslate(corner, linePos))); + CornerCurved.createNW(corner).drawU(ug.apply(new UTranslate(corner, linePos))); + + final double posB = fullDim.getWidth() - corner; + CornerCurved.createNW_arrow(corner).drawU(ug.apply(new UTranslate(posB, linePos))); + CornerCurved.createNE(corner).drawU(ug.apply(new UTranslate(posB, linePos))); + + } else { + + CornerCurved.createNE_arrow(corner).drawU(ug.apply(new UTranslate(deltax - corner, linePos))); + CornerCurved.createNW(corner).drawU(ug.apply(new UTranslate(deltax - corner, linePos))); + drawVline(ug, deltax - corner, linePos + corner, deltay + orig.getH1(stringBounder) - corner); + CornerCurved.createSW(corner) + .drawU(ug.apply(new UTranslate(deltax - corner, deltay + orig.getH1(stringBounder)))); + + final double posB = fullDim.getWidth() - deltax + corner; + CornerCurved.createSE(corner).drawU(ug.apply(new UTranslate(posB, deltay + orig.getH1(stringBounder)))); + drawVline(ug, posB, linePos + corner, deltay + orig.getH1(stringBounder) - corner); + CornerCurved.createNW_arrow(corner).drawU(ug.apply(new UTranslate(posB, linePos))); + CornerCurved.createNE(corner).drawU(ug.apply(new UTranslate(posB, linePos))); + } + + orig.drawU(ug.apply(new UTranslate(deltax, deltay))); + } + + @Override + public void push(ETile tile) { + throw new UnsupportedOperationException(); + } + +} diff --git a/src/net/sourceforge/plantuml/ebnf/EbnfEngine.java b/src/net/sourceforge/plantuml/ebnf/EbnfEngine.java index 420bd6741..9a8b476d8 100644 --- a/src/net/sourceforge/plantuml/ebnf/EbnfEngine.java +++ b/src/net/sourceforge/plantuml/ebnf/EbnfEngine.java @@ -39,11 +39,14 @@ import java.util.ArrayDeque; import java.util.Deque; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.ISkinSimple; +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.style.SName; +import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.Style; -import net.sourceforge.plantuml.style.StyleSignatureBasic; +import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; public class EbnfEngine { @@ -52,11 +55,15 @@ public class EbnfEngine { private final FontConfiguration fontConfiguration; private final Style style; private final HColorSet colorSet; + private final ISkinSimple spriteContainer; + private final HColor lineColor; public EbnfEngine(ISkinParam skinParam) { - this.style = getStyleSignature().getMergedStyle(skinParam.getCurrentStyleBuilder()); + this.spriteContainer = skinParam; + this.style = ETile.getStyleSignature().getMergedStyle(skinParam.getCurrentStyleBuilder()); this.fontConfiguration = style.getFontConfiguration(skinParam.getIHtmlColorSet()); this.colorSet = skinParam.getIHtmlColorSet(); + this.lineColor = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); } @@ -69,9 +76,17 @@ public class EbnfEngine { stack.addFirst(new ETileOptional(arg1)); } - public void repetition() { + public void repetitionZeroOrMore(boolean isTheo) { final ETile arg1 = stack.removeFirst(); - stack.addFirst(new ETileRepetition(arg1)); + if (isTheo) + stack.addFirst(new ETileOptional(new ETileOneOrMore(arg1))); + else + stack.addFirst(new ETileZeroOrMore(arg1)); + } + + public void repetitionOneOrMore() { + final ETile arg1 = stack.removeFirst(); + stack.addFirst(new ETileOneOrMore(arg1)); } public void alternation() { @@ -111,12 +126,13 @@ public class EbnfEngine { public TextBlock getTextBlock() { if (stack.size() != 1) - throw new IllegalStateException(); - return new ETileWithCircles(stack.peekFirst()); + return syntaxError(fontConfiguration, spriteContainer); + return new ETileWithCircles(stack.peekFirst(), lineColor); } - private StyleSignatureBasic getStyleSignature() { - return StyleSignatureBasic.of(SName.root, SName.element, SName.activityDiagram, SName.activity); + public static TextBlock syntaxError(FontConfiguration fontConfiguration, ISkinSimple spriteContainer) { + final Display msg = Display.create("Syntax error!"); + return msg.create(fontConfiguration, HorizontalAlignment.LEFT, spriteContainer); } } diff --git a/src/net/sourceforge/plantuml/ebnf/EbnfExpressions.java b/src/net/sourceforge/plantuml/ebnf/EbnfExpressions.java index 4b40b3eac..1a3a138d5 100644 --- a/src/net/sourceforge/plantuml/ebnf/EbnfExpressions.java +++ b/src/net/sourceforge/plantuml/ebnf/EbnfExpressions.java @@ -39,14 +39,22 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import net.sourceforge.plantuml.Pragma; + public class EbnfExpressions { - public static List build(List data) { + public static List build(List data, Pragma pragma) { final List all = new ArrayList<>(); + final boolean isTheo = pragma.isDefine("theo"); + final CharIterator it = new CharIteratorImpl(data); - while (it.peek() != 0) - all.add(new EbnfSingleExpression(it)); + while (it.peek() != 0) { + final EbnfSingleExpression tmp = EbnfSingleExpression.create(it, isTheo); + if (tmp.isEmpty()) + break; + all.add(tmp); + } return Collections.unmodifiableList(all); } diff --git a/src/net/sourceforge/plantuml/ebnf/EbnfSingleExpression.java b/src/net/sourceforge/plantuml/ebnf/EbnfSingleExpression.java index bb219ce03..b682e68ec 100644 --- a/src/net/sourceforge/plantuml/ebnf/EbnfSingleExpression.java +++ b/src/net/sourceforge/plantuml/ebnf/EbnfSingleExpression.java @@ -44,18 +44,30 @@ 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.StyleSignatureBasic; public class EbnfSingleExpression { - final List tokens = new ArrayList<>(); + private final List tokens = new ArrayList<>(); + private final boolean isTheo; - EbnfSingleExpression(CharIterator it) { + public static EbnfSingleExpression create(CharIterator it, boolean isTheo) { + return new EbnfSingleExpression(it, isTheo); + } + + private EbnfSingleExpression(CharIterator it, boolean isTheo) { + this.isTheo = isTheo; while (true) { final char ch = it.peek(); if (Character.isWhitespace(ch)) { + } else if (ch == '-') { + final int size = tokens.size(); + if (size > 0 && tokens.get(size - 1).getSymbol() == Symbol.REPETITION_CLOSE) { + tokens.set(size - 1, new Token(Symbol.REPETITION_MINUS_CLOSE, null)); + } else { + tokens.clear(); + return; + } } else if (isLetterOrDigit(ch)) { final String litteral = readLitteral(it); tokens.add(new Token(Symbol.LITTERAL, litteral)); @@ -87,32 +99,43 @@ public class EbnfSingleExpression { } else if (ch == '\'') { final String litteral = readString(it); tokens.add(new Token(Symbol.TERMINAL_STRING2, litteral)); - } else - throw new UnsupportedOperationException("" + ch); + } else { + tokens.clear(); + return; + } it.next(); continue; } } - private StyleSignatureBasic getStyleSignature() { - return StyleSignatureBasic.of(SName.root, SName.element, SName.activityDiagram, SName.activity); - } - public TextBlock getUDrawable(ISkinParam skinParam) { - final Iterator iterator = tokens.iterator(); - final Token name = iterator.next(); - final Token definition = iterator.next(); - final List full = new ShuntingYard(iterator).getOuputQueue(); - - final TextBlock main = getMainDrawing(skinParam, full.iterator()); - - final Style style = getStyleSignature().getMergedStyle(skinParam.getCurrentStyleBuilder()); + final Style style = ETile.getStyleSignature().getMergedStyle(skinParam.getCurrentStyleBuilder()); final FontConfiguration fc = style.getFontConfiguration(skinParam.getIHtmlColorSet()); - final TitleBox titleBox = new TitleBox(name.getData() + ":", fc); + if (tokens.size() == 0) + return EbnfEngine.syntaxError(fc, skinParam); - return TextBlockUtils.mergeTB(titleBox, TextBlockUtils.withMargin(main, 0, 0, 10, 15), - HorizontalAlignment.LEFT); + try { + final Iterator iterator = tokens.iterator(); + final Token name = iterator.next(); + final Token definition = iterator.next(); + if (definition.getSymbol() != Symbol.DEFINITION) + return EbnfEngine.syntaxError(fc, skinParam); + + final List full = new ShuntingYard(iterator).getOuputQueue(); + // System.err.println("full=" + full); + if (full.size() == 0) + return EbnfEngine.syntaxError(fc, skinParam); + + final TextBlock main = getMainDrawing(skinParam, full.iterator()); + final TitleBox titleBox = new TitleBox(name.getData(), fc); + + return TextBlockUtils.mergeTB(titleBox, TextBlockUtils.withMargin(main, 0, 0, 10, 15), + HorizontalAlignment.LEFT); + } catch (Exception e) { + e.printStackTrace(); + return EbnfEngine.syntaxError(fc, skinParam); + } } private TextBlock getMainDrawing(ISkinParam skinParam, Iterator it) { @@ -128,8 +151,10 @@ public class EbnfSingleExpression { engine.concatenation(); else if (element.getSymbol() == Symbol.OPTIONAL) engine.optional(); - else if (element.getSymbol() == Symbol.REPETITION) - engine.repetition(); + else if (element.getSymbol() == Symbol.REPETITION_ZERO_OR_MORE) + engine.repetitionZeroOrMore(isTheo); + else if (element.getSymbol() == Symbol.REPETITION_ONE_OR_MORE) + engine.repetitionOneOrMore(); else throw new UnsupportedOperationException(element.toString()); } @@ -165,6 +190,10 @@ public class EbnfSingleExpression { return ch == '-' || ch == '_' || Character.isLetterOrDigit(ch); } + public boolean isEmpty() { + return tokens.size() == 0; + } + } interface CharIterator { @@ -175,12 +204,14 @@ interface CharIterator { class CharIteratorImpl implements CharIterator { - final private List data; + final private List data = new ArrayList<>(); private int line = 0; private int pos = 0; - public CharIteratorImpl(List data) { - this.data = data; + public CharIteratorImpl(List input) { + for (String s : input) + if (s.trim().length() > 0) + data.add(s.trim()); } public char peek() { diff --git a/src/net/sourceforge/plantuml/ebnf/PSystemEbnf.java b/src/net/sourceforge/plantuml/ebnf/PSystemEbnf.java index dd135afd2..60516b99f 100644 --- a/src/net/sourceforge/plantuml/ebnf/PSystemEbnf.java +++ b/src/net/sourceforge/plantuml/ebnf/PSystemEbnf.java @@ -46,9 +46,11 @@ import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.UmlSource; +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.Style; import net.sourceforge.plantuml.svek.TextBlockBackcolored; public class PSystemEbnf extends TitledDiagram { @@ -63,8 +65,8 @@ public class PSystemEbnf extends TitledDiagram { return new DiagramDescription("(EBNF)"); } - public void doCommandLine(String line) { - lines.add(line); + public void addLine(String line) { + lines.add(line.trim()); } @Override @@ -74,7 +76,15 @@ public class PSystemEbnf extends TitledDiagram { } private TextBlockBackcolored getTextBlock() { - final List all = EbnfExpressions.build(lines); + final List all = EbnfExpressions.build(lines, getPragma()); + if (all.size() == 0) { + final Style style = ETile.getStyleSignature().getMergedStyle(getSkinParam().getCurrentStyleBuilder()); + final FontConfiguration fc = style.getFontConfiguration(getSkinParam().getIHtmlColorSet()); + + final TextBlock tmp = EbnfEngine.syntaxError(fc, getSkinParam()); + return TextBlockUtils.addBackcolor(tmp, null); + } + TextBlock result = all.get(0).getUDrawable(getSkinParam()); for (int i = 1; i < all.size(); i++) result = TextBlockUtils.mergeTB(result, all.get(i).getUDrawable(getSkinParam()), HorizontalAlignment.LEFT); diff --git a/src/net/sourceforge/plantuml/ebnf/PSystemEbnfFactory.java b/src/net/sourceforge/plantuml/ebnf/PSystemEbnfFactory.java index 5448f45f3..2a768d554 100644 --- a/src/net/sourceforge/plantuml/ebnf/PSystemEbnfFactory.java +++ b/src/net/sourceforge/plantuml/ebnf/PSystemEbnfFactory.java @@ -35,28 +35,35 @@ */ package net.sourceforge.plantuml.ebnf; -import net.sourceforge.plantuml.command.PSystemBasicFactory; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import net.sourceforge.plantuml.command.Command; +import net.sourceforge.plantuml.command.CommonCommands; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.core.DiagramType; import net.sourceforge.plantuml.core.UmlSource; -public class PSystemEbnfFactory extends PSystemBasicFactory { +public class PSystemEbnfFactory extends PSystemCommandFactory { public PSystemEbnfFactory() { super(DiagramType.EBNF); } @Override - public PSystemEbnf initDiagram(UmlSource source, String startLine) { - if (getDiagramType() == DiagramType.EBNF) - return new PSystemEbnf(source); + protected List createCommands() { - return null; + final List cmds = new ArrayList<>(); + CommonCommands.addCommonCommands1(cmds); + cmds.add(new CommandEBnfSingleLine()); + cmds.add(new CommandEbnfMultiline()); + return cmds; } @Override - public PSystemEbnf executeLine(UmlSource source, PSystemEbnf system, String line) { - system.doCommandLine(line); - return system; + public PSystemEbnf createEmptyDiagram(UmlSource source, Map skinParam) { + return new PSystemEbnf(source); } } diff --git a/src/net/sourceforge/plantuml/ebnf/ShuntingYard.java b/src/net/sourceforge/plantuml/ebnf/ShuntingYard.java index a26e61d2e..59c161bff 100644 --- a/src/net/sourceforge/plantuml/ebnf/ShuntingYard.java +++ b/src/net/sourceforge/plantuml/ebnf/ShuntingYard.java @@ -50,6 +50,9 @@ public class ShuntingYard { public ShuntingYard(Iterator it) { while (it.hasNext()) { final Token token = it.next(); + // System.err.println("token=" + token); + // System.err.println("ouputQueue=" + ouputQueue); + // System.err.println("operatorStack=" + operatorStack); if (token.getSymbol() == Symbol.LITTERAL || token.getSymbol() == Symbol.TERMINAL_STRING1 || token.getSymbol() == Symbol.TERMINAL_STRING2) { ouputQueue.add(token); @@ -67,13 +70,28 @@ public class ShuntingYard { } else if (token.getSymbol() == Symbol.OPTIONAL_OPEN) { operatorStack.addFirst(new Token(Symbol.OPTIONAL, null)); } else if (token.getSymbol() == Symbol.OPTIONAL_CLOSE) { + while (thereIsAnOperatorAtTheTopOfTheOperatorStack()) + ouputQueue.add(operatorStack.removeFirst()); final Token first = operatorStack.removeFirst(); + if (first.getSymbol() != Symbol.OPTIONAL) + throw new IllegalStateException(); ouputQueue.add(first); } else if (token.getSymbol() == Symbol.REPETITION_OPEN) { - operatorStack.addFirst(new Token(Symbol.REPETITION, null)); + operatorStack.addFirst(new Token(Symbol.REPETITION_ZERO_OR_MORE, null)); } else if (token.getSymbol() == Symbol.REPETITION_CLOSE) { + while (thereIsAnOperatorAtTheTopOfTheOperatorStack()) + ouputQueue.add(operatorStack.removeFirst()); final Token first = operatorStack.removeFirst(); + if (first.getSymbol() != Symbol.REPETITION_ZERO_OR_MORE) + throw new IllegalStateException(); ouputQueue.add(first); + } else if (token.getSymbol() == Symbol.REPETITION_MINUS_CLOSE) { + while (thereIsAnOperatorAtTheTopOfTheOperatorStack()) + ouputQueue.add(operatorStack.removeFirst()); + final Token first = operatorStack.removeFirst(); + if (first.getSymbol() != Symbol.REPETITION_ZERO_OR_MORE) + throw new IllegalStateException(); + ouputQueue.add(new Token(Symbol.REPETITION_ONE_OR_MORE, null)); } else { throw new UnsupportedOperationException(token.toString()); } @@ -81,10 +99,25 @@ public class ShuntingYard { } while (operatorStack.isEmpty() == false) { final Token token = operatorStack.removeFirst(); + if (token.getSymbol() == Symbol.OPTIONAL || token.getSymbol() == Symbol.REPETITION_ONE_OR_MORE + || token.getSymbol() == Symbol.REPETITION_ZERO_OR_MORE) { + ouputQueue.clear(); + return; + } ouputQueue.add(token); } } + private boolean thereIsAFunctionAtTheTopOfTheOperatorStack() { + final Token top = operatorStack.peekFirst(); + return top != null && top.getSymbol().isFunction(); + } + + private boolean thereIsAnOperatorAtTheTopOfTheOperatorStack() { + final Token top = operatorStack.peekFirst(); + return top != null && top.getSymbol().isOperator(); + } + private boolean thereIsAnOperatorAtTheTopOfTheOperatorStackWithGreaterPrecedence(Token token) { final Token top = operatorStack.peekFirst(); if (top != null && top.getSymbol().isOperator() diff --git a/src/net/sourceforge/plantuml/ebnf/Symbol.java b/src/net/sourceforge/plantuml/ebnf/Symbol.java index 6723d953d..79d8de3f5 100644 --- a/src/net/sourceforge/plantuml/ebnf/Symbol.java +++ b/src/net/sourceforge/plantuml/ebnf/Symbol.java @@ -49,7 +49,9 @@ public enum Symbol { OPTIONAL, REPETITION_OPEN, // { REPETITION_CLOSE, // } - REPETITION, // + REPETITION_MINUS_CLOSE, // } + REPETITION_ZERO_OR_MORE, // + REPETITION_ONE_OR_MORE, // GROUPING_OPEN, // ( GROUPING_CLOSE, // ) TERMINAL_STRING1, // " " @@ -72,4 +74,8 @@ public enum Symbol { return this == CONCATENATION || this == ALTERNATION; } + boolean isFunction() { + return this == OPTIONAL || this == REPETITION_ZERO_OR_MORE; + } + } diff --git a/src/net/sourceforge/plantuml/ebnf/Token.java b/src/net/sourceforge/plantuml/ebnf/Token.java index c135b1545..98694a461 100644 --- a/src/net/sourceforge/plantuml/ebnf/Token.java +++ b/src/net/sourceforge/plantuml/ebnf/Token.java @@ -43,6 +43,8 @@ public class Token { public Token(Symbol symbol, String data) { this.symbol = symbol; this.data = data; + if (data != null && data.length() == 0) + throw new IllegalArgumentException(); } @Override diff --git a/src/net/sourceforge/plantuml/ebnf/VLineCurved.java b/src/net/sourceforge/plantuml/ebnf/ZigZag.java similarity index 73% rename from src/net/sourceforge/plantuml/ebnf/VLineCurved.java rename to src/net/sourceforge/plantuml/ebnf/ZigZag.java index 06a95aaa0..bb4f46441 100644 --- a/src/net/sourceforge/plantuml/ebnf/VLineCurved.java +++ b/src/net/sourceforge/plantuml/ebnf/ZigZag.java @@ -37,27 +37,25 @@ package net.sourceforge.plantuml.ebnf; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.UPath; -public class VLineCurved implements UDrawable { +public class ZigZag implements UDrawable { - private final double height; - private final double delta; - private final UDrawable top; - private final UDrawable bottom; + private final double dx; + private final double dy; - public VLineCurved(double height, double delta, UDrawable top, UDrawable bottom) { - this.height = height; - this.delta = delta; - this.bottom = bottom; - this.top = top; + public ZigZag(double dx, double dy) { + this.dx = dx; + this.dy = dy; } @Override public void drawU(UGraphic ug) { - bottom.drawU(ug.apply(UTranslate.dy(height))); - ETileConcatenation.drawVline(ug, 0, delta, height - delta); - top.drawU(ug); + final UPath path = new UPath(); + path.moveTo(0, 0); + final double a = 0.8; + path.cubicTo(dx * a, 0, dx - dx * a, dy, dx, dy); + ug.draw(path); } } diff --git a/src/net/sourceforge/plantuml/eggs/PSystemColors.java b/src/net/sourceforge/plantuml/eggs/PSystemColors.java index e51d170f0..bdbc815b3 100644 --- a/src/net/sourceforge/plantuml/eggs/PSystemColors.java +++ b/src/net/sourceforge/plantuml/eggs/PSystemColors.java @@ -60,6 +60,7 @@ import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.URectangle; +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.HColorSet; @@ -258,7 +259,7 @@ public class PSystemColors extends PlainDiagram implements UDrawable { private TextBlock getTextName(final UFont font, String name, final HColor color) { final HColor opposite = color.opposite(); - final FontConfiguration fc = FontConfiguration.create(font, opposite, HColors.BLUE, true); + final FontConfiguration fc = FontConfiguration.create(font, opposite, HColors.BLUE, new UStroke()); final TextBlock tt = Display.getWithNewlines(name).create(fc, HorizontalAlignment.CENTER, new SpriteContainerEmpty()); return tt; diff --git a/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java b/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java index 9cb976b58..d12ed66b9 100644 --- a/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java +++ b/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java @@ -176,8 +176,8 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { return label; } - private TextBlock getQualifier(Link link, int n) { - final String tmp = n == 1 ? link.getQualifier1() : link.getQualifier2(); + private TextBlock getQuantifier(Link link, int n) { + final String tmp = n == 1 ? link.getQuantifier1() : link.getQuantifier2(); if (tmp == null) return null; @@ -323,7 +323,7 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { } final ElkPath elkPath = new ElkPath(diagram, SName.classDiagram, link, edge, getLabel(link), - getQualifier(link, 1), getQualifier(link, 2), magicY2); + getQuantifier(link, 1), getQuantifier(link, 2), magicY2); elkPath.drawU(ug.apply(new UTranslate(translate))); } @@ -497,9 +497,9 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { edge.setProperty(CoreOptions.EDGE_LABELS_INLINE, true); // edge.setProperty(CoreOptions.EDGE_TYPE, EdgeType.ASSOCIATION); } - if (link.getQualifier1() != null) { + if (link.getQuantifier1() != null) { final ElkLabel edgeLabel = ElkGraphUtil.createLabel(edge); - final XDimension2D dim = getQualifier(link, 1).calculateDimension(stringBounder); + final XDimension2D dim = getQuantifier(link, 1).calculateDimension(stringBounder); // Nasty trick, we store the kind of label in the text edgeLabel.setText("1"); edgeLabel.setDimensions(dim.getWidth(), dim.getHeight()); @@ -508,9 +508,9 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { edge.setProperty(CoreOptions.EDGE_LABELS_INLINE, true); // edge.setProperty(CoreOptions.EDGE_TYPE, EdgeType.ASSOCIATION); } - if (link.getQualifier2() != null) { + if (link.getQuantifier2() != null) { final ElkLabel edgeLabel = ElkGraphUtil.createLabel(edge); - final XDimension2D dim = getQualifier(link, 2).calculateDimension(stringBounder); + final XDimension2D dim = getQuantifier(link, 2).calculateDimension(stringBounder); // Nasty trick, we store the kind of label in the text edgeLabel.setText("2"); edgeLabel.setDimensions(dim.getWidth(), dim.getHeight()); diff --git a/src/net/sourceforge/plantuml/emoji/SvgNanoParser.java b/src/net/sourceforge/plantuml/emoji/SvgNanoParser.java index 8ec8654bf..7c7851f9f 100644 --- a/src/net/sourceforge/plantuml/emoji/SvgNanoParser.java +++ b/src/net/sourceforge/plantuml/emoji/SvgNanoParser.java @@ -228,7 +228,7 @@ public class SvgNanoParser implements Sprite { if (m.find()) { final String text = m.group(1); HColor color = HColorSet.instance().getColorOrWhite(fill); - final FontConfiguration fc = FontConfiguration.create(UFont.sansSerif(fontSize), color, color, false); + final FontConfiguration fc = FontConfiguration.create(UFont.sansSerif(fontSize), color, color, null); final UText utext = new UText(text, fc); UGraphic ug = ugs.getUg(); ug = ug.apply(new UTranslate(x, y)); diff --git a/src/net/sourceforge/plantuml/error/PSystemError.java b/src/net/sourceforge/plantuml/error/PSystemError.java index 3434dc9d6..0bd4e252b 100644 --- a/src/net/sourceforge/plantuml/error/PSystemError.java +++ b/src/net/sourceforge/plantuml/error/PSystemError.java @@ -352,7 +352,7 @@ public abstract class PSystemError extends PlainDiagram { "Details on [[https://plantuml.com/dedication]]"); final UFont font = UFont.sansSerif(14); - final FontConfiguration fc = FontConfiguration.create(font, HColors.BLACK, HColors.BLACK, false); + final FontConfiguration fc = FontConfiguration.create(font, HColors.BLACK, HColors.BLACK, null); final TextBlock text = TextBlockUtils .withMargin(disp.create(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty()), 10, 0); final TextBlock result; @@ -373,7 +373,7 @@ public abstract class PSystemError extends PlainDiagram { "Details on [[http://plantuml.com/adopt]]", " "); final UFont font = UFont.sansSerif(14); - final FontConfiguration fc = FontConfiguration.create(font, HColors.BLACK, HColors.BLACK, false); + final FontConfiguration fc = FontConfiguration.create(font, HColors.BLACK, HColors.BLACK, null); final TextBlock text = TextBlockUtils .withMargin(disp.create(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty()), 10, 0); final TextBlock result; diff --git a/src/net/sourceforge/plantuml/gitlog/MagicBox.java b/src/net/sourceforge/plantuml/gitlog/MagicBox.java index ca1d73afd..10b2a6abf 100644 --- a/src/net/sourceforge/plantuml/gitlog/MagicBox.java +++ b/src/net/sourceforge/plantuml/gitlog/MagicBox.java @@ -68,13 +68,13 @@ public class MagicBox { } private TextBlock getSmallBlock() { - final FontConfiguration fc = FontConfiguration.create(UFont.monospaced(15).bold(), fontColor, fontColor, false); + final FontConfiguration fc = FontConfiguration.create(UFont.monospaced(15).bold(), fontColor, fontColor, null); return node.getDisplay().create(fc, HorizontalAlignment.CENTER, skinParam); } private TextBlock getCommentBlock() { if (node.getComment() != null && node.isTop()) { - final FontConfiguration tag = FontConfiguration.create(UFont.sansSerif(13), fontColor, fontColor, false); + final FontConfiguration tag = FontConfiguration.create(UFont.sansSerif(13), fontColor, fontColor, null); return Display.create(node.getComment()).create(tag, HorizontalAlignment.CENTER, skinParam); } return TextBlockUtils.empty(0, 0); diff --git a/src/net/sourceforge/plantuml/graphic/BigFrame.java b/src/net/sourceforge/plantuml/graphic/BigFrame.java new file mode 100644 index 000000000..20aca3de8 --- /dev/null +++ b/src/net/sourceforge/plantuml/graphic/BigFrame.java @@ -0,0 +1,113 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, 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.graphic; + +import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.ugraphic.Shadowable; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UPath; +import net.sourceforge.plantuml.ugraphic.URectangle; +import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.color.HColors; + +public class BigFrame extends AbstractTextBlock { + private final TextBlock title; + private final double width; + private final double height; + private final SymbolContext symbolContext; + + public BigFrame(final TextBlock title, final double width, final double height, final SymbolContext symbolContext) { + this.title = title; + this.width = width; + this.height = height; + this.symbolContext = symbolContext; + } + + private double getYpos(XDimension2D dimTitle) { + if (dimTitle.getWidth() == 0) + return 12; + + return dimTitle.getHeight() + 3; + } + + public void drawU(UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final XDimension2D dim = calculateDimension(stringBounder); + ug = symbolContext.apply(ug); + final XDimension2D dimTitle = title.calculateDimension(stringBounder); + final double widthFull = dim.getWidth(); + final Shadowable rectangle = new URectangle(widthFull, dim.getHeight()).rounded(symbolContext.getRoundCorner()) + .ignoreForCompressionOnX().ignoreForCompressionOnY(); + rectangle.setDeltaShadow(symbolContext.getDeltaShadow()); + + ug.draw(rectangle); + + final double textWidth; + final int cornersize; + if (dimTitle.getWidth() == 0) { + textWidth = widthFull / 3; + cornersize = 7; + } else { + textWidth = dimTitle.getWidth() + 10; + cornersize = 10; + } + final double textHeight = getYpos(dimTitle); + + final UPath line = new UPath(); + line.setIgnoreForCompressionOnX(); + line.moveTo(textWidth, 0); + + line.lineTo(textWidth, textHeight - cornersize); + line.lineTo(textWidth - cornersize, textHeight); + + line.lineTo(0, textHeight); + ug.apply(HColors.none().bg()).draw(line); + final double widthTitle = title.calculateDimension(stringBounder).getWidth(); + + // Temporary hack... + if (widthFull - widthTitle < 25) + title.drawU(ug.apply(new UTranslate(3, 1))); + else + ug.apply(new UTranslate(3, 1)).draw(new SpecialText(title)); + + } + + @Override + public XDimension2D calculateDimension(StringBounder stringBounder) { + return new XDimension2D(width, height); + } + +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/graphic/FontConfiguration.java b/src/net/sourceforge/plantuml/graphic/FontConfiguration.java index c5823d2bb..b91363106 100644 --- a/src/net/sourceforge/plantuml/graphic/FontConfiguration.java +++ b/src/net/sourceforge/plantuml/graphic/FontConfiguration.java @@ -48,6 +48,7 @@ import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColors; @@ -57,13 +58,14 @@ public class FontConfiguration { private final UFont currentFont; private final UFont motherFont; private final HColor motherColor; - private final HColor hyperlinkColor; private final HColor currentColor; private final HColor extendedColor; private final FontPosition fontPosition; private final SvgAttributes svgAttributes; - private final boolean hyperlink; - private final boolean useUnderlineForHyperlink; + + private final UStroke hyperlinkUnderlineStroke; + private final HColor hyperlinkColor; + private final int tabSize; public String toStringDebug() { @@ -71,18 +73,18 @@ public class FontConfiguration { } public static FontConfiguration create(UFont font, HColor color, HColor hyperlinkColor, - boolean useUnderlineForHyperlink) { - return create(font, color, hyperlinkColor, useUnderlineForHyperlink, 8); + UStroke hyperlinkUnderlineStroke) { + return create(font, color, hyperlinkColor, hyperlinkUnderlineStroke, 8); } public static FontConfiguration create(UFont font, HColor color, HColor hyperlinkColor, - boolean useUnderlineForHyperlink, int tabSize) { + UStroke hyperlinkUnderlineStroke, int tabSize) { return new FontConfiguration(getStyles(font), font, color, font, color, null, FontPosition.NORMAL, - new SvgAttributes(), false, hyperlinkColor, useUnderlineForHyperlink, tabSize); + new SvgAttributes(), hyperlinkColor, hyperlinkUnderlineStroke, tabSize); } public static FontConfiguration blackBlueTrue(UFont font) { - return create(font, HColors.BLACK.withDark(HColors.WHITE), HColors.BLUE, true, 8); + return create(font, HColors.BLACK.withDark(HColors.WHITE), HColors.BLUE, new UStroke(), 8); } public static FontConfiguration create(ISkinParam skinParam, FontParam fontParam, Stereotype stereo) { @@ -97,37 +99,27 @@ public class FontConfiguration { public static FontConfiguration create(ISkinParam skinParam, Style style, Colors colors) { final HColor hyperlinkColor = style.value(PName.HyperLinkColor).asColor(skinParam.getIHtmlColorSet()); - final boolean useUnderlineForHyperlink = skinParam.useUnderlineForHyperlink(); + final UStroke hyperlinkUnderlineStroke = skinParam.useUnderlineForHyperlink(); HColor color = colors == null ? null : colors.getColor(ColorType.TEXT); if (color == null) color = style.value(PName.FontColor).asColor(skinParam.getIHtmlColorSet()); - return create(style.getUFont(), color, hyperlinkColor, useUnderlineForHyperlink, skinParam.getTabSize()); + return create(style.getUFont(), color, hyperlinkColor, hyperlinkUnderlineStroke, skinParam.getTabSize()); } // --- - public final boolean useUnderlineForHyperlink() { - return useUnderlineForHyperlink; - } - -// public final HColor getHyperlinkColor() { -// return hyperlinkColor; -// } - - // --- - private static EnumSet getStyles(UFont font) { final boolean bold = font.isBold(); final boolean italic = font.isItalic(); - if (bold && italic) { + if (bold && italic) return EnumSet.of(FontStyle.ITALIC, FontStyle.BOLD); - } - if (bold) { + + if (bold) return EnumSet.of(FontStyle.BOLD); - } - if (italic) { + + if (italic) return EnumSet.of(FontStyle.ITALIC); - } + return EnumSet.noneOf(FontStyle.class); } @@ -138,7 +130,7 @@ public class FontConfiguration { private FontConfiguration(EnumSet styles, UFont motherFont, HColor motherColor, UFont currentFont, HColor currentColor, HColor extendedColor, FontPosition fontPosition, SvgAttributes svgAttributes, - boolean hyperlink, HColor hyperlinkColor, boolean useUnderlineForHyperlink, int tabSize) { + HColor hyperlinkColor, UStroke hyperlinkUnderlineStroke, int tabSize) { this.styles = styles; this.currentFont = currentFont; this.motherFont = motherFont; @@ -147,61 +139,54 @@ public class FontConfiguration { this.extendedColor = extendedColor; this.fontPosition = fontPosition; this.svgAttributes = svgAttributes; - this.hyperlink = hyperlink; this.hyperlinkColor = hyperlinkColor; - this.useUnderlineForHyperlink = useUnderlineForHyperlink; + this.hyperlinkUnderlineStroke = hyperlinkUnderlineStroke; this.tabSize = tabSize; } public FontConfiguration forceFont(UFont newFont, HColor htmlColorForStereotype) { - if (newFont == null) { + if (newFont == null) return add(FontStyle.ITALIC); - } + FontConfiguration result = new FontConfiguration(styles, newFont, motherColor, newFont, currentColor, - extendedColor, fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink, - tabSize); - if (htmlColorForStereotype != null) { + extendedColor, fontPosition, svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize); + if (htmlColorForStereotype != null) result = result.changeColor(htmlColorForStereotype); - } + return result; } public FontConfiguration changeAttributes(SvgAttributes toBeAdded) { return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, extendedColor, - fontPosition, svgAttributes.add(toBeAdded), hyperlink, hyperlinkColor, useUnderlineForHyperlink, - tabSize); + fontPosition, svgAttributes.add(toBeAdded), hyperlinkColor, hyperlinkUnderlineStroke, tabSize); } private FontConfiguration withHyperlink() { - return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, extendedColor, - fontPosition, svgAttributes, true, hyperlinkColor, useUnderlineForHyperlink, tabSize); + return new FontConfiguration(styles, motherFont, motherColor, currentFont, hyperlinkColor, extendedColor, + fontPosition, svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize); } public FontConfiguration changeColor(HColor newHtmlColor) { - if (hyperlink) - return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, extendedColor, - fontPosition, svgAttributes, hyperlink, newHtmlColor, useUnderlineForHyperlink, tabSize); return new FontConfiguration(styles, motherFont, motherColor, currentFont, newHtmlColor, extendedColor, - fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink, tabSize); + fontPosition, svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize); } public FontConfiguration mute(Colors colors) { final HColor color = Objects.requireNonNull(colors).getColor(ColorType.TEXT); - if (color == null) { + if (color == null) return this; - } + return changeColor(color); } FontConfiguration changeExtendedColor(HColor newExtendedColor) { return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, newExtendedColor, - fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink, tabSize); + fontPosition, svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize); } public FontConfiguration changeSize(float size) { return new FontConfiguration(styles, motherFont, motherColor, currentFont.withSize(size), currentColor, - extendedColor, fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink, - tabSize); + extendedColor, fontPosition, svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize); } public FontConfiguration bigger(double delta) { @@ -210,28 +195,28 @@ public class FontConfiguration { public FontConfiguration changeFontPosition(FontPosition fontPosition) { return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, extendedColor, - fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink, tabSize); + fontPosition, svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize); } public FontConfiguration changeFamily(String family) { return new FontConfiguration(styles, motherFont, motherColor, new UFont(family, currentFont.getStyle(), currentFont.getSize()), currentColor, extendedColor, - fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink, tabSize); + fontPosition, svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize); } public FontConfiguration resetFont() { return new FontConfiguration(styles, motherFont, motherColor, motherFont, motherColor, null, - FontPosition.NORMAL, new SvgAttributes(), hyperlink, hyperlinkColor, useUnderlineForHyperlink, tabSize); + FontPosition.NORMAL, new SvgAttributes(), hyperlinkColor, hyperlinkUnderlineStroke, tabSize); } public FontConfiguration add(FontStyle style) { final EnumSet r = styles.clone(); - if (style == FontStyle.PLAIN) { + if (style == FontStyle.PLAIN) r.clear(); - } + r.add(style); return new FontConfiguration(r, motherFont, motherColor, currentFont, currentColor, extendedColor, fontPosition, - svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink, tabSize); + svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize); } public FontConfiguration italic() { @@ -259,9 +244,9 @@ public class FontConfiguration { } public FontConfiguration hyperlink() { - if (useUnderlineForHyperlink) { + if (hyperlinkUnderlineStroke != null) return add(FontStyle.UNDERLINE).withHyperlink(); - } + return withHyperlink(); } @@ -269,7 +254,7 @@ public class FontConfiguration { final EnumSet r = styles.clone(); r.remove(style); return new FontConfiguration(r, motherFont, motherColor, currentFont, currentColor, extendedColor, fontPosition, - svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink, tabSize); + svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize); } public UFont getFont() { @@ -281,9 +266,6 @@ public class FontConfiguration { } public HColor getColor() { - if (hyperlink) { - return hyperlinkColor; - } return currentColor; } @@ -311,4 +293,10 @@ public class FontConfiguration { return tabSize; } + public UStroke getUnderlineStroke() { + return hyperlinkUnderlineStroke; + // return new UStroke(); + // return new UStroke(3, 5, 2); + } + } diff --git a/src/net/sourceforge/plantuml/graphic/GraphicStrings.java b/src/net/sourceforge/plantuml/graphic/GraphicStrings.java index a44d9689f..7a016c635 100644 --- a/src/net/sourceforge/plantuml/graphic/GraphicStrings.java +++ b/src/net/sourceforge/plantuml/graphic/GraphicStrings.java @@ -51,6 +51,7 @@ import net.sourceforge.plantuml.ugraphic.PixelImage; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UImage; +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.HColors; @@ -63,7 +64,7 @@ public class GraphicStrings extends AbstractTextBlock implements IEntityImage { private final static HColor hyperlinkColor = HColors.BLUE; - private final static boolean useUnderlineForHyperlink = true; + private final static UStroke useUnderlineForHyperlink = new UStroke(); private final List strings; @@ -99,13 +100,11 @@ public class GraphicStrings extends AbstractTextBlock implements IEntityImage { } public static TextBlockBackcolored createBlackOnWhite(List strings) { - return new GraphicStrings(strings, sansSerif12(HColors.BLACK), HColors.WHITE, null, null, - CreoleMode.FULL); + return new GraphicStrings(strings, sansSerif12(HColors.BLACK), HColors.WHITE, null, null, CreoleMode.FULL); } public static TextBlockBackcolored createBlackOnWhiteMonospaced(List strings) { - return new GraphicStrings(strings, monospaced14(HColors.BLACK), HColors.WHITE, null, null, - CreoleMode.FULL); + return new GraphicStrings(strings, monospaced14(HColors.BLACK), HColors.WHITE, null, null, CreoleMode.FULL); } public static TextBlockBackcolored createBlackOnWhite(List strings, BufferedImage image, diff --git a/src/net/sourceforge/plantuml/graphic/HtmlCommandFactory.java b/src/net/sourceforge/plantuml/graphic/HtmlCommandFactory.java index 37b83e9e0..13a41c9b9 100644 --- a/src/net/sourceforge/plantuml/graphic/HtmlCommandFactory.java +++ b/src/net/sourceforge/plantuml/graphic/HtmlCommandFactory.java @@ -68,59 +68,47 @@ class HtmlCommandFactory { private Pattern2 htmlTag = MyPattern.cmpile(Splitter.htmlTag); HtmlCommand getHtmlCommand(String s) { - if (htmlTag.matcher(s).matches() == false) { + if (htmlTag.matcher(s).matches() == false) return new Text(s); - } - if (MyPattern.mtches(s, Splitter.imgPattern)) { + + if (MyPattern.mtches(s, Splitter.imgPattern)) return Img.getInstance(s, true); - } - if (MyPattern.mtches(s, Splitter.imgPatternNoSrcColon)) { + if (MyPattern.mtches(s, Splitter.imgPatternNoSrcColon)) return Img.getInstance(s, false); - } - if (addStyle.matcher(s).matches()) { + if (addStyle.matcher(s).matches()) return AddStyle.fromString(s); - } - if (removeStyle.matcher(s).matches()) { + + if (removeStyle.matcher(s).matches()) return new RemoveStyle(FontStyle.getStyle(s)); - } - if (MyPattern.mtches(s, Splitter.fontPattern)) { + if (MyPattern.mtches(s, Splitter.fontPattern)) return new ColorAndSizeChange(s); - } - if (MyPattern.mtches(s, Splitter.fontColorPattern2)) { + if (MyPattern.mtches(s, Splitter.fontColorPattern2)) return new ColorChange(s); - } - if (MyPattern.mtches(s, Splitter.fontSizePattern2)) { + if (MyPattern.mtches(s, Splitter.fontSizePattern2)) return new SizeChange(s); - } - if (MyPattern.mtches(s, Splitter.fontSup)) { + if (MyPattern.mtches(s, Splitter.fontSup)) return new ExposantChange(FontPosition.EXPOSANT); - } - if (MyPattern.mtches(s, Splitter.fontSub)) { + if (MyPattern.mtches(s, Splitter.fontSub)) return new ExposantChange(FontPosition.INDICE); - } - if (MyPattern.mtches(s, Splitter.endFontPattern)) { + if (MyPattern.mtches(s, Splitter.endFontPattern)) return new ResetFont(); - } - if (MyPattern.mtches(s, Splitter.endSupSub)) { + if (MyPattern.mtches(s, Splitter.endSupSub)) return new ExposantChange(FontPosition.NORMAL); - } - if (MyPattern.mtches(s, Splitter.fontFamilyPattern)) { + if (MyPattern.mtches(s, Splitter.fontFamilyPattern)) return new FontFamilyChange(s); - } - if (MyPattern.mtches(s, Splitter.spritePatternForMatch)) { + if (MyPattern.mtches(s, Splitter.spritePatternForMatch)) return new SpriteCommand(s); - } if (MyPattern.mtches(s, Splitter.linkPattern)) { final UrlBuilder urlBuilder = new UrlBuilder(null, UrlMode.STRICT); @@ -129,9 +117,8 @@ class HtmlCommandFactory { return new TextLink(url); } - if (MyPattern.mtches(s, Splitter.svgAttributePattern)) { + if (MyPattern.mtches(s, Splitter.svgAttributePattern)) return new SvgAttributesChange(s); - } return null; } diff --git a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java index 2444bc267..0e57533a1 100644 --- a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java +++ b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java @@ -315,7 +315,10 @@ public class QuoteUtils { "Vg jnf n znggre bs fheiviny. Jr gbbx ab fngvfsnpgvba va gur qrfgehpgvba bs bhe ohvyqref.", "Znxr yvxr n gerr naq trg bhg bs urer", "Vg'f fgebat naq vg'f fhqqra naq vg'f pehry fbzrgvzrf", "Uryy vf rzcgl naq nyy gur qrivyf ner urer", "Rg cbhe fbegve qrf zbzragf qvssvpvyrf...", - "cynaghzy: qvntenzf sbe pbashfvat crbcyr zber", "Ha zbeprnh dhv onynapr qh gbaareer?"); + "cynaghzy: qvntenzf sbe pbashfvat crbcyr zber", "Ha zbeprnh dhv onynapr qh gbaareer?", + "Pnhtug hc va pvepyrf, pbashfvba vf abguvat arj", + "N pbzcyrk flfgrz qrfvtarq sebz fpengpu arire jbexf naq pnaabg or cngpurq hc gb znxr vg jbex.", + "Gur vagrearg vf pbzvat", "Qba'g lbh xabj guvatf unccra sbe n ernfba"); private QuoteUtils() { } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolFrame.java b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java index e5648b064..3e9086760 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolFrame.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java @@ -60,11 +60,11 @@ class USymbolFrame extends USymbol { private void drawFrame(UGraphic ug, double width, double height, XDimension2D dimTitle, double shadowing, double roundCorner) { - final Shadowable shape = new URectangle(width, height).rounded(roundCorner).ignoreForCompressionOnX() + final Shadowable rectangle = new URectangle(width, height).rounded(roundCorner).ignoreForCompressionOnX() .ignoreForCompressionOnY(); - shape.setDeltaShadow(shadowing); + rectangle.setDeltaShadow(shadowing); - ug.draw(shape); + ug.draw(rectangle); final double textWidth; final int cornersize; @@ -77,15 +77,15 @@ class USymbolFrame extends USymbol { } final double textHeight = getYpos(dimTitle); - final UPath polygon = new UPath(); - polygon.setIgnoreForCompressionOnX(); - polygon.moveTo(textWidth, 0); + final UPath line = new UPath(); + line.setIgnoreForCompressionOnX(); + line.moveTo(textWidth, 0); - polygon.lineTo(textWidth, textHeight - cornersize); - polygon.lineTo(textWidth - cornersize, textHeight); + line.lineTo(textWidth, textHeight - cornersize); + line.lineTo(textWidth - cornersize, textHeight); - polygon.lineTo(0, textHeight); - ug.apply(HColors.none().bg()).draw(polygon); + line.lineTo(0, textHeight); + ug.apply(HColors.none().bg()).draw(line); } diff --git a/src/net/sourceforge/plantuml/html/LinkHtmlPrinter.java b/src/net/sourceforge/plantuml/html/LinkHtmlPrinter.java index abe6a74dc..b3b581953 100644 --- a/src/net/sourceforge/plantuml/html/LinkHtmlPrinter.java +++ b/src/net/sourceforge/plantuml/html/LinkHtmlPrinter.java @@ -73,16 +73,16 @@ public final class LinkHtmlPrinter { String label = link.getLabel() == null ? null : StringUtils.unicodeForHtml(link.getLabel()); String ent1 = ent1h; String ent2 = ent2h; - if (link.getQualifier1() != null) { - ent1 = ent1 + " (" + link.getQualifier1() + ")"; + if (link.getQuantifier1() != null) { + ent1 = ent1 + " (" + link.getQuantifier1() + ")"; if (label != null) { - label = "(" + link.getQualifier1() + " " + ent1h + ") " + label; + label = "(" + link.getQuantifier1() + " " + ent1h + ") " + label; } } - if (link.getQualifier2() != null) { - ent2 = ent2 + " (" + link.getQualifier2() + ")"; + if (link.getQuantifier2() != null) { + ent2 = ent2 + " (" + link.getQuantifier2() + ")"; if (label != null) { - label = label + " (" + link.getQualifier2() + " " + ent2h + ")"; + label = label + " (" + link.getQuantifier2() + " " + ent2h + ")"; } } if (chiral) { diff --git a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java index 48f27a508..b120b34c0 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java +++ b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java @@ -79,11 +79,11 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram } final Link l1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, node, link.getType(), LinkArg.build(link.getLabel(), link.getLength(), getSkinParam().classAttributeIconSize() > 0) - .withQualifier(link.getQualifier1(), null) + .withQuantifier(link.getQuantifier1(), null) .withDistanceAngle(link.getLabeldistance(), link.getLabelangle())); final Link l2 = new Link(getSkinParam().getCurrentStyleBuilder(), node, entity2, link.getType(), LinkArg.build(link.getLabel(), link.getLength(), getSkinParam().classAttributeIconSize() > 0) - .withQualifier(null, link.getQualifier2()) + .withQuantifier(null, link.getQuantifier2()) .withDistanceAngle(link.getLabeldistance(), link.getLabelangle())); addLink(l1); addLink(l2); @@ -175,13 +175,13 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram final Link entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point1, existingLink1.getType().getPart2(), LinkArg.build(existingLink1.getLabel(), existingLink1.getLength()) - .withQualifier(existingLink1.getQualifier1(), null) + .withQuantifier(existingLink1.getQuantifier1(), null) .withDistanceAngle(existingLink1.getLabeldistance(), existingLink1.getLabelangle())); entity1ToPoint.setLinkArrow(existingLink1.getLinkArrow()); final Link pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, entity2real, existingLink1.getType().getPart1(), LinkArg.noDisplay(existingLink1.getLength()) - .withQualifier(null, existingLink1.getQualifier2()) + .withQuantifier(null, existingLink1.getQuantifier2()) .withDistanceAngle(existingLink1.getLabeldistance(), existingLink1.getLabelangle())); // int length = 1; @@ -287,13 +287,13 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point, existingLink.getType().getPart2(), LinkArg.build(existingLink.getLabel(), existingLink.getLength()) - .withQualifier(existingLink.getQualifier1(), null) + .withQuantifier(existingLink.getQuantifier1(), null) .withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle())); entity1ToPoint.setLinkArrow(existingLink.getLinkArrow()); pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2real, existingLink.getType().getPart1(), LinkArg.noDisplay(existingLink.getLength()) - .withQualifier(null, existingLink.getQualifier2()) + .withQuantifier(null, existingLink.getQuantifier2()) .withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle())); int length = 1; @@ -333,11 +333,11 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, point, existingLink.getType().getPart2(), - LinkArg.build(existingLink.getLabel(), 2).withQualifier(existingLink.getQualifier1(), null) + LinkArg.build(existingLink.getLabel(), 2).withQuantifier(existingLink.getQuantifier1(), null) .withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle())); pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2, existingLink.getType().getPart1(), - LinkArg.noDisplay(2).withQualifier(null, existingLink.getQualifier2()) + LinkArg.noDisplay(2).withQuantifier(null, existingLink.getQuantifier2()) .withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle())); // entity1ToPoint = new Link(entity1, point, existingLink.getType(), // null, 2); diff --git a/src/net/sourceforge/plantuml/openiconic/PSystemListOpenIconic.java b/src/net/sourceforge/plantuml/openiconic/PSystemListOpenIconic.java index dcc8b7bdf..aa58ab877 100644 --- a/src/net/sourceforge/plantuml/openiconic/PSystemListOpenIconic.java +++ b/src/net/sourceforge/plantuml/openiconic/PSystemListOpenIconic.java @@ -66,7 +66,7 @@ public class PSystemListOpenIconic extends PlainDiagram { lines.add("Credit to"); lines.add("https://useiconic.com/open"); lines.add(" "); - try (BufferedReader br = new BufferedReader(new InputStreamReader(getRessourceAllTxt()))) { + try (BufferedReader br = new BufferedReader(new InputStreamReader(getResourceAllTxt()))) { String s = null; while ((s = br.readLine()) != null) { // lines.add("<¥> " + s); @@ -78,7 +78,7 @@ public class PSystemListOpenIconic extends PlainDiagram { return new TextBlockHorizontal(cols, VerticalAlignment.TOP); } - private InputStream getRessourceAllTxt() { + private InputStream getResourceAllTxt() { return DummyIcon.class.getResourceAsStream("all.txt"); } diff --git a/src/net/sourceforge/plantuml/posimo/DotPath.java b/src/net/sourceforge/plantuml/posimo/DotPath.java index 8ca401f27..8bc767f30 100644 --- a/src/net/sourceforge/plantuml/posimo/DotPath.java +++ b/src/net/sourceforge/plantuml/posimo/DotPath.java @@ -111,9 +111,9 @@ public class DotPath implements UShape, Moveable { } public DotPath(SvgResult fullSvg) { - if (isPathConsistent(fullSvg.getSvg()) == false) { + if (isPathConsistent(fullSvg.getSvg()) == false) throw new IllegalArgumentException(); - } + final int posC = fullSvg.indexOf("C", 0); if (posC == -1) throw new IllegalArgumentException(); @@ -282,21 +282,21 @@ public class DotPath implements UShape, Moveable { double result = Double.MAX_VALUE; for (XCubicCurve2D c : beziers) { final double d1 = ref.distance(c.x1, c.y1); - if (d1 < result) { + if (d1 < result) result = d1; - } + final double d2 = ref.distance(c.x2, c.y2); - if (d2 < result) { + if (d2 < result) result = d2; - } + final double d3 = ref.distance(c.ctrlx1, c.ctrly1); - if (d3 < result) { + if (d3 < result) result = d3; - } + final double d4 = ref.distance(c.ctrlx2, c.ctrly2); - if (d4 < result) { + if (d4 < result) result = d4; - } + } return result; diff --git a/src/net/sourceforge/plantuml/preproc/Stdlib.java b/src/net/sourceforge/plantuml/preproc/Stdlib.java index b11c7acb9..bb7d81353 100644 --- a/src/net/sourceforge/plantuml/preproc/Stdlib.java +++ b/src/net/sourceforge/plantuml/preproc/Stdlib.java @@ -48,7 +48,7 @@ public class Stdlib { if (folder == null || folder.info.size() == 0) return null; - final String data = folder.loadRessource(fullname.substring(last + 1)); + final String data = folder.loadResource(fullname.substring(last + 1)); if (data == null) return null; @@ -74,7 +74,7 @@ public class Stdlib { return result; } - private String loadRessource(String file) throws IOException { + private String loadResource(String file) throws IOException { final SoftReference cached = cache.get(file.toLowerCase()); if (cached != null) { final String cachedResult = cached.get(); diff --git a/src/net/sourceforge/plantuml/project/GanttDiagram.java b/src/net/sourceforge/plantuml/project/GanttDiagram.java index fd0a67d80..5670c0beb 100644 --- a/src/net/sourceforge/plantuml/project/GanttDiagram.java +++ b/src/net/sourceforge/plantuml/project/GanttDiagram.java @@ -243,7 +243,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit drawTasksRect(ug); drawTasksTitle(ugOrig, getTitlesColumnWidth(ug.getStringBounder()), getBarsColumnWidth(timeHeader)); - if (hideRessourceFoobox == false) + if (hideResourceFoobox == false) drawResources(ug); if (showFootbox) @@ -437,7 +437,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit getEnd(taskGroup), getSkinParam(), task, this, task.getStyleBuilder()); } else { final TaskImpl tmp = (TaskImpl) task; - final String disp = hideRessourceName ? tmp.getCode().getSimpleDisplay() : tmp.getPrettyDisplay(); + final String disp = hideResourceName ? tmp.getCode().getSimpleDisplay() : tmp.getPrettyDisplay(); if (tmp.isDiamond()) { draw = new TaskDrawDiamond(timeScale, y, disp, getStart(tmp), getSkinParam(), task, this, task.getStyleBuilder()); @@ -459,7 +459,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit double yy = lastY(stringBounder); if (yy == 0) { yy = headerHeight; - } else if (this.hideRessourceFoobox == false) + } else if (this.hideResourceFoobox == false) for (Resource res : resources.values()) { final ResourceDraw draw = new ResourceDraw(this, res, timeScale, yy, min, max); res.setTaskDraw(draw); @@ -839,16 +839,16 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit this.withCalendarDate = withCalendarDate; } - private boolean hideRessourceName; - private boolean hideRessourceFoobox; + private boolean hideResourceName; + private boolean hideResourceFoobox; - public CommandExecutionResult hideRessourceName() { - this.hideRessourceName = true; + public CommandExecutionResult hideResourceName() { + this.hideResourceName = true; return CommandExecutionResult.ok(); } - public CommandExecutionResult hideRessourceFootbox() { - this.hideRessourceFoobox = true; + public CommandExecutionResult hideResourceFootbox() { + this.hideResourceFoobox = true; return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java b/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java index 7aa4950ab..c48ebe4a6 100644 --- a/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java +++ b/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java @@ -53,8 +53,8 @@ import net.sourceforge.plantuml.project.command.CommandGanttArrow; import net.sourceforge.plantuml.project.command.CommandGanttArrow2; import net.sourceforge.plantuml.project.command.CommandGroupEnd; import net.sourceforge.plantuml.project.command.CommandGroupStart; -import net.sourceforge.plantuml.project.command.CommandHideRessourceFootbox; -import net.sourceforge.plantuml.project.command.CommandHideRessourceName; +import net.sourceforge.plantuml.project.command.CommandHideResourceFootbox; +import net.sourceforge.plantuml.project.command.CommandHideResourceName; import net.sourceforge.plantuml.project.command.CommandLabelOnColumn; import net.sourceforge.plantuml.project.command.CommandLanguage; import net.sourceforge.plantuml.project.command.CommandNoteBottom; @@ -117,8 +117,8 @@ public class GanttDiagramFactory extends PSystemCommandFactory { cmds.add(new CommandNoteBottom()); cmds.add(new CommandFootbox()); cmds.add(new CommandLabelOnColumn()); - cmds.add(new CommandHideRessourceName()); - cmds.add(new CommandHideRessourceFootbox()); + cmds.add(new CommandHideResourceName()); + cmds.add(new CommandHideResourceFootbox()); return cmds; } diff --git a/src/net/sourceforge/plantuml/project/Load.java b/src/net/sourceforge/plantuml/project/Load.java index ca76b041d..c828d22e0 100644 --- a/src/net/sourceforge/plantuml/project/Load.java +++ b/src/net/sourceforge/plantuml/project/Load.java @@ -51,4 +51,9 @@ public class Load implements Value { return winks * 100; } + @Override + public String toString() { + return "(" + winks + ")"; + } + } diff --git a/src/net/sourceforge/plantuml/project/command/CommandHideRessourceFootbox.java b/src/net/sourceforge/plantuml/project/command/CommandHideResourceFootbox.java similarity index 87% rename from src/net/sourceforge/plantuml/project/command/CommandHideRessourceFootbox.java rename to src/net/sourceforge/plantuml/project/command/CommandHideResourceFootbox.java index 72b7a84a8..7392e2f81 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandHideRessourceFootbox.java +++ b/src/net/sourceforge/plantuml/project/command/CommandHideResourceFootbox.java @@ -44,17 +44,17 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.project.GanttDiagram; -public class CommandHideRessourceFootbox extends SingleLineCommand2 { +public class CommandHideResourceFootbox extends SingleLineCommand2 { - public CommandHideRessourceFootbox() { + public CommandHideResourceFootbox() { super(getRegexConcat()); } static IRegex getRegexConcat() { - return RegexConcat.build(CommandHideRessourceFootbox.class.getName(), RegexLeaf.start(), // + return RegexConcat.build(CommandHideResourceFootbox.class.getName(), RegexLeaf.start(), // new RegexLeaf("hide"), // RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("ressources?"), // + new RegexLeaf("ress?ources?"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("footbox"), // RegexLeaf.end()); // @@ -62,7 +62,7 @@ public class CommandHideRessourceFootbox extends SingleLineCommand2 { +public class CommandHideResourceName extends SingleLineCommand2 { - public CommandHideRessourceName() { + public CommandHideResourceName() { super(getRegexConcat()); } static IRegex getRegexConcat() { - return RegexConcat.build(CommandHideRessourceName.class.getName(), RegexLeaf.start(), // + return RegexConcat.build(CommandHideResourceName.class.getName(), RegexLeaf.start(), // new RegexLeaf("hide"), // RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("ressources?"), // + new RegexLeaf("ress?ources?"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("names?"), // RegexLeaf.end()); // @@ -62,7 +62,7 @@ public class CommandHideRessourceName extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(GanttDiagram diagram, LineLocation location, RegexResult arg) { - return diagram.hideRessourceName(); + return diagram.hideResourceName(); } } diff --git a/src/net/sourceforge/plantuml/project/core/TaskImpl.java b/src/net/sourceforge/plantuml/project/core/TaskImpl.java index 21e41c513..eb13f81c4 100644 --- a/src/net/sourceforge/plantuml/project/core/TaskImpl.java +++ b/src/net/sourceforge/plantuml/project/core/TaskImpl.java @@ -94,7 +94,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { LoadPlanable result = defaultPlan; if (resources.size() > 0) - result = PlanUtils.multiply(defaultPlan, getRessourcePlan()); + result = PlanUtils.multiply(defaultPlan, getResourcePlan()); return result.getLoadAt(instant); } @@ -139,7 +139,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { this.pausedDayOfWeek.add(pause); } - private LoadPlanable getRessourcePlan() { + private LoadPlanable getResourcePlan() { if (resources.size() == 0) throw new IllegalStateException(); @@ -192,8 +192,9 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { public Day getStart() { Day result = (Day) solver.getData(TaskAttribute.START); - while (getLoadAt(result) == 0) - result = result.increment(); + if (diamond == false) + while (getLoadAt(result) == 0) + result = result.increment(); return result; } diff --git a/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java b/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java index 6fcadf478..0af1f9dd4 100644 --- a/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java +++ b/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java @@ -116,7 +116,7 @@ public class ResourceDraw implements UDrawable { private FontConfiguration getFontConfiguration(int size, HColor color) { final UFont font = UFont.serif(size); - return FontConfiguration.create(font, color, color, false); + return FontConfiguration.create(font, color, color, null); } public double getHeight() { diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeader.java b/src/net/sourceforge/plantuml/project/draw/TimeHeader.java index 1a7a29de8..4ad9858ae 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeader.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeader.java @@ -131,7 +131,7 @@ public abstract class TimeHeader { if (bold) font = font.bold(); - return FontConfiguration.create(font, color, color, false); + return FontConfiguration.create(font, color, color, null); } public final TimeScale getTimeScale() { diff --git a/src/net/sourceforge/plantuml/project/lang/Verbs.java b/src/net/sourceforge/plantuml/project/lang/Verbs.java index f842aef72..6bdddd416 100644 --- a/src/net/sourceforge/plantuml/project/lang/Verbs.java +++ b/src/net/sourceforge/plantuml/project/lang/Verbs.java @@ -123,7 +123,7 @@ public class Verbs { } public static IRegex lasts() { - return new RegexLeaf("lasts"); + return new RegexLeaf("(lasts|requires)"); } public static IRegex linksTo() { diff --git a/src/net/sourceforge/plantuml/project/solver/AbstractSolver.java b/src/net/sourceforge/plantuml/project/solver/AbstractSolver.java index d860fa020..6b352c674 100644 --- a/src/net/sourceforge/plantuml/project/solver/AbstractSolver.java +++ b/src/net/sourceforge/plantuml/project/solver/AbstractSolver.java @@ -53,14 +53,14 @@ public abstract class AbstractSolver implements Solver { final Value previous = values.remove(attribute); if (previous != null && attribute == TaskAttribute.START) { final Day previousInstant = (Day) previous; - if (previousInstant.compareTo((Day) value) > 0) { + if (previousInstant.compareTo((Day) value) > 0) value = previous; - } + } values.put(attribute, value); - if (values.size() > 2) { + if (values.size() > 2) removeFirstElement(); - } + assert values.size() <= 2; } @@ -74,12 +74,12 @@ public abstract class AbstractSolver implements Solver { final public Value getData(TaskAttribute attribute) { Value result = values.get(attribute); if (result == null) { - if (attribute == TaskAttribute.END) { + if (attribute == TaskAttribute.END) return computeEnd(); - } - if (attribute == TaskAttribute.START) { + + if (attribute == TaskAttribute.START) return computeStart(); - } + return Load.inWinks(1); // throw new UnsupportedOperationException(attribute.toString()); } diff --git a/src/net/sourceforge/plantuml/real/RealLine.java b/src/net/sourceforge/plantuml/real/RealLine.java index f2b066556..07fed45a9 100644 --- a/src/net/sourceforge/plantuml/real/RealLine.java +++ b/src/net/sourceforge/plantuml/real/RealLine.java @@ -97,12 +97,12 @@ class RealLine { for (AbstractReal real : all) { final double v = real.getCurrentValue(); // System.err.println("RealLine::compile v=" + v); - if (v > max) { + if (v > max) max = v; - } - if (v < min) { + + if (v < min) min = v; - } + } // System.err.println("RealLine::compile min=" + min + " max=" + max); return; @@ -117,12 +117,12 @@ class RealLine { } private void printCounter(Map counter) { - for (PositiveForce f : forces) { + for (PositiveForce f : forces) System.err.println("force=" + f); - } - for (Map.Entry ent : counter.entrySet()) { + + for (Map.Entry ent : counter.entrySet()) System.err.println("count=" + ent.getValue() + " for " + ent.getKey()); - } + } private static void incCounter(Map counter, PositiveForce f) { diff --git a/src/net/sourceforge/plantuml/sdot/CucaDiagramFileMakerSmetana.java b/src/net/sourceforge/plantuml/sdot/CucaDiagramFileMakerSmetana.java index 18a485e22..87c6917d0 100644 --- a/src/net/sourceforge/plantuml/sdot/CucaDiagramFileMakerSmetana.java +++ b/src/net/sourceforge/plantuml/sdot/CucaDiagramFileMakerSmetana.java @@ -155,8 +155,8 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker { continue; final ST_Agedge_s edge = ent.getValue(); - new SmetanaPath(link, edge, ymirror, diagram, getLabel(link), getQualifier(link, 1), - getQualifier(link, 2)).drawU(ug); + new SmetanaPath(link, edge, ymirror, diagram, getLabel(link), getQuantifier(link, 1), + getQuantifier(link, 2)).drawU(ug); } } @@ -447,8 +447,8 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker { return TextBlockUtils.withMargin(label, marginLabel, marginLabel); } - private TextBlock getQualifier(Link link, int n) { - final String tmp = n == 1 ? link.getQualifier1() : link.getQualifier2(); + private TextBlock getQuantifier(Link link, int n) { + final String tmp = n == 1 ? link.getQuantifier1() : link.getQuantifier2(); if (tmp == null) return null; @@ -514,7 +514,7 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker { agsafeset(e, new CString("label"), hackDim, new CString("")); // System.err.print("label=" + hackDim.getContent()); } - final TextBlock q1 = getQualifier(link, 1); + final TextBlock q1 = getQuantifier(link, 1); if (q1 != null) { final XDimension2D dimLabel = q1.calculateDimension(stringBounder); // System.err.println("dimLabel = " + dimLabel); @@ -522,7 +522,7 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker { (int) dimLabel.getHeight()); agsafeset(e, new CString("taillabel"), hackDim, new CString("")); } - final TextBlock q2 = getQualifier(link, 2); + final TextBlock q2 = getQuantifier(link, 2); if (q2 != null) { final XDimension2D dimLabel = q2.calculateDimension(stringBounder); // System.err.println("dimLabel = " + dimLabel); diff --git a/src/net/sourceforge/plantuml/sdot/SmetanaPath.java b/src/net/sourceforge/plantuml/sdot/SmetanaPath.java index 6d65468dc..82c1910ff 100644 --- a/src/net/sourceforge/plantuml/sdot/SmetanaPath.java +++ b/src/net/sourceforge/plantuml/sdot/SmetanaPath.java @@ -150,6 +150,7 @@ public class SmetanaPath implements UDrawable { extremity2.drawU(ug); } catch (UnsupportedOperationException e) { + e.printStackTrace(); System.err.println("CANNOT DRAW printExtremityAtStart"); } } @@ -174,6 +175,7 @@ public class SmetanaPath implements UDrawable { extremity1.drawU(ug); } catch (UnsupportedOperationException e) { + e.printStackTrace(); System.err.println("CANNOT DRAW printExtremityAtEnd"); } } diff --git a/src/net/sourceforge/plantuml/security/SecurityProfile.java b/src/net/sourceforge/plantuml/security/SecurityProfile.java index 12d81a48d..8ff2183d9 100644 --- a/src/net/sourceforge/plantuml/security/SecurityProfile.java +++ b/src/net/sourceforge/plantuml/security/SecurityProfile.java @@ -126,7 +126,7 @@ public enum SecurityProfile { case SANDBOX: return "This is completely safe: no access to local files or to distant URL."; case ALLOWLIST: - return "Some local ressource may be accessible."; + return "Some local resource may be accessible."; case INTERNET: return "Mode designed for server connected to Internet."; case LEGACY: diff --git a/src/net/sourceforge/plantuml/sequencediagram/Doll.java b/src/net/sourceforge/plantuml/sequencediagram/Doll.java index 35c88e155..40dd88362 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Doll.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Doll.java @@ -88,9 +88,8 @@ public class Doll implements WithStyle { this.styleBuilder = styleBuilder; this.tileArguments = Objects.requireNonNull(tileArguments); - if (first != null) { + if (first != null) this.participants.add(first); - } } diff --git a/src/net/sourceforge/plantuml/sequencediagram/Reference.java b/src/net/sourceforge/plantuml/sequencediagram/Reference.java index 2037fa215..42e4f53f9 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Reference.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Reference.java @@ -35,6 +35,7 @@ */ package net.sourceforge.plantuml.sequencediagram; +import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -75,7 +76,7 @@ public class Reference extends AbstractEvent implements Event { public Reference(List participants, Url url, Display strings, HColor backColorGeneral, HColor backColorElement, StyleBuilder styleBuilder) { - this.participants = participants; + this.participants = uniq(participants); this.url = url; this.strings = strings; this.backColorGeneral = backColorGeneral; @@ -84,8 +85,16 @@ public class Reference extends AbstractEvent implements Event { this.styleHeader = getHeaderStyleDefinition().getMergedStyle(styleBuilder); } + static private List uniq(List all) { + final List result = new ArrayList(); + for (Participant p : all) + if (result.contains(p) == false) + result.add(p); + return Collections.unmodifiableList(result); + } + public List getParticipant() { - return Collections.unmodifiableList(participants); + return participants; } public Display getStrings() { diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java index ca605b9ac..6f0e9a0e9 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java @@ -385,7 +385,7 @@ class DrawableSetInitializer { freeY2 = ((FrontierStack) freeY2).restore(); final Component compElse = drawableSet.getSkin().createComponent(m.getUsedStyles(), - ComponentType.GROUPING_ELSE, null, skinParam, Display.create(m.getComment())); + ComponentType.GROUPING_ELSE_LEGACY, null, skinParam, Display.create(m.getComment())); final Lazy lazy = new Lazy() { public double getNow() { final GraphicalElement after = drawableSet.getEvent(m.getJustAfter()); diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java index 84277a146..e2bb9d81d 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java @@ -139,9 +139,9 @@ public class SequenceDiagramArea { } public double getLegendY() { - if (isLegendTop) { + if (isLegendTop) return titleHeight + headerHeight + headerMargin; - } + return sequenceHeight + headerHeight + headerMargin + titleHeight; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java index e0c721628..5bf3fb536 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java @@ -42,7 +42,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import net.sourceforge.plantuml.AnnotatedWorker; +import net.sourceforge.plantuml.AnnotatedBuilder; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; @@ -136,11 +136,15 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { public ImageData createOne(OutputStream os, final int index, boolean isWithMetadata) throws IOException { final Page page = pages.get(index); - final SequenceDiagramArea area = new SequenceDiagramArea(fullDimension.getWidth(), page.getHeight()); + final AnnotatedBuilder builder = new AnnotatedBuilder(diagram, diagram.getSkinParam(), stringBounder); + double pageHeight = page.getHeight(); + if (builder.hasMainFrame()) + pageHeight += builder.mainFrameSuppHeight(); + + final SequenceDiagramArea area = new SequenceDiagramArea(fullDimension.getWidth(), pageHeight); final TextBlock compTitle; - final AnnotatedWorker annotatedWorker = new AnnotatedWorker(diagram, diagram.getSkinParam(), stringBounder); - final TextBlock caption = annotatedWorker.getCaption(); + final TextBlock caption = builder.getCaption(); area.setCaptionArea(caption.calculateDimension(stringBounder)); if (Display.isNull(page.getTitle())) { @@ -190,7 +194,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { area.getSequenceAreaY()); TextBlock core = drawableSet.asTextBlock(delta, fullDimension.getWidth(), page, diagram.isShowFootbox()); - core = annotatedWorker.addFrame(core); + core = builder.decoreWithFrame(core); core.drawU(ug.apply(forCore)); drawHeader(area, ug, index); diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java index e47aaca41..5c93d2e98 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java @@ -78,7 +78,7 @@ public class ElseTile extends AbstractTile { anElse.getBackColorGeneral()); final Display display = Display.create(anElse.getComment()); - final Component comp = skin.createComponent(anElse.getUsedStyles(), ComponentType.GROUPING_ELSE, null, tmp, + final Component comp = skin.createComponent(anElse.getUsedStyles(), ComponentType.GROUPING_ELSE_TEOZ, null, tmp, display); return comp; } @@ -107,9 +107,10 @@ public class ElseTile extends AbstractTile { final XDimension2D dim = comp.getPreferredDimension(getStringBounder()); double height = dim.getHeight(); - if (anElse.getComment() != null) { - height += 10; - } +// if (anElse.getComment() != null) +// height += 10; +// +// return height + 20; return height; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java index aa2b962d8..90aa1958e 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java @@ -108,12 +108,12 @@ public class GroupingTile extends AbstractTile { while (it.hasNext()) { final Event ev = it.next(); - if (ev instanceof GroupingLeaf && ((Grouping) ev).getType() == GroupingType.END) { + if (ev instanceof GroupingLeaf && ((Grouping) ev).getType() == GroupingType.END) break; - } - for (Tile tile : TileBuilder.buildOne(it, tileArgumentsOriginal, ev, this)) { + + for (Tile tile : TileBuilder.buildOne(it, tileArgumentsOriginal, ev, this)) tiles.add(tile); - } + } tiles = mergeParallel(getStringBounder(), tiles); @@ -131,13 +131,13 @@ public class GroupingTile extends AbstractTile { max2.add(m.addFixed(MARGINX)); } final double width = dim1.getWidth(); - if (min2.size() == 0) { + if (min2.size() == 0) min2.add(tileArgumentsOriginal.getOrigin()); - } + this.min = RealUtils.min(min2); - for (Tile anElse : allElses) { + for (Tile anElse : allElses) max2.add(anElse.getMaxX()); - } + max2.add(this.min.addFixed(width + 16)); this.max = RealUtils.max(max2); } @@ -205,9 +205,9 @@ public class GroupingTile extends AbstractTile { } public void addConstraints() { - for (Tile tile : tiles) { + for (Tile tile : tiles) tile.addConstraints(); - } + } public Real getMinX() { @@ -272,9 +272,9 @@ public class GroupingTile extends AbstractTile { private static List removeEmptyCloseToParallel(List tiles) { final List result = new ArrayList<>(); for (Tile tile : tiles) { - if (isParallel(tile)) { + if (isParallel(tile)) removeHeadEmpty(result); - } + result.add(tile); } return result; @@ -282,9 +282,9 @@ public class GroupingTile extends AbstractTile { } private static void removeHeadEmpty(List tiles) { - while (tiles.size() > 0 && tiles.get(tiles.size() - 1) instanceof EmptyTile) { + while (tiles.size() > 0 && tiles.get(tiles.size() - 1) instanceof EmptyTile) tiles.remove(tiles.size() - 1); - } + } public static boolean isParallel(Tile tile) { @@ -293,17 +293,13 @@ public class GroupingTile extends AbstractTile { void addYNewPages(Collection yNewPages) { for (Tile tile : tiles) { - if (tile instanceof GroupingTile) { + if (tile instanceof GroupingTile) ((GroupingTile) tile).addYNewPages(yNewPages); - } + if (tile instanceof NewpageTile) { final double y = ((NewpageTile) tile).getY(); yNewPages.add(y); } } } - - // public double getStartY() { - // return y + MARGINY; - // } } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java index dde99f440..a700470fe 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java @@ -38,7 +38,7 @@ package net.sourceforge.plantuml.sequencediagram.teoz; import java.io.IOException; import java.io.OutputStream; -import net.sourceforge.plantuml.AnnotatedWorker; +import net.sourceforge.plantuml.AnnotatedBuilder; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; @@ -74,7 +74,8 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { private final SequenceDiagram diagram; private final FileFormatOption fileFormatOption; private final Rose skin; - private final AnnotatedWorker annotatedWorker; + private final AnnotatedBuilder annotatedBuilder; + private final int index; public SequenceDiagramFileMakerTeoz(SequenceDiagram diagram, Rose skin, FileFormatOption fileFormatOption, @@ -87,13 +88,13 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { this.body = new PlayingSpaceWithParticipants(createMainTile()); this.footer = getFooterOrHeader(FontParam.FOOTER); this.header = getFooterOrHeader(FontParam.HEADER); - this.annotatedWorker = new AnnotatedWorker(diagram, diagram.getSkinParam(), stringBounder); + this.annotatedBuilder = new AnnotatedBuilder(diagram, diagram.getSkinParam(), stringBounder); this.min1 = body.getMinX(stringBounder); this.title = getTitle(); this.legend = getLegend(); - this.caption = annotatedWorker.getCaption(); + this.caption = annotatedBuilder.getCaption(); this.heightEnglober1 = dolls.getOffsetForEnglobers(stringBounder); this.heightEnglober2 = heightEnglober1 == 0 ? 0 : 10; @@ -107,7 +108,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { + header.calculateDimension(stringBounder).getHeight() + legend.calculateDimension(stringBounder).getHeight() + caption.calculateDimension(stringBounder).getHeight() - + footer.calculateDimension(stringBounder).getHeight() + (annotatedWorker.hasMainFrame() ? 10 : 0); + + footer.calculateDimension(stringBounder).getHeight() + (annotatedBuilder.hasMainFrame() ? 10 : 0); this.dimTotal = new XDimension2D(totalWidth, totalHeight); } @@ -264,8 +265,8 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { } ug = ug.apply(UTranslate.dy(heightEnglober1)); - final TextBlock bodyFramed = annotatedWorker.addFrame(body); - printAligned(ug.apply(UTranslate.dx((annotatedWorker.hasMainFrame() ? 4 : 0))), HorizontalAlignment.CENTER, + final TextBlock bodyFramed = annotatedBuilder.decoreWithFrame(body); + printAligned(ug.apply(UTranslate.dx((annotatedBuilder.hasMainFrame() ? 4 : 0))), HorizontalAlignment.CENTER, bodyFramed); ug = goDown(ug, bodyFramed); ug = ug.apply(UTranslate.dy(heightEnglober2)); diff --git a/src/net/sourceforge/plantuml/skin/ComponentType.java b/src/net/sourceforge/plantuml/skin/ComponentType.java index 1a5f52729..76951d4f8 100644 --- a/src/net/sourceforge/plantuml/skin/ComponentType.java +++ b/src/net/sourceforge/plantuml/skin/ComponentType.java @@ -56,7 +56,7 @@ public enum ComponentType implements Styleable { DELAY_LINE, PARTICIPANT_LINE, CONTINUE_LINE, // - GROUPING_ELSE, GROUPING_HEADER, GROUPING_SPACE, + GROUPING_ELSE_LEGACY, GROUPING_ELSE_TEOZ, GROUPING_HEADER, GROUPING_SPACE, // NEWPAGE, NOTE, NOTE_HEXAGONAL, NOTE_BOX, DIVIDER, REFERENCE, ENGLOBER, diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java index 0a8abc970..d54634ff2 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java @@ -59,10 +59,12 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent { private final HColor groupBorder; private final HColor backgroundColor; private final double roundCorner; + private final boolean teoz; - public ComponentRoseGroupingElse(Style style, CharSequence comment, ISkinSimple spriteContainer) { + public ComponentRoseGroupingElse(boolean teoz, Style style, CharSequence comment, ISkinSimple spriteContainer) { super(style, LineBreakStrategy.NONE, 5, 5, 1, spriteContainer, comment == null ? null : "[" + comment + "]"); + this.teoz = teoz; this.roundCorner = style.value(PName.RoundCorner).asInt(); this.groupBorder = style.value(PName.LineColor).asColor(getIHtmlColorSet()); this.backgroundColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet()); @@ -103,12 +105,18 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent { ug = ArrowConfiguration.stroke(ug, 2, 2, 1).apply(groupBorder); ug.apply(UTranslate.dy(1)).draw(ULine.hline(dimensionToUse.getWidth())); ug = ug.apply(new UStroke()); - getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), getMarginY()))); + if (teoz) + getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), getMarginY() + 2))); + else + getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), getMarginY()))); } @Override public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder); + if (teoz) + return getTextHeight(stringBounder) + 16; + else + return getTextHeight(stringBounder); } @Override diff --git a/src/net/sourceforge/plantuml/skin/rose/Rose.java b/src/net/sourceforge/plantuml/skin/rose/Rose.java index 07a9425de..013a78a9e 100644 --- a/src/net/sourceforge/plantuml/skin/rose/Rose.java +++ b/src/net/sourceforge/plantuml/skin/rose/Rose.java @@ -215,8 +215,11 @@ public class Rose { return new ComponentRoseGroupingHeader(styles == null ? null : styles[0], styles == null ? null : styles[1], stringsToDisplay, param); - if (type == ComponentType.GROUPING_ELSE) - return new ComponentRoseGroupingElse(styles == null ? null : styles[0], stringsToDisplay.get(0), param); + if (type == ComponentType.GROUPING_ELSE_LEGACY) + return new ComponentRoseGroupingElse(false, styles == null ? null : styles[0], stringsToDisplay.get(0), param); + + if (type == ComponentType.GROUPING_ELSE_TEOZ) + return new ComponentRoseGroupingElse(true, styles == null ? null : styles[0], stringsToDisplay.get(0), param); if (type == ComponentType.GROUPING_SPACE) return new ComponentRoseGroupingSpace(7); @@ -225,13 +228,16 @@ public class Rose { return new ComponentRoseActiveLine(styles == null ? null : styles[0], true, true, param.getIHtmlColorSet()); if (type == ComponentType.ALIVE_BOX_CLOSE_OPEN) - return new ComponentRoseActiveLine(styles == null ? null : styles[0], true, false, param.getIHtmlColorSet()); + return new ComponentRoseActiveLine(styles == null ? null : styles[0], true, false, + param.getIHtmlColorSet()); if (type == ComponentType.ALIVE_BOX_OPEN_CLOSE) { - return new ComponentRoseActiveLine(styles == null ? null : styles[0], false, true, param.getIHtmlColorSet()); + return new ComponentRoseActiveLine(styles == null ? null : styles[0], false, true, + param.getIHtmlColorSet()); } if (type == ComponentType.ALIVE_BOX_OPEN_OPEN) - return new ComponentRoseActiveLine(styles == null ? null : styles[0], false, false, param.getIHtmlColorSet()); + return new ComponentRoseActiveLine(styles == null ? null : styles[0], false, false, + param.getIHtmlColorSet()); if (type == ComponentType.DELAY_LINE) return new ComponentRoseDelayLine(null, getHtmlColor(param, stereotype, ColorParam.sequenceLifeLineBorder)); diff --git a/src/net/sourceforge/plantuml/sprite/PSystemListInternalSprites.java b/src/net/sourceforge/plantuml/sprite/PSystemListInternalSprites.java index 90b647786..363e1860f 100644 --- a/src/net/sourceforge/plantuml/sprite/PSystemListInternalSprites.java +++ b/src/net/sourceforge/plantuml/sprite/PSystemListInternalSprites.java @@ -62,10 +62,10 @@ public class PSystemListInternalSprites extends PlainDiagram { lines.add("Credit to"); lines.add("http://www.archimatetool.com"); lines.add(" "); - for (String folder : RessourcesUtils.getJarFile("sprites", true)) { + for (String folder : ResourcesUtils.getJarFile("sprites", true)) { lines.add("" + folder + " :"); lines.add(" "); - for (String png : RessourcesUtils.getJarFile("sprites/" + folder, false)) { + for (String png : ResourcesUtils.getJarFile("sprites/" + folder, false)) { if (png.endsWith(".png")) { final String spriteName = png.substring(0, png.length() - 4); lines.add("<$archimate/" + spriteName + "> " + spriteName); diff --git a/src/net/sourceforge/plantuml/sprite/RessourcesUtils.java b/src/net/sourceforge/plantuml/sprite/ResourcesUtils.java similarity index 99% rename from src/net/sourceforge/plantuml/sprite/RessourcesUtils.java rename to src/net/sourceforge/plantuml/sprite/ResourcesUtils.java index 7d3125e1c..a8d2fc613 100644 --- a/src/net/sourceforge/plantuml/sprite/RessourcesUtils.java +++ b/src/net/sourceforge/plantuml/sprite/ResourcesUtils.java @@ -52,7 +52,7 @@ import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.version.Version; -public class RessourcesUtils { +public class ResourcesUtils { public static Set getJarFile(String path, boolean folder) throws IOException { if (path.startsWith("/") || path.endsWith("/")) { diff --git a/src/net/sourceforge/plantuml/style/ClockwiseTopRightBottomLeft.java b/src/net/sourceforge/plantuml/style/ClockwiseTopRightBottomLeft.java index f9ef8159b..da10e42af 100644 --- a/src/net/sourceforge/plantuml/style/ClockwiseTopRightBottomLeft.java +++ b/src/net/sourceforge/plantuml/style/ClockwiseTopRightBottomLeft.java @@ -35,6 +35,9 @@ */ package net.sourceforge.plantuml.style; +import net.sourceforge.plantuml.awt.geom.XDimension2D; +import net.sourceforge.plantuml.ugraphic.UTranslate; + public class ClockwiseTopRightBottomLeft { private final double top; @@ -94,6 +97,10 @@ public class ClockwiseTopRightBottomLeft { this.left = left; } + public ClockwiseTopRightBottomLeft incTop(double delta) { + return new ClockwiseTopRightBottomLeft(top + delta, right, bottom, left); + } + @Override public String toString() { return "" + top + ":" + right + ":" + bottom + ":" + left; @@ -120,4 +127,12 @@ public class ClockwiseTopRightBottomLeft { return style.getMargin(); } + public UTranslate getTranslate() { + return new UTranslate(left, top); + } + + public XDimension2D apply(XDimension2D dim) { + return new XDimension2D(left + dim.getWidth() + right, top + dim.getHeight() + bottom); + } + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/style/PName.java b/src/net/sourceforge/plantuml/style/PName.java index 04b918e1f..aa60fa971 100644 --- a/src/net/sourceforge/plantuml/style/PName.java +++ b/src/net/sourceforge/plantuml/style/PName.java @@ -46,6 +46,8 @@ public enum PName { LineThickness, // DiagonalCorner, // HyperLinkColor, // + HyperlinkUnderlineStyle, // + HyperlinkUnderlineThickness, // HeadColor, // LineColor, // LineStyle, // diff --git a/src/net/sourceforge/plantuml/style/SName.java b/src/net/sourceforge/plantuml/style/SName.java index c9b229310..d33813043 100644 --- a/src/net/sourceforge/plantuml/style/SName.java +++ b/src/net/sourceforge/plantuml/style/SName.java @@ -72,6 +72,7 @@ public enum SName { destroy, // diamond, // document, // + ebnf, // element, // entity, // end, // @@ -94,6 +95,7 @@ public enum SName { leafNode, // legend, // lifeLine, // + mainframe, // map, // milestone, // mindmapDiagram, // diff --git a/src/net/sourceforge/plantuml/style/Style.java b/src/net/sourceforge/plantuml/style/Style.java index ffb199a91..2e9e1f9e5 100644 --- a/src/net/sourceforge/plantuml/style/Style.java +++ b/src/net/sourceforge/plantuml/style/Style.java @@ -196,7 +196,8 @@ public class Style { color = value(PName.FontColor).asColor(set); final HColor hyperlinkColor = value(PName.HyperLinkColor).asColor(set); - return FontConfiguration.create(font, color, hyperlinkColor, true); + final UStroke stroke = getStroke(PName.HyperlinkUnderlineThickness, PName.HyperlinkUnderlineStyle); + return FontConfiguration.create(font, color, hyperlinkColor, stroke); } public SymbolContext getSymbolContext(HColorSet set, Colors colors) { @@ -207,7 +208,10 @@ public class Style { if (foreColor == null) foreColor = value(PName.LineColor).asColor(set); final double deltaShadowing = value(PName.Shadowing).asDouble(); - return new SymbolContext(backColor, foreColor).withStroke(getStroke()).withDeltaShadow(deltaShadowing); + final double roundCorner = value(PName.RoundCorner).asDouble(); + final double diagonalCorner = value(PName.DiagonalCorner).asDouble(); + return new SymbolContext(backColor, foreColor).withStroke(getStroke()).withDeltaShadow(deltaShadowing) + .withCorner(roundCorner, diagonalCorner); } public SymbolContext getSymbolContext(HColorSet set) { @@ -226,8 +230,12 @@ public class Style { } public UStroke getStroke() { - final double thickness = value(PName.LineThickness).asDouble(); - final String dash = value(PName.LineStyle).asString(); + return getStroke(PName.LineThickness, PName.LineStyle); + } + + private UStroke getStroke(final PName thicknessParam, final PName styleParam) { + final double thickness = value(thicknessParam).asDouble(); + final String dash = value(styleParam).asString(); if (dash.length() == 0) return new UStroke(thickness); diff --git a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java index 4055f48bb..f4d9b586a 100644 --- a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java +++ b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java @@ -40,6 +40,7 @@ import java.io.OutputStream; import java.util.ArrayList; import java.util.List; +import net.sourceforge.plantuml.AnnotatedBuilder; import net.sourceforge.plantuml.AnnotatedWorker; import net.sourceforge.plantuml.BaseFile; import net.sourceforge.plantuml.FileFormatOption; @@ -104,7 +105,8 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker { // TODO There is something strange with the left margin of mainframe, I think // because AnnotatedWorker is used here // It can be looked at in another PR - result = new AnnotatedWorker(diagram, diagram.getSkinParam(), stringBounder).addAdd(result); + final AnnotatedBuilder builder = new AnnotatedBuilder(diagram, diagram.getSkinParam(), stringBounder); + result = new AnnotatedWorker(diagram, diagram.getSkinParam(), stringBounder, builder).addAdd(result); // TODO UmlDiagram.getWarningOrError() looks similar so this might be // simplified? - will leave for a separate PR diff --git a/src/net/sourceforge/plantuml/svek/DecorateEntityImage.java b/src/net/sourceforge/plantuml/svek/DecorateEntityImage.java index 3536d760f..756aa8aaa 100644 --- a/src/net/sourceforge/plantuml/svek/DecorateEntityImage.java +++ b/src/net/sourceforge/plantuml/svek/DecorateEntityImage.java @@ -69,9 +69,9 @@ public class DecorateEntityImage extends AbstractTextBlock implements TextBlockB public static TextBlock add(TextBlock original, TextBlock text, HorizontalAlignment horizontal, VerticalAlignment verticalAlignment) { - if (verticalAlignment == VerticalAlignment.TOP) { + if (verticalAlignment == VerticalAlignment.TOP) return addTop(original, text, horizontal); - } + return addBottom(original, text, horizontal); } @@ -115,28 +115,28 @@ public class DecorateEntityImage extends AbstractTextBlock implements TextBlockB } private XDimension2D getTextDim(TextBlock text, StringBounder stringBounder) { - if (text == null) { + if (text == null) return new XDimension2D(0, 0); - } + return text.calculateDimension(stringBounder); } private double getTextX(final XDimension2D dimText, final XDimension2D dimTotal, HorizontalAlignment h) { - if (h == HorizontalAlignment.CENTER) { + if (h == HorizontalAlignment.CENTER) return (dimTotal.getWidth() - dimText.getWidth()) / 2; - } else if (h == HorizontalAlignment.LEFT) { + else if (h == HorizontalAlignment.LEFT) return 0; - } else if (h == HorizontalAlignment.RIGHT) { + else if (h == HorizontalAlignment.RIGHT) return dimTotal.getWidth() - dimText.getWidth(); - } else { + else throw new IllegalStateException(); - } + } public HColor getBackcolor() { - if (original instanceof TextBlockBackcolored) { + if (original instanceof TextBlockBackcolored) return ((TextBlockBackcolored) original).getBackcolor(); - } + throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/svek/Kal.java b/src/net/sourceforge/plantuml/svek/Kal.java index 0b3041454..6c23ff7b1 100644 --- a/src/net/sourceforge/plantuml/svek/Kal.java +++ b/src/net/sourceforge/plantuml/svek/Kal.java @@ -47,6 +47,7 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.svek.extremity.Extremity; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.UStroke; @@ -141,8 +142,13 @@ public class Kal implements UDrawable { return position; } - public void setTranslate(UTranslate translate) { + public void setTranslate(UTranslate translate, UDrawable decoration) { this.translate = translate; + if (decoration instanceof Extremity) { + final Extremity extremity = (Extremity) decoration; + final UTranslate deltaForKal = extremity.getDeltaForKal(); + // this.translate = this.translate.compose(deltaForKal); + } } public double overlapx(Kal other) { diff --git a/src/net/sourceforge/plantuml/svek/SvekLine.java b/src/net/sourceforge/plantuml/svek/SvekLine.java index 63ac5f902..75835fa0f 100644 --- a/src/net/sourceforge/plantuml/svek/SvekLine.java +++ b/src/net/sourceforge/plantuml/svek/SvekLine.java @@ -213,10 +213,10 @@ public class SvekLine implements Moveable, Hideable, GuideLine { public SvekLine(Link link, ColorSequence colorSequence, ISkinParam skinParam, StringBounder stringBounder, FontConfiguration font, Bibliotekon bibliotekon, Pragma pragma, GraphvizVersion graphvizVersion) { - if (graphvizVersion.useShieldForQuantifier() && link.getLinkArg().getQualifier1() != null) + if (graphvizVersion.useShieldForQuantifier() && link.getLinkArg().getQuantifier1() != null) ((EntityImpl) link.getEntity1()).ensureMargins(Margins.uniform(16)); - if (graphvizVersion.useShieldForQuantifier() && link.getLinkArg().getQualifier2() != null) + if (graphvizVersion.useShieldForQuantifier() && link.getLinkArg().getQuantifier2() != null) ((EntityImpl) link.getEntity2()).ensureMargins(Margins.uniform(16)); if (link.getLinkArg().getKal1() != null) @@ -306,16 +306,16 @@ public class SvekLine implements Moveable, Hideable, GuideLine { } - if (link.getQualifier1() == null) + if (link.getQuantifier1() == null) startTailText = null; else - startTailText = Display.getWithNewlines(link.getQualifier1()).create(font, HorizontalAlignment.CENTER, + startTailText = Display.getWithNewlines(link.getQuantifier1()).create(font, HorizontalAlignment.CENTER, skinParam); - if (link.getQualifier2() == null) + if (link.getQuantifier2() == null) endHeadText = null; else - endHeadText = Display.getWithNewlines(link.getQualifier2()).create(font, HorizontalAlignment.CENTER, + endHeadText = Display.getWithNewlines(link.getQuantifier2()).create(font, HorizontalAlignment.CENTER, skinParam); if (link.getType().getMiddleDecor() == LinkMiddleDecor.NONE) @@ -783,11 +783,11 @@ public class SvekLine implements Moveable, Hideable, GuideLine { public void computeKal() { if (kal1 != null) { final UTranslate tr = new UTranslate(dotPath.getStartPoint()).compose(new UTranslate(dx, dy)); - kal1.setTranslate(tr); + kal1.setTranslate(tr, extremity1); } if (kal2 != null) { final UTranslate tr = new UTranslate(dotPath.getEndPoint()).compose(new UTranslate(dx, dy)); - kal2.setTranslate(tr); + kal2.setTranslate(tr, extremity2); } } diff --git a/src/net/sourceforge/plantuml/svek/extremity/Extremity.java b/src/net/sourceforge/plantuml/svek/extremity/Extremity.java index ad8e089e5..470ab514c 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/Extremity.java +++ b/src/net/sourceforge/plantuml/svek/extremity/Extremity.java @@ -37,9 +37,10 @@ package net.sourceforge.plantuml.svek.extremity; import net.sourceforge.plantuml.awt.geom.XPoint2D; import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.ugraphic.UTranslate; public abstract class Extremity implements UDrawable { - + protected double manageround(double angle) { final double deg = angle * 180.0 / Math.PI; if (isCloseTo(0, deg)) { @@ -66,11 +67,15 @@ public abstract class Extremity implements UDrawable { } return false; } - + public abstract XPoint2D somePoint(); - + public XPoint2D isTooSmallSoGiveThePointCloserToThisOne(XPoint2D pt) { return null; } + public UTranslate getDeltaForKal() { + return new UTranslate(); + } + } diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityDiamond.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityDiamond.java index 17776e45f..7fdfead80 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityDiamond.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityDiamond.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.svek.extremity; import net.sourceforge.plantuml.awt.geom.XPoint2D; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPolygon; +import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColors; class ExtremityDiamond extends Extremity { @@ -45,6 +46,7 @@ class ExtremityDiamond extends Extremity { private UPolygon polygon = new UPolygon(); private final boolean fill; private final XPoint2D contact; + private final UTranslate deltaForKal; @Override public XPoint2D somePoint() { @@ -63,9 +65,15 @@ class ExtremityDiamond extends Extremity { polygon.addPoint(-xWing, yAperture); polygon.addPoint(0, 0); polygon.rotate(angle + Math.PI / 2); + this.deltaForKal = new UTranslate(polygon.getPoint(2)).reverse(); polygon = polygon.translate(p1.getX(), p1.getY()); } + @Override + public UTranslate getDeltaForKal() { + return deltaForKal; + } + public void drawU(UGraphic ug) { if (fill) ug = ug.apply(HColors.changeBack(ug)); diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryDoubleLine.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryDoubleLine.java index 07d8a48c0..e7ed5458a 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryDoubleLine.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryDoubleLine.java @@ -42,6 +42,12 @@ import net.sourceforge.plantuml.svek.Side; public class ExtremityFactoryDoubleLine extends AbstractExtremityFactory implements ExtremityFactory { + @Override + public UDrawable createUDrawable(XPoint2D p0, double angle, Side side) { + angle -= Math.PI / 2; + return new ExtremityDoubleLine(p0, angle); + } + @Override public UDrawable createUDrawable(XPoint2D p0, XPoint2D p1, XPoint2D p2, Side side) { final double ortho = atan2(p0, p2); diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryLineCrowfoot.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryLineCrowfoot.java index 72147f744..32d597507 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryLineCrowfoot.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryLineCrowfoot.java @@ -41,6 +41,12 @@ import net.sourceforge.plantuml.svek.AbstractExtremityFactory; import net.sourceforge.plantuml.svek.Side; public class ExtremityFactoryLineCrowfoot extends AbstractExtremityFactory implements ExtremityFactory { + + @Override + public UDrawable createUDrawable(XPoint2D p0, double angle, Side side) { + angle -= Math.PI / 2; + return new ExtremityLineCrowfoot(p0, angle); + } @Override public UDrawable createUDrawable(XPoint2D p0, XPoint2D p1, XPoint2D p2, Side side) { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageAssociationPoint.java b/src/net/sourceforge/plantuml/svek/image/EntityImageAssociationPoint.java index 5bad93433..0e55bc052 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageAssociationPoint.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageAssociationPoint.java @@ -39,12 +39,17 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.svek.AbstractEntityImage; import net.sourceforge.plantuml.svek.ShapeType; +import net.sourceforge.plantuml.ugraphic.CopyForegroundColorToBackgroundColor; import net.sourceforge.plantuml.ugraphic.UEllipse; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UShape; -import net.sourceforge.plantuml.ugraphic.color.HColors; +import net.sourceforge.plantuml.ugraphic.color.HColor; public class EntityImageAssociationPoint extends AbstractEntityImage { @@ -58,9 +63,16 @@ public class EntityImageAssociationPoint extends AbstractEntityImage { return new XDimension2D(SIZE, SIZE); } + private Style getStyle() { + return StyleSignatureBasic.of(SName.root, SName.element, SName.classDiagram, SName.arrow) + .withTOBECHANGED(getStereo()).getMergedStyle(getSkinParam().getCurrentStyleBuilder()); + } + final public void drawU(UGraphic ug) { final UShape circle = new UEllipse(SIZE, SIZE); - ug.apply(HColors.none()).apply(HColors.BLACK.bg()).draw(circle); + + final HColor color = getStyle().value(PName.LineColor).asColor(getSkinParam().getIHtmlColorSet()); + ug.apply(color).apply(new CopyForegroundColorToBackgroundColor()).draw(circle); } public ShapeType getShapeType() { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java b/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java index edd9540f8..134f1d1c6 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java @@ -39,7 +39,6 @@ import java.util.EnumMap; import java.util.Map; import net.sourceforge.plantuml.Direction; -import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineConfigurable; import net.sourceforge.plantuml.Url; @@ -96,8 +95,8 @@ public class EntityImageClass extends AbstractEntityImage implements Stencil, Wi final boolean showMethods = portionShower.showPortion(EntityPortion.METHOD, entity); final boolean showFields = portionShower.showPortion(EntityPortion.FIELD, entity); - this.body = entity.getBodier().getBody(FontParam.CLASS_ATTRIBUTE, getSkinParam(), showMethods, showFields, - entity.getStereotype(), getStyle(), null); + this.body = entity.getBodier().getBody(getSkinParam(), showMethods, showFields, entity.getStereotype(), + getStyle(), null); this.header = new EntityImageClassHeader(entity, getSkinParam(), portionShower); this.url = entity.getUrl99(); @@ -192,8 +191,9 @@ public class EntityImageClass extends AbstractEntityImage implements Stencil, Wi borderColor = getStyle().value(PName.LineColor).asColor(getSkinParam().getIHtmlColorSet()); if (headerBackcolor == null) - headerBackcolor = backcolor == null ? getStyleHeader().value(PName.BackGroundColor) - .asColor(getSkinParam().getIHtmlColorSet()) : backcolor; + headerBackcolor = backcolor == null + ? getStyleHeader().value(PName.BackGroundColor).asColor(getSkinParam().getIHtmlColorSet()) + : backcolor; if (backcolor == null) backcolor = getStyle().value(PName.BackGroundColor).asColor(getSkinParam().getIHtmlColorSet()); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageJson.java b/src/net/sourceforge/plantuml/svek/image/EntityImageJson.java index 3cb79c8a1..29615a6dc 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageJson.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageJson.java @@ -105,8 +105,8 @@ public class EntityImageJson extends AbstractEntityImage implements Stencil, Wit final FontConfiguration fontConfiguration = getStyleHeader() .getFontConfiguration(getSkinParam().getIHtmlColorSet()); - this.entries = entity.getBodier().getBody(FontParam.OBJECT_ATTRIBUTE, skinParam, false, false, - entity.getStereotype(), getStyle(), fontConfiguration); + this.entries = entity.getBodier().getBody(skinParam, false, false, entity.getStereotype(), getStyle(), + fontConfiguration); this.url = entity.getUrl99(); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageMap.java b/src/net/sourceforge/plantuml/svek/image/EntityImageMap.java index e7add8abd..5e5ab9361 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageMap.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageMap.java @@ -109,8 +109,8 @@ public class EntityImageMap extends AbstractEntityImage implements Stencil, With final FontConfiguration fontConfiguration = getStyleHeader() .getFontConfiguration(getSkinParam().getIHtmlColorSet()); - this.entries = entity.getBodier().getBody(FontParam.OBJECT_ATTRIBUTE, skinParam, false, false, - entity.getStereotype(), getStyle(), fontConfiguration); + this.entries = entity.getBodier().getBody(skinParam, false, false, entity.getStereotype(), getStyle(), + fontConfiguration); this.url = entity.getUrl99(); @@ -164,8 +164,9 @@ public class EntityImageMap extends AbstractEntityImage implements Stencil, With borderColor = getStyle().value(PName.LineColor).asColor(getSkinParam().getIHtmlColorSet()); if (headerBackcolor == null) - headerBackcolor = backcolor == null ? getStyleHeader().value(PName.BackGroundColor) - .asColor(getSkinParam().getIHtmlColorSet()) : backcolor; + headerBackcolor = backcolor == null + ? getStyleHeader().value(PName.BackGroundColor).asColor(getSkinParam().getIHtmlColorSet()) + : backcolor; if (backcolor == null) backcolor = style.value(PName.BackGroundColor).asColor(getSkinParam().getIHtmlColorSet()); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java b/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java index babfa1f13..46e31dcad 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java @@ -114,8 +114,8 @@ public class EntityImageObject extends AbstractEntityImage implements Stencil, W this.fields = new TextBlockLineBefore(getStyle().value(PName.LineThickness).asDouble(), new TextBlockEmpty(10, 16)); else - this.fields = entity.getBodier().getBody(FontParam.OBJECT_ATTRIBUTE, skinParam, false, showFields, - entity.getStereotype(), getStyle(), null); + this.fields = entity.getBodier().getBody(skinParam, false, showFields, entity.getStereotype(), getStyle(), + null); this.url = entity.getUrl99(); @@ -167,8 +167,9 @@ public class EntityImageObject extends AbstractEntityImage implements Stencil, W final HColor borderColor = style.value(PName.LineColor).asColor(getSkinParam().getIHtmlColorSet()); if (headerBackcolor == null) - headerBackcolor = backcolor == null ? getStyleHeader().value(PName.BackGroundColor) - .asColor(getSkinParam().getIHtmlColorSet()) : backcolor; + headerBackcolor = backcolor == null + ? getStyleHeader().value(PName.BackGroundColor).asColor(getSkinParam().getIHtmlColorSet()) + : backcolor; if (backcolor == null) backcolor = style.value(PName.BackGroundColor).asColor(getSkinParam().getIHtmlColorSet()); diff --git a/src/net/sourceforge/plantuml/theme/ThemeUtils.java b/src/net/sourceforge/plantuml/theme/ThemeUtils.java index 72442e838..ac42b9d76 100644 --- a/src/net/sourceforge/plantuml/theme/ThemeUtils.java +++ b/src/net/sourceforge/plantuml/theme/ThemeUtils.java @@ -48,7 +48,7 @@ import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.preproc.ReadLine; import net.sourceforge.plantuml.preproc.ReadLineReader; import net.sourceforge.plantuml.preproc.Stdlib; -import net.sourceforge.plantuml.sprite.RessourcesUtils; +import net.sourceforge.plantuml.sprite.ResourcesUtils; public class ThemeUtils { @@ -59,7 +59,7 @@ public class ThemeUtils { private static final String THEME_PATH = "themes"; public static List getAllThemeNames() throws IOException { - final Collection filenames = Objects.requireNonNull(RessourcesUtils.getJarFile(THEME_PATH, false)); + final Collection filenames = Objects.requireNonNull(ResourcesUtils.getJarFile(THEME_PATH, false)); final List result = new ArrayList<>(); for (String f : filenames) { if (f.startsWith(THEME_FILE_PREFIX) && f.endsWith(THEME_FILE_SUFFIX)) { diff --git a/src/net/sourceforge/plantuml/tim/expression/ShuntingYard.java b/src/net/sourceforge/plantuml/tim/expression/ShuntingYard.java index 1ac9a1885..f28892627 100644 --- a/src/net/sourceforge/plantuml/tim/expression/ShuntingYard.java +++ b/src/net/sourceforge/plantuml/tim/expression/ShuntingYard.java @@ -81,7 +81,7 @@ public class ShuntingYard { ouputQueue.add(variable.toToken()); } } else if (token.getTokenType() == TokenType.OPERATOR) { - while ((thereIsAFunctionAtTheTopOfTheOperatorStack(token) // + while ((thereIsAFunctionAtTheTopOfTheOperatorStack() // || thereIsAnOperatorAtTheTopOfTheOperatorStackWithGreaterPrecedence(token) // || theOperatorAtTheTopOfTheOperatorStackHasEqualPrecedenceAndIsLeftAssociative(token)) // && theOperatorAtTheTopOfTheOperatorStackIsNotALeftParenthesis(token)) @@ -125,7 +125,7 @@ public class ShuntingYard { return name.matches("[a-zA-Z0-9.$_]+"); } - private boolean thereIsAFunctionAtTheTopOfTheOperatorStack(Token token) { + private boolean thereIsAFunctionAtTheTopOfTheOperatorStack() { final Token top = operatorStack.peekFirst(); return top != null && top.getTokenType() == TokenType.FUNCTION_NAME; } diff --git a/src/net/sourceforge/plantuml/timingdiagram/graphic/TimeArrow.java b/src/net/sourceforge/plantuml/timingdiagram/graphic/TimeArrow.java index a7cf51d80..072db08bc 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/graphic/TimeArrow.java +++ b/src/net/sourceforge/plantuml/timingdiagram/graphic/TimeArrow.java @@ -110,7 +110,7 @@ public class TimeArrow implements UDrawable { final UFont font = UFont.serif(14); final HColor color = type.getSpecificColor(); - return FontConfiguration.create(font, color, color, false); + return FontConfiguration.create(font, color, color, null); } public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/ugraphic/AbstractCommonUGraphic.java b/src/net/sourceforge/plantuml/ugraphic/AbstractCommonUGraphic.java index 3ac067231..83fee8516 100644 --- a/src/net/sourceforge/plantuml/ugraphic/AbstractCommonUGraphic.java +++ b/src/net/sourceforge/plantuml/ugraphic/AbstractCommonUGraphic.java @@ -88,6 +88,8 @@ public abstract class AbstractCommonUGraphic implements UGraphic { copy.backColor = ((UBackground) change).getBackColor(); } else if (change instanceof HColor) { copy.color = (HColor) change; + } else if (change instanceof CopyForegroundColorToBackgroundColor) { + copy.backColor = this.color; } return copy; } diff --git a/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphic.java b/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphic.java index d64eeb7dd..6ecdb2ef1 100644 --- a/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphic.java +++ b/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphic.java @@ -49,8 +49,9 @@ public abstract class AbstractUGraphic extends AbstractCommonUGraphic { private final O graphic; // It would be nice to do something like this but not sure how: - // Map, UDriver> - // See https://stackoverflow.com/questions/416540/java-map-with-values-limited-by-keys-type-parameter + // Map, UDriver> + // See + // https://stackoverflow.com/questions/416540/java-map-with-values-limited-by-keys-type-parameter private final Map, UDriver> drivers = new HashMap<>(); public AbstractUGraphic(HColor defaultBackground, ColorMapper colorMapper, StringBounder stringBounder, O graphic) { @@ -76,25 +77,25 @@ public abstract class AbstractUGraphic extends AbstractCommonUGraphic { this.drivers.put(cl, driver); } - private static final UDriver NOOP_DRIVER = new UDriver() { + private static final UDriver NOOP_DRIVER = new UDriver() { @Override public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, Object object) { } }; - + @SuppressWarnings("unchecked") final protected void ignoreShape(Class cl) { registerDriver(cl, (UDriver) NOOP_DRIVER); } - + public final void draw(SHAPE shape) { if (shape instanceof SpecialText) { ((SpecialText) shape).getTitle().drawU(this); return; } - if (shape instanceof UEmpty) { + if (shape instanceof UEmpty) return; - } + if (shape instanceof UComment) { drawComment((UComment) shape); return; @@ -103,12 +104,12 @@ public abstract class AbstractUGraphic extends AbstractCommonUGraphic { @SuppressWarnings("unchecked") final UDriver driver = (UDriver) drivers.get(shape.getClass()); - if (driver == null) { + if (driver == null) throw new UnsupportedOperationException(shape.getClass().toString() + " " + this.getClass()); - } - if (getParam().isHidden() && manageHiddenAutomatically()) { + + if (getParam().isHidden() && manageHiddenAutomatically()) return; - } + beforeDraw(); driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), graphic); afterDraw(); diff --git a/src/net/sourceforge/plantuml/ugraphic/CopyForegroundColorToBackgroundColor.java b/src/net/sourceforge/plantuml/ugraphic/CopyForegroundColorToBackgroundColor.java new file mode 100644 index 000000000..019c7ec1c --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/CopyForegroundColorToBackgroundColor.java @@ -0,0 +1,40 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2023, 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.ugraphic; + +public class CopyForegroundColorToBackgroundColor implements UChange { + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java index 027ebf28d..9224370fc 100644 --- a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java +++ b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java @@ -51,6 +51,7 @@ import java.util.Set; import javax.swing.ImageIcon; import net.sourceforge.plantuml.AnimatedGifEncoder; +import net.sourceforge.plantuml.AnnotatedBuilder; import net.sourceforge.plantuml.AnnotatedWorker; import net.sourceforge.plantuml.CMapData; import net.sourceforge.plantuml.ColorParam; @@ -229,7 +230,9 @@ public class ImageBuilder { if (annotations && titledDiagram != null) { if (!(udrawable instanceof TextBlock)) throw new IllegalStateException("udrawable is not a TextBlock"); - final AnnotatedWorker annotatedWorker = new AnnotatedWorker(titledDiagram, skinParam, stringBounder); + final AnnotatedBuilder builder = new AnnotatedBuilder(titledDiagram, skinParam, stringBounder); + final AnnotatedWorker annotatedWorker = new AnnotatedWorker(titledDiagram, skinParam, stringBounder, + builder); udrawable = annotatedWorker.addAdd((TextBlock) udrawable); } diff --git a/src/net/sourceforge/plantuml/ugraphic/LimitFinder.java b/src/net/sourceforge/plantuml/ugraphic/LimitFinder.java index 00614e381..a610ca65a 100644 --- a/src/net/sourceforge/plantuml/ugraphic/LimitFinder.java +++ b/src/net/sourceforge/plantuml/ugraphic/LimitFinder.java @@ -53,8 +53,8 @@ public class LimitFinder extends UGraphicNo { final UTranslate tmp = change instanceof UTranslate ? this.getTranslate().compose((UTranslate) change) : this.getTranslate(); final LimitFinder result = new LimitFinder(this.getStringBounder(), tmp, this.minmax); - if (!instanceOfAny(change, UAntiAliasing.class, UBackground.class, UClip.class, HColor.class, UHidden.class, - UStroke.class, UTranslate.class)) + if (instanceOfAny(change, UAntiAliasing.class, UBackground.class, UClip.class, HColor.class, UHidden.class, + UStroke.class, UTranslate.class, CopyForegroundColorToBackgroundColor.class) == false) throw new UnsupportedOperationException(change.getClass().toString()); result.clip = change instanceof UClip ? ((UClip) change).translate(result.getTranslate()) : this.clip; return result; @@ -113,6 +113,8 @@ public class LimitFinder extends UGraphicNo { // Ignored } else if (shape instanceof SpecialText) { // Ignored + } else if (shape instanceof CopyForegroundColorToBackgroundColor) { + // Ignored } else if (shape instanceof UPixel) { addPoint(x, y); } else { diff --git a/src/net/sourceforge/plantuml/ugraphic/UPolygon.java b/src/net/sourceforge/plantuml/ugraphic/UPolygon.java index 4633e6409..567887595 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UPolygon.java +++ b/src/net/sourceforge/plantuml/ugraphic/UPolygon.java @@ -65,6 +65,10 @@ public class UPolygon extends AbstractShadowable { this.name = name; } + public XPoint2D getPoint(int idx) { + return all.get(idx); + } + public XPoint2D checkMiddleContactForSpecificTriangle(XPoint2D center) { for (int i = 0; i < all.size() - 1; i++) { final XPoint2D pt1 = all.get(i); diff --git a/src/net/sourceforge/plantuml/ugraphic/UStroke.java b/src/net/sourceforge/plantuml/ugraphic/UStroke.java index 9e6b63aad..c058a49f8 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UStroke.java +++ b/src/net/sourceforge/plantuml/ugraphic/UStroke.java @@ -65,9 +65,9 @@ public class UStroke implements UChange { } private UStroke applyThickness(UStroke thickness) { - if (thickness == null) { + if (thickness == null) return this; - } + return new UStroke(dashVisible, dashSpace, thickness.thickness); } @@ -84,9 +84,9 @@ public class UStroke implements UChange { } public String getDasharraySvg() { - if (dashVisible == 0) { + if (dashVisible == 0) return null; - } + return "" + dashVisible + "," + dashSpace; } diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverTextEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverTextEps.java index cbf3f7c79..3643d0643 100644 --- a/src/net/sourceforge/plantuml/ugraphic/eps/DriverTextEps.java +++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverTextEps.java @@ -69,14 +69,12 @@ public class DriverTextEps implements UDriver { public void draw(UText shape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) { final UClip clip = clipContainer.getClip(); - if (clip != null && clip.isInside(x, y) == false) { + if (clip != null && clip.isInside(x, y) == false) return; - } final FontConfiguration fontConfiguration = shape.getFontConfiguration(); - if (fontConfiguration.getColor().isTransparent()) { + if (fontConfiguration.getColor().isTransparent()) return; - } if (strategy == EpsStrategy.WITH_MACRO_AND_TEXT) { drawAsText(shape, x, y, param, eps, mapper); @@ -93,9 +91,9 @@ public class DriverTextEps implements UDriver { eps.setStrokeColor(extended); eps.setFillColor(extended); eps.setStrokeWidth(1, 0, 0); - if (dim == null) { + if (dim == null) dim = getMinMax(x, y, getOutline(textLayout).getPathIterator(null)); - } + eps.epsRectangle(dim.getMinX() - 1, dim.getMinY() - 1, dim.getWidth() + 2, dim.getHeight() + 2, 0, 0); } } @@ -105,25 +103,25 @@ public class DriverTextEps implements UDriver { if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) { final HColor extended = fontConfiguration.getExtendedColor(); - if (extended != null) { + if (extended != null) eps.setStrokeColor(extended.toColor(mapper)); - } - if (dim == null) { + + if (dim == null) dim = getMinMax(x, y, getOutline(textLayout).getPathIterator(null)); - } + eps.setStrokeWidth(1.1, 0, 0); eps.epsLine(x, y + 1.5, x + dim.getWidth(), y + 1.5); eps.setStrokeWidth(1, 0, 0); } if (fontConfiguration.containsStyle(FontStyle.WAVE)) { - if (dim == null) { + if (dim == null) dim = getMinMax(x, y, getOutline(textLayout).getPathIterator(null)); - } + final int ypos = (int) (y + 2.5) - 1; final HColor extended = fontConfiguration.getExtendedColor(); - if (extended != null) { + if (extended != null) eps.setStrokeColor(extended.toColor(mapper)); - } + eps.setStrokeWidth(1.1, 0, 0); for (int i = (int) x; i < x + dim.getWidth() - 5; i += 6) { eps.epsLine(i, ypos - 0, i + 3, ypos + 1); @@ -133,12 +131,12 @@ public class DriverTextEps implements UDriver { } if (fontConfiguration.containsStyle(FontStyle.STRIKE)) { final HColor extended = fontConfiguration.getExtendedColor(); - if (extended != null) { + if (extended != null) eps.setStrokeColor(extended.toColor(mapper)); - } - if (dim == null) { + + if (dim == null) dim = getMinMax(x, y, getOutline(textLayout).getPathIterator(null)); - } + // final FontMetrics fm = font.getFontMetrics(); final double ypos = (dim.getMinY() + dim.getMaxY() * 2) / 3; eps.setStrokeWidth(1.3, 0, 0); @@ -188,19 +186,18 @@ public class DriverTextEps implements UDriver { final double coord[] = new double[6]; while (path.isDone() == false) { final int code = path.currentSegment(coord); - if (code == PathIterator.SEG_MOVETO) { + if (code == PathIterator.SEG_MOVETO) eps.moveto(coord[0] + x, coord[1] + y); - } else if (code == PathIterator.SEG_LINETO) { + else if (code == PathIterator.SEG_LINETO) eps.lineto(coord[0] + x, coord[1] + y); - } else if (code == PathIterator.SEG_CLOSE) { + else if (code == PathIterator.SEG_CLOSE) eps.closepath(); - } else if (code == PathIterator.SEG_CUBICTO) { + else if (code == PathIterator.SEG_CUBICTO) eps.curveto(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y); - } else if (code == PathIterator.SEG_QUADTO) { + else if (code == PathIterator.SEG_QUADTO) eps.quadto(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y); - } else { + else throw new UnsupportedOperationException("code=" + code); - } path.next(); } @@ -213,16 +210,16 @@ public class DriverTextEps implements UDriver { final List closings = getClosings(shape.getPathIterator(null)); final List result = new ArrayList<>(); for (Integer cl : closings) { - if (cl + 2 >= count) { + if (cl + 2 >= count) break; - } + final PathIterator path1 = new PathIteratorLimited(shape, 0, cl); final PathIterator path2 = new PathIteratorLimited(shape, cl + 1, Integer.MAX_VALUE); final double max1 = getMinMax(0, 0, path1).getMaxX(); final double min2 = getMinMax(0, 0, path2).getMinX(); - if (min2 > max1) { + if (min2 > max1) result.add(cl); - } + } return result; } @@ -233,9 +230,9 @@ public class DriverTextEps implements UDriver { final double coord[] = new double[6]; while (path.isDone() == false) { final int code = path.currentSegment(coord); - if (code == PathIterator.SEG_CLOSE) { + if (code == PathIterator.SEG_CLOSE) result.add(current); - } + current++; path.next(); } diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java index 4a50f3e3b..18048cadb 100644 --- a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java +++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java @@ -69,7 +69,10 @@ public class DriverLineG2d extends DriverShadowedG2d implements UDriver { final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); final String fontNames[] = ge.getAvailableFontFamilyNames(); final int j = fontNames.length; - for (int i = 0; i < j; i++) { + for (int i = 0; i < j; i++) Log.info("Available fonts: " + fontNames[i]); - } + } public void draw(UText shape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) { @@ -85,7 +85,7 @@ public class DriverTextAsPathG2d implements UDriver { final XDimension2D dim = stringBounder.calculateDimension(font, shape.getText()); final double height = max(10, dim.getHeight()); final double width = dim.getWidth(); - + if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) { final Color extended = fontConfiguration.getExtendedColor().toColor(mapper); if (extended != null) { @@ -106,9 +106,9 @@ public class DriverTextAsPathG2d implements UDriver { if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) { final HColor extended = fontConfiguration.getExtendedColor(); - if (extended != null) { + if (extended != null) g2d.setColor(extended.toColor(mapper)); - } + final int ypos = (int) (y + 2.5); g2d.setStroke(new BasicStroke((float) 1)); g2d.drawLine((int) x, ypos, (int) (x + width), ypos); @@ -117,9 +117,9 @@ public class DriverTextAsPathG2d implements UDriver { if (fontConfiguration.containsStyle(FontStyle.WAVE)) { final int ypos = (int) (y + 2.5) - 1; final HColor extended = fontConfiguration.getExtendedColor(); - if (extended != null) { + if (extended != null) g2d.setColor(extended.toColor(mapper)); - } + for (int i = (int) x; i < x + width - 5; i += 6) { g2d.drawLine(i, ypos - 0, i + 3, ypos + 1); g2d.drawLine(i + 3, ypos + 1, i + 6, ypos - 0); @@ -129,9 +129,9 @@ public class DriverTextAsPathG2d implements UDriver { final FontMetrics fm = g2d.getFontMetrics(font.getUnderlayingFont()); final int ypos = (int) (y - fm.getDescent() - 0.5); final HColor extended = fontConfiguration.getExtendedColor(); - if (extended != null) { + if (extended != null) g2d.setColor(extended.toColor(mapper)); - } + g2d.setStroke(new BasicStroke((float) 1.5)); g2d.drawLine((int) x, ypos, (int) (x + width), ypos); g2d.setStroke(new BasicStroke()); diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java index 3187e782b..519960682 100644 --- a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java +++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java @@ -56,6 +56,7 @@ import net.sourceforge.plantuml.text.StyledString; import net.sourceforge.plantuml.ugraphic.UDriver; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UText; import net.sourceforge.plantuml.ugraphic.color.ColorMapper; import net.sourceforge.plantuml.ugraphic.color.HColor; @@ -74,9 +75,9 @@ public class DriverTextG2d implements UDriver { public void draw(UText shape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) { final FontConfiguration fontConfiguration = shape.getFontConfiguration(); - if (fontConfiguration.getColor().isTransparent()) { + if (fontConfiguration.getColor().isTransparent()) return; - } + final String text = shape.getText(); final List strings = StyledString.build(text); @@ -88,11 +89,11 @@ public class DriverTextG2d implements UDriver { } } - private double printSingleText(Graphics2D g2d, final FontConfiguration fontConfiguration, final String text, double x, - double y, ColorMapper mapper) { + private double printSingleText(Graphics2D g2d, final FontConfiguration fontConfiguration, final String text, + double x, double y, ColorMapper mapper) { final UFont font = fontConfiguration.getFont(); final HColor extended = fontConfiguration.getExtendedColor(); - + final XDimension2D dim = stringBounder.calculateDimension(font, text); final double height = max(10, dim.getHeight()); final double width = dim.getWidth(); @@ -114,7 +115,8 @@ public class DriverTextG2d implements UDriver { if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) { final Rectangle2D.Double area = new Rectangle2D.Double(x, y - height + 1.5, width, height); if (extended instanceof HColorGradient) { - final GradientPaint paint = DriverRectangleG2d.getPaintGradient(x, y, mapper, width, height, extended); + final GradientPaint paint = DriverRectangleG2d.getPaintGradient(x, y, mapper, width, height, + extended); g2d.setPaint(paint); g2d.fill(area); } else { @@ -135,19 +137,22 @@ public class DriverTextG2d implements UDriver { g2d.drawString(text, (float) x, (float) y); if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) { - if (extended != null) { + if (extended != null) g2d.setColor(extended.toColor(mapper)); + + final UStroke stroke = fontConfiguration.getUnderlineStroke(); + if (stroke.getThickness() > 0) { + DriverLineG2d.manageStroke(stroke, g2d); + final int ypos = (int) (y + 2.5); + g2d.drawLine((int) x, ypos, (int) (x + width), ypos); + g2d.setStroke(new BasicStroke()); } - final int ypos = (int) (y + 2.5); - g2d.setStroke(new BasicStroke((float) 1)); - g2d.drawLine((int) x, ypos, (int) (x + width), ypos); - g2d.setStroke(new BasicStroke()); } if (fontConfiguration.containsStyle(FontStyle.WAVE)) { final int ypos = (int) (y + 2.5) - 1; - if (extended != null) { + if (extended != null) g2d.setColor(extended.toColor(mapper)); - } + for (int i = (int) x; i < x + width - 5; i += 6) { g2d.drawLine(i, ypos - 0, i + 3, ypos + 1); g2d.drawLine(i + 3, ypos + 1, i + 6, ypos - 0); @@ -156,9 +161,9 @@ public class DriverTextG2d implements UDriver { if (fontConfiguration.containsStyle(FontStyle.STRIKE)) { final FontMetrics fm = g2d.getFontMetrics(font.getUnderlayingFont()); final int ypos = (int) (y - fm.getDescent() - 0.5); - if (extended != null) { + if (extended != null) g2d.setColor(extended.toColor(mapper)); - } + g2d.setStroke(new BasicStroke((float) 1.5)); g2d.drawLine((int) x, ypos, (int) (x + width), ypos); g2d.setStroke(new BasicStroke()); diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java index fe38e0c05..44755056f 100644 --- a/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java +++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java @@ -63,25 +63,25 @@ public class DriverTextSvg implements UDriver { public void draw(UText shape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) { final UClip clip = clipContainer.getClip(); - if (clip != null && clip.isInside(x, y) == false) { + if (clip != null && clip.isInside(x, y) == false) return; - } final FontConfiguration fontConfiguration = shape.getFontConfiguration(); - if (fontConfiguration.getColor().isTransparent()) { + if (fontConfiguration.getColor().isTransparent()) return; - } + final UFont font = fontConfiguration.getFont(); String fontWeight = null; - if (fontConfiguration.containsStyle(FontStyle.BOLD) || font.isBold()) { + if (fontConfiguration.containsStyle(FontStyle.BOLD) || font.isBold()) fontWeight = "bold"; - } + String fontStyle = null; - if (fontConfiguration.containsStyle(FontStyle.ITALIC) || font.isItalic()) { + if (fontConfiguration.containsStyle(FontStyle.ITALIC) || font.isItalic()) fontStyle = "italic"; - } + String textDecoration = null; - if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) { + if (fontConfiguration.containsStyle(FontStyle.UNDERLINE) + && fontConfiguration.getUnderlineStroke().getThickness() > 0) { textDecoration = "underline"; } else if (fontConfiguration.containsStyle(FontStyle.STRIKE)) { textDecoration = "line-through"; diff --git a/src/net/sourceforge/plantuml/utils/ObjectUtils.java b/src/net/sourceforge/plantuml/utils/ObjectUtils.java index 4d646c0ce..8b43e2a8d 100644 --- a/src/net/sourceforge/plantuml/utils/ObjectUtils.java +++ b/src/net/sourceforge/plantuml/utils/ObjectUtils.java @@ -3,11 +3,10 @@ package net.sourceforge.plantuml.utils; public class ObjectUtils { public static boolean instanceOfAny(Object object, Class... classes) { - for (Class c : classes) { - if (c.isInstance(object)) { + for (Class c : classes) + if (c.isInstance(object)) return true; - } - } + return false; } } diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 914dd6da2..b48369726 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -81,7 +81,7 @@ public class Version { } public static int beta() { - final int beta = 0; + final int beta = 1; return beta; } diff --git a/src/net/sourceforge/plantuml/wire/WBlock.java b/src/net/sourceforge/plantuml/wire/WBlock.java index e18470689..573a12b87 100644 --- a/src/net/sourceforge/plantuml/wire/WBlock.java +++ b/src/net/sourceforge/plantuml/wire/WBlock.java @@ -234,7 +234,7 @@ public class WBlock { public void drawMe(UGraphic ug) { drawBox(ug); final UFont font = UFont.sansSerif(12); - final FontConfiguration fc = FontConfiguration.create(font, getBlack(), getBlack(), false); + final FontConfiguration fc = FontConfiguration.create(font, getBlack(), getBlack(), null); final Display display = Display.create(name.replace('_', ' ')); final TextBlock text = display.create(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); text.drawU(ug.apply(UTranslate.dx(5))); diff --git a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramArgo.java b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramArgo.java index 1ba419516..e3184bba0 100644 --- a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramArgo.java +++ b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramArgo.java @@ -81,8 +81,8 @@ public class XmiClassDiagramArgo extends XmiClassDiagramAbstract implements XmlD end1.setAttribute("xmi.id", "end" + classDiagram.getUniqueSequence()); end1.setAttribute("association", assId); end1.setAttribute("type", link.getEntity1().getUid()); - if (link.getQualifier1() != null) - end1.setAttribute("name", forXMI(link.getQualifier1())); + if (link.getQuantifier1() != null) + end1.setAttribute("name", forXMI(link.getQuantifier1())); final Element endparticipant1 = document.createElement("UML:AssociationEnd.participant"); @@ -104,8 +104,8 @@ public class XmiClassDiagramArgo extends XmiClassDiagramAbstract implements XmlD end2.setAttribute("xmi.id", "end" + classDiagram.getUniqueSequence()); end2.setAttribute("association", assId); end2.setAttribute("type", link.getEntity2().getUid()); - if (link.getQualifier2() != null) - end2.setAttribute("name", forXMI(link.getQualifier2())); + if (link.getQuantifier2() != null) + end2.setAttribute("name", forXMI(link.getQuantifier2())); final Element endparticipant2 = document.createElement("UML:AssociationEnd.participant"); diff --git a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStar.java b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStar.java index 603289d47..c6a087036 100644 --- a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStar.java +++ b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStar.java @@ -84,8 +84,8 @@ public class XmiClassDiagramStar extends XmiClassDiagramAbstract implements XmlD end1.setAttribute("xmi.id", "end" + classDiagram.getUniqueSequence()); end1.setAttribute("association", assId); end1.setAttribute("type", link.getEntity1().getUid()); - if (link.getQualifier1() != null) - end1.setAttribute("name", forXMI(link.getQualifier1())); + if (link.getQuantifier1() != null) + end1.setAttribute("name", forXMI(link.getQuantifier1())); final Element endparticipant1 = document.createElement("UML:AssociationEnd.participant"); @@ -102,8 +102,8 @@ public class XmiClassDiagramStar extends XmiClassDiagramAbstract implements XmlD end2.setAttribute("xmi.id", "end" + classDiagram.getUniqueSequence()); end2.setAttribute("association", assId); end2.setAttribute("type", link.getEntity2().getUid()); - if (link.getQualifier2() != null) - end2.setAttribute("name", forXMI(link.getQualifier2())); + if (link.getQuantifier2() != null) + end2.setAttribute("name", forXMI(link.getQuantifier2())); final Element endparticipant2 = document.createElement("UML:AssociationEnd.participant"); diff --git a/src/net/sourceforge/plantuml/xmi/XmiDescriptionDiagram.java b/src/net/sourceforge/plantuml/xmi/XmiDescriptionDiagram.java index c70d2b69e..3df9420a7 100644 --- a/src/net/sourceforge/plantuml/xmi/XmiDescriptionDiagram.java +++ b/src/net/sourceforge/plantuml/xmi/XmiDescriptionDiagram.java @@ -147,8 +147,8 @@ public class XmiDescriptionDiagram implements XmlDiagramTransformer { end1.setAttribute("xmi.id", "end" + diagram.getUniqueSequence()); end1.setAttribute("association", assId); end1.setAttribute("type", link.getEntity1().getUid()); - if (link.getQualifier1() != null) - end1.setAttribute("name", forXMI(link.getQualifier1())); + if (link.getQuantifier1() != null) + end1.setAttribute("name", forXMI(link.getQuantifier1())); final Element endparticipant1 = document.createElement("UML:AssociationEnd.participant"); @@ -165,8 +165,8 @@ public class XmiDescriptionDiagram implements XmlDiagramTransformer { end2.setAttribute("xmi.id", "end" + diagram.getUniqueSequence()); end2.setAttribute("association", assId); end2.setAttribute("type", link.getEntity2().getUid()); - if (link.getQualifier2() != null) - end2.setAttribute("name", forXMI(link.getQualifier2())); + if (link.getQuantifier2() != null) + end2.setAttribute("name", forXMI(link.getQuantifier2())); final Element endparticipant2 = document.createElement("UML:AssociationEnd.participant"); if (link.getType().getDecor1() == LinkDecor.COMPOSITION) diff --git a/src/net/sourceforge/plantuml/xmi/XmiStateDiagram.java b/src/net/sourceforge/plantuml/xmi/XmiStateDiagram.java index 5740dc966..86a3cb36c 100644 --- a/src/net/sourceforge/plantuml/xmi/XmiStateDiagram.java +++ b/src/net/sourceforge/plantuml/xmi/XmiStateDiagram.java @@ -155,8 +155,8 @@ public class XmiStateDiagram implements XmlDiagramTransformer { end1.setAttribute("xmi.id", "end" + diagram.getUniqueSequence()); end1.setAttribute("association", assId); end1.setAttribute("type", link.getEntity1().getUid()); - if (link.getQualifier1() != null) { - end1.setAttribute("name", forXMI(link.getQualifier1())); + if (link.getQuantifier1() != null) { + end1.setAttribute("name", forXMI(link.getQuantifier1())); } final Element endparticipant1 = document.createElement("UML:AssociationEnd.participant"); @@ -174,8 +174,8 @@ public class XmiStateDiagram implements XmlDiagramTransformer { end2.setAttribute("xmi.id", "end" + diagram.getUniqueSequence()); end2.setAttribute("association", assId); end2.setAttribute("type", link.getEntity2().getUid()); - if (link.getQualifier2() != null) { - end2.setAttribute("name", forXMI(link.getQualifier2())); + if (link.getQuantifier2() != null) { + end2.setAttribute("name", forXMI(link.getQuantifier2())); } final Element endparticipant2 = document.createElement("UML:AssociationEnd.participant"); if (link.getType().getDecor1() == LinkDecor.COMPOSITION) { diff --git a/test/net/sourceforge/plantuml/SkinParamTest.java b/test/net/sourceforge/plantuml/SkinParamTest.java index dec9d27df..b9a066183 100644 --- a/test/net/sourceforge/plantuml/SkinParamTest.java +++ b/test/net/sourceforge/plantuml/SkinParamTest.java @@ -29,8 +29,8 @@ class SkinParamTest { // /** - * A long and verbose test method! - * But it helps us to avoid accidentally changing a default style. + * A long and verbose test method! But it helps us to avoid accidentally + * changing a default style. */ @ParameterizedTest @EnumSource(UmlDiagramType.class) @@ -257,7 +257,7 @@ class SkinParamTest { assertThat(skinParam.useSwimlanes(umlDiagramType)).isFalse(); - assertThat(skinParam.useUnderlineForHyperlink()).isTrue(); + assertThat(skinParam.useUnderlineForHyperlink()).isNotNull(); final LineBreakStrategy wrapWidth = skinParam.wrapWidth(); assertThat(wrapWidth.isAuto()).isFalse(); @@ -289,63 +289,41 @@ class SkinParamTest { } @ParameterizedTest - @CsvSource({ - "true, true", - "tRUe, true", - "TRUE, true", - "other_value, false", - }) + @CsvSource({ "true, true", "tRUe, true", "TRUE, true", "other_value, false", }) public void test_fixCircleLabelOverlapping(String paramValue, boolean expected) { final SkinParam skinParam = createSkinParam("fixCircleLabelOverlapping", paramValue); assertThat(skinParam.fixCircleLabelOverlapping()).isEqualTo(expected); } @ParameterizedTest - @CsvSource({ - "old, true", - "oLd, true", - "OLD, true", - "other_value, false", - }) + @CsvSource({ "old, true", "oLd, true", "OLD, true", "other_value, false", }) public void test_genericDisplay(String paramValue, boolean expected) { final SkinParam skinParam = createSkinParam("genericDisplay", paramValue); assertThat(skinParam.displayGenericWithOldFashion()).isEqualTo(expected); } @ParameterizedTest - @CsvSource({ - "0, MAX_VALUE", - "1, MAX_VALUE", - "2, 2", - "123, 123" - }) + @CsvSource({ "0, MAX_VALUE", "1, MAX_VALUE", "2, 2", "123, 123" }) public void test_groupInheritance(String paramValue, String expectedValue) { final SkinParam skinParam = createSkinParam("groupInheritance", paramValue); assertThat(skinParam.groupInheritance()).isEqualTo(intFromCsv(expectedValue)); } @ParameterizedTest - @CsvSource({ - "true, true", - "tRUe, true", - "TRUE, true", - "other_value, false", - }) + @CsvSource({ "true, true", "tRUe, true", "TRUE, true", "other_value, false", }) public void test_handwritten(String paramValue, boolean expected) { final SkinParam skinParam = createSkinParam("handwritten", paramValue); assertThat(skinParam.handwritten()).isEqualTo(expected); } @ParameterizedTest - @CsvSource({ - "false, false", - "fALSe, false", - "FALSE, false", - "other_value, true", - }) + @CsvSource({ "false, false", "fALSe, false", "FALSE, false", "other_value, true", }) public void test_hyperlinkUnderline(String paramValue, boolean expected) { final SkinParam skinParam = createSkinParam("hyperlinkUnderline", paramValue); - assertThat(skinParam.useUnderlineForHyperlink()).isEqualTo(expected); + if (expected) + assertThat(skinParam.useUnderlineForHyperlink()).isNotNull(); + else + assertThat(skinParam.useUnderlineForHyperlink()).isNull(); } @Test @@ -379,36 +357,21 @@ class SkinParamTest { } @ParameterizedTest - @CsvSource({ - "true, true", - "tRUe, true", - "TRUE, true", - "other_value, false", - }) + @CsvSource({ "true, true", "tRUe, true", "TRUE, true", "other_value, false", }) public void test_responseMessageBelowArrow(String paramValue, boolean expected) { final SkinParam skinParam = createSkinParam("responseMessageBelowArrow", paramValue); assertThat(skinParam.responseMessageBelowArrow()).isEqualTo(expected); } @ParameterizedTest - @CsvSource({ - "true, true", - "tRUe, true", - "TRUE, true", - "other_value, false", - }) + @CsvSource({ "true, true", "tRUe, true", "TRUE, true", "other_value, false", }) public void test_sameClassWidth(String paramValue, boolean expected) { final SkinParam skinParam = createSkinParam("sameClassWidth", paramValue); assertThat(skinParam.sameClassWidth()).isEqualTo(expected); } @ParameterizedTest - @CsvSource({ - "underline, true", - "undERLine, true", - "UNDERLINE, true", - "other_value, false", - }) + @CsvSource({ "underline, true", "undERLine, true", "UNDERLINE, true", "other_value, false", }) public void test_sequenceParticipant(String paramValue, boolean expected) { final SkinParam skinParam = createSkinParam("sequenceParticipant", paramValue); assertThat(skinParam.forceSequenceParticipantUnderlined()).isEqualTo(expected); @@ -416,11 +379,8 @@ class SkinParamTest { @Test public void testSplitParam() { - final SkinParam skinParam = createSkinParam( - "pageBorderColor", "red", - "pageExternalColor", "yellow", - "pageMargin", "123" - ); + final SkinParam skinParam = createSkinParam("pageBorderColor", "red", "pageExternalColor", "yellow", + "pageMargin", "123"); final SplitParam splitParam = skinParam.getSplitParam(); assertThat(splitParam.getBorderColor()).isEqualTo(Color.RED); @@ -429,36 +389,21 @@ class SkinParamTest { } @ParameterizedTest - @CsvSource({ - "bottom, false", - "boTTom, false", - "BOTTOM, false", - "other_value, true", - }) + @CsvSource({ "bottom, false", "boTTom, false", "BOTTOM, false", "other_value, true", }) public void test_stereotypePosition(String paramValue, boolean expected) { final SkinParam skinParam = createSkinParam("stereotypePosition", paramValue); assertThat(skinParam.stereotypePositionTop()).isEqualTo(expected); } @ParameterizedTest - @CsvSource({ - "strictuml, true", - "strICTuml, true", - "STRICTUML, true", - "other_value, false", - }) + @CsvSource({ "strictuml, true", "strICTuml, true", "STRICTUML, true", "other_value, false", }) public void test_style(String paramValue, boolean expected) { final SkinParam skinParam = createSkinParam("style", paramValue); assertThat(skinParam.strictUmlStyle()).isEqualTo(expected); } @ParameterizedTest - @CsvSource({ - "false, false", - "fALSe, false", - "FALSE, false", - "other_value, true", - }) + @CsvSource({ "false, false", "fALSe, false", "FALSE, false", "other_value, true", }) public void test_svgDimensionStyle(String paramValue, boolean expected) { final SkinParam skinParam = createSkinParam("svgDimensionStyle", paramValue); assertThat(skinParam.svgDimensionStyle()).isEqualTo(expected); @@ -472,20 +417,12 @@ class SkinParamTest { @ParameterizedTest @CsvSource({ - // swimlane swimlanes expected - " true, any_value, true", - " tRUe, any_value, true", - " TRUE, any_value, true", - " other_value, true, true", - " other_value, tRUe, true", - " other_value, TRUE, true", - " other_value, other_value, false", - }) + // swimlane swimlanes expected + " true, any_value, true", " tRUe, any_value, true", " TRUE, any_value, true", + " other_value, true, true", " other_value, tRUe, true", " other_value, TRUE, true", + " other_value, other_value, false", }) public void test_swimlanes(String swimlane, String swimlanes, boolean expected) { - final SkinParam skinParam = createSkinParam( - "swimlane", swimlane, - "swimlanes", swimlanes - ); + final SkinParam skinParam = createSkinParam("swimlane", swimlane, "swimlanes", swimlanes); assertThat(skinParam.swimlanes()).isEqualTo(expected); } @@ -500,7 +437,8 @@ class SkinParamTest { // private SkinParam createSkinParam(String... keyValuePairs) { - // Using SEQUENCE here is an arbitrary decision that should not affect test outcome + // Using SEQUENCE here is an arbitrary decision that should not affect test + // outcome final SkinParam skinParam = SkinParam.create(UmlDiagramType.SEQUENCE); for (int i = 0; i < keyValuePairs.length; i += 2) { skinParam.setParam(StringUtils.goLowerCase(keyValuePairs[i]), keyValuePairs[i + 1]); diff --git a/test/nonreg/simple/A0005_TestResult.java b/test/nonreg/simple/A0005_TestResult.java index b59329391..9bf7cce50 100644 --- a/test/nonreg/simple/A0005_TestResult.java +++ b/test/nonreg/simple/A0005_TestResult.java @@ -5,7 +5,7 @@ public class A0005_TestResult { /* """ DPI: 96 -dimension: [ 128.0935 ; 275.0000 ] +dimension: [ 134.0935 ; 281.0000 ] scaleFactor: 1.0000 seed: 1145907385572836867 svgLinkTarget: _top @@ -13,12 +13,12 @@ hoverPathColorRGB: null preserveAspectRatio: none EMPTY: - pt1: [ 43.7612 ; 0.0000 ] - pt2: [ 122.0935 ; 11.0000 ] + pt1: [ 49.7612 ; 0.0000 ] + pt2: [ 128.0935 ; 11.0000 ] RECTANGLE: - pt1: [ 43.7612 ; 0.0000 ] - pt2: [ 121.0935 ; 10.0000 ] + pt1: [ 49.7612 ; 0.0000 ] + pt2: [ 127.0935 ; 10.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -28,19 +28,19 @@ RECTANGLE: TEXT: text: header - position: [ 43.7612 ; 7.7778 ] + position: [ 49.7612 ; 7.7778 ] orientation: 0 font: SansSerif.plain/10 [] color: ff888888 extendedColor: NULL_COLOR EMPTY: - pt1: [ 20.7059 ; 11.0000 ] - pt2: [ 101.3876 ; 46.0000 ] + pt1: [ 23.7059 ; 11.0000 ] + pt2: [ 104.3876 ; 46.0000 ] RECTANGLE: - pt1: [ 25.7059 ; 16.0000 ] - pt2: [ 95.3876 ; 40.0000 ] + pt1: [ 28.7059 ; 16.0000 ] + pt2: [ 98.3876 ; 40.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -50,7 +50,7 @@ RECTANGLE: TEXT: text: title - position: [ 30.7059 ; 31.8889 ] + position: [ 33.7059 ; 31.8889 ] orientation: 0 font: SansSerif.bold/14 [BOLD] color: ff000000 @@ -58,8 +58,8 @@ TEXT: COMMENT: class Bob RECTANGLE: - pt1: [ 29.1999 ; 136.0000 ] - pt2: [ 105.9463 ; 198.0000 ] + pt1: [ 32.1999 ; 136.0000 ] + pt2: [ 108.9463 ; 198.0000 ] xCorner: 5 yCorner: 5 stroke: 0.0-0.0-0.5 @@ -68,12 +68,12 @@ RECTANGLE: backcolor: fff1f1f1 EMPTY: - pt1: [ 33.2685 ; 136.0000 ] - pt2: [ 59.2685 ; 168.0000 ] + pt1: [ 36.2685 ; 136.0000 ] + pt2: [ 62.2685 ; 168.0000 ] ELLIPSE: - pt1: [ 37.2685 ; 141.0000 ] - pt2: [ 59.2685 ; 163.0000 ] + pt1: [ 40.2685 ; 141.0000 ] + pt2: [ 62.2685 ; 163.0000 ] start: 0.0 extend: 0.0 stroke: 0.0-0.0-1.0 @@ -83,56 +83,56 @@ ELLIPSE: CENTERED_CHAR: char: C - position: [ 48.2685 ; 152.0000 ] + position: [ 51.2685 ; 152.0000 ] font: Monospaced.bold/17 color: ff000000 EMPTY: - pt1: [ 60.1726 ; 145.0000 ] - pt2: [ 101.8776 ; 159.0000 ] + pt1: [ 63.1726 ; 145.0000 ] + pt2: [ 104.8776 ; 159.0000 ] TEXT: text: Bob - position: [ 63.1726 ; 155.8889 ] + position: [ 66.1726 ; 155.8889 ] orientation: 0 font: SansSerif.plain/14 [] color: ff000000 extendedColor: NULL_COLOR LINE: - pt1: [ 30.1999 ; 168.0000 ] - pt2: [ 104.9463 ; 168.0000 ] + pt1: [ 33.1999 ; 168.0000 ] + pt2: [ 107.9463 ; 168.0000 ] stroke: 0.0-0.0-0.5 shadow: 0 color: ff181818 EMPTY: - pt1: [ 29.1999 ; 168.0000 ] - pt2: [ 105.9463 ; 190.0000 ] + pt1: [ 32.1999 ; 168.0000 ] + pt2: [ 108.9463 ; 190.0000 ] TEXT: text: hello - position: [ 35.1999 ; 182.8889 ] + position: [ 38.1999 ; 182.8889 ] orientation: 0 font: SansSerif.plain/14 [] color: ff000000 extendedColor: NULL_COLOR LINE: - pt1: [ 30.1999 ; 190.0000 ] - pt2: [ 104.9463 ; 190.0000 ] + pt1: [ 33.1999 ; 190.0000 ] + pt2: [ 107.9463 ; 190.0000 ] stroke: 0.0-0.0-0.5 shadow: 0 color: ff181818 EMPTY: - pt1: [ 29.1999 ; 190.0000 ] - pt2: [ 41.1999 ; 198.0000 ] + pt1: [ 32.1999 ; 190.0000 ] + pt2: [ 44.1999 ; 198.0000 ] COMMENT: class Sally RECTANGLE: - pt1: [ 21.6999 ; 52.0000 ] - pt2: [ 113.3937 ; 100.0000 ] + pt1: [ 24.6999 ; 52.0000 ] + pt2: [ 116.3937 ; 100.0000 ] xCorner: 5 yCorner: 5 stroke: 0.0-0.0-0.5 @@ -141,12 +141,12 @@ RECTANGLE: backcolor: fff1f1f1 EMPTY: - pt1: [ 21.6999 ; 52.0000 ] - pt2: [ 47.6999 ; 84.0000 ] + pt1: [ 24.6999 ; 52.0000 ] + pt2: [ 50.6999 ; 84.0000 ] ELLIPSE: - pt1: [ 25.6999 ; 57.0000 ] - pt2: [ 47.6999 ; 79.0000 ] + pt1: [ 28.6999 ; 57.0000 ] + pt2: [ 50.6999 ; 79.0000 ] start: 0.0 extend: 0.0 stroke: 0.0-0.0-1.0 @@ -156,43 +156,43 @@ ELLIPSE: CENTERED_CHAR: char: C - position: [ 36.6999 ; 68.0000 ] + position: [ 39.6999 ; 68.0000 ] font: Monospaced.bold/17 color: ff000000 EMPTY: - pt1: [ 47.6999 ; 61.0000 ] - pt2: [ 113.3937 ; 75.0000 ] + pt1: [ 50.6999 ; 61.0000 ] + pt2: [ 116.3937 ; 75.0000 ] TEXT: text: Sally - position: [ 50.6999 ; 71.8889 ] + position: [ 53.6999 ; 71.8889 ] orientation: 0 font: SansSerif.plain/14 [] color: ff000000 extendedColor: NULL_COLOR LINE: - pt1: [ 22.6999 ; 84.0000 ] - pt2: [ 112.3937 ; 84.0000 ] + pt1: [ 25.6999 ; 84.0000 ] + pt2: [ 115.3937 ; 84.0000 ] stroke: 0.0-0.0-0.5 shadow: 0 color: ff181818 EMPTY: - pt1: [ 21.6999 ; 84.0000 ] - pt2: [ 33.6999 ; 92.0000 ] + pt1: [ 24.6999 ; 84.0000 ] + pt2: [ 36.6999 ; 92.0000 ] LINE: - pt1: [ 22.6999 ; 92.0000 ] - pt2: [ 112.3937 ; 92.0000 ] + pt1: [ 25.6999 ; 92.0000 ] + pt2: [ 115.3937 ; 92.0000 ] stroke: 0.0-0.0-0.5 shadow: 0 color: ff181818 EMPTY: - pt1: [ 21.6999 ; 92.0000 ] - pt2: [ 33.6999 ; 100.0000 ] + pt1: [ 24.6999 ; 92.0000 ] + pt2: [ 36.6999 ; 100.0000 ] PATH: - type: SEG_MOVETO @@ -208,11 +208,11 @@ PATH: POLYGON: points: - - [ 67.6999 ; 135.7328 ] - - [ 71.6999 ; 126.7328 ] - - [ 67.6999 ; 130.7328 ] - - [ 63.6999 ; 126.7328 ] - - [ 67.6999 ; 135.7328 ] + - [ 70.6999 ; 135.7328 ] + - [ 74.6999 ; 126.7328 ] + - [ 70.6999 ; 130.7328 ] + - [ 66.6999 ; 126.7328 ] + - [ 70.6999 ; 135.7328 ] stroke: 0.0-0.0-1.0 shadow: 0 color: ff181818 @@ -220,11 +220,11 @@ POLYGON: EMPTY: pt1: [ 0.0000 ; 193.0000 ] - pt2: [ 122.0935 ; 236.0000 ] + pt2: [ 128.0935 ; 242.0000 ] RECTANGLE: - pt1: [ 8.0000 ; 201.0000 ] - pt2: [ 113.0935 ; 227.0000 ] + pt1: [ 12.0000 ; 205.0000 ] + pt2: [ 115.0935 ; 229.0000 ] xCorner: 15 yCorner: 15 stroke: 0.0-0.0-1.0 @@ -234,19 +234,19 @@ RECTANGLE: TEXT: text: legend - position: [ 14.0000 ; 217.8889 ] + position: [ 17.0000 ; 220.8889 ] orientation: 0 font: SansSerif.plain/14 [] color: ff000000 extendedColor: NULL_COLOR EMPTY: - pt1: [ 2.6679 ; 236.0000 ] - pt2: [ 119.4256 ; 253.0000 ] + pt1: [ 5.6679 ; 242.0000 ] + pt2: [ 122.4256 ; 259.0000 ] RECTANGLE: - pt1: [ 3.6679 ; 237.0000 ] - pt2: [ 117.4256 ; 251.0000 ] + pt1: [ 6.6679 ; 243.0000 ] + pt2: [ 120.4256 ; 257.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -256,19 +256,19 @@ RECTANGLE: TEXT: text: caption - position: [ 3.6679 ; 247.8889 ] + position: [ 6.6679 ; 253.8889 ] orientation: 0 font: SansSerif.plain/14 [] color: ff000000 extendedColor: NULL_COLOR EMPTY: - pt1: [ 16.9796 ; 253.0000 ] - pt2: [ 105.1139 ; 269.0000 ] + pt1: [ 19.9796 ; 259.0000 ] + pt2: [ 108.1139 ; 275.0000 ] RECTANGLE: - pt1: [ 16.9796 ; 253.0000 ] - pt2: [ 104.1139 ; 268.0000 ] + pt1: [ 19.9796 ; 259.0000 ] + pt2: [ 107.1139 ; 274.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -278,7 +278,7 @@ RECTANGLE: TEXT: text: footer - position: [ 16.9796 ; 264.6667 ] + position: [ 19.9796 ; 270.6667 ] orientation: 0 font: SansSerif.plain/15 [] color: ffff0000 diff --git a/test/nonreg/simple/A0006_TestResult.java b/test/nonreg/simple/A0006_TestResult.java index 36cfff6c9..c82dc67d1 100644 --- a/test/nonreg/simple/A0006_TestResult.java +++ b/test/nonreg/simple/A0006_TestResult.java @@ -5,7 +5,7 @@ public class A0006_TestResult { /* """ DPI: 96 -dimension: [ 149.3989 ; 225.0000 ] +dimension: [ 149.3989 ; 231.0000 ] scaleFactor: 1.0000 seed: -2375783792654745998 svgLinkTarget: _top @@ -35,12 +35,12 @@ TEXT: extendedColor: NULL_COLOR EMPTY: - pt1: [ 13.3206 ; 186.0000 ] - pt2: [ 130.0783 ; 203.0000 ] + pt1: [ 13.3206 ; 192.0000 ] + pt2: [ 130.0783 ; 209.0000 ] RECTANGLE: - pt1: [ 14.3206 ; 187.0000 ] - pt2: [ 128.0783 ; 201.0000 ] + pt1: [ 14.3206 ; 193.0000 ] + pt2: [ 128.0783 ; 207.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -50,7 +50,7 @@ RECTANGLE: TEXT: text: caption - position: [ 14.3206 ; 197.8889 ] + position: [ 14.3206 ; 203.8889 ] orientation: 0 font: SansSerif.plain/14 [] color: ff000000 @@ -183,12 +183,12 @@ TEXT: extendedColor: NULL_COLOR EMPTY: - pt1: [ 27.6323 ; 203.0000 ] - pt2: [ 115.7666 ; 219.0000 ] + pt1: [ 27.6323 ; 209.0000 ] + pt2: [ 115.7666 ; 225.0000 ] RECTANGLE: - pt1: [ 27.6323 ; 203.0000 ] - pt2: [ 114.7666 ; 218.0000 ] + pt1: [ 27.6323 ; 209.0000 ] + pt2: [ 114.7666 ; 224.0000 ] xCorner: 0 yCorner: 0 stroke: 0.0-0.0-1.0 @@ -198,19 +198,19 @@ RECTANGLE: TEXT: text: footer - position: [ 27.6323 ; 214.6667 ] + position: [ 27.6323 ; 220.6667 ] orientation: 0 font: SansSerif.plain/15 [] color: ffff0000 extendedColor: NULL_COLOR EMPTY: - pt1: [ 10.6527 ; 143.0000 ] - pt2: [ 132.7462 ; 186.0000 ] + pt1: [ 7.6527 ; 143.0000 ] + pt2: [ 135.7462 ; 192.0000 ] RECTANGLE: - pt1: [ 18.6527 ; 151.0000 ] - pt2: [ 123.7462 ; 177.0000 ] + pt1: [ 19.6527 ; 155.0000 ] + pt2: [ 122.7462 ; 179.0000 ] xCorner: 15 yCorner: 15 stroke: 0.0-0.0-1.0 @@ -220,7 +220,7 @@ RECTANGLE: TEXT: text: legend - position: [ 24.6527 ; 167.8889 ] + position: [ 24.6527 ; 170.8889 ] orientation: 0 font: SansSerif.plain/14 [] color: ff000000