From 97d3281ec368b2bb83f48650cf63e0b7caa4679d Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Wed, 16 Nov 2022 00:15:21 +0100 Subject: [PATCH] Improve stdlib versioning --- .../ftile/vcompact/FtileWithNoteOpale.java | 8 +++ .../ftile/vcompact/FtileWithNotes.java | 17 +++-- .../ftile/vertical/FtileBox.java | 5 +- .../ftile/vertical/FtileBoxOld.java | 8 +-- .../plantuml/baraye/CucaDiagram.java | 10 +++ .../sourceforge/plantuml/baraye/Plasma.java | 9 ++- .../sourceforge/plantuml/baraye/Quark.java | 14 +++- .../command/CommandCreateClass.java | 64 +++++++++++++------ .../command/CommandCreateClassMultilines.java | 26 +++++++- .../plantuml/command/CommandNamespace.java | 17 +++-- .../plantuml/command/CommandPackage.java | 37 +++++++---- .../plantuml/creole/SheetBlock1.java | 16 ++++- .../plantuml/creole/SheetBlock2.java | 11 ++++ .../sourceforge/plantuml/mindmap/Idea.java | 16 ++--- .../sourceforge/plantuml/preproc/Stdlib.java | 19 +++++- .../statediagram/command/CommandAddField.java | 24 +++++++ .../timingdiagram/TimeConstraint.java | 37 +++++++---- .../sourceforge/plantuml/version/Version.java | 2 +- 18 files changed, 261 insertions(+), 79 deletions(-) diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java index 12482c0b3..033d2b2d6 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java @@ -44,6 +44,7 @@ import net.sourceforge.plantuml.AlignmentParam; import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.PositionedNote; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; @@ -245,5 +246,12 @@ public class FtileWithNoteOpale extends AbstractFtile implements Stencil, Stylea public double getEndingX(StringBounder stringBounder, double y) { return opale.calculateDimension(stringBounder).getWidth() - opale.getMarginX1(); } + + @Override + final public LinkRendering getInLinkRendering() { + return tile.getInLinkRendering(); + } + + } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java index d87008043..24c2eac1f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java @@ -40,6 +40,7 @@ import java.util.Set; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.PositionedNote; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; @@ -147,12 +148,11 @@ public class FtileWithNotes extends AbstractFtile { } } - if (left == null) { + if (left == null) left = TextBlockUtils.empty(0, 0); - } - if (right == null) { + + if (right == null) right = TextBlockUtils.empty(0, 0); - } } @@ -204,10 +204,10 @@ public class FtileWithNotes extends AbstractFtile { final XDimension2D dimTotal = calculateDimensionInternal(stringBounder); final FtileGeometry orig = tile.calculateDimension(stringBounder); final UTranslate translate = getTranslate(stringBounder); - if (orig.hasPointOut()) { + if (orig.hasPointOut()) return new FtileGeometry(dimTotal, orig.getLeft() + translate.getDx(), orig.getInY() + translate.getDy(), orig.getOutY() + translate.getDy()); - } + return new FtileGeometry(dimTotal, orig.getLeft() + translate.getDx(), orig.getInY() + translate.getDy()); } @@ -219,4 +219,9 @@ public class FtileWithNotes extends AbstractFtile { return new XDimension2D(dimTile.getWidth() + dimLeft.getWidth() + dimRight.getWidth(), height); } + @Override + final public LinkRendering getInLinkRendering() { + return tile.getInLinkRendering(); + } + } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java index 8b6ce3e6f..6a840a956 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java @@ -101,14 +101,15 @@ public class FtileBox extends AbstractFtile { return StyleSignatureBasic.of(SName.root, SName.element, SName.activityDiagram, SName.arrow); } + @Override final public LinkRendering getInLinkRendering() { return inRendering; } public Set getSwimlanes() { - if (swimlane == null) { + if (swimlane == null) return Collections.emptySet(); - } + return Collections.singleton(swimlane); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBoxOld.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBoxOld.java index 10f066c94..75f8d0c4e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBoxOld.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBoxOld.java @@ -164,13 +164,9 @@ public class FtileBoxOld extends AbstractFtile { final LineBreakStrategy wrapWidth = style.wrapWidth(); this.minimumWidth = style.value(PName.MinimumWidth).asDouble(); - // final HorizontalAlignment alignment = - // skinParam.getDefaultTextAlignment(horizontalAlignment); final Sheet sheet = skinParam.sheet(fc, horizontalAlignment, CreoleMode.FULL).createSheet(label); -// this.tb = new SheetBlock1(sheet, wrapWidth, 0, this.padding.getLeft(), this.padding.getRight()); -// this.tb = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, 0, this.padding.getLeft(), this.padding.getRight()), -// new MyStencil(), new UStroke(1)); - this.tb = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, style.getPadding()), new MyStencil(), + + this.tb = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, style), new MyStencil(), new UStroke(1)); this.print = label.toString(); diff --git a/src/net/sourceforge/plantuml/baraye/CucaDiagram.java b/src/net/sourceforge/plantuml/baraye/CucaDiagram.java index d4d68123b..3cf1beb42 100644 --- a/src/net/sourceforge/plantuml/baraye/CucaDiagram.java +++ b/src/net/sourceforge/plantuml/baraye/CucaDiagram.java @@ -93,6 +93,8 @@ import net.sourceforge.plantuml.xmlsc.StateDiagramScxmlMaker; public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, PortionShower, ICucaDiagram { + static public final boolean QUARK = false; + static private final boolean G1972 = false; // private String namespaceSeparator = "."; @@ -100,6 +102,14 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, private String namespaceSeparator = null; private boolean namespaceSeparatorHasBeenSet = false; + public Quark currentQuark() { + throw new UnsupportedOperationException(); + } + + public /*protected*/ Plasma getPlasma() { + throw new UnsupportedOperationException(); + } + public final boolean V1972() { if (getPragma().backToLegacyPackage()) { return false; diff --git a/src/net/sourceforge/plantuml/baraye/Plasma.java b/src/net/sourceforge/plantuml/baraye/Plasma.java index 6f4fcf0e6..ad84da55a 100644 --- a/src/net/sourceforge/plantuml/baraye/Plasma.java +++ b/src/net/sourceforge/plantuml/baraye/Plasma.java @@ -113,13 +113,20 @@ public class Plasma { // return false; // } - public Quark getIfExists(String name) { + public Quark getIfExistsFromName(String name) { for (Quark quark : quarks.values()) if (quark.getName().equals(name)) return quark; return null; } + public Quark getIfExistsFromFullPath(String full) { + for (Quark quark : quarks.values()) + if (quark.toString(separator).equals(full)) + return quark; + return null; + } + public Quark getIfExists(List signature) { return quarks.get(signature); } diff --git a/src/net/sourceforge/plantuml/baraye/Quark.java b/src/net/sourceforge/plantuml/baraye/Quark.java index b0e5e5d84..a10b398b7 100644 --- a/src/net/sourceforge/plantuml/baraye/Quark.java +++ b/src/net/sourceforge/plantuml/baraye/Quark.java @@ -165,6 +165,12 @@ public class Quark extends Ident implements Code { return plasma.getIfExists(sig); } + public Quark parse(Quark path) { + final List sig = new ArrayList<>(getSignature()); + sig.addAll(path.getSignature()); + return plasma.ensurePresent(sig); + } + public Quark child(String name) { return plasma.parse(this, name); } @@ -182,13 +188,15 @@ public class Quark extends Ident implements Code { } public void internalMove(Quark src, Quark dest) { + System.err.print("Intermal move from " + this + " to "); if (src.getDepth() + 1 != dest.getDepth()) throw new UnsupportedOperationException("to be finished"); - final String name = getName(); + final List previous = this.getSignature(); parts.clear(); parts.addAll(dest.getSignature()); - parts.add(name); - this.parent = dest; + parts.addAll(previous.subList(src.getDepth(), previous.size())); + this.parent = plasma.ensurePresent(parts.subList(0, parts.size() - 1)); + System.err.println(toString()); } } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java index 0d9674d8f..fba1c0a99 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java @@ -41,7 +41,10 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.CucaDiagram; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; @@ -113,9 +116,11 @@ public class CommandCreateClass extends SingleLineCommand2 { new RegexOptional(new RegexConcat(new RegexLeaf("##"), new RegexLeaf("LINECOLOR", "(?:\\[(dotted|dashed|bold)\\])?(\\w+)?"))), // new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(), - new RegexLeaf("EXTENDS", "(extends)[%s]+(" + CommandCreateClassMultilines.CODES + "|[%g]([^%g]+)[%g])"))), // + new RegexLeaf("EXTENDS", + "(extends)[%s]+(" + CommandCreateClassMultilines.CODES + "|[%g]([^%g]+)[%g])"))), // new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(), - new RegexLeaf("IMPLEMENTS", "(implements)[%s]+(" + CommandCreateClassMultilines.CODES + "|[%g]([^%g]+)[%g])"))), // + new RegexLeaf("IMPLEMENTS", + "(implements)[%s]+(" + CommandCreateClassMultilines.CODES + "|[%g]([^%g]+)[%g])"))), // new RegexOptional(new RegexConcat(RegexLeaf.spaceZeroOrMore(), new RegexLeaf("\\{"), RegexLeaf.spaceZeroOrMore(), new RegexLeaf("\\}"))), // RegexLeaf.end()); @@ -137,26 +142,50 @@ public class CommandCreateClass extends SingleLineCommand2 { final String generic = genericOption != null ? genericOption : arg.get("GENERIC", 0); final String stereo = arg.get("STEREO", 0); - final ILeaf entity; - final Ident idNewLong = diagram.buildLeafIdent(idShort); - if (diagram.V1972()) { - if (diagram.leafExistSmart(idNewLong)) { - entity = diagram.getOrCreateLeaf(idNewLong, idNewLong, type, null); - if (entity.muteToType(type, null) == false) - return CommandExecutionResult.error("Bad name"); + /* final */ ILeaf entity; - } else { + if (CucaDiagram.QUARK) { + final Quark current = diagram.currentQuark(); + final Quark idNewLong = (Quark) diagram.buildLeafIdent(idShort); + if (idNewLong.getData() == null) entity = diagram.createLeaf(idNewLong, idNewLong, Display.getWithNewlines(display), type, null); + else + entity = (ILeaf) idNewLong.getData(); + if (entity == null || entity.isGroup()) { + for (Quark tmp : diagram.getPlasma().quarks()) + if (tmp.getData() instanceof EntityImp) { + final EntityImp tmp2 = (EntityImp) tmp.getData(); + if (tmp2 != null && tmp.getName().equals(idShort) && tmp2.isGroup() == false) { + entity = (ILeaf) tmp.getData(); + break; + } + } + } + if (entity == null) { + final Display withNewlines = Display.getWithNewlines(display); + entity = diagram.createLeaf(idNewLong, idNewLong, withNewlines, type, null); } } else { - final Code code = diagram.buildCode(idShort); - if (diagram.leafExist(code)) { - entity = diagram.getOrCreateLeaf(idNewLong, code, type, null); - if (entity.muteToType(type, null) == false) - return CommandExecutionResult.error("Bad name"); + final Ident idNewLong = diagram.buildLeafIdent(idShort); + if (diagram.V1972()) { + if (diagram.leafExistSmart(idNewLong)) { + entity = diagram.getOrCreateLeaf(idNewLong, idNewLong, type, null); + if (entity.muteToType(type, null) == false) + return CommandExecutionResult.error("Bad name"); + } else { + entity = diagram.createLeaf(idNewLong, idNewLong, Display.getWithNewlines(display), type, null); + } } else { - entity = diagram.createLeaf(idNewLong, code, Display.getWithNewlines(display), type, null); + final Code code = diagram.buildCode(idShort); + if (diagram.leafExist(code)) { + entity = diagram.getOrCreateLeaf(idNewLong, code, type, null); + if (entity.muteToType(type, null) == false) + return CommandExecutionResult.error("Bad name"); + + } else { + entity = diagram.createLeaf(idNewLong, code, Display.getWithNewlines(display), type, null); + } } } if (stereo != null) { @@ -179,8 +208,7 @@ public class CommandCreateClass extends SingleLineCommand2 { Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); final String s = arg.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); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java index d94cca3e2..d696676e8 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java @@ -41,8 +41,11 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.CucaDiagram; +import net.sourceforge.plantuml.baraye.EntityImp; import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.ILeaf; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.command.BlocLines; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -249,7 +252,27 @@ public class CommandCreateClassMultilines extends CommandMultilines2 { final Code code; final IGroup currentPackage; final Display display; - final Ident idNewLong = diagram.buildLeafIdent(idShort); - if (diagram.V1972()) { + final Ident idNewLong; + if (CucaDiagram.QUARK) { + final Quark current = diagram.currentQuark(); + code = current; + display = Display.getWithNewlines(idShort); + idNewLong = current.child(idShort); + currentPackage = (IGroup) current.getData(); + } else if (diagram.V1972()) { + idNewLong = diagram.buildLeafIdent(idShort); code = null; currentPackage = null; display = Display.getWithNewlines(idNewLong.getName()); } else { + idNewLong = diagram.buildLeafIdent(idShort); code = diagram.buildCode(idShort); currentPackage = diagram.getCurrentGroup(); display = Display.getWithNewlines(code); @@ -110,8 +120,7 @@ public class CommandNamespace extends SingleLineCommand2 { final String color = arg.get("COLOR", 0); if (color != null) { - p.setSpecificColorTOBEREMOVED(ColorType.BACK, - diagram.getSkinParam().getIHtmlColorSet().getColor(color)); + p.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(color)); } return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/command/CommandPackage.java b/src/net/sourceforge/plantuml/command/CommandPackage.java index b70c300d8..bf24abdd0 100644 --- a/src/net/sourceforge/plantuml/command/CommandPackage.java +++ b/src/net/sourceforge/plantuml/command/CommandPackage.java @@ -40,8 +40,10 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.UrlMode; +import net.sourceforge.plantuml.baraye.CucaDiagram; import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.IGroup; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines; import net.sourceforge.plantuml.command.regex.IRegex; @@ -123,30 +125,37 @@ public class CommandPackage extends SingleLineCommand2 { display = name; idShort = arg.get("AS", 0); } + + final Ident ident; + final Code code; + + if (CucaDiagram.QUARK) { + final Quark current = diagram.currentQuark(); + code = current; + ident = current.child(idShort); + } else { + ident = diagram.buildLeafIdent(idShort); + code = diagram.V1972() ? ident : diagram.buildCode(idShort); + if (diagram.V1972() && override1972) + display = ident.getLast(); + } final IGroup currentPackage = diagram.getCurrentGroup(); - // final Ident ident = diagram.buildLeafIdentSpecial(idShort); - final Ident ident = diagram.buildLeafIdent(idShort); - final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort); - if (diagram.V1972() && override1972) - display = ident.getLast(); + diagram.gotoGroup(ident, code, Display.getWithNewlines(display), GroupType.PACKAGE, currentPackage, NamespaceStrategy.SINGLE); + final IEntity p = diagram.getCurrentGroup(); + final String stereotype = arg.get("STEREOTYPE", 0); - // final USymbol type = USymbol.getFromString(arg.get("TYPE", 0), - // diagram.getSkinParam().getActorStyle()); -// if (type == USymbol.TOGETHER) { -// p.setUSymbol(type); -// p.setThisIsTogether(); -// } else + if (stereotype != null) { final USymbol usymbol = USymbols.fromString(stereotype, diagram.getSkinParam().actorStyle(), diagram.getSkinParam().componentStyle(), diagram.getSkinParam().packageStyle()); - if (usymbol == null) { + if (usymbol == null) p.setStereotype(Stereotype.build(stereotype)); - } else { + else p.setUSymbol(usymbol); - } + } CommandCreateClassMultilines.addTags(p, arg.getLazzy("TAGS", 0)); diff --git a/src/net/sourceforge/plantuml/creole/SheetBlock1.java b/src/net/sourceforge/plantuml/creole/SheetBlock1.java index 587306714..ea76b5dc8 100644 --- a/src/net/sourceforge/plantuml/creole/SheetBlock1.java +++ b/src/net/sourceforge/plantuml/creole/SheetBlock1.java @@ -53,6 +53,8 @@ import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -74,14 +76,16 @@ public class SheetBlock1 extends AbstractTextBlock implements TextBlock, Atom, S private final double marginX1; private final double marginX2; private Class lastCaller; + private double minimumWidth; @HaxeIgnored public SheetBlock1(Sheet sheet, LineBreakStrategy maxWidth, double padding) { this(sheet, maxWidth, ClockwiseTopRightBottomLeft.same(padding), 0, 0); } - public SheetBlock1(Sheet sheet, LineBreakStrategy maxWidth, ClockwiseTopRightBottomLeft padding) { - this(sheet, maxWidth, padding, 0, 0); + public SheetBlock1(Sheet sheet, LineBreakStrategy maxWidth, Style style) { + this(sheet, maxWidth, style.getPadding(), 0, 0); + this.minimumWidth = style.value(PName.MinimumWidth).asDouble(); } public SheetBlock1(Sheet sheet, LineBreakStrategy maxWidth, double padding, double marginX1, double marginX2) { @@ -113,6 +117,10 @@ public class SheetBlock1 extends AbstractTextBlock implements TextBlock, Atom, S return HorizontalAlignment.LEFT; } + public HorizontalAlignment getHorizontalAlignment() { + return sheet.getHorizontalAlignment(); + } + private void initMap(StringBounder stringBounder) { final Class currentCaller = stringBounder.getClass(); if (lastCaller == currentCaller) @@ -210,4 +218,8 @@ public class SheetBlock1 extends AbstractTextBlock implements TextBlock, Atom, S return calculateDimension(stringBounder).getWidth() + marginX2; } + public final double getMinimumWidth() { + return minimumWidth; + } + } diff --git a/src/net/sourceforge/plantuml/creole/SheetBlock2.java b/src/net/sourceforge/plantuml/creole/SheetBlock2.java index ed56ec8d1..c16c83c5f 100644 --- a/src/net/sourceforge/plantuml/creole/SheetBlock2.java +++ b/src/net/sourceforge/plantuml/creole/SheetBlock2.java @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XRectangle2D; import net.sourceforge.plantuml.creole.atom.Atom; import net.sourceforge.plantuml.graphic.AbstractTextBlock; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -50,6 +51,7 @@ import net.sourceforge.plantuml.svek.WithPorts; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.UTranslate; final public class SheetBlock2 extends AbstractTextBlock implements TextBlock, Atom, WithPorts { @@ -81,6 +83,10 @@ final public class SheetBlock2 extends AbstractTextBlock implements TextBlock, A this.defaultStroke = defaultStroke; } + private HorizontalAlignment getHorizontalAlignment() { + return block.getHorizontalAlignment(); + } + @Override public String toString() { return block.toString(); @@ -94,6 +100,11 @@ final public class SheetBlock2 extends AbstractTextBlock implements TextBlock, A if (stencil != null) ug = UGraphicStencil.create(ug, stencil, defaultStroke); + if (getHorizontalAlignment() == HorizontalAlignment.CENTER && block.getMinimumWidth() > 0) { + final double width = calculateDimension(ug.getStringBounder()).getWidth(); + final double dx = (block.getMinimumWidth() - width) / 2; + ug = ug.apply(UTranslate.dx(dx)); + } block.drawU(ug); } diff --git a/src/net/sourceforge/plantuml/mindmap/Idea.java b/src/net/sourceforge/plantuml/mindmap/Idea.java index ed2fa3cda..a56a38ac9 100644 --- a/src/net/sourceforge/plantuml/mindmap/Idea.java +++ b/src/net/sourceforge/plantuml/mindmap/Idea.java @@ -62,23 +62,23 @@ class Idea { private StyleSignatureBasic getDefaultStyleDefinitionNode(int level) { final String depth = SName.depth(level); - if (level == 0) { + if (level == 0) return StyleSignatureBasic.of(SName.root, SName.element, SName.mindmapDiagram, SName.node, SName.rootNode) .add(stereotype).add(depth); - } - if (shape == IdeaShape.NONE && children.size() == 0) { + + if (shape == IdeaShape.NONE && children.size() == 0) return StyleSignatureBasic .of(SName.root, SName.element, SName.mindmapDiagram, SName.node, SName.leafNode, SName.boxless) .add(stereotype).add(depth); - } - if (shape == IdeaShape.NONE) { + + if (shape == IdeaShape.NONE) return StyleSignatureBasic.of(SName.root, SName.element, SName.mindmapDiagram, SName.node, SName.boxless) .add(stereotype).add(depth); - } - if (children.size() == 0) { + + if (children.size() == 0) return StyleSignatureBasic.of(SName.root, SName.element, SName.mindmapDiagram, SName.node, SName.leafNode) .add(stereotype).add(depth); - } + return StyleSignatureBasic.of(SName.root, SName.element, SName.mindmapDiagram, SName.node).add(stereotype) .add(depth); } diff --git a/src/net/sourceforge/plantuml/preproc/Stdlib.java b/src/net/sourceforge/plantuml/preproc/Stdlib.java index bb7d81353..3627db18a 100644 --- a/src/net/sourceforge/plantuml/preproc/Stdlib.java +++ b/src/net/sourceforge/plantuml/preproc/Stdlib.java @@ -68,12 +68,28 @@ public class Stdlib { final String info = dataStream.readUTF(); dataStream.close(); - result = new Stdlib(name, info); + + final String link = getLinkFromInfo(info); + if (link == null) + result = new Stdlib(name, info); + else + result = retrieve(link); + all.put(name, result); } return result; } + private static String getLinkFromInfo(String infoString) { + for (String s : infoString.split("\n")) + if (s.contains("=")) { + final String data[] = s.split("="); + if (data[0].equals("LINK")) + return data[1]; + } + return null; + } + private String loadResource(String file) throws IOException { final SoftReference cached = cache.get(file.toLowerCase()); if (cached != null) { @@ -194,7 +210,6 @@ public class Stdlib { final String data[] = s.split("="); this.info.put(data[0], data[1]); } - } private static DataInputStream getDataStream(String name) throws IOException { diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandAddField.java b/src/net/sourceforge/plantuml/statediagram/command/CommandAddField.java index 25b335c02..984686ce9 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandAddField.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandAddField.java @@ -36,7 +36,9 @@ package net.sourceforge.plantuml.statediagram.command; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.baraye.CucaDiagram; import net.sourceforge.plantuml.baraye.IEntity; +import net.sourceforge.plantuml.baraye.Quark; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.IRegex; @@ -66,9 +68,31 @@ public class CommandAddField extends SingleLineCommand2 { new RegexLeaf("FIELD", "(.*)"), RegexLeaf.end()); } + private CommandExecutionResult executeArgQuark(StateDiagram diagram, LineLocation location, RegexResult arg) + throws NoSuchColorException { + final String codeString = arg.getLazzy("CODE", 0); + + final Quark quark = diagram.currentQuark(); + Quark child = quark.childIfExists(codeString); + if (child == null && quark.getName().equals(codeString)) + child = quark; + if (child == null) + child = quark.child(codeString); + + final IEntity entity = diagram.getOrCreateLeaf(child, child, null, null); + + final String field = arg.get("FIELD", 0); + + entity.getBodier().addFieldOrMethod(field); + return CommandExecutionResult.ok(); + } + @Override protected CommandExecutionResult executeArg(StateDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { + if (CucaDiagram.QUARK) + return executeArgQuark(diagram, location, arg); + final String codeString = arg.getLazzy("CODE", 0); final String field = arg.get("FIELD", 0); diff --git a/src/net/sourceforge/plantuml/timingdiagram/TimeConstraint.java b/src/net/sourceforge/plantuml/timingdiagram/TimeConstraint.java index 69d7710e2..f11a6c197 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/TimeConstraint.java +++ b/src/net/sourceforge/plantuml/timingdiagram/TimeConstraint.java @@ -37,6 +37,7 @@ package net.sourceforge.plantuml.timingdiagram; import java.util.List; import java.util.Objects; +import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XPoint2D; @@ -108,14 +109,20 @@ public class TimeConstraint { final double x1 = ruler.getPosInPixel(tick1); final double x2 = ruler.getPosInPixel(tick2); ug = ug.apply(UTranslate.dx(x1)); - ug.apply(getUStroke()).draw(ULine.hline(x2 - x1)); + final double len = x2 - x1; + ug.apply(getUStroke()).draw(ULine.hline(len)); - ug.draw(getPolygon(-Math.PI / 2, new XPoint2D(0, 0))); - ug.draw(getPolygon(Math.PI / 2, new XPoint2D(x2 - x1, 0))); + if (len > 10) { + ug.draw(getPolygon(Direction.LEFT, new XPoint2D(0, 0))); + ug.draw(getPolygon(Direction.RIGHT, new XPoint2D(len, 0))); + } else { + ug.draw(getPolygon(Direction.RIGHT, new XPoint2D(0, 0))); + ug.draw(getPolygon(Direction.LEFT, new XPoint2D(len, 0))); + } final TextBlock text = getTextBlock(label); final XDimension2D dimText = text.calculateDimension(ug.getStringBounder()); - final double x = (x2 - x1 - dimText.getWidth()) / 2; + final double x = (len - dimText.getWidth()) / 2; text.drawU(ug.apply(new UTranslate(x, -getConstraintHeight(ug.getStringBounder())))); } @@ -149,15 +156,23 @@ public class TimeConstraint { return 5; } - private UPolygon getPolygon(final double angle, final XPoint2D end) { - final double delta = 20.0 * Math.PI / 180.0; - final XPoint2D pt1 = TimeArrow.onCircle(end, angle + delta); - final XPoint2D pt2 = TimeArrow.onCircle(end, angle - delta); + private UPolygon getPolygon(Direction dir, XPoint2D end) { + final double dx = 8; + final double dy = 4; + final XPoint2D pt1; + final XPoint2D pt2; + if (dir == Direction.RIGHT) { + pt1 = end.move(-dx, dy); + pt2 = end.move(-dx, -dy); + } else { + pt1 = end.move(dx, dy); + pt2 = end.move(dx, -dy); + } final UPolygon polygon = new UPolygon(); - polygon.addPoint(pt1.getX(), pt1.getY()); - polygon.addPoint(pt2.getX(), pt2.getY()); - polygon.addPoint(end.getX(), end.getY()); + polygon.addPoint(pt1); + polygon.addPoint(pt2); + polygon.addPoint(end); return polygon; } diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 7282c26df..80e8ef448 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -81,7 +81,7 @@ public class Version { } public static int beta() { - final int beta = 7; + final int beta = 8; return beta; }