This commit is contained in:
Arnaud Roques 2022-10-05 22:32:57 +02:00
parent 70ad50746a
commit f0048de5b7
133 changed files with 1942 additions and 1133 deletions

View File

@ -5,6 +5,7 @@ root {
FontName SansSerif FontName SansSerif
HyperLinkColor blue HyperLinkColor blue
HyperLinkUnderlineThickness 1
FontColor black FontColor black
FontSize 14 FontSize 14
FontStyle plain FontStyle plain
@ -47,8 +48,8 @@ document {
BackGroundColor #D BackGroundColor #D
FontSize 14 FontSize 14
RoundCorner 15 RoundCorner 15
Padding 6 Padding 5
Margin 8 Margin 12
} }
caption { caption {
HorizontalAlignment center HorizontalAlignment center
@ -69,6 +70,11 @@ stereotype {
} }
mainframe {
Padding 1 5
LineThickness 1.5
Margin 10 5
}
element { element {
Shadowing 0.0 Shadowing 0.0

View File

@ -1,6 +1,7 @@
root { root {
FontName SansSerif FontName SansSerif
HyperLinkColor blue HyperLinkColor blue
HyperLinkUnderlineThickness 1
FontColor black FontColor black
FontSize 14 FontSize 14
FontStyle plain FontStyle plain

View File

@ -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());
}
}

View File

@ -35,130 +35,52 @@
*/ */
package net.sourceforge.plantuml; 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.DisplayPositioned;
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.SymbolContext;
import net.sourceforge.plantuml.graphic.TextBlock; 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.DecorateEntityImage;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; 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 { public class AnnotatedWorker {
private final Annotated annotated; private final Annotated annotated;
private final ISkinParam skinParam; private final ISkinParam skinParam;
private final StringBounder stringBounder; 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.annotated = annotated;
this.skinParam = skinParam; this.skinParam = skinParam;
this.stringBounder = stringBounder; this.stringBounder = stringBounder;
this.builder = builder;
} }
public TextBlockBackcolored addAdd(TextBlock result) { public TextBlockBackcolored addAdd(TextBlock result) {
result = addFrame(result); result = builder.decoreWithFrame(result);
result = addLegend(result); result = addLegend(result);
result = addTitle(result); result = addTitle(result);
result = addCaption(result); result = addCaption(result);
result = addHeaderAndFooter(result); result = builder.addHeaderAndFooter(result);
return (TextBlockBackcolored) result; return (TextBlockBackcolored) result;
} }
public boolean hasMainFrame() { public TextBlock addLegend(TextBlock original) {
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) {
final DisplayPositioned legend = annotated.getLegend(); final DisplayPositioned legend = annotated.getLegend();
if (legend.isNull()) if (legend.isNull())
return original; return original;
final TextBlock text = EntityImageLegend.create(legend.getDisplay(), getSkinParam()); return DecorateEntityImage.add(original, builder.getLegend(), legend.getHorizontalAlignment(),
legend.getVerticalAlignment());
return DecorateEntityImage.add(original, text, legend.getHorizontalAlignment(), legend.getVerticalAlignment());
} }
private ISkinParam getSkinParam() { public TextBlock addTitle(TextBlock original) {
return skinParam; final DisplayPositioned title = (DisplayPositioned) annotated.getTitle();
if (title.isNull())
return original;
return DecorateEntityImage.addTop(original, builder.getTitle(), HorizontalAlignment.CENTER);
} }
private TextBlock addCaption(TextBlock original) { private TextBlock addCaption(TextBlock original) {
@ -166,57 +88,7 @@ public class AnnotatedWorker {
if (caption.isNull()) if (caption.isNull())
return original; return original;
final TextBlock text = getCaption(); return DecorateEntityImage.addBottom(original, builder.getCaption(), HorizontalAlignment.CENTER);
return DecorateEntityImage.addBottom(original, text, 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());
}
} }

View File

@ -62,7 +62,7 @@ public interface ISkinParam extends ISkinSimple {
public HColor getHyperlinkColor(); public HColor getHyperlinkColor();
public boolean useUnderlineForHyperlink(); public UStroke useUnderlineForHyperlink();
public HColor getBackgroundColor(); public HColor getBackgroundColor();

View File

@ -48,8 +48,8 @@ public interface LineLocation extends Comparable<LineLocation> {
public int getPosition(); public int getPosition();
/** /**
* A description of the ressource. * A description of the resource.
* If the ressource is a file, this is the complete path of the file. * If the resource is a file, this is the complete path of the file.
*/ */
public String getDescription(); public String getDescription();

View File

@ -925,8 +925,10 @@ public class SkinParam implements ISkinParam {
return htmlColorSet; return htmlColorSet;
} }
public boolean useUnderlineForHyperlink() { public UStroke useUnderlineForHyperlink() {
return !valueIs("hyperlinkunderline", "false"); if (valueIs("hyperlinkunderline", "false") == false)
return new UStroke();
return null;
} }
public int groupInheritance() { public int groupInheritance() {

View File

@ -234,7 +234,7 @@ public class SkinParamDelegator implements ISkinParam {
} }
@Override @Override
public boolean useUnderlineForHyperlink() { public UStroke useUnderlineForHyperlink() {
return skinParam.useUnderlineForHyperlink(); return skinParam.useUnderlineForHyperlink();
} }

View File

@ -42,54 +42,57 @@ public enum UmlDiagramType {
HELP, GANTT, SALT, JSON, GIT, BOARD, YAML, HCL, EBNF; HELP, GANTT, SALT, JSON, GIT, BOARD, YAML, HCL, EBNF;
public SName getStyleName() { public SName getStyleName() {
if (this == SEQUENCE) { if (this == SEQUENCE)
return SName.sequenceDiagram; return SName.sequenceDiagram;
}
if (this == STATE) { if (this == STATE)
return SName.stateDiagram; return SName.stateDiagram;
}
if (this == CLASS) { if (this == CLASS)
return SName.classDiagram; return SName.classDiagram;
}
if (this == OBJECT) { if (this == OBJECT)
return SName.objectDiagram; return SName.objectDiagram;
}
if (this == ACTIVITY) { if (this == ACTIVITY)
return SName.activityDiagram; return SName.activityDiagram;
}
if (this == DESCRIPTION) { if (this == DESCRIPTION)
return SName.componentDiagram; return SName.componentDiagram;
}
if (this == COMPOSITE) { if (this == COMPOSITE)
return SName.componentDiagram; return SName.componentDiagram;
}
if (this == MINDMAP) { if (this == MINDMAP)
return SName.mindmapDiagram; return SName.mindmapDiagram;
}
if (this == WBS) { if (this == WBS)
return SName.wbsDiagram; return SName.wbsDiagram;
}
if (this == GANTT) { if (this == GANTT)
return SName.ganttDiagram; return SName.ganttDiagram;
}
if (this == SALT) { if (this == SALT)
return SName.saltDiagram; return SName.saltDiagram;
}
if (this == YAML) { if (this == YAML)
return SName.yamlDiagram; return SName.yamlDiagram;
}
if (this == HCL) { if (this == HCL)
return SName.yamlDiagram; return SName.yamlDiagram;
}
if (this == JSON) { if (this == JSON)
return SName.jsonDiagram; return SName.jsonDiagram;
}
if (this == TIMING) { if (this == TIMING)
return SName.timingDiagram; return SName.timingDiagram;
}
if (this == NWDIAG) { if (this == NWDIAG)
return SName.nwdiagDiagram; return SName.nwdiagDiagram;
}
if (this == EBNF)
return SName.ebnf;
return SName.activityDiagram; return SName.activityDiagram;
} }
} }

View File

@ -126,7 +126,7 @@ public class CommandIf extends SingleLineCommand2<ActivityDiagram> {
final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(arg.get("BRACKET", 0)), lenght); final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(arg.get("BRACKET", 0)), lenght);
Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), entity1, branch, 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())); .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()));
if (arg.get("ARROW", 0) != null) { if (arg.get("ARROW", 0) != null) {
final Direction direction = StringUtils.getArrowDirection(arg.get("ARROW", 0)); final Direction direction = StringUtils.getArrowDirection(arg.get("ARROW", 0));

View File

@ -141,7 +141,7 @@ public class TextSkin extends Rose {
if (type == ComponentType.GROUPING_SPACE) if (type == ComponentType.GROUPING_SPACE)
return new ComponentRoseGroupingSpace(1); 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); return new ComponentTextGroupingElse(type, stringsToDisplay, fileFormat);
if (type == ComponentType.DELAY_TEXT) if (type == ComponentType.DELAY_TEXT)

View File

@ -159,7 +159,7 @@ public class BpmElement extends AbstractConnectorPuzzle implements ConnectorPuzz
return FtileBox.create(skinParam, display, null, BoxStyle.PLAIN, null); return FtileBox.create(skinParam, display, null, BoxStyle.PLAIN, null);
} }
final UFont font = UFont.serif(14); 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)) { if (Display.isNull(display)) {
return Display.getWithNewlines(type.toString()).create(fc, HorizontalAlignment.LEFT, skinParam); return Display.getWithNewlines(type.toString()).create(fc, HorizontalAlignment.LEFT, skinParam);
} }

View File

@ -111,9 +111,9 @@ public class CommandCreateClass extends SingleLineCommand2<ClassDiagram> {
new RegexOptional(new RegexConcat(new RegexLeaf("##"), new RegexOptional(new RegexConcat(new RegexLeaf("##"),
new RegexLeaf("LINECOLOR", "(?:\\[(dotted|dashed|bold)\\])?(\\w+)?"))), // new RegexLeaf("LINECOLOR", "(?:\\[(dotted|dashed|bold)\\])?(\\w+)?"))), //
new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(), 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 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("\\{"), new RegexOptional(new RegexConcat(RegexLeaf.spaceZeroOrMore(), new RegexLeaf("\\{"),
RegexLeaf.spaceZeroOrMore(), new RegexLeaf("\\}"))), // RegexLeaf.spaceZeroOrMore(), new RegexLeaf("\\}"))), //
RegexLeaf.end()); RegexLeaf.end());

View File

@ -126,9 +126,9 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
new RegexOptional(new RegexConcat(new RegexLeaf("##"), new RegexOptional(new RegexConcat(new RegexLeaf("##"),
new RegexLeaf("LINECOLOR", "(?:\\[(dotted|dashed|bold)\\])?(\\w+)?"))), // new RegexLeaf("LINECOLOR", "(?:\\[(dotted|dashed|bold)\\])?(\\w+)?"))), //
new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(), 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 RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(),
new RegexLeaf("IMPLEMENTS", "(implements)[%s]+(" + CommandCreateClassMultilines.CODES + ")"))), // new RegexLeaf("IMPLEMENTS", "(implements)[%s]+(" + CommandCreateClassMultilines.CODES + "|[%g]([^%g]+)[%g])"))), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("\\{"), // new RegexLeaf("\\{"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -206,7 +206,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
if (mode == Mode.EXTENDS && entity.getLeafType() == LeafType.INTERFACE) if (mode == Mode.EXTENDS && entity.getLeafType() == LeafType.INTERFACE)
type2 = LeafType.INTERFACE; type2 = LeafType.INTERFACE;
final String codes = arg.get(keyword, 1); final String codes = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(keyword, 1));
for (String s : codes.split(",")) { for (String s : codes.split(",")) {
final String idShort = StringUtils.trin(s); final String idShort = StringUtils.trin(s);
final Ident ident = diagram.buildLeafIdent(idShort); final Ident ident = diagram.buildLeafIdent(idShort);
@ -218,7 +218,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
final LinkArg linkArg = LinkArg.noDisplay(2); final LinkArg linkArg = LinkArg.noDisplay(2);
final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl2, entity, typeLink, final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl2, entity, typeLink,
linkArg.withQualifier(null, null).withDistanceAngle(diagram.getLabeldistance(), linkArg.withQuantifier(null, null).withDistanceAngle(diagram.getLabeldistance(),
diagram.getLabelangle())); diagram.getLabelangle()));
diagram.addLink(link); diagram.addLink(link);
} }
@ -283,8 +283,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet()); Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet());
final String s = line0.get("LINECOLOR", 1); final String s = line0.get("LINECOLOR", 1);
final HColor lineColor = s == null ? null final HColor lineColor = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s);
: diagram.getSkinParam().getIHtmlColorSet().getColor(s);
if (lineColor != null) if (lineColor != null)
colors = colors.add(ColorType.LINE, lineColor); colors = colors.add(ColorType.LINE, lineColor);

View File

@ -102,7 +102,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
new RegexConcat( new RegexConcat(
// //
new RegexLeaf("ARROW_HEAD1", new RegexLeaf("ARROW_HEAD1",
"([%s]+[ox]|[)#\\[<*+^}]|\\<_|\\<\\|[\\:\\|]|[<\\[]\\||\\}o|\\}\\||\\|o|\\|\\|)?"), // "((?<=[%s])+[ox]|[)#\\[<*+^}]|\\<_|\\<\\|[\\:\\|]|[<\\[]\\||\\}o|\\}\\||\\|o|\\|\\|)?"), //
new RegexLeaf("ARROW_BODY1", "([-=.]+)"), // new RegexLeaf("ARROW_BODY1", "([-=.]+)"), //
new RegexLeaf("ARROW_STYLE1", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), // new RegexLeaf("ARROW_STYLE1", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), //
new RegexLeaf("ARROW_DIRECTION", "(left|right|up|down|le?|ri?|up?|do?)?"), // new RegexLeaf("ARROW_DIRECTION", "(left|right|up|down|le?|ri?|up?|do?)?"), //
@ -237,7 +237,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
final LinkArg linkArg = LinkArg final LinkArg linkArg = LinkArg
.build(labels.getDisplay(), queue, diagram.getSkinParam().classAttributeIconSize() > 0) .build(labels.getDisplay(), queue, diagram.getSkinParam().classAttributeIconSize() > 0)
.withQualifier(labels.getFirstLabel(), labels.getSecondLabel()) .withQuantifier(labels.getFirstLabel(), labels.getSecondLabel())
.withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()).withKal(kal1, kal2); .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()).withKal(kal1, kal2);
Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, linkArg); Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, linkArg);
@ -379,7 +379,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
final String secondLabel = arg.get("SECOND_LABEL", 0); final String secondLabel = arg.get("SECOND_LABEL", 0);
final LinkArg linkArg = LinkArg.build(labelLink, queue, diagram.getSkinParam().classAttributeIconSize() > 0); final LinkArg linkArg = LinkArg.build(labelLink, queue, diagram.getSkinParam().classAttributeIconSize() > 0);
final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, 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.getLabelangle()));
link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet())); link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()));

View File

@ -190,7 +190,7 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(labelLink), length, final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(labelLink), length,
diagram.getSkinParam().classAttributeIconSize() > 0); diagram.getSkinParam().classAttributeIconSize() > 0);
final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, 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.getLabelangle()));
diagram.resetPragmaLabel(); diagram.resetPragmaLabel();
addLink(diagram, link, arg.get("HEADER", 0)); addLink(diagram, link, arg.get("HEADER", 0));

View File

@ -37,7 +37,6 @@ package net.sourceforge.plantuml.cucadiagram;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
@ -54,8 +53,8 @@ public interface Bodier {
public boolean addFieldOrMethod(String s) throws NoSuchColorException; public boolean addFieldOrMethod(String s) throws NoSuchColorException;
public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields, public TextBlock getBody(ISkinParam skinParam, boolean showMethods, boolean showFields, Stereotype stereotype,
Stereotype stereotype, Style style, FontConfiguration fontConfiguration); Style style, FontConfiguration fontConfiguration);
public List<CharSequence> getRawBody(); public List<CharSequence> getRawBody();

View File

@ -38,7 +38,6 @@ package net.sourceforge.plantuml.cucadiagram;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
@ -81,9 +80,9 @@ public class BodierJSon implements Bodier {
} }
@Override @Override
public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, final boolean showMethods, public TextBlock getBody(ISkinParam skinParam, final boolean showMethods, final boolean showFields,
final boolean showFields, Stereotype stereotype, Style style, FontConfiguration fontConfiguration) { Stereotype stereotype, Style style, FontConfiguration fontConfiguration) {
return new TextBlockCucaJSon(fontConfiguration, fontParam, skinParam, json); return new TextBlockCucaJSon(fontConfiguration, skinParam, json, style.wrapWidth());
} }
@Override @Override

View File

