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

View File

@ -1,6 +1,7 @@
root {
FontName SansSerif
HyperLinkColor blue
HyperLinkUnderlineThickness 1
FontColor black
FontSize 14
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;
import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.awt.geom.XRectangle2D;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositioned;
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.SymbolContext;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.USymbols;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignatureBasic;
import net.sourceforge.plantuml.svek.DecorateEntityImage;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class AnnotatedWorker {
private final Annotated annotated;
private final ISkinParam skinParam;
private final StringBounder stringBounder;
private final AnnotatedBuilder builder;
public AnnotatedWorker(Annotated annotated, ISkinParam skinParam, StringBounder stringBounder) {
public AnnotatedWorker(Annotated annotated, ISkinParam skinParam, StringBounder stringBounder,
AnnotatedBuilder builder) {
this.annotated = annotated;
this.skinParam = skinParam;
this.stringBounder = stringBounder;
this.builder = builder;
}
public TextBlockBackcolored addAdd(TextBlock result) {
result = addFrame(result);
result = builder.decoreWithFrame(result);
result = addLegend(result);
result = addTitle(result);
result = addCaption(result);
result = addHeaderAndFooter(result);
result = builder.addHeaderAndFooter(result);
return (TextBlockBackcolored) result;
}
public boolean hasMainFrame() {
return annotated.getMainFrame() != null;
}
public TextBlock addFrame(final TextBlock original) {
final Display mainFrame = annotated.getMainFrame();
if (mainFrame == null)
return original;
final double x1 = 5;
final double x2 = 7;
final double y1 = 10;
final double y2 = 10;
final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.frame)
.getMergedStyle(skinParam.getCurrentStyleBuilder());
final double deltaShadow = style.value(PName.Shadowing).asDouble();
final FontConfiguration fontConfiguration = FontConfiguration.create(getSkinParam(), style);
final UStroke stroke = style.getStroke();
final HColor borderColor = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet());
final SymbolContext symbolContext = new SymbolContext(getBackgroundColor(), borderColor).withShadow(deltaShadow)
.withStroke(stroke);
final MinMax originalMinMax = TextBlockUtils.getMinMax(original, stringBounder, false);
final TextBlock title = mainFrame.create(fontConfiguration, HorizontalAlignment.CENTER, getSkinParam());
final XDimension2D dimTitle = title.calculateDimension(stringBounder);
final double width = x1 + Math.max(originalMinMax.getWidth(), dimTitle.getWidth()) + x2;
final double height = dimTitle.getHeight() + y1 + originalMinMax.getHeight() + y2;
final TextBlock frame = USymbols.FRAME.asBig(title, HorizontalAlignment.LEFT, TextBlockUtils.empty(0, 0), width,
height, symbolContext, skinParam.getStereotypeAlignment());
return new TextBlockBackcolored() {
public void drawU(UGraphic ug) {
frame.drawU(ug.apply(UTranslate.dx(originalMinMax.getMinX())));
original.drawU(ug.apply(new UTranslate(x1, y1 + dimTitle.getHeight())));
// original.drawU(ug);
}
public MinMax getMinMax(StringBounder stringBounder) {
return TextBlockUtils.getMinMax(this, stringBounder, false);
}
public XRectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) {
final XRectangle2D rect = original.getInnerPosition(member, stringBounder, strategy);
return new XRectangle2D(rect.getX() + x1, rect.getY() + y1 + dimTitle.getHeight(),
rect.getWidth(), rect.getHeight());
}
public XDimension2D calculateDimension(StringBounder stringBounder) {
return original.calculateDimension(stringBounder);
}
public HColor getBackcolor() {
return symbolContext.getBackColor();
}
};
}
private HColor getBackgroundColor() {
return getSkinParam().getBackgroundColor();
}
private TextBlock addLegend(TextBlock original) {
public TextBlock addLegend(TextBlock original) {
final DisplayPositioned legend = annotated.getLegend();
if (legend.isNull())
return original;
final TextBlock text = EntityImageLegend.create(legend.getDisplay(), getSkinParam());
return DecorateEntityImage.add(original, text, legend.getHorizontalAlignment(), legend.getVerticalAlignment());
return DecorateEntityImage.add(original, builder.getLegend(), legend.getHorizontalAlignment(),
legend.getVerticalAlignment());
}
private ISkinParam getSkinParam() {
return skinParam;
public TextBlock addTitle(TextBlock original) {
final DisplayPositioned title = (DisplayPositioned) annotated.getTitle();
if (title.isNull())
return original;
return DecorateEntityImage.addTop(original, builder.getTitle(), HorizontalAlignment.CENTER);
}
private TextBlock addCaption(TextBlock original) {
@ -166,57 +88,7 @@ public class AnnotatedWorker {
if (caption.isNull())
return original;
final TextBlock text = getCaption();
return DecorateEntityImage.addBottom(original, text, HorizontalAlignment.CENTER);
return DecorateEntityImage.addBottom(original, builder.getCaption(), HorizontalAlignment.CENTER);
}
public TextBlock getCaption() {
final DisplayPositioned caption = annotated.getCaption();
if (caption.isNull())
return TextBlockUtils.empty(0, 0);
final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.caption)
.getMergedStyle(skinParam.getCurrentStyleBuilder());
return style.createTextBlockBordered(caption.getDisplay(), skinParam.getIHtmlColorSet(), skinParam,
Style.ID_CAPTION);
}
private TextBlock addTitle(TextBlock original) {
final DisplayPositioned title = (DisplayPositioned) annotated.getTitle();
if (title.isNull())
return original;
final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.title)
.getMergedStyle(skinParam.getCurrentStyleBuilder());
final TextBlock block = style.createTextBlockBordered(title.getDisplay(), skinParam.getIHtmlColorSet(),
skinParam, Style.ID_TITLE);
return DecorateEntityImage.addTop(original, block, HorizontalAlignment.CENTER);
}
private TextBlock addHeaderAndFooter(TextBlock original) {
final DisplaySection footer = annotated.getFooter();
final DisplaySection header = annotated.getHeader();
if (footer.isNull() && header.isNull())
return original;
TextBlock textFooter = null;
if (footer.isNull() == false) {
final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.footer)
.getMergedStyle(skinParam.getCurrentStyleBuilder());
textFooter = footer.createRibbon(FontConfiguration.create(getSkinParam(), FontParam.FOOTER, null),
getSkinParam(), style);
}
TextBlock textHeader = null;
if (header.isNull() == false) {
final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.header)
.getMergedStyle(skinParam.getCurrentStyleBuilder());
textHeader = header.createRibbon(FontConfiguration.create(getSkinParam(), FontParam.HEADER, null),
getSkinParam(), style);
}
return DecorateEntityImage.addTopAndBottom(original, textHeader, header.getHorizontalAlignment(), textFooter,
footer.getHorizontalAlignment());
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -141,7 +141,7 @@ public class TextSkin extends Rose {
if (type == ComponentType.GROUPING_SPACE)
return new ComponentRoseGroupingSpace(1);
if (type == ComponentType.GROUPING_ELSE)
if (type == ComponentType.GROUPING_ELSE_LEGACY || type == ComponentType.GROUPING_ELSE_TEOZ)
return new ComponentTextGroupingElse(type, stringsToDisplay, fileFormat);
if (type == ComponentType.DELAY_TEXT)

View File

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

View File

@ -111,9 +111,9 @@ public class CommandCreateClass extends SingleLineCommand2<ClassDiagram> {
new RegexOptional(new RegexConcat(new RegexLeaf("##"),
new RegexLeaf("LINECOLOR", "(?:\\[(dotted|dashed|bold)\\])?(\\w+)?"))), //
new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(),
new RegexLeaf("EXTENDS", "(extends)[%s]+(" + CommandCreateClassMultilines.CODES + ")"))), //
new RegexLeaf("EXTENDS", "(extends)[%s]+(" + CommandCreateClassMultilines.CODES + "|[%g]([^%g]+)[%g])"))), //
new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(),
new RegexLeaf("IMPLEMENTS", "(implements)[%s]+(" + CommandCreateClassMultilines.CODES + ")"))), //
new RegexLeaf("IMPLEMENTS", "(implements)[%s]+(" + CommandCreateClassMultilines.CODES + "|[%g]([^%g]+)[%g])"))), //
new RegexOptional(new RegexConcat(RegexLeaf.spaceZeroOrMore(), new RegexLeaf("\\{"),
RegexLeaf.spaceZeroOrMore(), new RegexLeaf("\\}"))), //
RegexLeaf.end());