@ -41,7 +41,6 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlBuilder;
@ -210,11 +209,11 @@ public class BodierLikeClassOrObject implements Bodier {
} }
@Override @Override
public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields, public TextBlock getBody(ISkinParam skinParam, boolean showMethods, boolean showFields, Stereotype stereotype,
Stereotype stereotype, Style style, FontConfiguration fontConfiguration) { Style style, FontConfiguration fontConfiguration) {
if (BodyFactory.BODY3) if (BodyFactory.BODY3)
return new Body3(rawBody, fontParam, skinParam, stereotype, style); return new Body3(rawBody, skinParam, stereotype, style);
if (type.isLikeClass() && isBodyEnhanced()) { if (type.isLikeClass() && isBodyEnhanced()) {
if (showMethods || showFields) if (showMethods || showFields)

View File

@ -44,8 +44,8 @@ import java.util.Objects;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.Style;
@ -110,9 +110,10 @@ public class BodierMap implements Bodier {
} }
@Override @Override
public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, final boolean showMethods, public TextBlock getBody(ISkinParam skinParam, final boolean showMethods, final boolean showFields,
final boolean showFields, Stereotype stereotype, Style style, FontConfiguration fontConfiguration) { Stereotype stereotype, Style style, FontConfiguration fontConfiguration) {
return new TextBlockMap(fontConfiguration, fontParam, skinParam, map); final LineBreakStrategy wordWrap = style.wrapWidth();
return new TextBlockMap(fontConfiguration, skinParam, map, wordWrap);
} }
@Override @Override

View File

@ -40,7 +40,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
@ -94,8 +93,8 @@ public class BodierSimple implements Bodier {
} }
@Override @Override
public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields, public TextBlock getBody(ISkinParam skinParam, boolean showMethods, boolean showFields, Stereotype stereotype,
Stereotype stereotype, Style style, FontConfiguration fontConfiguration) { Style style, FontConfiguration fontConfiguration) {
return BodyFactory.create1(skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), rawBody, skinParam, return BodyFactory.create1(skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), rawBody, skinParam,
stereotype, leaf, style); stereotype, leaf, style);
} }

View File