View File

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

View File

@ -102,7 +102,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
new RegexConcat(
//
new RegexLeaf("ARROW_HEAD1",
"([%s]+[ox]|[)#\\[<*+^}]|\\<_|\\<\\|[\\:\\|]|[<\\[]\\||\\}o|\\}\\||\\|o|\\|\\|)?"), //
"((?<=[%s])+[ox]|[)#\\[<*+^}]|\\<_|\\<\\|[\\:\\|]|[<\\[]\\||\\}o|\\}\\||\\|o|\\|\\|)?"), //
new RegexLeaf("ARROW_BODY1", "([-=.]+)"), //
new RegexLeaf("ARROW_STYLE1", "(?:\\[(" + CommandLinkElement.LINE_STYLE + ")\\])?"), //
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
.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);
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 LinkArg linkArg = LinkArg.build(labelLink, queue, diagram.getSkinParam().classAttributeIconSize() > 0);
final Link link = new Link(diagram.getSkinParam().getCurrentStyleBuilder(), cl1, cl2, linkType,
linkArg.withQualifier(firstLabel, secondLabel).withDistanceAngle(diagram.getLabeldistance(),
linkArg.withQuantifier(firstLabel, secondLabel).withDistanceAngle(diagram.getLabeldistance(),
diagram.getLabelangle()));
link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -73,7 +73,7 @@ public class PSystemDefinition extends PlainDiagram implements UDrawable {
public void drawU(UGraphic ug) {
final UFont font = UFont.sansSerif(14);
final FontConfiguration fc = FontConfiguration.create(font, HColors.BLACK, HColors.BLACK, false);
final FontConfiguration fc = FontConfiguration.create(font, HColors.BLACK, HColors.BLACK, null);
Display.getWithNewlines(startLine).create(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty()).drawU(ug);
}

View File

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

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

View File

@ -35,13 +35,120 @@
*/
package net.sourceforge.plantuml.ebnf;
import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.StyleSignatureBasic;
import net.sourceforge.plantuml.ugraphic.CopyForegroundColorToBackgroundColor;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UPath;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public interface ETile extends TextBlock {
public abstract class ETile extends AbstractTextBlock {
public double linePos(StringBounder stringBounder);
protected final boolean TRACE = false;
public void push(ETile tile);
public static StyleSignatureBasic getStyleSignature() {
return StyleSignatureBasic.of(SName.root, SName.element, SName.ebnf);
}
public abstract void push(ETile tile);
@Override
final public XDimension2D calculateDimension(StringBounder stringBounder) {
final double width = getWidth(stringBounder);
final double h1 = getH1(stringBounder);
final double h2 = getH2(stringBounder);
return new XDimension2D(width, h1 + h2);
}
public abstract double getWidth(StringBounder stringBounder);
public abstract double getH1(StringBounder stringBounder);
public abstract double getH2(StringBounder stringBounder);
protected final void drawHline(UGraphic ug, double y, double x1, double x2) {
ug.apply(new UTranslate(x1, y)).draw(ULine.hline(x2 - x1));
}
protected final void drawHlineDirected(UGraphic ug, double y, double x1, double x2, double coef) {
ug.apply(new UTranslate(x1, y)).draw(ULine.hline(x2 - x1));
if (x2 > x1 + 20)
ug.apply(new CopyForegroundColorToBackgroundColor())
.apply(new UTranslate(x1 * (1 - coef) + x2 * coef - 2, y)).draw(getArrowToRight());
}
protected final void drawHlineAntiDirected(UGraphic ug, double y, double x1, double x2, double coef) {
ug.apply(new UTranslate(x1, y)).draw(ULine.hline(x2 - x1));
ug.apply(new CopyForegroundColorToBackgroundColor()).apply(new UTranslate(x1 * (1 - coef) + x2 * coef - 2, y))
.draw(getArrowToLeft());
}
protected final void drawVline(UGraphic ug, double x, double y1, double y2) {
ug.apply(new UTranslate(x, y1)).draw(ULine.vline(y2 - y1));
}
protected final void drawVlineDirected(UGraphic ug, double x, double y1, double y2) {
ug.apply(new UTranslate(x, y1)).draw(ULine.vline(y2 - y1));
ug.apply(new CopyForegroundColorToBackgroundColor()).apply(new UTranslate(x, y1 * .5 + y2 * .5 - 2))
.draw(getArrowToBottom());
}
protected final void drawVlineAntiDirected(UGraphic ug, double x, double y1, double y2) {
ug.apply(new UTranslate(x, y1)).draw(ULine.vline(y2 - y1));
ug.apply(new CopyForegroundColorToBackgroundColor()).apply(new UTranslate(x, y1 * .5 + y2 * .5 + 2))
.draw(getArrowToTop());
}
static UPath getArrowToLeft() {
final UPath arrow = new UPath();
arrow.moveTo(0, 0);
arrow.lineTo(0, -3);
arrow.lineTo(-6, 0);
arrow.lineTo(0, 3);
arrow.lineTo(0, 0);
arrow.closePath();
return arrow;
}
static UPath getArrowToRight() {
final UPath arrow = new UPath();
arrow.moveTo(0, 0);
arrow.lineTo(0, -3);
arrow.lineTo(6, 0);
arrow.lineTo(0, 3);
arrow.lineTo(0, 0);
arrow.closePath();
return arrow;
}
static UPath getArrowToBottom() {
final UPath arrow = new UPath();
arrow.moveTo(0, 0);
arrow.lineTo(3, 0);
arrow.lineTo(0, 6);
arrow.lineTo(-3, 0);
arrow.lineTo(0, 0);
arrow.closePath();
return arrow;
}
static UPath getArrowToTop() {
final UPath arrow = new UPath();
arrow.moveTo(0, 0);
arrow.lineTo(3, 0);
arrow.lineTo(0, -6);
arrow.lineTo(-3, 0);
arrow.lineTo(0, 0);
arrow.closePath();
return arrow;
}
}

View File

@ -39,18 +39,15 @@ import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.StyleSignatureBasic;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColors;
public class ETileAlternation extends AbstractTextBlock implements ETile {
public class ETileAlternation extends ETile {
private final List<ETile> tiles = new ArrayList<>();
private final double marginx = 12;
private boolean inZeroOrMore;
@Override
public void push(ETile tile) {
@ -58,14 +55,37 @@ public class ETileAlternation extends AbstractTextBlock implements ETile {
}
@Override
public double linePos(StringBounder stringBounder) {
return tiles.get(0).linePos(stringBounder);
public double getH1(StringBounder stringBounder) {
return tiles.get(0).getH1(stringBounder);
}
@Override
public double getH2(StringBounder stringBounder) {
double height = tiles.get(0).getH2(stringBounder);
for (int i = 1; i < tiles.size(); i++) {
final ETile tile = tiles.get(i);
height += tile.getH1(stringBounder);
height += tile.getH2(stringBounder);
height += 10;
}
return height;
}
@Override
public double getWidth(StringBounder stringBounder) {
double width = 0;
for (ETile tile : tiles) {
final XDimension2D dim = tile.calculateDimension(stringBounder);
width = Math.max(width, dim.getWidth());
}
width += 2 * 2 * marginx;
return width;
}
@Override
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
ug = ug.apply(HColors.BLACK);
double y = 0;
double lastLinePos = 0;
@ -79,53 +99,65 @@ public class ETileAlternation extends AbstractTextBlock implements ETile {
final double q = r - marginx;
final double p = q - marginx;
for (int i = 0; i < tiles.size(); i++) {
final ETile tile = tiles.get(i);
final XDimension2D dim = tile.calculateDimension(stringBounder);
lastLinePos = y + tile.linePos(stringBounder);
tile.drawU(ug.apply(new UTranslate(c, y)));
final double linePos = getH1(stringBounder);
if (inZeroOrMore) {
for (int i = 0; i < tiles.size(); i++) {
final ETile tile = tiles.get(i);
final XDimension2D dim = tile.calculateDimension(stringBounder);
lastLinePos = y + tile.getH1(stringBounder);
tile.drawU(ug.apply(new UTranslate(c, y)));
if (i == 0) {
ETileConcatenation.drawHline(ug, lastLinePos, a, c);
ETileConcatenation.drawHline(ug, lastLinePos, c + dim.getWidth(), r);
} else if (i > 0 && i < tiles.size() - 1) {
CornerCurved.createSW(marginx).drawU(ug.apply(new UTranslate(b, lastLinePos)));
ETileConcatenation.drawHline(ug, lastLinePos, c + dim.getWidth(), p);
drawHlineDirected(ug, lastLinePos, c + dim.getWidth(), p, 0.3);
CornerCurved.createSE(marginx).drawU(ug.apply(new UTranslate(q, lastLinePos)));
} else if (i == tiles.size() - 1) {
ETileConcatenation.drawHline(ug, lastLinePos, c + dim.getWidth(), p);
y += dim.getHeight() + 10;
}
y += dim.getHeight() + 10;
drawVline(ug, b, 0, lastLinePos - marginx);
drawVline(ug, q, 0, lastLinePos - marginx);
} else {
for (int i = 0; i < tiles.size(); i++) {
final ETile tile = tiles.get(i);
final XDimension2D dim = tile.calculateDimension(stringBounder);
lastLinePos = y + tile.getH1(stringBounder);
tile.drawU(ug.apply(new UTranslate(c, y)));
if (i == 0) {
drawHline(ug, lastLinePos, a, c);
drawHline(ug, lastLinePos, c + dim.getWidth(), r);
} else if (i > 0 && i < tiles.size() - 1) {
CornerCurved.createSW(marginx).drawU(ug.apply(new UTranslate(b, lastLinePos)));
drawHlineDirected(ug, lastLinePos, c + dim.getWidth(), p, 0.5);
CornerCurved.createSE(marginx).drawU(ug.apply(new UTranslate(q, lastLinePos)));
} else if (i == tiles.size() - 1) {
drawHlineDirected(ug, lastLinePos, c + dim.getWidth(), p, 0.5);
}
y += dim.getHeight() + 10;
}
final double height42 = lastLinePos - linePos;
final UGraphic ug_b = ug.apply(new UTranslate(b, linePos));
final UGraphic ug_q = ug.apply(new UTranslate(q, linePos));
CornerCurved.createSW(marginx).drawU(ug_b.apply(UTranslate.dy(height42)));
drawVline(ug_b, 0, marginx, height42 - marginx);
CornerCurved.createNE(marginx).drawU(ug_b);
CornerCurved.createSE(marginx).drawU(ug_q.apply(UTranslate.dy(height42)));
drawVline(ug_q, 0, marginx, height42 - marginx);
CornerCurved.createNW(marginx).drawU(ug_q);
}
final double linePos = linePos(stringBounder);
final VLineCurved hlineIn = new VLineCurved(lastLinePos - linePos, marginx, CornerCurved.createNE(marginx),
CornerCurved.createSW(marginx));
hlineIn.drawU(ug.apply(new UTranslate(b, linePos)));
final VLineCurved hlineOut = new VLineCurved(lastLinePos - linePos, marginx, CornerCurved.createNW(marginx),
CornerCurved.createSE(marginx));
hlineOut.drawU(ug.apply(new UTranslate(q, linePos)));
}
@Override
public XDimension2D calculateDimension(StringBounder stringBounder) {
double width = 0;
double height = 0;
for (ETile tile : tiles) {
final XDimension2D dim = tile.calculateDimension(stringBounder);
height += dim.getHeight();
height += 10;
width = Math.max(width, dim.getWidth());
}
width += 2 * 2 * marginx;
return new XDimension2D(width, height);
}
public void setInZeroOrMore(boolean inZeroOrMore) {
this.inZeroOrMore = true;
private StyleSignatureBasic getStyleSignature() {
return StyleSignatureBasic.of(SName.root, SName.element, SName.activityDiagram, SName.activity);
}
}

View File

@ -36,7 +36,6 @@
package net.sourceforge.plantuml.ebnf;
import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.style.PName;
@ -49,7 +48,7 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSet;
public class ETileBox extends AbstractTextBlock implements ETile {
public class ETileBox extends ETile {
private final String value;
private final FontConfiguration fc;
@ -68,8 +67,19 @@ public class ETileBox extends AbstractTextBlock implements ETile {
}
@Override
public XDimension2D calculateDimension(StringBounder stringBounder) {
return XDimension2D.delta(getTextDim(stringBounder), 10);
public double getH1(StringBounder stringBounder) {
final double height = getTextDim(stringBounder).getHeight() + 10;
return height / 2;
}
@Override
public double getH2(StringBounder stringBounder) {
return getH1(stringBounder);
}
@Override
public double getWidth(StringBounder stringBounder) {
return getTextDim(stringBounder).getWidth() + 10;
}
private XDimension2D getTextDim(StringBounder stringBounder) {
@ -94,12 +104,6 @@ public class ETileBox extends AbstractTextBlock implements ETile {
ug.apply(new UTranslate(5, 5 + dimText.getHeight() - utext.getDescent(ug.getStringBounder()))).draw(utext);
}
@Override
public double linePos(StringBounder stringBounder) {
final double height = calculateDimension(stringBounder).getHeight();
return height / 2;
}
@Override
public void push(ETile tile) {
throw new UnsupportedOperationException();

View File

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

View File

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

View File

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

View File

@ -36,45 +36,58 @@
package net.sourceforge.plantuml.ebnf;
import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.CopyForegroundColorToBackgroundColor;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColors;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class ETileWithCircles extends AbstractTextBlock implements ETile {
public class ETileWithCircles extends ETile {
private static final double SIZE = 8;
private final double deltax = 15;
private final double deltax = 30;
private final ETile orig;
private final HColor lineColor;
public ETileWithCircles(ETile orig) {
public ETileWithCircles(ETile orig, HColor lineColor) {
this.orig = orig;
this.lineColor = lineColor;
}
@Override
public XDimension2D calculateDimension(StringBounder stringBounder) {
return XDimension2D.delta(orig.calculateDimension(stringBounder), 2 * deltax, 0);
public double getWidth(StringBounder stringBounder) {
return orig.getWidth(stringBounder) + 2 * deltax;
}
@Override
public double getH1(StringBounder stringBounder) {
return orig.getH1(stringBounder);
}
@Override
public double getH2(StringBounder stringBounder) {
return orig.getH2(stringBounder);
}
@Override
public void drawU(UGraphic ug) {
final double linePos = linePos(ug.getStringBounder());
final double linePos = getH1(ug.getStringBounder());
final XDimension2D fullDim = calculateDimension(ug.getStringBounder());
ug = ug.apply(lineColor).apply(new UStroke(1.5));
orig.drawU(ug.apply(UTranslate.dx(deltax)));
ug = ug.apply(HColors.BLACK).apply(HColors.BLACK.bg());
final UEllipse circle = new UEllipse(SIZE, SIZE);
ug.apply(new UTranslate(0, linePos - SIZE / 2)).draw(circle);
ug.apply(new UTranslate(fullDim.getWidth() - SIZE / 2, linePos - SIZE / 2)).draw(circle);
ETileConcatenation.drawHline(ug, linePos, SIZE / 2, deltax);
ETileConcatenation.drawHline(ug, linePos, fullDim.getWidth() - deltax, fullDim.getWidth() - SIZE / 2);
}
@Override
public double linePos(StringBounder stringBounder) {
return orig.linePos(stringBounder);
final UEllipse circle = new UEllipse(SIZE, SIZE);
ug.apply(new UStroke(2)).apply(new UTranslate(0, linePos - SIZE / 2)).draw(circle);
ug.apply(new UStroke(1)).apply(new CopyForegroundColorToBackgroundColor())
.apply(new UTranslate(fullDim.getWidth() - SIZE / 2, linePos - SIZE / 2)).draw(circle);
ug = ug.apply(new UStroke(1.5));
drawHlineDirected(ug, linePos, SIZE, deltax, 0.5);
drawHlineDirected(ug, linePos, fullDim.getWidth() - deltax, fullDim.getWidth() - SIZE / 2, 0.5);
}
@Override

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

View File

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

View File

@ -44,18 +44,30 @@ import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignatureBasic;
public class EbnfSingleExpression {
final List<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) {
final char ch = it.peek();
if (Character.isWhitespace(ch)) {
} else if (ch == '-') {
final int size = tokens.size();
if (size > 0 && tokens.get(size - 1).getSymbol() == Symbol.REPETITION_CLOSE) {
tokens.set(size - 1, new Token(Symbol.REPETITION_MINUS_CLOSE, null));
} else {
tokens.clear();
return;
}
} else if (isLetterOrDigit(ch)) {
final String litteral = readLitteral(it);
tokens.add(new Token(Symbol.LITTERAL, litteral));
@ -87,32 +99,43 @@ public class EbnfSingleExpression {
} else if (ch == '\'') {
final String litteral = readString(it);
tokens.add(new Token(Symbol.TERMINAL_STRING2, litteral));
} else
throw new UnsupportedOperationException("" + ch);
} else {
tokens.clear();
return;
}
it.next();
continue;
}
}
private StyleSignatureBasic getStyleSignature() {
return StyleSignatureBasic.of(SName.root, SName.element, SName.activityDiagram, SName.activity);
}
public TextBlock getUDrawable(ISkinParam skinParam) {
final Iterator<Token> iterator = tokens.iterator();
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 Style style = ETile.getStyleSignature().getMergedStyle(skinParam.getCurrentStyleBuilder());
final FontConfiguration fc = style.getFontConfiguration(skinParam.getIHtmlColorSet());
final TitleBox titleBox = new TitleBox(name.getData() + ":", fc);
if (tokens.size() == 0)
return EbnfEngine.syntaxError(fc, skinParam);
return TextBlockUtils.mergeTB(titleBox, TextBlockUtils.withMargin(main, 0, 0, 10, 15),
HorizontalAlignment.LEFT);
try {
final Iterator<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) {
@ -128,8 +151,10 @@ public class EbnfSingleExpression {
engine.concatenation();
else if (element.getSymbol() == Symbol.OPTIONAL)
engine.optional();
else if (element.getSymbol() == Symbol.REPETITION)
engine.repetition();
else if (element.getSymbol() == Symbol.REPETITION_ZERO_OR_MORE)
engine.repetitionZeroOrMore(isTheo);
else if (element.getSymbol() == Symbol.REPETITION_ONE_OR_MORE)
engine.repetitionOneOrMore();
else
throw new UnsupportedOperationException(element.toString());
}
@ -165,6 +190,10 @@ public class EbnfSingleExpression {
return ch == '-' || ch == '_' || Character.isLetterOrDigit(ch);
}
public boolean isEmpty() {
return tokens.size() == 0;
}
}
interface CharIterator {
@ -175,12 +204,14 @@ interface CharIterator {
class CharIteratorImpl implements CharIterator {
final private List<String> data;
final private List<String> data = new ArrayList<>();
private int line = 0;
private int pos = 0;
public CharIteratorImpl(List<String> data) {
this.data = data;
public CharIteratorImpl(List<String> input) {
for (String s : input)
if (s.trim().length() > 0)
data.add(s.trim());
}
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.ImageData;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
public class PSystemEbnf extends TitledDiagram {
@ -63,8 +65,8 @@ public class PSystemEbnf extends TitledDiagram {
return new DiagramDescription("(EBNF)");
}
public void doCommandLine(String line) {
lines.add(line);
public void addLine(String line) {
lines.add(line.trim());
}
@Override
@ -74,7 +76,15 @@ public class PSystemEbnf extends TitledDiagram {
}
private TextBlockBackcolored getTextBlock() {
final List<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());
for (int i = 1; i < all.size(); i++)
result = TextBlockUtils.mergeTB(result, all.get(i).getUDrawable(getSkinParam()), HorizontalAlignment.LEFT);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -60,6 +60,7 @@ import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSet;
@ -258,7 +259,7 @@ public class PSystemColors extends PlainDiagram implements UDrawable {
private TextBlock getTextName(final UFont font, String name, final HColor color) {
final HColor opposite = color.opposite();
final FontConfiguration fc = FontConfiguration.create(font, opposite, HColors.BLUE, true);
final FontConfiguration fc = FontConfiguration.create(font, opposite, HColors.BLUE, new UStroke());
final TextBlock tt = Display.getWithNewlines(name).create(fc, HorizontalAlignment.CENTER,
new SpriteContainerEmpty());
return tt;

View File

@ -176,8 +176,8 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker {
return label;
}
private TextBlock getQualifier(Link link, int n) {
final String tmp = n == 1 ? link.getQualifier1() : link.getQualifier2();
private TextBlock getQuantifier(Link link, int n) {
final String tmp = n == 1 ? link.getQuantifier1() : link.getQuantifier2();
if (tmp == null)
return null;
@ -323,7 +323,7 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker {
}
final ElkPath elkPath = new ElkPath(diagram, SName.classDiagram, link, edge, getLabel(link),
getQualifier(link, 1), getQualifier(link, 2), magicY2);
getQuantifier(link, 1), getQuantifier(link, 2), magicY2);
elkPath.drawU(ug.apply(new UTranslate(translate)));
}
@ -497,9 +497,9 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker {
edge.setProperty(CoreOptions.EDGE_LABELS_INLINE, true);
// edge.setProperty(CoreOptions.EDGE_TYPE, EdgeType.ASSOCIATION);
}
if (link.getQualifier1() != null) {
if (link.getQuantifier1() != null) {
final ElkLabel edgeLabel = ElkGraphUtil.createLabel(edge);
final XDimension2D dim = getQualifier(link, 1).calculateDimension(stringBounder);
final XDimension2D dim = getQuantifier(link, 1).calculateDimension(stringBounder);
// Nasty trick, we store the kind of label in the text
edgeLabel.setText("1");
edgeLabel.setDimensions(dim.getWidth(), dim.getHeight());
@ -508,9 +508,9 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker {
edge.setProperty(CoreOptions.EDGE_LABELS_INLINE, true);
// edge.setProperty(CoreOptions.EDGE_TYPE, EdgeType.ASSOCIATION);
}
if (link.getQualifier2() != null) {
if (link.getQuantifier2() != null) {
final ElkLabel edgeLabel = ElkGraphUtil.createLabel(edge);
final XDimension2D dim = getQualifier(link, 2).calculateDimension(stringBounder);
final XDimension2D dim = getQuantifier(link, 2).calculateDimension(stringBounder);
// Nasty trick, we store the kind of label in the text
edgeLabel.setText("2");
edgeLabel.setDimensions(dim.getWidth(), dim.getHeight());

View File

@ -228,7 +228,7 @@ public class SvgNanoParser implements Sprite {
if (m.find()) {
final String text = m.group(1);
HColor color = HColorSet.instance().getColorOrWhite(fill);
final FontConfiguration fc = FontConfiguration.create(UFont.sansSerif(fontSize), color, color, false);
final FontConfiguration fc = FontConfiguration.create(UFont.sansSerif(fontSize), color, color, null);
final UText utext = new UText(text, fc);
UGraphic ug = ugs.getUg();
ug = ug.apply(new UTranslate(x, y));

View File

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

View File

@ -68,13 +68,13 @@ public class MagicBox {
}
private TextBlock getSmallBlock() {
final FontConfiguration fc = FontConfiguration.create(UFont.monospaced(15).bold(), fontColor, fontColor, false);
final FontConfiguration fc = FontConfiguration.create(UFont.monospaced(15).bold(), fontColor, fontColor, null);
return node.getDisplay().create(fc, HorizontalAlignment.CENTER, skinParam);
}
private TextBlock getCommentBlock() {
if (node.getComment() != null && node.isTop()) {
final FontConfiguration tag = FontConfiguration.create(UFont.sansSerif(13), fontColor, fontColor, false);
final FontConfiguration tag = FontConfiguration.create(UFont.sansSerif(13), fontColor, fontColor, null);
return Display.create(node.getComment()).create(tag, HorizontalAlignment.CENTER, skinParam);
}
return TextBlockUtils.empty(0, 0);

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

View File

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

View File

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

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.",
"Znxr yvxr n gerr naq trg bhg bs urer", "Vg'f fgebat naq vg'f fhqqra naq vg'f pehry fbzrgvzrf",
"Uryy vf rzcgl naq nyy gur qrivyf ner urer", "Rg cbhe fbegve qrf zbzragf qvssvpvyrf...",
"cynaghzy: qvntenzf sbe pbashfvat crbcyr zber", "Ha zbeprnh dhv onynapr qh gbaareer?");
"cynaghzy: qvntenzf sbe pbashfvat crbcyr zber", "Ha zbeprnh dhv onynapr qh gbaareer?",
"Pnhtug hc va pvepyrf, pbashfvba vf abguvat arj",
"N pbzcyrk flfgrz qrfvtarq sebz fpengpu arire jbexf naq pnaabg or cngpurq hc gb znxr vg jbex.",
"Gur vagrearg vf pbzvat", "Qba'g lbh xabj guvatf unccra sbe n ernfba");
private QuoteUtils() {
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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.CommandGroupEnd;
import net.sourceforge.plantuml.project.command.CommandGroupStart;
import net.sourceforge.plantuml.project.command.CommandHideRessourceFootbox;
import net.sourceforge.plantuml.project.command.CommandHideRessourceName;
import net.sourceforge.plantuml.project.command.CommandHideResourceFootbox;
import net.sourceforge.plantuml.project.command.CommandHideResourceName;
import net.sourceforge.plantuml.project.command.CommandLabelOnColumn;
import net.sourceforge.plantuml.project.command.CommandLanguage;
import net.sourceforge.plantuml.project.command.CommandNoteBottom;
@ -117,8 +117,8 @@ public class GanttDiagramFactory extends PSystemCommandFactory {
cmds.add(new CommandNoteBottom());
cmds.add(new CommandFootbox());
cmds.add(new CommandLabelOnColumn());
cmds.add(new CommandHideRessourceName());
cmds.add(new CommandHideRessourceFootbox());
cmds.add(new CommandHideResourceName());
cmds.add(new CommandHideResourceFootbox());
return cmds;
}

View File

@ -51,4 +51,9 @@ public class Load implements Value {
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.project.GanttDiagram;
public class CommandHideRessourceFootbox extends SingleLineCommand2<GanttDiagram> {
public class CommandHideResourceFootbox extends SingleLineCommand2<GanttDiagram> {
public CommandHideRessourceFootbox() {
public CommandHideResourceFootbox() {
super(getRegexConcat());
}
static IRegex getRegexConcat() {
return RegexConcat.build(CommandHideRessourceFootbox.class.getName(), RegexLeaf.start(), //
return RegexConcat.build(CommandHideResourceFootbox.class.getName(), RegexLeaf.start(), //
new RegexLeaf("hide"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("ressources?"), //
new RegexLeaf("ress?ources?"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("footbox"), //
RegexLeaf.end()); //
@ -62,7 +62,7 @@ public class CommandHideRessourceFootbox extends SingleLineCommand2<GanttDiagram
@Override
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.project.GanttDiagram;
public class CommandHideRessourceName extends SingleLineCommand2<GanttDiagram> {
public class CommandHideResourceName extends SingleLineCommand2<GanttDiagram> {
public CommandHideRessourceName() {
public CommandHideResourceName() {
super(getRegexConcat());
}
static IRegex getRegexConcat() {
return RegexConcat.build(CommandHideRessourceName.class.getName(), RegexLeaf.start(), //
return RegexConcat.build(CommandHideResourceName.class.getName(), RegexLeaf.start(), //
new RegexLeaf("hide"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("ressources?"), //
new RegexLeaf("ress?ources?"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("names?"), //
RegexLeaf.end()); //
@ -62,7 +62,7 @@ public class CommandHideRessourceName extends SingleLineCommand2<GanttDiagram> {
@Override
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;
if (resources.size() > 0)
result = PlanUtils.multiply(defaultPlan, getRessourcePlan());
result = PlanUtils.multiply(defaultPlan, getResourcePlan());
return result.getLoadAt(instant);
}
@ -139,7 +139,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable {
this.pausedDayOfWeek.add(pause);
}
private LoadPlanable getRessourcePlan() {
private LoadPlanable getResourcePlan() {
if (resources.size() == 0)
throw new IllegalStateException();
@ -192,8 +192,9 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable {
public Day getStart() {
Day result = (Day) solver.getData(TaskAttribute.START);
while (getLoadAt(result) == 0)
result = result.increment();
if (diamond == false)
while (getLoadAt(result) == 0)
result = result.increment();
return result;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -385,7 +385,7 @@ class DrawableSetInitializer {
freeY2 = ((FrontierStack) freeY2).restore();
final Component compElse = drawableSet.getSkin().createComponent(m.getUsedStyles(),
ComponentType.GROUPING_ELSE, null, skinParam, Display.create(m.getComment()));
ComponentType.GROUPING_ELSE_LEGACY, null, skinParam, Display.create(m.getComment()));
final Lazy lazy = new Lazy() {
public double getNow() {
final GraphicalElement after = drawableSet.getEvent(m.getJustAfter());

View File

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

View File

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

View File

@ -78,7 +78,7 @@ public class ElseTile extends AbstractTile {
anElse.getBackColorGeneral());
final Display display = Display.create(anElse.getComment());
final Component comp = skin.createComponent(anElse.getUsedStyles(), ComponentType.GROUPING_ELSE, null, tmp,
final Component comp = skin.createComponent(anElse.getUsedStyles(), ComponentType.GROUPING_ELSE_TEOZ, null, tmp,
display);
return comp;
}
@ -107,9 +107,10 @@ public class ElseTile extends AbstractTile {
final XDimension2D dim = comp.getPreferredDimension(getStringBounder());
double height = dim.getHeight();
if (anElse.getComment() != null) {
height += 10;
}
// if (anElse.getComment() != null)
// height += 10;
//
// return height + 20;
return height;
}

View File

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

View File

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

View File

@ -56,7 +56,7 @@ public enum ComponentType implements Styleable {
DELAY_LINE, PARTICIPANT_LINE, CONTINUE_LINE,
//
GROUPING_ELSE, GROUPING_HEADER, GROUPING_SPACE,
GROUPING_ELSE_LEGACY, GROUPING_ELSE_TEOZ, GROUPING_HEADER, GROUPING_SPACE,
//
NEWPAGE, NOTE, NOTE_HEXAGONAL, NOTE_BOX, DIVIDER, REFERENCE, ENGLOBER,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -196,7 +196,8 @@ public class Style {
color = value(PName.FontColor).asColor(set);
final HColor hyperlinkColor = value(PName.HyperLinkColor).asColor(set);
return FontConfiguration.create(font, color, hyperlinkColor, true);
final UStroke stroke = getStroke(PName.HyperlinkUnderlineThickness, PName.HyperlinkUnderlineStyle);
return FontConfiguration.create(font, color, hyperlinkColor, stroke);
}
public SymbolContext getSymbolContext(HColorSet set, Colors colors) {
@ -207,7 +208,10 @@ public class Style {
if (foreColor == null)
foreColor = value(PName.LineColor).asColor(set);
final double deltaShadowing = value(PName.Shadowing).asDouble();
return new SymbolContext(backColor, foreColor).withStroke(getStroke()).withDeltaShadow(deltaShadowing);
final double roundCorner = value(PName.RoundCorner).asDouble();
final double diagonalCorner = value(PName.DiagonalCorner).asDouble();
return new SymbolContext(backColor, foreColor).withStroke(getStroke()).withDeltaShadow(deltaShadowing)
.withCorner(roundCorner, diagonalCorner);
}
public SymbolContext getSymbolContext(HColorSet set) {
@ -226,8 +230,12 @@ public class Style {
}
public UStroke getStroke() {
final double thickness = value(PName.LineThickness).asDouble();
final String dash = value(PName.LineStyle).asString();
return getStroke(PName.LineThickness, PName.LineStyle);
}
private UStroke getStroke(final PName thicknessParam, final PName styleParam) {
final double thickness = value(thicknessParam).asDouble();
final String dash = value(styleParam).asString();
if (dash.length() == 0)
return new UStroke(thickness);

View File

@ -40,6 +40,7 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.AnnotatedBuilder;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.BaseFile;
import net.sourceforge.plantuml.FileFormatOption;
@ -104,7 +105,8 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
// TODO There is something strange with the left margin of mainframe, I think
// because AnnotatedWorker is used here
// It can be looked at in another PR
result = new AnnotatedWorker(diagram, diagram.getSkinParam(), stringBounder).addAdd(result);
final AnnotatedBuilder builder = new AnnotatedBuilder(diagram, diagram.getSkinParam(), stringBounder);
result = new AnnotatedWorker(diagram, diagram.getSkinParam(), stringBounder, builder).addAdd(result);
// TODO UmlDiagram.getWarningOrError() looks similar so this might be
// simplified? - will leave for a separate PR

View File

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

View File

@ -47,6 +47,7 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.svek.extremity.Extremity;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UStroke;
@ -141,8 +142,13 @@ public class Kal implements UDrawable {
return position;
}
public void setTranslate(UTranslate translate) {
public void setTranslate(UTranslate translate, UDrawable decoration) {
this.translate = translate;
if (decoration instanceof Extremity) {
final Extremity extremity = (Extremity) decoration;
final UTranslate deltaForKal = extremity.getDeltaForKal();
// this.translate = this.translate.compose(deltaForKal);
}
}
public double overlapx(Kal other) {

View File

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

View File

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

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