@ -38,7 +38,6 @@ package net.sourceforge.plantuml.cucadiagram;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.AbstractTextBlock;
@ -55,17 +54,14 @@ import net.sourceforge.plantuml.ugraphic.UGraphic;
public class Body3 extends AbstractTextBlock implements TextBlock, WithPorts { public class Body3 extends AbstractTextBlock implements TextBlock, WithPorts {
private final List<CharSequence> rawBody = new ArrayList<>(); private final List<CharSequence> rawBody = new ArrayList<>();
private final FontParam fontParam;
private final ISkinParam skinParam; private final ISkinParam skinParam;
private final Stereotype stereotype; private final Stereotype stereotype;
private final Style style; private final Style style;
public Body3(List<CharSequence> rawBody_, FontParam fontParam, ISkinParam skinParam, Stereotype stereotype, public Body3(List<CharSequence> rawBody_, ISkinParam skinParam, Stereotype stereotype, Style style) {
Style style) { for (CharSequence s : rawBody_)
for (CharSequence s : rawBody_) {
this.rawBody.add(VisibilityModifier.replaceVisibilityModifierByUnicodeChar(s.toString(), true)); this.rawBody.add(VisibilityModifier.replaceVisibilityModifierByUnicodeChar(s.toString(), true));
}
this.fontParam = fontParam;
this.skinParam = skinParam; this.skinParam = skinParam;
this.stereotype = stereotype; this.stereotype = stereotype;
this.style = style; this.style = style;
@ -77,17 +73,9 @@ public class Body3 extends AbstractTextBlock implements TextBlock, WithPorts {
} }
private TextBlock getTextBlock() { private TextBlock getTextBlock() {
Display display = Display.create(rawBody); final Display display = Display.create(rawBody);
final FontConfiguration config = FontConfiguration.create(skinParam, style);
FontConfiguration config; return display.create(config, HorizontalAlignment.LEFT, skinParam);
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;
} }
@Override @Override

View File

@ -278,12 +278,12 @@ public class Link extends WithLinkType implements Hideable, Removeable {
this.getLinkArg().setLength(length); this.getLinkArg().setLength(length);
} }
public String getQualifier1() { public String getQuantifier1() {
return getLinkArg().getQualifier1(); return getLinkArg().getQuantifier1();
} }
public String getQualifier2() { public String getQuantifier2() {
return getLinkArg().getQualifier2(); return getLinkArg().getQuantifier2();
} }
public final double getWeight() { public final double getWeight() {
@ -356,7 +356,7 @@ public class Link extends WithLinkType implements Hideable, Removeable {
// return decor.getMargin() + q; // return decor.getMargin() + q;
// } // }
private double getQualifierMargin(StringBounder stringBounder, UFont fontQualif, String qualif, private double getQuantifierMargin(StringBounder stringBounder, UFont fontQualif, String qualif,
ISkinSimple spriteContainer) { ISkinSimple spriteContainer) {
if (qualif != null) { if (qualif != null) {
final TextBlock b = Display.create(qualif).create(FontConfiguration.blackBlueTrue(fontQualif), final TextBlock b = Display.create(qualif).create(FontConfiguration.blackBlueTrue(fontQualif),

View File

@ -40,8 +40,8 @@ import net.sourceforge.plantuml.skin.VisibilityModifier;
public class LinkArg { public class LinkArg {
private final Display label; private final Display label;
private final String qualifier1; private final String quantifier1;
private final String qualifier2; private final String quantifier2;
private final String labeldistance; private final String labeldistance;
private final String labelangle; private final String labelangle;
@ -72,29 +72,29 @@ public class LinkArg {
return new LinkArg(newLabel, length, null, null, null, null, visibilityModifier, null, null); return new LinkArg(newLabel, length, null, null, null, null, visibilityModifier, null, null);
} }
public LinkArg withQualifier(String qualifier1, String qualifier2) { public LinkArg withQuantifier(String quantifier1, String quantifier2) {
return new LinkArg(label, length, qualifier1, qualifier2, labeldistance, labelangle, visibilityModifier, kal1, return new LinkArg(label, length, quantifier1, quantifier2, labeldistance, labelangle, visibilityModifier, kal1,
kal2); kal2);
} }
public LinkArg withKal(String kal1, String 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); kal2);
} }
public LinkArg withDistanceAngle(String labeldistance, String labelangle) { 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); 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) { String labelangle, VisibilityModifier visibilityModifier, String kal1, String kal2) {
this.label = label; this.label = label;
this.visibilityModifier = visibilityModifier; this.visibilityModifier = visibilityModifier;
this.length = length; this.length = length;
this.qualifier1 = qualifier1; this.quantifier1 = quantifier1;
this.qualifier2 = qualifier2; this.quantifier2 = quantifier2;
this.labeldistance = labeldistance; this.labeldistance = labeldistance;
this.labelangle = labelangle; this.labelangle = labelangle;
this.kal1 = kal1; this.kal1 = kal1;
@ -102,7 +102,7 @@ public class LinkArg {
} }
public LinkArg getInv() { 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); kal2);
} }
@ -114,12 +114,12 @@ public class LinkArg {
return length; return length;
} }
public final String getQualifier1() { public final String getQuantifier1() {
return qualifier1; return quantifier1;
} }
public final String getQualifier2() { public final String getQuantifier2() {
return qualifier2; return quantifier2;
} }
public final String getLabeldistance() { public final String getLabeldistance() {

View File

@ -35,9 +35,10 @@
*/ */
package net.sourceforge.plantuml.cucadiagram; package net.sourceforge.plantuml.cucadiagram;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
@ -55,26 +56,26 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts { public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts {
private final FontParam fontParam;
private final ISkinParam skinParam; private final ISkinParam skinParam;
private final FontConfiguration fontConfiguration; private final FontConfiguration fontConfiguration;
private final JsonValue json; private final JsonValue json;
private TextBlockJson jsonTextBlock; private TextBlockJson jsonTextBlock;
private double totalWidth; private double mainTotalWidth;
private final LineBreakStrategy wordWrap;
public TextBlockCucaJSon(FontConfiguration fontConfiguration, FontParam fontParam, ISkinParam skinParam, public TextBlockCucaJSon(FontConfiguration fontConfiguration, ISkinParam skinParam, JsonValue json,
JsonValue json) { LineBreakStrategy wordWrap) {
this.fontParam = fontParam;
this.skinParam = skinParam; this.skinParam = skinParam;
this.json = json; this.json = json;
this.fontConfiguration = fontConfiguration; this.fontConfiguration = fontConfiguration;
this.wordWrap = wordWrap;
} }
private TextBlockJson getJsonTextBlock() { private TextBlockJson getJsonTextBlock() {
if (jsonTextBlock == null) if (jsonTextBlock == null)
this.jsonTextBlock = new TextBlockJson(json, 0); this.jsonTextBlock = new TextBlockJson(json, 0);
jsonTextBlock.totalWidth = totalWidth; jsonTextBlock.jsonTotalWidth = mainTotalWidth;
return jsonTextBlock; return jsonTextBlock;
} }
@ -94,11 +95,11 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts {
class TextBlockJson extends AbstractTextBlock { class TextBlockJson extends AbstractTextBlock {
private final JsonObject obj; private final JsonObject obj;
private double totalWidth; private double jsonTotalWidth;
public TextBlockJson(JsonValue json, double totalWidth) { public TextBlockJson(JsonValue json, double totalWidth) {
this.obj = json.asObject(); this.obj = json.asObject();
this.totalWidth = totalWidth; this.jsonTotalWidth = totalWidth;
} }
@Override @Override
@ -109,7 +110,7 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts {
private double getWidth1(StringBounder stringBounder) { private double getWidth1(StringBounder stringBounder) {
double result = 0; double result = 0;
for (JsonObject.Member s : obj) { 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()); result = Math.max(result, tb1.calculateDimension(stringBounder).getWidth());
} }
return result; return result;
@ -118,7 +119,7 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts {
private double getWidth2(StringBounder stringBounder) { private double getWidth2(StringBounder stringBounder) {
double result = 0; double result = 0;
for (JsonObject.Member s : obj) { 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()); result = Math.max(result, tb2.calculateDimension(stringBounder).getWidth());
} }
return result; return result;
@ -127,8 +128,8 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts {
private double getHeight(StringBounder stringBounder) { private double getHeight(StringBounder stringBounder) {
double result = 0; double result = 0;
for (JsonObject.Member s : obj) { for (JsonObject.Member s : obj) {
final TextBlock tb1 = getTextBlockKey(s.getName()); final TextBlock tb1 = getTextBlock(s.getName());
final TextBlock tb2 = getTextBlockValue(s.getValue(), totalWidth); final TextBlock tb2 = getTextBlockValue(s.getValue(), jsonTotalWidth);
final XDimension2D dim1 = tb1.calculateDimension(stringBounder); final XDimension2D dim1 = tb1.calculateDimension(stringBounder);
final XDimension2D dim2 = tb2.calculateDimension(stringBounder); final XDimension2D dim2 = tb2.calculateDimension(stringBounder);
result += Math.max(dim1.getHeight(), dim2.getHeight()); result += Math.max(dim1.getHeight(), dim2.getHeight());
@ -140,13 +141,12 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder(); final StringBounder stringBounder = ug.getStringBounder();
final double width1 = getWidth1(stringBounder); final double width1 = getWidth1(stringBounder);
final double width2 = getWidth2(stringBounder);
final double height = getHeight(stringBounder); final double height = getHeight(stringBounder);
ug.apply(UTranslate.dx(width1)).draw(ULine.vline(height)); 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) { for (JsonObject.Member s : obj) {
final TextBlock tb1 = getTextBlockKey(s.getName()); final TextBlock tb1 = getTextBlock(s.getName());
final TextBlock tb2 = getTextBlockValue(s.getValue(), width2); final TextBlock tb2 = getTextBlockValue(s.getValue(), this.jsonTotalWidth - width1);
final XDimension2D dim1 = tb1.calculateDimension(stringBounder); final XDimension2D dim1 = tb1.calculateDimension(stringBounder);
final XDimension2D dim2 = tb2.calculateDimension(stringBounder); final XDimension2D dim2 = tb2.calculateDimension(stringBounder);
ug.draw(hline); ug.draw(hline);
@ -162,10 +162,7 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts {
private TextBlock getTextBlockValue(JsonValue value, double width2) { private TextBlock getTextBlockValue(JsonValue value, double width2) {
if (value.isString() || value.isNull() || value.isTrue() || value.isFalse() || value.isNumber()) { if (value.isString() || value.isNull() || value.isTrue() || value.isFalse() || value.isNumber()) {
final String tmp = value.isString() ? value.asString() : value.toString(); final String tmp = value.isString() ? value.asString() : value.toString();
final Display display = Display.getWithNewlines(tmp); return getTextBlock(tmp);
TextBlock result = display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam);
result = TextBlockUtils.withMargin(result, 5, 2);
return result;
} }
if (value.isArray()) if (value.isArray())
return new TextBlockArray(value.asArray(), width2); return new TextBlockArray(value.asArray(), width2);
@ -173,8 +170,13 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts {
return new TextBlockJson(value, width2); return new TextBlockJson(value, width2);
final String tmp = value.getClass().getSimpleName(); final String tmp = value.getClass().getSimpleName();
final Display display = Display.getWithNewlines(tmp); return getTextBlock(tmp);
TextBlock result = display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam); }
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); result = TextBlockUtils.withMargin(result, 5, 2);
return result; return result;
} }
@ -182,18 +184,18 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts {
class TextBlockArray extends AbstractTextBlock { class TextBlockArray extends AbstractTextBlock {
private final JsonArray array; private final JsonArray array;
private final double totalWidth; private final double arrayTotalWidth;
public TextBlockArray(JsonArray array, double totalWidth) { public TextBlockArray(JsonArray array, double totalWidth) {
this.array = array; this.array = array;
this.totalWidth = totalWidth; this.arrayTotalWidth = totalWidth;
} }
@Override @Override
public XDimension2D calculateDimension(StringBounder stringBounder) { public XDimension2D calculateDimension(StringBounder stringBounder) {
XDimension2D result = new XDimension2D(0, 0); XDimension2D result = new XDimension2D(0, 0);
for (JsonValue element : array) { for (JsonValue element : array) {
final TextBlock tb = getTextBlockValue(element, totalWidth); final TextBlock tb = getTextBlockValue(element, arrayTotalWidth);
final XDimension2D dim = tb.calculateDimension(stringBounder); final XDimension2D dim = tb.calculateDimension(stringBounder);
result = XDimension2D.mergeTB(result, dim); result = XDimension2D.mergeTB(result, dim);
} }
@ -202,10 +204,10 @@ public class TextBlockCucaJSon extends AbstractTextBlock implements WithPorts {
@Override @Override
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
final ULine hline = ULine.hline(this.totalWidth); final ULine hline = ULine.hline(this.arrayTotalWidth);
int nb = 0; int nb = 0;
for (JsonValue element : array) { for (JsonValue element : array) {
final TextBlock tb = getTextBlockValue(element, totalWidth); final TextBlock tb = getTextBlockValue(element, arrayTotalWidth);
if (nb > 0) if (nb > 0)
ug.draw(hline); ug.draw(hline);
nb++; 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() { private FontConfiguration getFontConfiguration() {
if (fontConfiguration == null)
return FontConfiguration.create(skinParam, fontParam, null);
return fontConfiguration; return fontConfiguration;
} }
public void setTotalWidth(double totalWidth) { public void setTotalWidth(double totalWidth) {
this.totalWidth = totalWidth; this.mainTotalWidth = totalWidth;
} }
} }

View File

@ -41,9 +41,10 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
@ -62,16 +63,14 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
public class TextBlockMap extends AbstractTextBlock implements WithPorts { public class TextBlockMap extends AbstractTextBlock implements WithPorts {
private final FontParam fontParam;
private final ISkinParam skinParam; private final ISkinParam skinParam;
private final FontConfiguration fontConfiguration; private final FontConfiguration fontConfiguration;
private final Map<TextBlock, TextBlock> blocksMap = new LinkedHashMap<>(); private final Map<TextBlock, TextBlock> blocksMap = new LinkedHashMap<>();
private final List<String> keys = new ArrayList<>(); private final List<String> keys = new ArrayList<>();
private double totalWidth; private double totalWidth;
public TextBlockMap(FontConfiguration fontConfiguration, FontParam fontParam, ISkinParam skinParam, public TextBlockMap(FontConfiguration fontConfiguration, ISkinParam skinParam, Map<String, String> map,
Map<String, String> map) { LineBreakStrategy wordWrap) {
this.fontParam = fontParam;
this.skinParam = skinParam; this.skinParam = skinParam;
this.fontConfiguration = fontConfiguration; this.fontConfiguration = fontConfiguration;
for (Map.Entry<String, String> ent : map.entrySet()) { for (Map.Entry<String, String> ent : map.entrySet()) {
@ -80,8 +79,8 @@ public class TextBlockMap extends AbstractTextBlock implements WithPorts {
key = key.substring(1); key = key.substring(1);
this.keys.add(key); this.keys.add(key);
final String value = ent.getValue(); final String value = ent.getValue();
final TextBlock block1 = getTextBlock(key); final TextBlock block1 = getTextBlock(key, wordWrap);
final TextBlock block2 = getTextBlock(value); final TextBlock block2 = getTextBlock(value, wordWrap);
this.blocksMap.put(block1, block2); this.blocksMap.put(block1, block2);
} }
} }
@ -117,9 +116,9 @@ public class TextBlockMap extends AbstractTextBlock implements WithPorts {
private double getMaxWidth(StringBounder stringBounder, Collection<TextBlock> blocks) { private double getMaxWidth(StringBounder stringBounder, Collection<TextBlock> blocks) {
double width = 0; double width = 0;
for (TextBlock block : blocks) { for (TextBlock block : blocks)
width = Math.max(width, block.calculateDimension(stringBounder).getWidth()); width = Math.max(width, block.calculateDimension(stringBounder).getWidth());
}
return width; return width;
} }
@ -137,10 +136,6 @@ public class TextBlockMap extends AbstractTextBlock implements WithPorts {
ugline.draw(ULine.hline(trueWidth)); ugline.draw(ULine.hline(trueWidth));
final double heightOfRow = getHeightOfRow(stringBounder, key, value); final double heightOfRow = getHeightOfRow(stringBounder, key, value);
if (value instanceof Point) { 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; final double posColA = (trueWidth - key.calculateDimension(stringBounder).getWidth()) / 2;
key.drawU(ugline.apply(UTranslate.dx(posColA))); key.drawU(ugline.apply(UTranslate.dx(posColA)));
} else { } else {
@ -151,7 +146,6 @@ public class TextBlockMap extends AbstractTextBlock implements WithPorts {
} }
y += heightOfRow; y += heightOfRow;
} }
// ug.apply(UTranslate.dx(widthColA)).draw(ULine.vline(fullDim.getHeight()));
} }
private double getTotalHeight(StringBounder stringBounder) { private double getTotalHeight(StringBounder stringBounder) {
@ -169,12 +163,13 @@ public class TextBlockMap extends AbstractTextBlock implements WithPorts {
value.calculateDimension(stringBounder).getHeight()); value.calculateDimension(stringBounder).getHeight());
} }
private TextBlock getTextBlock(String key) { private TextBlock getTextBlock(String key, LineBreakStrategy wordWrap) {
if (key.equals("\0")) { if (key.equals("\0"))
return new Point(getFontConfiguration().getColor()); return new Point(fontConfiguration.getColor());
}
final Display display = Display.getWithNewlines(key); 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); result = TextBlockUtils.withMargin(result, 5, 2);
return result; 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) { public void setTotalWidth(double totalWidth) {
this.totalWidth = totalWidth; this.totalWidth = totalWidth;
} }

View File

@ -73,7 +73,7 @@ public class PSystemDefinition extends PlainDiagram implements UDrawable {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
final UFont font = UFont.sansSerif(14); 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); Display.getWithNewlines(startLine).create(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty()).drawU(ug);
} }

View File

@ -262,7 +262,7 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(labels.getLabelLink()), queue.length(), final LinkArg linkArg = LinkArg.build(Display.getWithNewlines(labels.getLabelLink()), queue.length(),
diagram.getSkinParam().classAttributeIconSize() > 0); diagram.getSkinParam().classAttributeIconSize() > 0);
Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType, 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())); .withDistanceAngle(diagram.getLabeldistance(), diagram.getLabelangle()));
link.setLinkArrow(labels.getLinkArrow()); link.setLinkArrow(labels.getLinkArrow());
if (dir == Direction.LEFT || dir == Direction.UP) if (dir == Direction.LEFT || dir == Direction.UP)

View File

@ -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<PSystemEbnf> {
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();
}
}

View File

@ -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<PSystemEbnf> {
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();
}
}

View File

@ -36,8 +36,10 @@
package net.sourceforge.plantuml.ebnf; package net.sourceforge.plantuml.ebnf;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.ugraphic.CopyForegroundColorToBackgroundColor;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UPath; import net.sourceforge.plantuml.ugraphic.UPath;
import net.sourceforge.plantuml.ugraphic.UTranslate;
enum CornerType { enum CornerType {
NW, NE, SE, SW; NW, NE, SE, SW;
@ -47,28 +49,38 @@ public class CornerCurved implements UDrawable {
private final double delta; private final double delta;
private final CornerType type; 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.delta = delta;
this.type = type; this.type = type;
this.withArrow = withArrow;
if (delta <= 0) if (delta <= 0)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
public static UDrawable createSW(double delta) { 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) { 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) { 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) { 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 @Override
@ -88,10 +100,16 @@ public class CornerCurved implements UDrawable {
case NE: case NE:
path.moveTo(-delta, 0); path.moveTo(-delta, 0);
path.cubicTo(-a, 0, 0, a, 0, delta); path.cubicTo(-a, 0, 0, a, 0, delta);
if (withArrow)
ug.apply(new CopyForegroundColorToBackgroundColor()).apply(UTranslate.dy(delta - 5))
.draw(ETile.getArrowToBottom());
break; break;
case NW: case NW:
path.moveTo(0, delta); path.moveTo(0, delta);
path.cubicTo(0, a, a, 0, delta, 0); path.cubicTo(0, a, a, 0, delta, 0);
if (withArrow)
ug.apply(new CopyForegroundColorToBackgroundColor()).apply(UTranslate.dy(delta))
.draw(ETile.getArrowToTop());
break; break;
} }

View File

@ -35,13 +35,120 @@
*/ */
package net.sourceforge.plantuml.ebnf; 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.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;
}
} }

View File

@ -39,18 +39,15 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.StringBounder; 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.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; 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<ETile> tiles = new ArrayList<>(); private final List<ETile> tiles = new ArrayList<>();
private final double marginx = 12; private final double marginx = 12;
private boolean inZeroOrMore;
@Override @Override
public void push(ETile tile) { public void push(ETile tile) {
@ -58,14 +55,37 @@ public class ETileAlternation extends AbstractTextBlock implements ETile {
} }
@Override @Override
public double linePos(StringBounder stringBounder) { public double getH1(StringBounder stringBounder) {
return tiles.get(0).linePos(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 @Override
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder(); final StringBounder stringBounder = ug.getStringBounder();
ug = ug.apply(HColors.BLACK);
double y = 0; double y = 0;
double lastLinePos = 0; double lastLinePos = 0;
@ -79,53 +99,65 @@ public class ETileAlternation extends AbstractTextBlock implements ETile {
final double q = r - marginx; final double q = r - marginx;
final double p = q - marginx; final double p = q - marginx;
for (int i = 0; i < tiles.size(); i++) { final double linePos = getH1(stringBounder);
final ETile tile = tiles.get(i);
final XDimension2D dim = tile.calculateDimension(stringBounder); if (inZeroOrMore) {
lastLinePos = y + tile.linePos(stringBounder); for (int i = 0; i < tiles.size(); i++) {
tile.drawU(ug.apply(new UTranslate(c, y))); 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))); 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))); 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 void setInZeroOrMore(boolean inZeroOrMore) {
public XDimension2D calculateDimension(StringBounder stringBounder) { this.inZeroOrMore = true;
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);
}
private StyleSignatureBasic getStyleSignature() {
return StyleSignatureBasic.of(SName.root, SName.element, SName.activityDiagram, SName.activity);
} }
} }

View File

@ -36,7 +36,6 @@
package net.sourceforge.plantuml.ebnf; package net.sourceforge.plantuml.ebnf;
import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.style.PName; 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.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSet; 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 String value;
private final FontConfiguration fc; private final FontConfiguration fc;
@ -68,8 +67,19 @@ public class ETileBox extends AbstractTextBlock implements ETile {
} }
@Override @Override
public XDimension2D calculateDimension(StringBounder stringBounder) { public double getH1(StringBounder stringBounder) {
return XDimension2D.delta(getTextDim(stringBounder), 10); 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) { 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); 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 @Override
public void push(ETile tile) { public void push(ETile tile) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();

View File

@ -38,17 +38,13 @@ package net.sourceforge.plantuml.ebnf;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UTranslate; 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<ETile> tiles = new ArrayList<>(); private final List<ETile> tiles = new ArrayList<>();
@Override @Override
@ -56,59 +52,56 @@ public class ETileConcatenation extends AbstractTextBlock implements ETile {
tiles.add(0, tile); 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 @Override
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder(); final StringBounder stringBounder = ug.getStringBounder();
ug = ug.apply(HColors.BLACK);
final double fullLinePos = linePos(stringBounder); final double fullLinePos = getH1(stringBounder);
double x = 0; double x = 0;
drawHline(ug, fullLinePos, 0, x); drawHline(ug, fullLinePos, 0, x);
for (int i = 0; i < tiles.size(); i++) { for (int i = 0; i < tiles.size(); i++) {
final ETile tile = tiles.get(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))); tile.drawU(ug.apply(new UTranslate(x, fullLinePos - linePos)));
x += tile.calculateDimension(stringBounder).getWidth(); x += tile.calculateDimension(stringBounder).getWidth();
if (i != tiles.size() - 1) { if (i != tiles.size() - 1) {
drawHline(ug, fullLinePos, x, x + marginx); drawHlineDirected(ug, fullLinePos, x, x + marginx, 0.5);
x += marginx; x += marginx;
} }
} }
} }
public static void drawHline(UGraphic ug, double y, double x1, double x2) { @Override
ug.apply(new UTranslate(x1, y)).draw(ULine.hline(x2 - x1)); public double getH1(StringBounder stringBounder) {
} double result = 0;
public static void drawVline(UGraphic ug, double x, double y1, double y2) { for (ETile tile : tiles)
ug.apply(new UTranslate(x, y1)).draw(ULine.vline(y2 - y1)); result = Math.max(result, tile.getH1(stringBounder));
return result;
} }
@Override @Override
public XDimension2D calculateDimension(StringBounder stringBounder) { public double getH2(StringBounder stringBounder) {
double width = 0; double result = 0;
double height = 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++) { for (int i = 0; i < tiles.size(); i++) {
final ETile tile = tiles.get(i); final ETile tile = tiles.get(i);
final XDimension2D dim = tile.calculateDimension(stringBounder); width += tile.getWidth(stringBounder);
height = Math.max(height, dim.getHeight());
width += dim.getWidth();
if (i != tiles.size() - 1) if (i != tiles.size() - 1)
width += marginx; width += marginx;
} }
return new XDimension2D(width, height); return width;
} }
} }

View File

@ -36,57 +36,58 @@
package net.sourceforge.plantuml.ebnf; package net.sourceforge.plantuml.ebnf;
import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColors; 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 deltax = 15;
private final double deltay = 10; private final double deltay = 12;
private final ETile orig; private final ETile orig;
public ETileRepetition(ETile orig) { public ETileOneOrMore(ETile orig) {
this.orig = orig; this.orig = orig;
} }
@Override @Override
public XDimension2D calculateDimension(StringBounder stringBounder) { public double getH1(StringBounder stringBounder) {
return XDimension2D.delta(orig.calculateDimension(stringBounder), 2 * deltax, deltay); 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 @Override
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
final XDimension2D fullDim = calculateDimension(ug.getStringBounder()); final XDimension2D fullDim = calculateDimension(ug.getStringBounder());
ug = ug.apply(HColors.BLACK); if (TRACE)
final double linePos = linePos(ug.getStringBounder()); ug.apply(HColors.RED).draw(new URectangle(fullDim));
final double posA = 7; final double linePos = getH1(ug.getStringBounder());
final double posB = fullDim.getWidth() - 7; CornerCurved.createSW(8).drawU(ug.apply(new UTranslate(8, linePos)));
drawVline(ug, 8, 8 + 5, linePos - 8);
final double corner = 12; CornerCurved.createNW(8).drawU(ug.apply(new UTranslate(8, 5)));
CornerCurved.createNW(corner).drawU(ug.apply(new UTranslate(posA, linePos))); drawHlineAntiDirected(ug, 5, deltax, fullDim.getWidth() - deltax, 0.6);
ETileConcatenation.drawVline(ug, posA, linePos + corner, fullDim.getHeight() - 1 - corner);
CornerCurved.createSW(corner).drawU(ug.apply(new UTranslate(posA, fullDim.getHeight() - 1)));
CornerCurved.createNE(corner).drawU(ug.apply(new UTranslate(posB, linePos))); CornerCurved.createSE(8).drawU(ug.apply(new UTranslate(fullDim.getWidth() - 8, linePos)));
ETileConcatenation.drawVline(ug, posB, linePos + corner, fullDim.getHeight() - 1 - corner); drawVline(ug, fullDim.getWidth() - 8, 8 + 5, linePos - 8);
CornerCurved.createSE(corner).drawU(ug.apply(new UTranslate(posB, fullDim.getHeight() - 1))); 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); orig.drawU(ug.apply(new UTranslate(deltax, deltay)));
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);
} }
@Override @Override

View File

@ -36,54 +36,69 @@
package net.sourceforge.plantuml.ebnf; package net.sourceforge.plantuml.ebnf;
import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColors; 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;
private final double deltax = 15; private final double deltay = 16;
private final double deltay = 24;
private final ETile orig; private final ETile orig;
private final boolean specialForAlternate;
public ETileOptional(ETile orig) { public ETileOptional(ETile orig) {
this.orig = orig; this.orig = orig;
this.specialForAlternate = orig instanceof ETileAlternation;
this.deltax = this.specialForAlternate ? 0 : 15;
} }
@Override @Override
public XDimension2D calculateDimension(StringBounder stringBounder) { public double getH1(StringBounder stringBounder) {
return XDimension2D.delta(orig.calculateDimension(stringBounder), 2 * deltax, deltay); 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 @Override
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
final XDimension2D fullDim = calculateDimension(ug.getStringBounder()); final XDimension2D fullDim = calculateDimension(ug.getStringBounder());
ug = ug.apply(HColors.BLACK); if (TRACE)
final double linePos = linePos(ug.getStringBounder()); ug.apply(HColors.BLUE).draw(new URectangle(fullDim));
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)));
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))); final double posA = specialForAlternate ? 12 : 8;
ETileConcatenation.drawVline(ug, fullDim.getWidth() - 8, linePos - posLineTop + 8, linePos - 8); final double corner = specialForAlternate ? 12 : 8;
CornerCurved.createNE(8).drawU(ug.apply(new UTranslate(fullDim.getWidth() - 8, linePos - posLineTop))); final double posB = fullDim.getWidth() - posA;
ETileConcatenation.drawHline(ug, linePos, 0, deltax); CornerCurved.createSE(corner).drawU(ug.apply(new UTranslate(posA, linePos)));
ETileConcatenation.drawHline(ug, linePos, fullDim.getWidth() - deltax, fullDim.getWidth()); 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))); orig.drawU(ug.apply(new UTranslate(deltax, deltay)));
} }
@Override
public double linePos(StringBounder stringBounder) {
return deltay + orig.linePos(stringBounder);
}
@Override @Override
public void push(ETile tile) { public void push(ETile tile) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();

View File

@ -36,45 +36,58 @@
package net.sourceforge.plantuml.ebnf; package net.sourceforge.plantuml.ebnf;
import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.CopyForegroundColorToBackgroundColor;
import net.sourceforge.plantuml.ugraphic.UEllipse; import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate; 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 static final double SIZE = 8;
private final double deltax = 15; private final double deltax = 30;
private final ETile orig; private final ETile orig;
private final HColor lineColor;
public ETileWithCircles(ETile orig) { public ETileWithCircles(ETile orig, HColor lineColor) {
this.orig = orig; this.orig = orig;
this.lineColor = lineColor;
} }
@Override @Override
public XDimension2D calculateDimension(StringBounder stringBounder) { public double getWidth(StringBounder stringBounder) {
return XDimension2D.delta(orig.calculateDimension(stringBounder), 2 * deltax, 0); 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 @Override
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
final double linePos = linePos(ug.getStringBounder()); final double linePos = getH1(ug.getStringBounder());
final XDimension2D fullDim = calculateDimension(ug.getStringBounder()); final XDimension2D fullDim = calculateDimension(ug.getStringBounder());
ug = ug.apply(lineColor).apply(new UStroke(1.5));
orig.drawU(ug.apply(UTranslate.dx(deltax))); 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 final UEllipse circle = new UEllipse(SIZE, SIZE);
public double linePos(StringBounder stringBounder) {
return orig.linePos(stringBounder); 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 @Override

View File

@ -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();
}
}

View File

@ -39,11 +39,14 @@ import java.util.ArrayDeque;
import java.util.Deque; import java.util.Deque;
import net.sourceforge.plantuml.ISkinParam; 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.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.TextBlock; 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.Style;
import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSet; import net.sourceforge.plantuml.ugraphic.color.HColorSet;
public class EbnfEngine { public class EbnfEngine {
@ -52,11 +55,15 @@ public class EbnfEngine {
private final FontConfiguration fontConfiguration; private final FontConfiguration fontConfiguration;
private final Style style; private final Style style;
private final HColorSet colorSet; private final HColorSet colorSet;
private final ISkinSimple spriteContainer;
private final HColor lineColor;
public EbnfEngine(ISkinParam skinParam) { 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.fontConfiguration = style.getFontConfiguration(skinParam.getIHtmlColorSet());
this.colorSet = 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)); stack.addFirst(new ETileOptional(arg1));
} }
public void repetition() { public void repetitionZeroOrMore(boolean isTheo) {
final ETile arg1 = stack.removeFirst(); 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() { public void alternation() {
@ -111,12 +126,13 @@ public class EbnfEngine {
public TextBlock getTextBlock() { public TextBlock getTextBlock() {
if (stack.size() != 1) if (stack.size() != 1)
throw new IllegalStateException(); return syntaxError(fontConfiguration, spriteContainer);
return new ETileWithCircles(stack.peekFirst()); return new ETileWithCircles(stack.peekFirst(), lineColor);
} }
private StyleSignatureBasic getStyleSignature() { public static TextBlock syntaxError(FontConfiguration fontConfiguration, ISkinSimple spriteContainer) {
return StyleSignatureBasic.of(SName.root, SName.element, SName.activityDiagram, SName.activity); final Display msg = Display.create("Syntax error!");
return msg.create(fontConfiguration, HorizontalAlignment.LEFT, spriteContainer);
} }
} }

View File

@ -39,14 +39,22 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.Pragma;
public class EbnfExpressions { public class EbnfExpressions {
public static List<EbnfSingleExpression> build(List<String> data) { public static List<EbnfSingleExpression> build(List<String> data, Pragma pragma) {
final List<EbnfSingleExpression> all = new ArrayList<>(); final List<EbnfSingleExpression> all = new ArrayList<>();
final boolean isTheo = pragma.isDefine("theo");
final CharIterator it = new CharIteratorImpl(data); final CharIterator it = new CharIteratorImpl(data);
while (it.peek() != 0) while (it.peek() != 0) {
all.add(new EbnfSingleExpression(it)); final EbnfSingleExpression tmp = EbnfSingleExpression.create(it, isTheo);
if (tmp.isEmpty())
break;
all.add(tmp);
}
return Collections.unmodifiableList(all); return Collections.unmodifiableList(all);
} }

View File

@ -44,18 +44,30 @@ import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignatureBasic;
public class EbnfSingleExpression { public class EbnfSingleExpression {
final List<Token> tokens = new ArrayList<>(); private final List<Token> 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) { while (true) {
final char ch = it.peek(); final char ch = it.peek();
if (Character.isWhitespace(ch)) { 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)) { } else if (isLetterOrDigit(ch)) {
final String litteral = readLitteral(it); final String litteral = readLitteral(it);
tokens.add(new Token(Symbol.LITTERAL, litteral)); tokens.add(new Token(Symbol.LITTERAL, litteral));
@ -87,32 +99,43 @@ public class EbnfSingleExpression {
} else if (ch == '\'') { } else if (ch == '\'') {
final String litteral = readString(it); final String litteral = readString(it);
tokens.add(new Token(Symbol.TERMINAL_STRING2, litteral)); tokens.add(new Token(Symbol.TERMINAL_STRING2, litteral));
} else } else {
throw new UnsupportedOperationException("" + ch); tokens.clear();
return;
}
it.next(); it.next();
continue; continue;
} }
} }
private StyleSignatureBasic getStyleSignature() {
return StyleSignatureBasic.of(SName.root, SName.element, SName.activityDiagram, SName.activity);
}
public TextBlock getUDrawable(ISkinParam skinParam) { public TextBlock getUDrawable(ISkinParam skinParam) {
final Iterator<Token> iterator = tokens.iterator(); final Style style = ETile.getStyleSignature().getMergedStyle(skinParam.getCurrentStyleBuilder());
final Token name = iterator.next();
final Token definition = iterator.next();
final List<Token> full = new ShuntingYard(iterator).getOuputQueue();
final TextBlock main = getMainDrawing(skinParam, full.iterator());
final Style style = getStyleSignature().getMergedStyle(skinParam.getCurrentStyleBuilder());
final FontConfiguration fc = style.getFontConfiguration(skinParam.getIHtmlColorSet()); 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), try {
HorizontalAlignment.LEFT); final Iterator<Token> 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<Token> 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<Token> it) { private TextBlock getMainDrawing(ISkinParam skinParam, Iterator<Token> it) {
@ -128,8 +151,10 @@ public class EbnfSingleExpression {
engine.concatenation(); engine.concatenation();
else if (element.getSymbol() == Symbol.OPTIONAL) else if (element.getSymbol() == Symbol.OPTIONAL)
engine.optional(); engine.optional();
else if (element.getSymbol() == Symbol.REPETITION) else if (element.getSymbol() == Symbol.REPETITION_ZERO_OR_MORE)
engine.repetition(); engine.repetitionZeroOrMore(isTheo);
else if (element.getSymbol() == Symbol.REPETITION_ONE_OR_MORE)
engine.repetitionOneOrMore();
else else
throw new UnsupportedOperationException(element.toString()); throw new UnsupportedOperationException(element.toString());
} }
@ -165,6 +190,10 @@ public class EbnfSingleExpression {
return ch == '-' || ch == '_' || Character.isLetterOrDigit(ch); return ch == '-' || ch == '_' || Character.isLetterOrDigit(ch);
} }
public boolean isEmpty() {
return tokens.size() == 0;
}
} }
interface CharIterator { interface CharIterator {
@ -175,12 +204,14 @@ interface CharIterator {
class CharIteratorImpl implements CharIterator { class CharIteratorImpl implements CharIterator {
final private List<String> data; final private List<String> data = new ArrayList<>();
private int line = 0; private int line = 0;
private int pos = 0; private int pos = 0;
public CharIteratorImpl(List<String> data) { public CharIteratorImpl(List<String> input) {
this.data = data; for (String s : input)
if (s.trim().length() > 0)
data.add(s.trim());
} }
public char peek() { public char peek() {

View File

@ -46,9 +46,11 @@ import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
public class PSystemEbnf extends TitledDiagram { public class PSystemEbnf extends TitledDiagram {
@ -63,8 +65,8 @@ public class PSystemEbnf extends TitledDiagram {
return new DiagramDescription("(EBNF)"); return new DiagramDescription("(EBNF)");
} }
public void doCommandLine(String line) { public void addLine(String line) {
lines.add(line); lines.add(line.trim());
} }
@Override @Override
@ -74,7 +76,15 @@ public class PSystemEbnf extends TitledDiagram {
} }
private TextBlockBackcolored getTextBlock() { private TextBlockBackcolored getTextBlock() {
final List<EbnfSingleExpression> all = EbnfExpressions.build(lines); final List<EbnfSingleExpression> 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()); TextBlock result = all.get(0).getUDrawable(getSkinParam());
for (int i = 1; i < all.size(); i++) for (int i = 1; i < all.size(); i++)
result = TextBlockUtils.mergeTB(result, all.get(i).getUDrawable(getSkinParam()), HorizontalAlignment.LEFT); result = TextBlockUtils.mergeTB(result, all.get(i).getUDrawable(getSkinParam()), HorizontalAlignment.LEFT);

View File

@ -35,28 +35,35 @@
*/ */
package net.sourceforge.plantuml.ebnf; 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.DiagramType;
import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.core.UmlSource;
public class PSystemEbnfFactory extends PSystemBasicFactory<PSystemEbnf> { public class PSystemEbnfFactory extends PSystemCommandFactory {
public PSystemEbnfFactory() { public PSystemEbnfFactory() {
super(DiagramType.EBNF); super(DiagramType.EBNF);
} }
@Override @Override
public PSystemEbnf initDiagram(UmlSource source, String startLine) { protected List<Command> createCommands() {
if (getDiagramType() == DiagramType.EBNF)
return new PSystemEbnf(source);
return null; final List<Command> cmds = new ArrayList<>();
CommonCommands.addCommonCommands1(cmds);
cmds.add(new CommandEBnfSingleLine());
cmds.add(new CommandEbnfMultiline());
return cmds;
} }
@Override @Override
public PSystemEbnf executeLine(UmlSource source, PSystemEbnf system, String line) { public PSystemEbnf createEmptyDiagram(UmlSource source, Map<String, String> skinParam) {
system.doCommandLine(line); return new PSystemEbnf(source);
return system;
} }
} }

View File

@ -50,6 +50,9 @@ public class ShuntingYard {
public ShuntingYard(Iterator<Token> it) { public ShuntingYard(Iterator<Token> it) {
while (it.hasNext()) { while (it.hasNext()) {
final Token token = it.next(); 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 if (token.getSymbol() == Symbol.LITTERAL || token.getSymbol() == Symbol.TERMINAL_STRING1
|| token.getSymbol() == Symbol.TERMINAL_STRING2) { || token.getSymbol() == Symbol.TERMINAL_STRING2) {
ouputQueue.add(token); ouputQueue.add(token);
@ -67,13 +70,28 @@ public class ShuntingYard {
} else if (token.getSymbol() == Symbol.OPTIONAL_OPEN) { } else if (token.getSymbol() == Symbol.OPTIONAL_OPEN) {
operatorStack.addFirst(new Token(Symbol.OPTIONAL, null)); operatorStack.addFirst(new Token(Symbol.OPTIONAL, null));
} else if (token.getSymbol() == Symbol.OPTIONAL_CLOSE) { } else if (token.getSymbol() == Symbol.OPTIONAL_CLOSE) {
while (thereIsAnOperatorAtTheTopOfTheOperatorStack())
ouputQueue.add(operatorStack.removeFirst());
final Token first = operatorStack.removeFirst(); final Token first = operatorStack.removeFirst();
if (first.getSymbol() != Symbol.OPTIONAL)
throw new IllegalStateException();
ouputQueue.add(first); ouputQueue.add(first);
} else if (token.getSymbol() == Symbol.REPETITION_OPEN) { } 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) { } else if (token.getSymbol() == Symbol.REPETITION_CLOSE) {
while (thereIsAnOperatorAtTheTopOfTheOperatorStack())
ouputQueue.add(operatorStack.removeFirst());
final Token first = operatorStack.removeFirst(); final Token first = operatorStack.removeFirst();
if (first.getSymbol() != Symbol.REPETITION_ZERO_OR_MORE)
throw new IllegalStateException();
ouputQueue.add(first); 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 { } else {
throw new UnsupportedOperationException(token.toString()); throw new UnsupportedOperationException(token.toString());
} }
@ -81,10 +99,25 @@ public class ShuntingYard {
} }
while (operatorStack.isEmpty() == false) { while (operatorStack.isEmpty() == false) {
final Token token = operatorStack.removeFirst(); 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); 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) { private boolean thereIsAnOperatorAtTheTopOfTheOperatorStackWithGreaterPrecedence(Token token) {
final Token top = operatorStack.peekFirst(); final Token top = operatorStack.peekFirst();
if (top != null && top.getSymbol().isOperator() if (top != null && top.getSymbol().isOperator()

View File

@ -49,7 +49,9 @@ public enum Symbol {
OPTIONAL, OPTIONAL,
REPETITION_OPEN, // { REPETITION_OPEN, // {
REPETITION_CLOSE, // } REPETITION_CLOSE, // }
REPETITION, // REPETITION_MINUS_CLOSE, // }
REPETITION_ZERO_OR_MORE, //
REPETITION_ONE_OR_MORE, //
GROUPING_OPEN, // ( GROUPING_OPEN, // (
GROUPING_CLOSE, // ) GROUPING_CLOSE, // )
TERMINAL_STRING1, // " " TERMINAL_STRING1, // " "
@ -72,4 +74,8 @@ public enum Symbol {
return this == CONCATENATION || this == ALTERNATION; return this == CONCATENATION || this == ALTERNATION;
} }
boolean isFunction() {
return this == OPTIONAL || this == REPETITION_ZERO_OR_MORE;
}
} }

View File

@ -43,6 +43,8 @@ public class Token {
public Token(Symbol symbol, String data) { public Token(Symbol symbol, String data) {
this.symbol = symbol; this.symbol = symbol;
this.data = data; this.data = data;
if (data != null && data.length() == 0)
throw new IllegalArgumentException();
} }
@Override @Override

View File

@ -37,27 +37,25 @@ package net.sourceforge.plantuml.ebnf;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.ugraphic.UGraphic; 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 dx;
private final double delta; private final double dy;
private final UDrawable top;
private final UDrawable bottom;
public VLineCurved(double height, double delta, UDrawable top, UDrawable bottom) { public ZigZag(double dx, double dy) {
this.height = height; this.dx = dx;
this.delta = delta; this.dy = dy;
this.bottom = bottom;
this.top = top;
} }
@Override @Override
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
bottom.drawU(ug.apply(UTranslate.dy(height))); final UPath path = new UPath();
ETileConcatenation.drawVline(ug, 0, delta, height - delta); path.moveTo(0, 0);
top.drawU(ug); final double a = 0.8;
path.cubicTo(dx * a, 0, dx - dx * a, dy, dx, dy);
ug.draw(path);
} }
} }

View File

@ -60,6 +60,7 @@ import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSet; 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) { private TextBlock getTextName(final UFont font, String name, final HColor color) {
final HColor opposite = color.opposite(); 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, final TextBlock tt = Display.getWithNewlines(name).create(fc, HorizontalAlignment.CENTER,
new SpriteContainerEmpty()); new SpriteContainerEmpty());
return tt; return tt;

View File

@ -176,8 +176,8 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker {
return label; return label;
} }
private TextBlock getQualifier(Link link, int n) { private TextBlock getQuantifier(Link link, int n) {
final String tmp = n == 1 ? link.getQualifier1() : link.getQualifier2(); final String tmp = n == 1 ? link.getQuantifier1() : link.getQuantifier2();
if (tmp == null) if (tmp == null)
return null; return null;
@ -323,7 +323,7 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker {
} }
final ElkPath elkPath = new ElkPath(diagram, SName.classDiagram, link, edge, getLabel(link), 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))); 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_LABELS_INLINE, true);
// edge.setProperty(CoreOptions.EDGE_TYPE, EdgeType.ASSOCIATION); // edge.setProperty(CoreOptions.EDGE_TYPE, EdgeType.ASSOCIATION);
} }
if (link.getQualifier1() != null) { if (link.getQuantifier1() != null) {
final ElkLabel edgeLabel = ElkGraphUtil.createLabel(edge); 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 // Nasty trick, we store the kind of label in the text
edgeLabel.setText("1"); edgeLabel.setText("1");
edgeLabel.setDimensions(dim.getWidth(), dim.getHeight()); 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_LABELS_INLINE, true);
// edge.setProperty(CoreOptions.EDGE_TYPE, EdgeType.ASSOCIATION); // edge.setProperty(CoreOptions.EDGE_TYPE, EdgeType.ASSOCIATION);
} }
if (link.getQualifier2() != null) { if (link.getQuantifier2() != null) {
final ElkLabel edgeLabel = ElkGraphUtil.createLabel(edge); 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 // Nasty trick, we store the kind of label in the text
edgeLabel.setText("2"); edgeLabel.setText("2");
edgeLabel.setDimensions(dim.getWidth(), dim.getHeight()); edgeLabel.setDimensions(dim.getWidth(), dim.getHeight());

View File

@ -228,7 +228,7 @@ public class SvgNanoParser implements Sprite {
if (m.find()) { if (m.find()) {
final String text = m.group(1); final String text = m.group(1);
HColor color = HColorSet.instance().getColorOrWhite(fill); 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); final UText utext = new UText(text, fc);
UGraphic ug = ugs.getUg(); UGraphic ug = ugs.getUg();
ug = ug.apply(new UTranslate(x, y)); ug = ug.apply(new UTranslate(x, y));

View File

@ -352,7 +352,7 @@ public abstract class PSystemError extends PlainDiagram {
"Details on <i>[[https://plantuml.com/dedication]]"); "Details on <i>[[https://plantuml.com/dedication]]");
final UFont font = UFont.sansSerif(14); 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 final TextBlock text = TextBlockUtils
.withMargin(disp.create(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty()), 10, 0); .withMargin(disp.create(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty()), 10, 0);
final TextBlock result; final TextBlock result;
@ -373,7 +373,7 @@ public abstract class PSystemError extends PlainDiagram {
"Details on <i>[[http://plantuml.com/adopt]]", " "); "Details on <i>[[http://plantuml.com/adopt]]", " ");
final UFont font = UFont.sansSerif(14); 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 final TextBlock text = TextBlockUtils
.withMargin(disp.create(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty()), 10, 0); .withMargin(disp.create(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty()), 10, 0);
final TextBlock result; final TextBlock result;

View File

@ -68,13 +68,13 @@ public class MagicBox {
} }
private TextBlock getSmallBlock() { 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); return node.getDisplay().create(fc, HorizontalAlignment.CENTER, skinParam);
} }
private TextBlock getCommentBlock() { private TextBlock getCommentBlock() {
if (node.getComment() != null && node.isTop()) { 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 Display.create(node.getComment()).create(tag, HorizontalAlignment.CENTER, skinParam);
} }
return TextBlockUtils.empty(0, 0); return TextBlockUtils.empty(0, 0);

View File

@ -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);
}
}

View File

@ -48,6 +48,7 @@ import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.ugraphic.UFont; 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.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColors; import net.sourceforge.plantuml.ugraphic.color.HColors;
@ -57,13 +58,14 @@ public class FontConfiguration {
private final UFont currentFont; private final UFont currentFont;
private final UFont motherFont; private final UFont motherFont;
private final HColor motherColor; private final HColor motherColor;
private final HColor hyperlinkColor;
private final HColor currentColor; private final HColor currentColor;
private final HColor extendedColor; private final HColor extendedColor;
private final FontPosition fontPosition; private final FontPosition fontPosition;
private final SvgAttributes svgAttributes; private final SvgAttributes svgAttributes;
private final boolean hyperlink;
private final boolean useUnderlineForHyperlink; private final UStroke hyperlinkUnderlineStroke;
private final HColor hyperlinkColor;
private final int tabSize; private final int tabSize;
public String toStringDebug() { public String toStringDebug() {
@ -71,18 +73,18 @@ public class FontConfiguration {
} }
public static FontConfiguration create(UFont font, HColor color, HColor hyperlinkColor, public static FontConfiguration create(UFont font, HColor color, HColor hyperlinkColor,
boolean useUnderlineForHyperlink) { UStroke hyperlinkUnderlineStroke) {
return create(font, color, hyperlinkColor, useUnderlineForHyperlink, 8); return create(font, color, hyperlinkColor, hyperlinkUnderlineStroke, 8);
} }
public static FontConfiguration create(UFont font, HColor color, HColor hyperlinkColor, 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, 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) { 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) { 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) { public static FontConfiguration create(ISkinParam skinParam, Style style, Colors colors) {
final HColor hyperlinkColor = style.value(PName.HyperLinkColor).asColor(skinParam.getIHtmlColorSet()); 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); HColor color = colors == null ? null : colors.getColor(ColorType.TEXT);
if (color == null) if (color == null)
color = style.value(PName.FontColor).asColor(skinParam.getIHtmlColorSet()); 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<FontStyle> getStyles(UFont font) { private static EnumSet<FontStyle> getStyles(UFont font) {
final boolean bold = font.isBold(); final boolean bold = font.isBold();
final boolean italic = font.isItalic(); final boolean italic = font.isItalic();
if (bold && italic) { if (bold && italic)
return EnumSet.of(FontStyle.ITALIC, FontStyle.BOLD); return EnumSet.of(FontStyle.ITALIC, FontStyle.BOLD);
}
if (bold) { if (bold)
return EnumSet.of(FontStyle.BOLD); return EnumSet.of(FontStyle.BOLD);
}
if (italic) { if (italic)
return EnumSet.of(FontStyle.ITALIC); return EnumSet.of(FontStyle.ITALIC);
}
return EnumSet.noneOf(FontStyle.class); return EnumSet.noneOf(FontStyle.class);
} }
@ -138,7 +130,7 @@ public class FontConfiguration {
private FontConfiguration(EnumSet<FontStyle> styles, UFont motherFont, HColor motherColor, UFont currentFont, private FontConfiguration(EnumSet<FontStyle> styles, UFont motherFont, HColor motherColor, UFont currentFont,
HColor currentColor, HColor extendedColor, FontPosition fontPosition, SvgAttributes svgAttributes, 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.styles = styles;
this.currentFont = currentFont; this.currentFont = currentFont;
this.motherFont = motherFont; this.motherFont = motherFont;
@ -147,61 +139,54 @@ public class FontConfiguration {
this.extendedColor = extendedColor; this.extendedColor = extendedColor;
this.fontPosition = fontPosition; this.fontPosition = fontPosition;
this.svgAttributes = svgAttributes; this.svgAttributes = svgAttributes;
this.hyperlink = hyperlink;
this.hyperlinkColor = hyperlinkColor; this.hyperlinkColor = hyperlinkColor;
this.useUnderlineForHyperlink = useUnderlineForHyperlink; this.hyperlinkUnderlineStroke = hyperlinkUnderlineStroke;
this.tabSize = tabSize; this.tabSize = tabSize;
} }
public FontConfiguration forceFont(UFont newFont, HColor htmlColorForStereotype) { public FontConfiguration forceFont(UFont newFont, HColor htmlColorForStereotype) {
if (newFont == null) { if (newFont == null)
return add(FontStyle.ITALIC); return add(FontStyle.ITALIC);
}
FontConfiguration result = new FontConfiguration(styles, newFont, motherColor, newFont, currentColor, FontConfiguration result = new FontConfiguration(styles, newFont, motherColor, newFont, currentColor,
extendedColor, fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink, extendedColor, fontPosition, svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize);
tabSize); if (htmlColorForStereotype != null)
if (htmlColorForStereotype != null) {
result = result.changeColor(htmlColorForStereotype); result = result.changeColor(htmlColorForStereotype);
}
return result; return result;
} }
public FontConfiguration changeAttributes(SvgAttributes toBeAdded) { public FontConfiguration changeAttributes(SvgAttributes toBeAdded) {
return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, extendedColor, return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, extendedColor,
fontPosition, svgAttributes.add(toBeAdded), hyperlink, hyperlinkColor, useUnderlineForHyperlink, fontPosition, svgAttributes.add(toBeAdded), hyperlinkColor, hyperlinkUnderlineStroke, tabSize);
tabSize);
} }
private FontConfiguration withHyperlink() { private FontConfiguration withHyperlink() {
return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, extendedColor, return new FontConfiguration(styles, motherFont, motherColor, currentFont, hyperlinkColor, extendedColor,
fontPosition, svgAttributes, true, hyperlinkColor, useUnderlineForHyperlink, tabSize); fontPosition, svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize);
} }
public FontConfiguration changeColor(HColor newHtmlColor) { 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, 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) { public FontConfiguration mute(Colors colors) {
final HColor color = Objects.requireNonNull(colors).getColor(ColorType.TEXT); final HColor color = Objects.requireNonNull(colors).getColor(ColorType.TEXT);
if (color == null) { if (color == null)
return this; return this;
}
return changeColor(color); return changeColor(color);
} }
FontConfiguration changeExtendedColor(HColor newExtendedColor) { FontConfiguration changeExtendedColor(HColor newExtendedColor) {
return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, 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) { public FontConfiguration changeSize(float size) {
return new FontConfiguration(styles, motherFont, motherColor, currentFont.withSize(size), currentColor, return new FontConfiguration(styles, motherFont, motherColor, currentFont.withSize(size), currentColor,
extendedColor, fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink, extendedColor, fontPosition, svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize);
tabSize);
} }
public FontConfiguration bigger(double delta) { public FontConfiguration bigger(double delta) {
@ -210,28 +195,28 @@ public class FontConfiguration {
public FontConfiguration changeFontPosition(FontPosition fontPosition) { public FontConfiguration changeFontPosition(FontPosition fontPosition) {
return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, extendedColor, 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) { public FontConfiguration changeFamily(String family) {
return new FontConfiguration(styles, motherFont, motherColor, return new FontConfiguration(styles, motherFont, motherColor,
new UFont(family, currentFont.getStyle(), currentFont.getSize()), currentColor, extendedColor, new UFont(family, currentFont.getStyle(), currentFont.getSize()), currentColor, extendedColor,
fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink, tabSize); fontPosition, svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize);
} }
public FontConfiguration resetFont() { public FontConfiguration resetFont() {
return new FontConfiguration(styles, motherFont, motherColor, motherFont, motherColor, null, 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) { public FontConfiguration add(FontStyle style) {
final EnumSet<FontStyle> r = styles.clone(); final EnumSet<FontStyle> r = styles.clone();
if (style == FontStyle.PLAIN) { if (style == FontStyle.PLAIN)
r.clear(); r.clear();
}
r.add(style); r.add(style);
return new FontConfiguration(r, motherFont, motherColor, currentFont, currentColor, extendedColor, fontPosition, return new FontConfiguration(r, motherFont, motherColor, currentFont, currentColor, extendedColor, fontPosition,
svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink, tabSize); svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize);
} }
public FontConfiguration italic() { public FontConfiguration italic() {
@ -259,9 +244,9 @@ public class FontConfiguration {
} }
public FontConfiguration hyperlink() { public FontConfiguration hyperlink() {
if (useUnderlineForHyperlink) { if (hyperlinkUnderlineStroke != null)
return add(FontStyle.UNDERLINE).withHyperlink(); return add(FontStyle.UNDERLINE).withHyperlink();
}
return withHyperlink(); return withHyperlink();
} }
@ -269,7 +254,7 @@ public class FontConfiguration {
final EnumSet<FontStyle> r = styles.clone(); final EnumSet<FontStyle> r = styles.clone();
r.remove(style); r.remove(style);
return new FontConfiguration(r, motherFont, motherColor, currentFont, currentColor, extendedColor, fontPosition, return new FontConfiguration(r, motherFont, motherColor, currentFont, currentColor, extendedColor, fontPosition,
svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink, tabSize); svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize);
} }
public UFont getFont() { public UFont getFont() {
@ -281,9 +266,6 @@ public class FontConfiguration {
} }
public HColor getColor() { public HColor getColor() {
if (hyperlink) {
return hyperlinkColor;
}
return currentColor; return currentColor;
} }
@ -311,4 +293,10 @@ public class FontConfiguration {
return tabSize; return tabSize;
} }
public UStroke getUnderlineStroke() {
return hyperlinkUnderlineStroke;
// return new UStroke();
// return new UStroke(3, 5, 2);
}
} }

View File

@ -51,6 +51,7 @@ import net.sourceforge.plantuml.ugraphic.PixelImage;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UImage; import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColors; 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 HColor hyperlinkColor = HColors.BLUE;
private final static boolean useUnderlineForHyperlink = true; private final static UStroke useUnderlineForHyperlink = new UStroke();
private final List<String> strings; private final List<String> strings;
@ -99,13 +100,11 @@ public class GraphicStrings extends AbstractTextBlock implements IEntityImage {
} }
public static TextBlockBackcolored createBlackOnWhite(List<String> strings) { public static TextBlockBackcolored createBlackOnWhite(List<String> strings) {
return new GraphicStrings(strings, sansSerif12(HColors.BLACK), HColors.WHITE, null, null, return new GraphicStrings(strings, sansSerif12(HColors.BLACK), HColors.WHITE, null, null, CreoleMode.FULL);
CreoleMode.FULL);
} }
public static TextBlockBackcolored createBlackOnWhiteMonospaced(List<String> strings) { public static TextBlockBackcolored createBlackOnWhiteMonospaced(List<String> strings) {
return new GraphicStrings(strings, monospaced14(HColors.BLACK), HColors.WHITE, null, null, return new GraphicStrings(strings, monospaced14(HColors.BLACK), HColors.WHITE, null, null, CreoleMode.FULL);
CreoleMode.FULL);
} }
public static TextBlockBackcolored createBlackOnWhite(List<String> strings, BufferedImage image, public static TextBlockBackcolored createBlackOnWhite(List<String> strings, BufferedImage image,

View File

@ -68,59 +68,47 @@ class HtmlCommandFactory {
private Pattern2 htmlTag = MyPattern.cmpile(Splitter.htmlTag); private Pattern2 htmlTag = MyPattern.cmpile(Splitter.htmlTag);
HtmlCommand getHtmlCommand(String s) { HtmlCommand getHtmlCommand(String s) {
if (htmlTag.matcher(s).matches() == false) { if (htmlTag.matcher(s).matches() == false)
return new Text(s); return new Text(s);
}
if (MyPattern.mtches(s, Splitter.imgPattern)) { if (MyPattern.mtches(s, Splitter.imgPattern))
return Img.getInstance(s, true); return Img.getInstance(s, true);
}
if (MyPattern.mtches(s, Splitter.imgPatternNoSrcColon)) { if (MyPattern.mtches(s, Splitter.imgPatternNoSrcColon))
return Img.getInstance(s, false); return Img.getInstance(s, false);
}
if (addStyle.matcher(s).matches()) { if (addStyle.matcher(s).matches())
return AddStyle.fromString(s); return AddStyle.fromString(s);
}
if (removeStyle.matcher(s).matches()) { if (removeStyle.matcher(s).matches())
return new RemoveStyle(FontStyle.getStyle(s)); return new RemoveStyle(FontStyle.getStyle(s));
}
if (MyPattern.mtches(s, Splitter.fontPattern)) { if (MyPattern.mtches(s, Splitter.fontPattern))
return new ColorAndSizeChange(s); return new ColorAndSizeChange(s);
}
if (MyPattern.mtches(s, Splitter.fontColorPattern2)) { if (MyPattern.mtches(s, Splitter.fontColorPattern2))
return new ColorChange(s); return new ColorChange(s);
}
if (MyPattern.mtches(s, Splitter.fontSizePattern2)) { if (MyPattern.mtches(s, Splitter.fontSizePattern2))
return new SizeChange(s); return new SizeChange(s);
}
if (MyPattern.mtches(s, Splitter.fontSup)) { if (MyPattern.mtches(s, Splitter.fontSup))
return new ExposantChange(FontPosition.EXPOSANT); return new ExposantChange(FontPosition.EXPOSANT);
}
if (MyPattern.mtches(s, Splitter.fontSub)) { if (MyPattern.mtches(s, Splitter.fontSub))
return new ExposantChange(FontPosition.INDICE); return new ExposantChange(FontPosition.INDICE);
}
if (MyPattern.mtches(s, Splitter.endFontPattern)) { if (MyPattern.mtches(s, Splitter.endFontPattern))
return new ResetFont(); return new ResetFont();
}
if (MyPattern.mtches(s, Splitter.endSupSub)) { if (MyPattern.mtches(s, Splitter.endSupSub))
return new ExposantChange(FontPosition.NORMAL); return new ExposantChange(FontPosition.NORMAL);
}
if (MyPattern.mtches(s, Splitter.fontFamilyPattern)) { if (MyPattern.mtches(s, Splitter.fontFamilyPattern))
return new FontFamilyChange(s); return new FontFamilyChange(s);
}
if (MyPattern.mtches(s, Splitter.spritePatternForMatch)) { if (MyPattern.mtches(s, Splitter.spritePatternForMatch))
return new SpriteCommand(s); return new SpriteCommand(s);
}
if (MyPattern.mtches(s, Splitter.linkPattern)) { if (MyPattern.mtches(s, Splitter.linkPattern)) {
final UrlBuilder urlBuilder = new UrlBuilder(null, UrlMode.STRICT); final UrlBuilder urlBuilder = new UrlBuilder(null, UrlMode.STRICT);
@ -129,9 +117,8 @@ class HtmlCommandFactory {
return new TextLink(url); return new TextLink(url);
} }
if (MyPattern.mtches(s, Splitter.svgAttributePattern)) { if (MyPattern.mtches(s, Splitter.svgAttributePattern))
return new SvgAttributesChange(s); return new SvgAttributesChange(s);
}
return null; return null;
} }

View File

@ -315,7 +315,10 @@ public class QuoteUtils {
"Vg jnf n znggre bs fheiviny. Jr gbbx ab fngvfsnpgvba va gur qrfgehpgvba bs bhe ohvyqref.", "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", "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...", "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() { private QuoteUtils() {
} }

View File

@ -60,11 +60,11 @@ class USymbolFrame extends USymbol {
private void drawFrame(UGraphic ug, double width, double height, XDimension2D dimTitle, double shadowing, private void drawFrame(UGraphic ug, double width, double height, XDimension2D dimTitle, double shadowing,
double roundCorner) { double roundCorner) {
final Shadowable shape = new URectangle(width, height).rounded(roundCorner).ignoreForCompressionOnX() final Shadowable rectangle = new URectangle(width, height).rounded(roundCorner).ignoreForCompressionOnX()
.ignoreForCompressionOnY(); .ignoreForCompressionOnY();
shape.setDeltaShadow(shadowing); rectangle.setDeltaShadow(shadowing);
ug.draw(shape); ug.draw(rectangle);
final double textWidth; final double textWidth;
final int cornersize; final int cornersize;
@ -77,15 +77,15 @@ class USymbolFrame extends USymbol {
} }
final double textHeight = getYpos(dimTitle); final double textHeight = getYpos(dimTitle);
final UPath polygon = new UPath(); final UPath line = new UPath();
polygon.setIgnoreForCompressionOnX(); line.setIgnoreForCompressionOnX();
polygon.moveTo(textWidth, 0); line.moveTo(textWidth, 0);
polygon.lineTo(textWidth, textHeight - cornersize); line.lineTo(textWidth, textHeight - cornersize);
polygon.lineTo(textWidth - cornersize, textHeight); line.lineTo(textWidth - cornersize, textHeight);
polygon.lineTo(0, textHeight); line.lineTo(0, textHeight);
ug.apply(HColors.none().bg()).draw(polygon); ug.apply(HColors.none().bg()).draw(line);
} }

View File

@ -73,16 +73,16 @@ public final class LinkHtmlPrinter {
String label = link.getLabel() == null ? null : StringUtils.unicodeForHtml(link.getLabel()); String label = link.getLabel() == null ? null : StringUtils.unicodeForHtml(link.getLabel());
String ent1 = ent1h; String ent1 = ent1h;
String ent2 = ent2h; String ent2 = ent2h;
if (link.getQualifier1() != null) { if (link.getQuantifier1() != null) {
ent1 = ent1 + " (" + link.getQualifier1() + ")"; ent1 = ent1 + " (" + link.getQuantifier1() + ")";
if (label != null) { if (label != null) {
label = "(" + link.getQualifier1() + " " + ent1h + ") " + label; label = "(" + link.getQuantifier1() + " " + ent1h + ") " + label;
} }
} }
if (link.getQualifier2() != null) { if (link.getQuantifier2() != null) {
ent2 = ent2 + " (" + link.getQualifier2() + ")"; ent2 = ent2 + " (" + link.getQuantifier2() + ")";
if (label != null) { if (label != null) {
label = label + " (" + link.getQualifier2() + " " + ent2h + ")"; label = label + " (" + link.getQuantifier2() + " " + ent2h + ")";
} }
} }
if (chiral) { if (chiral) {

View File

@ -79,11 +79,11 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
} }
final Link l1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, node, link.getType(), final Link l1 = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, node, link.getType(),
LinkArg.build(link.getLabel(), link.getLength(), getSkinParam().classAttributeIconSize() > 0) LinkArg.build(link.getLabel(), link.getLength(), getSkinParam().classAttributeIconSize() > 0)
.withQualifier(link.getQualifier1(), null) .withQuantifier(link.getQuantifier1(), null)
.withDistanceAngle(link.getLabeldistance(), link.getLabelangle())); .withDistanceAngle(link.getLabeldistance(), link.getLabelangle()));
final Link l2 = new Link(getSkinParam().getCurrentStyleBuilder(), node, entity2, link.getType(), final Link l2 = new Link(getSkinParam().getCurrentStyleBuilder(), node, entity2, link.getType(),
LinkArg.build(link.getLabel(), link.getLength(), getSkinParam().classAttributeIconSize() > 0) LinkArg.build(link.getLabel(), link.getLength(), getSkinParam().classAttributeIconSize() > 0)
.withQualifier(null, link.getQualifier2()) .withQuantifier(null, link.getQuantifier2())
.withDistanceAngle(link.getLabeldistance(), link.getLabelangle())); .withDistanceAngle(link.getLabeldistance(), link.getLabelangle()));
addLink(l1); addLink(l1);
addLink(l2); addLink(l2);
@ -175,13 +175,13 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
final Link entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point1, final Link entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point1,
existingLink1.getType().getPart2(), existingLink1.getType().getPart2(),
LinkArg.build(existingLink1.getLabel(), existingLink1.getLength()) LinkArg.build(existingLink1.getLabel(), existingLink1.getLength())
.withQualifier(existingLink1.getQualifier1(), null) .withQuantifier(existingLink1.getQuantifier1(), null)
.withDistanceAngle(existingLink1.getLabeldistance(), existingLink1.getLabelangle())); .withDistanceAngle(existingLink1.getLabeldistance(), existingLink1.getLabelangle()));
entity1ToPoint.setLinkArrow(existingLink1.getLinkArrow()); entity1ToPoint.setLinkArrow(existingLink1.getLinkArrow());
final Link pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, entity2real, final Link pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point1, entity2real,
existingLink1.getType().getPart1(), existingLink1.getType().getPart1(),
LinkArg.noDisplay(existingLink1.getLength()) LinkArg.noDisplay(existingLink1.getLength())
.withQualifier(null, existingLink1.getQualifier2()) .withQuantifier(null, existingLink1.getQuantifier2())
.withDistanceAngle(existingLink1.getLabeldistance(), existingLink1.getLabelangle())); .withDistanceAngle(existingLink1.getLabeldistance(), existingLink1.getLabelangle()));
// int length = 1; // int length = 1;
@ -287,13 +287,13 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point, entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1real, point,
existingLink.getType().getPart2(), existingLink.getType().getPart2(),
LinkArg.build(existingLink.getLabel(), existingLink.getLength()) LinkArg.build(existingLink.getLabel(), existingLink.getLength())
.withQualifier(existingLink.getQualifier1(), null) .withQuantifier(existingLink.getQuantifier1(), null)
.withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle())); .withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle()));
entity1ToPoint.setLinkArrow(existingLink.getLinkArrow()); entity1ToPoint.setLinkArrow(existingLink.getLinkArrow());
pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2real, pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2real,
existingLink.getType().getPart1(), existingLink.getType().getPart1(),
LinkArg.noDisplay(existingLink.getLength()) LinkArg.noDisplay(existingLink.getLength())
.withQualifier(null, existingLink.getQualifier2()) .withQuantifier(null, existingLink.getQuantifier2())
.withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle())); .withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle()));
int length = 1; int length = 1;
@ -333,11 +333,11 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, point, entity1ToPoint = new Link(getSkinParam().getCurrentStyleBuilder(), entity1, point,
existingLink.getType().getPart2(), 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())); .withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle()));
pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2, pointToEntity2 = new Link(getSkinParam().getCurrentStyleBuilder(), point, entity2,
existingLink.getType().getPart1(), existingLink.getType().getPart1(),
LinkArg.noDisplay(2).withQualifier(null, existingLink.getQualifier2()) LinkArg.noDisplay(2).withQuantifier(null, existingLink.getQuantifier2())
.withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle())); .withDistanceAngle(existingLink.getLabeldistance(), existingLink.getLabelangle()));
// entity1ToPoint = new Link(entity1, point, existingLink.getType(), // entity1ToPoint = new Link(entity1, point, existingLink.getType(),
// null, 2); // null, 2);

View File

@ -66,7 +66,7 @@ public class PSystemListOpenIconic extends PlainDiagram {
lines.add("<i>Credit to"); lines.add("<i>Credit to");
lines.add("https://useiconic.com/open"); lines.add("https://useiconic.com/open");
lines.add(" "); lines.add(" ");
try (BufferedReader br = new BufferedReader(new InputStreamReader(getRessourceAllTxt()))) { try (BufferedReader br = new BufferedReader(new InputStreamReader(getResourceAllTxt()))) {
String s = null; String s = null;
while ((s = br.readLine()) != null) { while ((s = br.readLine()) != null) {
// lines.add("<&yen> " + s); // lines.add("<&yen> " + s);
@ -78,7 +78,7 @@ public class PSystemListOpenIconic extends PlainDiagram {
return new TextBlockHorizontal(cols, VerticalAlignment.TOP); return new TextBlockHorizontal(cols, VerticalAlignment.TOP);
} }
private InputStream getRessourceAllTxt() { private InputStream getResourceAllTxt() {
return DummyIcon.class.getResourceAsStream("all.txt"); return DummyIcon.class.getResourceAsStream("all.txt");
} }

View File

@ -111,9 +111,9 @@ public class DotPath implements UShape, Moveable {
} }
public DotPath(SvgResult fullSvg) { public DotPath(SvgResult fullSvg) {
if (isPathConsistent(fullSvg.getSvg()) == false) { if (isPathConsistent(fullSvg.getSvg()) == false)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
}
final int posC = fullSvg.indexOf("C", 0); final int posC = fullSvg.indexOf("C", 0);
if (posC == -1) if (posC == -1)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@ -282,21 +282,21 @@ public class DotPath implements UShape, Moveable {
double result = Double.MAX_VALUE; double result = Double.MAX_VALUE;
for (XCubicCurve2D c : beziers) { for (XCubicCurve2D c : beziers) {
final double d1 = ref.distance(c.x1, c.y1); final double d1 = ref.distance(c.x1, c.y1);
if (d1 < result) { if (d1 < result)
result = d1; result = d1;
}
final double d2 = ref.distance(c.x2, c.y2); final double d2 = ref.distance(c.x2, c.y2);
if (d2 < result) { if (d2 < result)
result = d2; result = d2;
}
final double d3 = ref.distance(c.ctrlx1, c.ctrly1); final double d3 = ref.distance(c.ctrlx1, c.ctrly1);
if (d3 < result) { if (d3 < result)
result = d3; result = d3;
}
final double d4 = ref.distance(c.ctrlx2, c.ctrly2); final double d4 = ref.distance(c.ctrlx2, c.ctrly2);
if (d4 < result) { if (d4 < result)
result = d4; result = d4;
}
} }
return result; return result;

View File

@ -48,7 +48,7 @@ public class Stdlib {
if (folder == null || folder.info.size() == 0) if (folder == null || folder.info.size() == 0)
return null; return null;
final String data = folder.loadRessource(fullname.substring(last + 1)); final String data = folder.loadResource(fullname.substring(last + 1));
if (data == null) if (data == null)
return null; return null;
@ -74,7 +74,7 @@ public class Stdlib {
return result; return result;
} }
private String loadRessource(String file) throws IOException { private String loadResource(String file) throws IOException {
final SoftReference<String> cached = cache.get(file.toLowerCase()); final SoftReference<String> cached = cache.get(file.toLowerCase());
if (cached != null) { if (cached != null) {
final String cachedResult = cached.get(); final String cachedResult = cached.get();

View File

@ -243,7 +243,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
drawTasksRect(ug); drawTasksRect(ug);
drawTasksTitle(ugOrig, getTitlesColumnWidth(ug.getStringBounder()), getBarsColumnWidth(timeHeader)); drawTasksTitle(ugOrig, getTitlesColumnWidth(ug.getStringBounder()), getBarsColumnWidth(timeHeader));
if (hideRessourceFoobox == false) if (hideResourceFoobox == false)
drawResources(ug); drawResources(ug);
if (showFootbox) if (showFootbox)
@ -437,7 +437,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
getEnd(taskGroup), getSkinParam(), task, this, task.getStyleBuilder()); getEnd(taskGroup), getSkinParam(), task, this, task.getStyleBuilder());
} else { } else {
final TaskImpl tmp = (TaskImpl) task; 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()) { if (tmp.isDiamond()) {
draw = new TaskDrawDiamond(timeScale, y, disp, getStart(tmp), getSkinParam(), task, this, draw = new TaskDrawDiamond(timeScale, y, disp, getStart(tmp), getSkinParam(), task, this,
task.getStyleBuilder()); task.getStyleBuilder());
@ -459,7 +459,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
double yy = lastY(stringBounder); double yy = lastY(stringBounder);
if (yy == 0) { if (yy == 0) {
yy = headerHeight; yy = headerHeight;
} else if (this.hideRessourceFoobox == false) } else if (this.hideResourceFoobox == false)
for (Resource res : resources.values()) { for (Resource res : resources.values()) {
final ResourceDraw draw = new ResourceDraw(this, res, timeScale, yy, min, max); final ResourceDraw draw = new ResourceDraw(this, res, timeScale, yy, min, max);
res.setTaskDraw(draw); res.setTaskDraw(draw);
@ -839,16 +839,16 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
this.withCalendarDate = withCalendarDate; this.withCalendarDate = withCalendarDate;
} }
private boolean hideRessourceName; private boolean hideResourceName;
private boolean hideRessourceFoobox; private boolean hideResourceFoobox;
public CommandExecutionResult hideRessourceName() { public CommandExecutionResult hideResourceName() {
this.hideRessourceName = true; this.hideResourceName = true;
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }
public CommandExecutionResult hideRessourceFootbox() { public CommandExecutionResult hideResourceFootbox() {
this.hideRessourceFoobox = true; this.hideResourceFoobox = true;
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }

View File

@ -53,8 +53,8 @@ import net.sourceforge.plantuml.project.command.CommandGanttArrow;
import net.sourceforge.plantuml.project.command.CommandGanttArrow2; import net.sourceforge.plantuml.project.command.CommandGanttArrow2;
import net.sourceforge.plantuml.project.command.CommandGroupEnd; import net.sourceforge.plantuml.project.command.CommandGroupEnd;
import net.sourceforge.plantuml.project.command.CommandGroupStart; import net.sourceforge.plantuml.project.command.CommandGroupStart;
import net.sourceforge.plantuml.project.command.CommandHideRessourceFootbox; import net.sourceforge.plantuml.project.command.CommandHideResourceFootbox;
import net.sourceforge.plantuml.project.command.CommandHideRessourceName; import net.sourceforge.plantuml.project.command.CommandHideResourceName;
import net.sourceforge.plantuml.project.command.CommandLabelOnColumn; import net.sourceforge.plantuml.project.command.CommandLabelOnColumn;
import net.sourceforge.plantuml.project.command.CommandLanguage; import net.sourceforge.plantuml.project.command.CommandLanguage;
import net.sourceforge.plantuml.project.command.CommandNoteBottom; import net.sourceforge.plantuml.project.command.CommandNoteBottom;
@ -117,8 +117,8 @@ public class GanttDiagramFactory extends PSystemCommandFactory {
cmds.add(new CommandNoteBottom()); cmds.add(new CommandNoteBottom());
cmds.add(new CommandFootbox()); cmds.add(new CommandFootbox());
cmds.add(new CommandLabelOnColumn()); cmds.add(new CommandLabelOnColumn());
cmds.add(new CommandHideRessourceName()); cmds.add(new CommandHideResourceName());
cmds.add(new CommandHideRessourceFootbox()); cmds.add(new CommandHideResourceFootbox());
return cmds; return cmds;
} }

View File

@ -51,4 +51,9 @@ public class Load implements Value {
return winks * 100; return winks * 100;
} }
@Override
public String toString() {
return "(" + winks + ")";
}
} }

View File

@ -44,17 +44,17 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.GanttDiagram;
public class CommandHideRessourceFootbox extends SingleLineCommand2<GanttDiagram> { public class CommandHideResourceFootbox extends SingleLineCommand2<GanttDiagram> {
public CommandHideRessourceFootbox() { public CommandHideResourceFootbox() {
super(getRegexConcat()); super(getRegexConcat());
} }
static IRegex getRegexConcat() { static IRegex getRegexConcat() {
return RegexConcat.build(CommandHideRessourceFootbox.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandHideResourceFootbox.class.getName(), RegexLeaf.start(), //
new RegexLeaf("hide"), // new RegexLeaf("hide"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("ressources?"), // new RegexLeaf("ress?ources?"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("footbox"), // new RegexLeaf("footbox"), //
RegexLeaf.end()); // RegexLeaf.end()); //
@ -62,7 +62,7 @@ public class CommandHideRessourceFootbox extends SingleLineCommand2<GanttDiagram
@Override @Override
protected CommandExecutionResult executeArg(GanttDiagram diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(GanttDiagram diagram, LineLocation location, RegexResult arg) {
return diagram.hideRessourceFootbox(); return diagram.hideResourceFootbox();
} }
} }

View File

@ -44,17 +44,17 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.GanttDiagram;
public class CommandHideRessourceName extends SingleLineCommand2<GanttDiagram> { public class CommandHideResourceName extends SingleLineCommand2<GanttDiagram> {
public CommandHideRessourceName() { public CommandHideResourceName() {
super(getRegexConcat()); super(getRegexConcat());
} }
static IRegex getRegexConcat() { static IRegex getRegexConcat() {
return RegexConcat.build(CommandHideRessourceName.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandHideResourceName.class.getName(), RegexLeaf.start(), //
new RegexLeaf("hide"), // new RegexLeaf("hide"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("ressources?"), // new RegexLeaf("ress?ources?"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("names?"), // new RegexLeaf("names?"), //
RegexLeaf.end()); // RegexLeaf.end()); //
@ -62,7 +62,7 @@ public class CommandHideRessourceName extends SingleLineCommand2<GanttDiagram> {
@Override @Override
protected CommandExecutionResult executeArg(GanttDiagram diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(GanttDiagram diagram, LineLocation location, RegexResult arg) {
return diagram.hideRessourceName(); return diagram.hideResourceName();
} }
} }

View File

@ -94,7 +94,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable {
LoadPlanable result = defaultPlan; LoadPlanable result = defaultPlan;
if (resources.size() > 0) if (resources.size() > 0)
result = PlanUtils.multiply(defaultPlan, getRessourcePlan()); result = PlanUtils.multiply(defaultPlan, getResourcePlan());
return result.getLoadAt(instant); return result.getLoadAt(instant);
} }
@ -139,7 +139,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable {
this.pausedDayOfWeek.add(pause); this.pausedDayOfWeek.add(pause);
} }
private LoadPlanable getRessourcePlan() { private LoadPlanable getResourcePlan() {
if (resources.size() == 0) if (resources.size() == 0)
throw new IllegalStateException(); throw new IllegalStateException();
@ -192,8 +192,9 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable {
public Day getStart() { public Day getStart() {
Day result = (Day) solver.getData(TaskAttribute.START); Day result = (Day) solver.getData(TaskAttribute.START);
while (getLoadAt(result) == 0) if (diamond == false)
result = result.increment(); while (getLoadAt(result) == 0)
result = result.increment();
return result; return result;
} }

View File

@ -116,7 +116,7 @@ public class ResourceDraw implements UDrawable {
private FontConfiguration getFontConfiguration(int size, HColor color) { private FontConfiguration getFontConfiguration(int size, HColor color) {
final UFont font = UFont.serif(size); final UFont font = UFont.serif(size);
return FontConfiguration.create(font, color, color, false); return FontConfiguration.create(font, color, color, null);
} }
public double getHeight() { public double getHeight() {

View File

@ -131,7 +131,7 @@ public abstract class TimeHeader {
if (bold) if (bold)
font = font.bold(); font = font.bold();
return FontConfiguration.create(font, color, color, false); return FontConfiguration.create(font, color, color, null);
} }
public final TimeScale getTimeScale() { public final TimeScale getTimeScale() {

View File

@ -123,7 +123,7 @@ public class Verbs {
} }
public static IRegex lasts() { public static IRegex lasts() {
return new RegexLeaf("lasts"); return new RegexLeaf("(lasts|requires)");
} }
public static IRegex linksTo() { public static IRegex linksTo() {

View File

@ -53,14 +53,14 @@ public abstract class AbstractSolver implements Solver {
final Value previous = values.remove(attribute); final Value previous = values.remove(attribute);
if (previous != null && attribute == TaskAttribute.START) { if (previous != null && attribute == TaskAttribute.START) {
final Day previousInstant = (Day) previous; final Day previousInstant = (Day) previous;
if (previousInstant.compareTo((Day) value) > 0) { if (previousInstant.compareTo((Day) value) > 0)
value = previous; value = previous;
}
} }
values.put(attribute, value); values.put(attribute, value);
if (values.size() > 2) { if (values.size() > 2)
removeFirstElement(); removeFirstElement();
}
assert values.size() <= 2; assert values.size() <= 2;
} }
@ -74,12 +74,12 @@ public abstract class AbstractSolver implements Solver {
final public Value getData(TaskAttribute attribute) { final public Value getData(TaskAttribute attribute) {
Value result = values.get(attribute); Value result = values.get(attribute);
if (result == null) { if (result == null) {
if (attribute == TaskAttribute.END) { if (attribute == TaskAttribute.END)
return computeEnd(); return computeEnd();
}
if (attribute == TaskAttribute.START) { if (attribute == TaskAttribute.START)
return computeStart(); return computeStart();
}
return Load.inWinks(1); return Load.inWinks(1);
// throw new UnsupportedOperationException(attribute.toString()); // throw new UnsupportedOperationException(attribute.toString());
} }

View File

@ -97,12 +97,12 @@ class RealLine {
for (AbstractReal real : all) { for (AbstractReal real : all) {
final double v = real.getCurrentValue(); final double v = real.getCurrentValue();
// System.err.println("RealLine::compile v=" + v); // System.err.println("RealLine::compile v=" + v);
if (v > max) { if (v > max)
max = v; max = v;
}
if (v < min) { if (v < min)
min = v; min = v;
}
} }
// System.err.println("RealLine::compile min=" + min + " max=" + max); // System.err.println("RealLine::compile min=" + min + " max=" + max);
return; return;
@ -117,12 +117,12 @@ class RealLine {
} }
private void printCounter(Map<PositiveForce, Integer> counter) { private void printCounter(Map<PositiveForce, Integer> counter) {
for (PositiveForce f : forces) { for (PositiveForce f : forces)
System.err.println("force=" + f); System.err.println("force=" + f);
}
for (Map.Entry<PositiveForce, Integer> ent : counter.entrySet()) { for (Map.Entry<PositiveForce, Integer> ent : counter.entrySet())
System.err.println("count=" + ent.getValue() + " for " + ent.getKey()); System.err.println("count=" + ent.getValue() + " for " + ent.getKey());
}
} }
private static void incCounter(Map<PositiveForce, Integer> counter, PositiveForce f) { private static void incCounter(Map<PositiveForce, Integer> counter, PositiveForce f) {

View File

@ -155,8 +155,8 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
continue; continue;
final ST_Agedge_s edge = ent.getValue(); final ST_Agedge_s edge = ent.getValue();
new SmetanaPath(link, edge, ymirror, diagram, getLabel(link), getQualifier(link, 1), new SmetanaPath(link, edge, ymirror, diagram, getLabel(link), getQuantifier(link, 1),
getQualifier(link, 2)).drawU(ug); getQuantifier(link, 2)).drawU(ug);
} }
} }
@ -447,8 +447,8 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
return TextBlockUtils.withMargin(label, marginLabel, marginLabel); return TextBlockUtils.withMargin(label, marginLabel, marginLabel);
} }
private TextBlock getQualifier(Link link, int n) { private TextBlock getQuantifier(Link link, int n) {
final String tmp = n == 1 ? link.getQualifier1() : link.getQualifier2(); final String tmp = n == 1 ? link.getQuantifier1() : link.getQuantifier2();
if (tmp == null) if (tmp == null)
return null; return null;
@ -514,7 +514,7 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
agsafeset(e, new CString("label"), hackDim, new CString("")); agsafeset(e, new CString("label"), hackDim, new CString(""));
// System.err.print("label=" + hackDim.getContent()); // System.err.print("label=" + hackDim.getContent());
} }
final TextBlock q1 = getQualifier(link, 1); final TextBlock q1 = getQuantifier(link, 1);
if (q1 != null) { if (q1 != null) {
final XDimension2D dimLabel = q1.calculateDimension(stringBounder); final XDimension2D dimLabel = q1.calculateDimension(stringBounder);
// System.err.println("dimLabel = " + dimLabel); // System.err.println("dimLabel = " + dimLabel);
@ -522,7 +522,7 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
(int) dimLabel.getHeight()); (int) dimLabel.getHeight());
agsafeset(e, new CString("taillabel"), hackDim, new CString("")); agsafeset(e, new CString("taillabel"), hackDim, new CString(""));
} }
final TextBlock q2 = getQualifier(link, 2); final TextBlock q2 = getQuantifier(link, 2);
if (q2 != null) { if (q2 != null) {
final XDimension2D dimLabel = q2.calculateDimension(stringBounder); final XDimension2D dimLabel = q2.calculateDimension(stringBounder);
// System.err.println("dimLabel = " + dimLabel); // System.err.println("dimLabel = " + dimLabel);

View File

@ -150,6 +150,7 @@ public class SmetanaPath implements UDrawable {
extremity2.drawU(ug); extremity2.drawU(ug);
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
e.printStackTrace();
System.err.println("CANNOT DRAW printExtremityAtStart"); System.err.println("CANNOT DRAW printExtremityAtStart");
} }
} }
@ -174,6 +175,7 @@ public class SmetanaPath implements UDrawable {
extremity1.drawU(ug); extremity1.drawU(ug);
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
e.printStackTrace();
System.err.println("CANNOT DRAW printExtremityAtEnd"); System.err.println("CANNOT DRAW printExtremityAtEnd");
} }
} }

View File

@ -126,7 +126,7 @@ public enum SecurityProfile {
case SANDBOX: case SANDBOX:
return "This is completely safe: no access to local files or to distant URL."; return "This is completely safe: no access to local files or to distant URL.";
case ALLOWLIST: case ALLOWLIST:
return "Some local ressource may be accessible."; return "Some local resource may be accessible.";
case INTERNET: case INTERNET:
return "<i>Mode designed for server connected to Internet."; return "<i>Mode designed for server connected to Internet.";
case LEGACY: case LEGACY:

View File

@ -88,9 +88,8 @@ public class Doll implements WithStyle {
this.styleBuilder = styleBuilder; this.styleBuilder = styleBuilder;
this.tileArguments = Objects.requireNonNull(tileArguments); this.tileArguments = Objects.requireNonNull(tileArguments);
if (first != null) { if (first != null)
this.participants.add(first); this.participants.add(first);
}
} }

View File

@ -35,6 +35,7 @@
*/ */
package net.sourceforge.plantuml.sequencediagram; package net.sourceforge.plantuml.sequencediagram;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -75,7 +76,7 @@ public class Reference extends AbstractEvent implements Event {
public Reference(List<Participant> participants, Url url, Display strings, HColor backColorGeneral, public Reference(List<Participant> participants, Url url, Display strings, HColor backColorGeneral,
HColor backColorElement, StyleBuilder styleBuilder) { HColor backColorElement, StyleBuilder styleBuilder) {
this.participants = participants; this.participants = uniq(participants);
this.url = url; this.url = url;
this.strings = strings; this.strings = strings;
this.backColorGeneral = backColorGeneral; this.backColorGeneral = backColorGeneral;
@ -84,8 +85,16 @@ public class Reference extends AbstractEvent implements Event {
this.styleHeader = getHeaderStyleDefinition().getMergedStyle(styleBuilder); this.styleHeader = getHeaderStyleDefinition().getMergedStyle(styleBuilder);
} }
static private List<Participant> uniq(List<Participant> all) {
final List<Participant> result = new ArrayList<Participant>();
for (Participant p : all)
if (result.contains(p) == false)
result.add(p);
return Collections.unmodifiableList(result);
}
public List<Participant> getParticipant() { public List<Participant> getParticipant() {
return Collections.unmodifiableList(participants); return participants;
} }
public Display getStrings() { public Display getStrings() {

View File

@ -385,7 +385,7 @@ class DrawableSetInitializer {
freeY2 = ((FrontierStack) freeY2).restore(); freeY2 = ((FrontierStack) freeY2).restore();
final Component compElse = drawableSet.getSkin().createComponent(m.getUsedStyles(), 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() { final Lazy lazy = new Lazy() {
public double getNow() { public double getNow() {
final GraphicalElement after = drawableSet.getEvent(m.getJustAfter()); final GraphicalElement after = drawableSet.getEvent(m.getJustAfter());

View File

@ -139,9 +139,9 @@ public class SequenceDiagramArea {
} }
public double getLegendY() { public double getLegendY() {
if (isLegendTop) { if (isLegendTop)
return titleHeight + headerHeight + headerMargin; return titleHeight + headerHeight + headerMargin;
}
return sequenceHeight + headerHeight + headerMargin + titleHeight; return sequenceHeight + headerHeight + headerMargin + titleHeight;
} }

View File

@ -42,7 +42,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.sourceforge.plantuml.AnnotatedWorker; import net.sourceforge.plantuml.AnnotatedBuilder;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; 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 { public ImageData createOne(OutputStream os, final int index, boolean isWithMetadata) throws IOException {
final Page page = pages.get(index); 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 TextBlock compTitle;
final AnnotatedWorker annotatedWorker = new AnnotatedWorker(diagram, diagram.getSkinParam(), stringBounder); final TextBlock caption = builder.getCaption();
final TextBlock caption = annotatedWorker.getCaption();
area.setCaptionArea(caption.calculateDimension(stringBounder)); area.setCaptionArea(caption.calculateDimension(stringBounder));
if (Display.isNull(page.getTitle())) { if (Display.isNull(page.getTitle())) {
@ -190,7 +194,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
area.getSequenceAreaY()); area.getSequenceAreaY());
TextBlock core = drawableSet.asTextBlock(delta, fullDimension.getWidth(), page, TextBlock core = drawableSet.asTextBlock(delta, fullDimension.getWidth(), page,
diagram.isShowFootbox()); diagram.isShowFootbox());
core = annotatedWorker.addFrame(core); core = builder.decoreWithFrame(core);
core.drawU(ug.apply(forCore)); core.drawU(ug.apply(forCore));
drawHeader(area, ug, index); drawHeader(area, ug, index);

View File

@ -78,7 +78,7 @@ public class ElseTile extends AbstractTile {
anElse.getBackColorGeneral()); anElse.getBackColorGeneral());
final Display display = Display.create(anElse.getComment()); 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); display);
return comp; return comp;
} }
@ -107,9 +107,10 @@ public class ElseTile extends AbstractTile {
final XDimension2D dim = comp.getPreferredDimension(getStringBounder()); final XDimension2D dim = comp.getPreferredDimension(getStringBounder());
double height = dim.getHeight(); double height = dim.getHeight();
if (anElse.getComment() != null) { // if (anElse.getComment() != null)
height += 10; // height += 10;
} //
// return height + 20;
return height; return height;
} }

View File

@ -108,12 +108,12 @@ public class GroupingTile extends AbstractTile {
while (it.hasNext()) { while (it.hasNext()) {
final Event ev = it.next(); final Event ev = it.next();
if (ev instanceof GroupingLeaf && ((Grouping) ev).getType() == GroupingType.END) { if (ev instanceof GroupingLeaf && ((Grouping) ev).getType() == GroupingType.END)
break; break;
}
for (Tile tile : TileBuilder.buildOne(it, tileArgumentsOriginal, ev, this)) { for (Tile tile : TileBuilder.buildOne(it, tileArgumentsOriginal, ev, this))
tiles.add(tile); tiles.add(tile);
}
} }
tiles = mergeParallel(getStringBounder(), tiles); tiles = mergeParallel(getStringBounder(), tiles);
@ -131,13 +131,13 @@ public class GroupingTile extends AbstractTile {
max2.add(m.addFixed(MARGINX)); max2.add(m.addFixed(MARGINX));
} }
final double width = dim1.getWidth(); final double width = dim1.getWidth();
if (min2.size() == 0) { if (min2.size() == 0)
min2.add(tileArgumentsOriginal.getOrigin()); min2.add(tileArgumentsOriginal.getOrigin());
}
this.min = RealUtils.min(min2); this.min = RealUtils.min(min2);
for (Tile anElse : allElses) { for (Tile anElse : allElses)
max2.add(anElse.getMaxX()); max2.add(anElse.getMaxX());
}
max2.add(this.min.addFixed(width + 16)); max2.add(this.min.addFixed(width + 16));
this.max = RealUtils.max(max2); this.max = RealUtils.max(max2);
} }
@ -205,9 +205,9 @@ public class GroupingTile extends AbstractTile {
} }
public void addConstraints() { public void addConstraints() {
for (Tile tile : tiles) { for (Tile tile : tiles)
tile.addConstraints(); tile.addConstraints();
}
} }
public Real getMinX() { public Real getMinX() {
@ -272,9 +272,9 @@ public class GroupingTile extends AbstractTile {
private static List<Tile> removeEmptyCloseToParallel(List<Tile> tiles) { private static List<Tile> removeEmptyCloseToParallel(List<Tile> tiles) {
final List<Tile> result = new ArrayList<>(); final List<Tile> result = new ArrayList<>();
for (Tile tile : tiles) { for (Tile tile : tiles) {
if (isParallel(tile)) { if (isParallel(tile))
removeHeadEmpty(result); removeHeadEmpty(result);
}
result.add(tile); result.add(tile);
} }
return result; return result;
@ -282,9 +282,9 @@ public class GroupingTile extends AbstractTile {
} }
private static void removeHeadEmpty(List<Tile> tiles) { private static void removeHeadEmpty(List<Tile> 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); tiles.remove(tiles.size() - 1);
}
} }
public static boolean isParallel(Tile tile) { public static boolean isParallel(Tile tile) {
@ -293,17 +293,13 @@ public class GroupingTile extends AbstractTile {
void addYNewPages(Collection<Double> yNewPages) { void addYNewPages(Collection<Double> yNewPages) {
for (Tile tile : tiles) { for (Tile tile : tiles) {
if (tile instanceof GroupingTile) { if (tile instanceof GroupingTile)
((GroupingTile) tile).addYNewPages(yNewPages); ((GroupingTile) tile).addYNewPages(yNewPages);
}
if (tile instanceof NewpageTile) { if (tile instanceof NewpageTile) {
final double y = ((NewpageTile) tile).getY(); final double y = ((NewpageTile) tile).getY();
yNewPages.add(y); yNewPages.add(y);
} }
} }
} }
// public double getStartY() {
// return y + MARGINY;
// }
} }

View File

@ -38,7 +38,7 @@ package net.sourceforge.plantuml.sequencediagram.teoz;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import net.sourceforge.plantuml.AnnotatedWorker; import net.sourceforge.plantuml.AnnotatedBuilder;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
@ -74,7 +74,8 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
private final SequenceDiagram diagram; private final SequenceDiagram diagram;
private final FileFormatOption fileFormatOption; private final FileFormatOption fileFormatOption;
private final Rose skin; private final Rose skin;
private final AnnotatedWorker annotatedWorker; private final AnnotatedBuilder annotatedBuilder;
private final int index; private final int index;
public SequenceDiagramFileMakerTeoz(SequenceDiagram diagram, Rose skin, FileFormatOption fileFormatOption, public SequenceDiagramFileMakerTeoz(SequenceDiagram diagram, Rose skin, FileFormatOption fileFormatOption,
@ -87,13 +88,13 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
this.body = new PlayingSpaceWithParticipants(createMainTile()); this.body = new PlayingSpaceWithParticipants(createMainTile());
this.footer = getFooterOrHeader(FontParam.FOOTER); this.footer = getFooterOrHeader(FontParam.FOOTER);
this.header = getFooterOrHeader(FontParam.HEADER); 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.min1 = body.getMinX(stringBounder);
this.title = getTitle(); this.title = getTitle();
this.legend = getLegend(); this.legend = getLegend();
this.caption = annotatedWorker.getCaption(); this.caption = annotatedBuilder.getCaption();
this.heightEnglober1 = dolls.getOffsetForEnglobers(stringBounder); this.heightEnglober1 = dolls.getOffsetForEnglobers(stringBounder);
this.heightEnglober2 = heightEnglober1 == 0 ? 0 : 10; this.heightEnglober2 = heightEnglober1 == 0 ? 0 : 10;
@ -107,7 +108,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
+ header.calculateDimension(stringBounder).getHeight() + header.calculateDimension(stringBounder).getHeight()
+ legend.calculateDimension(stringBounder).getHeight() + legend.calculateDimension(stringBounder).getHeight()
+ caption.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); this.dimTotal = new XDimension2D(totalWidth, totalHeight);
} }
@ -264,8 +265,8 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
} }
ug = ug.apply(UTranslate.dy(heightEnglober1)); ug = ug.apply(UTranslate.dy(heightEnglober1));
final TextBlock bodyFramed = annotatedWorker.addFrame(body); final TextBlock bodyFramed = annotatedBuilder.decoreWithFrame(body);
printAligned(ug.apply(UTranslate.dx((annotatedWorker.hasMainFrame() ? 4 : 0))), HorizontalAlignment.CENTER, printAligned(ug.apply(UTranslate.dx((annotatedBuilder.hasMainFrame() ? 4 : 0))), HorizontalAlignment.CENTER,
bodyFramed); bodyFramed);
ug = goDown(ug, bodyFramed); ug = goDown(ug, bodyFramed);
ug = ug.apply(UTranslate.dy(heightEnglober2)); ug = ug.apply(UTranslate.dy(heightEnglober2));

View File

@ -56,7 +56,7 @@ public enum ComponentType implements Styleable {
DELAY_LINE, PARTICIPANT_LINE, CONTINUE_LINE, 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, NEWPAGE, NOTE, NOTE_HEXAGONAL, NOTE_BOX, DIVIDER, REFERENCE, ENGLOBER,

View File

@ -59,10 +59,12 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent {
private final HColor groupBorder; private final HColor groupBorder;
private final HColor backgroundColor; private final HColor backgroundColor;
private final double roundCorner; 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 + "]"); super(style, LineBreakStrategy.NONE, 5, 5, 1, spriteContainer, comment == null ? null : "[" + comment + "]");
this.teoz = teoz;
this.roundCorner = style.value(PName.RoundCorner).asInt(); this.roundCorner = style.value(PName.RoundCorner).asInt();
this.groupBorder = style.value(PName.LineColor).asColor(getIHtmlColorSet()); this.groupBorder = style.value(PName.LineColor).asColor(getIHtmlColorSet());
this.backgroundColor = style.value(PName.BackGroundColor).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 = ArrowConfiguration.stroke(ug, 2, 2, 1).apply(groupBorder);
ug.apply(UTranslate.dy(1)).draw(ULine.hline(dimensionToUse.getWidth())); ug.apply(UTranslate.dy(1)).draw(ULine.hline(dimensionToUse.getWidth()));
ug = ug.apply(new UStroke()); 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 @Override
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight(StringBounder stringBounder) {
return getTextHeight(stringBounder); if (teoz)
return getTextHeight(stringBounder) + 16;
else
return getTextHeight(stringBounder);
} }
@Override @Override

View File

@ -215,8 +215,11 @@ public class Rose {
return new ComponentRoseGroupingHeader(styles == null ? null : styles[0], styles == null ? null : styles[1], return new ComponentRoseGroupingHeader(styles == null ? null : styles[0], styles == null ? null : styles[1],
stringsToDisplay, param); stringsToDisplay, param);
if (type == ComponentType.GROUPING_ELSE) if (type == ComponentType.GROUPING_ELSE_LEGACY)
return new ComponentRoseGroupingElse(styles == null ? null : styles[0], stringsToDisplay.get(0), param); 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) if (type == ComponentType.GROUPING_SPACE)
return new ComponentRoseGroupingSpace(7); return new ComponentRoseGroupingSpace(7);
@ -225,13 +228,16 @@ public class Rose {
return new ComponentRoseActiveLine(styles == null ? null : styles[0], true, true, param.getIHtmlColorSet()); return new ComponentRoseActiveLine(styles == null ? null : styles[0], true, true, param.getIHtmlColorSet());
if (type == ComponentType.ALIVE_BOX_CLOSE_OPEN) 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) { 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) 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) if (type == ComponentType.DELAY_LINE)
return new ComponentRoseDelayLine(null, getHtmlColor(param, stereotype, ColorParam.sequenceLifeLineBorder)); return new ComponentRoseDelayLine(null, getHtmlColor(param, stereotype, ColorParam.sequenceLifeLineBorder));

View File

@ -62,10 +62,10 @@ public class PSystemListInternalSprites extends PlainDiagram {
lines.add("<i>Credit to"); lines.add("<i>Credit to");
lines.add("http://www.archimatetool.com"); lines.add("http://www.archimatetool.com");
lines.add(" "); lines.add(" ");
for (String folder : RessourcesUtils.getJarFile("sprites", true)) { for (String folder : ResourcesUtils.getJarFile("sprites", true)) {
lines.add("<u>" + folder + "</u> :"); lines.add("<u>" + folder + "</u> :");
lines.add(" "); lines.add(" ");
for (String png : RessourcesUtils.getJarFile("sprites/" + folder, false)) { for (String png : ResourcesUtils.getJarFile("sprites/" + folder, false)) {
if (png.endsWith(".png")) { if (png.endsWith(".png")) {
final String spriteName = png.substring(0, png.length() - 4); final String spriteName = png.substring(0, png.length() - 4);
lines.add("<$archimate/" + spriteName + "> " + spriteName); lines.add("<$archimate/" + spriteName + "> " + spriteName);

View File

@ -52,7 +52,7 @@ import net.sourceforge.plantuml.log.Logme;
import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.version.Version; import net.sourceforge.plantuml.version.Version;
public class RessourcesUtils { public class ResourcesUtils {
public static Set<String> getJarFile(String path, boolean folder) throws IOException { public static Set<String> getJarFile(String path, boolean folder) throws IOException {
if (path.startsWith("/") || path.endsWith("/")) { if (path.startsWith("/") || path.endsWith("/")) {

View File

@ -35,6 +35,9 @@
*/ */
package net.sourceforge.plantuml.style; package net.sourceforge.plantuml.style;
import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class ClockwiseTopRightBottomLeft { public class ClockwiseTopRightBottomLeft {
private final double top; private final double top;
@ -94,6 +97,10 @@ public class ClockwiseTopRightBottomLeft {
this.left = left; this.left = left;
} }
public ClockwiseTopRightBottomLeft incTop(double delta) {
return new ClockwiseTopRightBottomLeft(top + delta, right, bottom, left);
}
@Override @Override
public String toString() { public String toString() {
return "" + top + ":" + right + ":" + bottom + ":" + left; return "" + top + ":" + right + ":" + bottom + ":" + left;
@ -120,4 +127,12 @@ public class ClockwiseTopRightBottomLeft {
return style.getMargin(); 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);
}
} }

View File

@ -46,6 +46,8 @@ public enum PName {
LineThickness, // LineThickness, //
DiagonalCorner, // DiagonalCorner, //
HyperLinkColor, // HyperLinkColor, //
HyperlinkUnderlineStyle, //
HyperlinkUnderlineThickness, //
HeadColor, // HeadColor, //
LineColor, // LineColor, //
LineStyle, // LineStyle, //

View File

@ -72,6 +72,7 @@ public enum SName {
destroy, // destroy, //
diamond, // diamond, //
document, // document, //
ebnf, //
element, // element, //
entity, // entity, //
end, // end, //
@ -94,6 +95,7 @@ public enum SName {
leafNode, // leafNode, //
legend, // legend, //
lifeLine, // lifeLine, //
mainframe, //
map, // map, //
milestone, // milestone, //
mindmapDiagram, // mindmapDiagram, //

View File

@ -196,7 +196,8 @@ public class Style {
color = value(PName.FontColor).asColor(set); color = value(PName.FontColor).asColor(set);
final HColor hyperlinkColor = value(PName.HyperLinkColor).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) { public SymbolContext getSymbolContext(HColorSet set, Colors colors) {
@ -207,7 +208,10 @@ public class Style {
if (foreColor == null) if (foreColor == null)
foreColor = value(PName.LineColor).asColor(set); foreColor = value(PName.LineColor).asColor(set);
final double deltaShadowing = value(PName.Shadowing).asDouble(); 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) { public SymbolContext getSymbolContext(HColorSet set) {
@ -226,8 +230,12 @@ public class Style {
} }
public UStroke getStroke() { public UStroke getStroke() {
final double thickness = value(PName.LineThickness).asDouble(); return getStroke(PName.LineThickness, PName.LineStyle);
final String dash = value(PName.LineStyle).asString(); }
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) if (dash.length() == 0)
return new UStroke(thickness); return new UStroke(thickness);

View File

@ -40,6 +40,7 @@ import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AnnotatedBuilder;
import net.sourceforge.plantuml.AnnotatedWorker; import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.BaseFile; import net.sourceforge.plantuml.BaseFile;
import net.sourceforge.plantuml.FileFormatOption; 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 // TODO There is something strange with the left margin of mainframe, I think
// because AnnotatedWorker is used here // because AnnotatedWorker is used here
// It can be looked at in another PR // 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 // TODO UmlDiagram.getWarningOrError() looks similar so this might be
// simplified? - will leave for a separate PR // simplified? - will leave for a separate PR

View File

@ -69,9 +69,9 @@ public class DecorateEntityImage extends AbstractTextBlock implements TextBlockB
public static TextBlock add(TextBlock original, TextBlock text, HorizontalAlignment horizontal, public static TextBlock add(TextBlock original, TextBlock text, HorizontalAlignment horizontal,
VerticalAlignment verticalAlignment) { VerticalAlignment verticalAlignment) {
if (verticalAlignment == VerticalAlignment.TOP) { if (verticalAlignment == VerticalAlignment.TOP)
return addTop(original, text, horizontal); return addTop(original, text, horizontal);
}
return addBottom(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) { private XDimension2D getTextDim(TextBlock text, StringBounder stringBounder) {
if (text == null) { if (text == null)
return new XDimension2D(0, 0); return new XDimension2D(0, 0);
}
return text.calculateDimension(stringBounder); return text.calculateDimension(stringBounder);
} }
private double getTextX(final XDimension2D dimText, final XDimension2D dimTotal, HorizontalAlignment h) { 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; return (dimTotal.getWidth() - dimText.getWidth()) / 2;
} else if (h == HorizontalAlignment.LEFT) { else if (h == HorizontalAlignment.LEFT)
return 0; return 0;
} else if (h == HorizontalAlignment.RIGHT) { else if (h == HorizontalAlignment.RIGHT)
return dimTotal.getWidth() - dimText.getWidth(); return dimTotal.getWidth() - dimText.getWidth();
} else { else
throw new IllegalStateException(); throw new IllegalStateException();
}
} }
public HColor getBackcolor() { public HColor getBackcolor() {
if (original instanceof TextBlockBackcolored) { if (original instanceof TextBlockBackcolored)
return ((TextBlockBackcolored) original).getBackcolor(); return ((TextBlockBackcolored) original).getBackcolor();
}
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -47,6 +47,7 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.svek.extremity.Extremity;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UStroke;
@ -141,8 +142,13 @@ public class Kal implements UDrawable {
return position; return position;
} }
public void setTranslate(UTranslate translate) { public void setTranslate(UTranslate translate, UDrawable decoration) {
this.translate = translate; 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) { public double overlapx(Kal other) {

View File

@ -213,10 +213,10 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
public SvekLine(Link link, ColorSequence colorSequence, ISkinParam skinParam, StringBounder stringBounder, public SvekLine(Link link, ColorSequence colorSequence, ISkinParam skinParam, StringBounder stringBounder,
FontConfiguration font, Bibliotekon bibliotekon, Pragma pragma, GraphvizVersion graphvizVersion) { 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)); ((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)); ((EntityImpl) link.getEntity2()).ensureMargins(Margins.uniform(16));
if (link.getLinkArg().getKal1() != null) 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; startTailText = null;
else else
startTailText = Display.getWithNewlines(link.getQualifier1()).create(font, HorizontalAlignment.CENTER, startTailText = Display.getWithNewlines(link.getQuantifier1()).create(font, HorizontalAlignment.CENTER,
skinParam); skinParam);
if (link.getQualifier2() == null) if (link.getQuantifier2() == null)
endHeadText = null; endHeadText = null;
else else
endHeadText = Display.getWithNewlines(link.getQualifier2()).create(font, HorizontalAlignment.CENTER, endHeadText = Display.getWithNewlines(link.getQuantifier2()).create(font, HorizontalAlignment.CENTER,
skinParam); skinParam);
if (link.getType().getMiddleDecor() == LinkMiddleDecor.NONE) if (link.getType().getMiddleDecor() == LinkMiddleDecor.NONE)
@ -783,11 +783,11 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
public void computeKal() { public void computeKal() {
if (kal1 != null) { if (kal1 != null) {
final UTranslate tr = new UTranslate(dotPath.getStartPoint()).compose(new UTranslate(dx, dy)); final UTranslate tr = new UTranslate(dotPath.getStartPoint()).compose(new UTranslate(dx, dy));
kal1.setTranslate(tr); kal1.setTranslate(tr, extremity1);
} }
if (kal2 != null) { if (kal2 != null) {
final UTranslate tr = new UTranslate(dotPath.getEndPoint()).compose(new UTranslate(dx, dy)); final UTranslate tr = new UTranslate(dotPath.getEndPoint()).compose(new UTranslate(dx, dy));
kal2.setTranslate(tr); kal2.setTranslate(tr, extremity2);
} }
} }

View File

@ -37,9 +37,10 @@ package net.sourceforge.plantuml.svek.extremity;
import net.sourceforge.plantuml.awt.geom.XPoint2D; import net.sourceforge.plantuml.awt.geom.XPoint2D;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public abstract class Extremity implements UDrawable { public abstract class Extremity implements UDrawable {
protected double manageround(double angle) { protected double manageround(double angle) {
final double deg = angle * 180.0 / Math.PI; final double deg = angle * 180.0 / Math.PI;
if (isCloseTo(0, deg)) { if (isCloseTo(0, deg)) {
@ -66,11 +67,15 @@ public abstract class Extremity implements UDrawable {
} }
return false; return false;
} }
public abstract XPoint2D somePoint(); public abstract XPoint2D somePoint();
public XPoint2D isTooSmallSoGiveThePointCloserToThisOne(XPoint2D pt) { public XPoint2D isTooSmallSoGiveThePointCloserToThisOne(XPoint2D pt) {
return null; return null;
} }
public UTranslate getDeltaForKal() {
return new UTranslate();
}
} }

Some files were not shown because too many files have changed in this diff Show More