From 5599f8fc827d9675879254ec215b1dd440bab7d0 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Tue, 9 Nov 2021 18:47:19 +0100 Subject: [PATCH] wip --- .../sourceforge/plantuml/AbstractPSystem.java | 8 +- src/net/sourceforge/plantuml/Annotated.java | 8 +- .../sourceforge/plantuml/AnnotatedWorker.java | 10 +-- .../sourceforge/plantuml/TitledDiagram.java | 20 ++--- .../activitydiagram3/InstructionFork.java | 33 ++++++++ .../activitydiagram3/InstructionIf.java | 2 +- .../activitydiagram3/InstructionRepeat.java | 1 - .../activitydiagram3/InstructionSplit.java | 2 - .../activitydiagram3/InstructionSwitch.java | 44 +++++++--- .../activitydiagram3/InstructionWhile.java | 16 ++++ .../plantuml/command/CommandCaption.java | 4 +- .../plantuml/command/CommandLegend.java | 4 +- .../command/CommandMultilinesCaption.java | 4 +- .../command/CommandMultilinesLegend.java | 4 +- .../command/CommandMultilinesTitle.java | 4 +- .../plantuml/command/CommandTitle.java | 4 +- .../sourceforge/plantuml/core/UmlSource.java | 6 +- ...ositionned.java => DisplayPositioned.java} | 12 +-- .../plantuml/cucadiagram/GroupRoot.java | 4 +- .../plantuml/cucadiagram/IGroup.java | 4 +- .../cucadiagram/entity/EntityImpl.java | 8 +- .../plantuml/jsondiagram/JsonDiagram.java | 6 +- .../jsondiagram/JsonDiagramFactory.java | 2 +- .../plantuml/jsondiagram/StyleExtractor.java | 45 ++++++----- .../AbstractClassOrObjectDiagram.java | 4 +- .../plantuml/svek/DecorateEntityImage.java | 8 +- .../plantuml/svek/GeneralImageBuilder.java | 6 +- .../svek/image/EntityImageEmptyPackage.java | 4 +- .../sourceforge/plantuml/tim/TContext.java | 4 + .../plantuml/tim/expression/TValue.java | 6 +- .../sourceforge/plantuml/tim/stdlib/Chr.java | 68 ++++++++++++++++ .../sourceforge/plantuml/tim/stdlib/Size.java | 81 +++++++++++++++++++ .../sourceforge/plantuml/version/Version.java | 2 +- .../plantuml/vizjs/VizJsEngine.java | 1 - .../plantuml/yaml/YamlDiagramFactory.java | 10 ++- 35 files changed, 344 insertions(+), 105 deletions(-) rename src/net/sourceforge/plantuml/cucadiagram/{DisplayPositionned.java => DisplayPositioned.java} (80%) create mode 100644 src/net/sourceforge/plantuml/tim/stdlib/Chr.java create mode 100644 src/net/sourceforge/plantuml/tim/stdlib/Size.java diff --git a/src/net/sourceforge/plantuml/AbstractPSystem.java b/src/net/sourceforge/plantuml/AbstractPSystem.java index 68829e822..117945689 100644 --- a/src/net/sourceforge/plantuml/AbstractPSystem.java +++ b/src/net/sourceforge/plantuml/AbstractPSystem.java @@ -49,7 +49,7 @@ import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.stats.StatsUtilsIncrement; @@ -128,11 +128,11 @@ public abstract class AbstractPSystem implements Diagram { this.splitPagesVertical = splitPagesVertical; } - public DisplayPositionned getTitle() { + public DisplayPositioned getTitle() { if (source == null) { - return DisplayPositionned.single(Display.empty(), HorizontalAlignment.CENTER, VerticalAlignment.TOP); + return DisplayPositioned.single(Display.empty(), HorizontalAlignment.CENTER, VerticalAlignment.TOP); } - return DisplayPositionned.single(source.getTitle(), HorizontalAlignment.CENTER, VerticalAlignment.TOP); + return DisplayPositioned.single(source.getTitle(), HorizontalAlignment.CENTER, VerticalAlignment.TOP); } public String getWarningOrError() { diff --git a/src/net/sourceforge/plantuml/Annotated.java b/src/net/sourceforge/plantuml/Annotated.java index 182603c0e..b076972a0 100644 --- a/src/net/sourceforge/plantuml/Annotated.java +++ b/src/net/sourceforge/plantuml/Annotated.java @@ -36,16 +36,16 @@ package net.sourceforge.plantuml; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.cucadiagram.DisplaySection; public interface Annotated { - public DisplayPositionned getTitle(); + public DisplayPositioned getTitle(); - public DisplayPositionned getCaption(); + public DisplayPositioned getCaption(); - public DisplayPositionned getLegend(); + public DisplayPositioned getLegend(); public DisplaySection getHeader(); diff --git a/src/net/sourceforge/plantuml/AnnotatedWorker.java b/src/net/sourceforge/plantuml/AnnotatedWorker.java index 5a2c869da..fcc12d385 100644 --- a/src/net/sourceforge/plantuml/AnnotatedWorker.java +++ b/src/net/sourceforge/plantuml/AnnotatedWorker.java @@ -40,7 +40,7 @@ import java.awt.geom.Rectangle2D; import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.cucadiagram.DisplaySection; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -142,7 +142,7 @@ public class AnnotatedWorker { } private TextBlock addLegend(TextBlock original) { - final DisplayPositionned legend = annotated.getLegend(); + final DisplayPositioned legend = annotated.getLegend(); if (legend.isNull()) { return original; } @@ -156,7 +156,7 @@ public class AnnotatedWorker { } private TextBlock addCaption(TextBlock original) { - final DisplayPositionned caption = annotated.getCaption(); + final DisplayPositioned caption = annotated.getCaption(); if (caption.isNull()) { return original; } @@ -165,7 +165,7 @@ public class AnnotatedWorker { } public TextBlock getCaption() { - final DisplayPositionned caption = annotated.getCaption(); + final DisplayPositioned caption = annotated.getCaption(); if (caption.isNull()) { return TextBlockUtils.empty(0, 0); } @@ -179,7 +179,7 @@ public class AnnotatedWorker { } private TextBlock addTitle(TextBlock original) { - final DisplayPositionned title = annotated.getTitle(); + final DisplayPositioned title = annotated.getTitle(); if (title.isNull()) { return original; } diff --git a/src/net/sourceforge/plantuml/TitledDiagram.java b/src/net/sourceforge/plantuml/TitledDiagram.java index ce079c780..b684efb2f 100644 --- a/src/net/sourceforge/plantuml/TitledDiagram.java +++ b/src/net/sourceforge/plantuml/TitledDiagram.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.cucadiagram.DisplaySection; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment; @@ -63,10 +63,10 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, public static boolean FORCE_SMETANA = false; public static boolean FORCE_ELK = false; - private DisplayPositionned title = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.TOP); + private DisplayPositioned title = DisplayPositioned.none(HorizontalAlignment.CENTER, VerticalAlignment.TOP); - private DisplayPositionned caption = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM); - private DisplayPositionned legend = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM); + private DisplayPositioned caption = DisplayPositioned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM); + private DisplayPositioned legend = DisplayPositioned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM); private final DisplaySection header = DisplaySection.none(); private final DisplaySection footer = DisplaySection.none(); private Display mainFrame; @@ -164,7 +164,7 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, // return i; // } - final public void setTitle(DisplayPositionned title) { + final public void setTitle(DisplayPositioned title) { if (title.isNull() || title.getDisplay().isWhite()) { return; } @@ -172,7 +172,7 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, } @Override - final public DisplayPositionned getTitle() { + final public DisplayPositioned getTitle() { return title; } @@ -180,11 +180,11 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, this.mainFrame = mainFrame; } - final public void setCaption(DisplayPositionned caption) { + final public void setCaption(DisplayPositioned caption) { this.caption = caption; } - final public DisplayPositionned getCaption() { + final public DisplayPositioned getCaption() { return caption; } @@ -196,11 +196,11 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, return footer; } - final public DisplayPositionned getLegend() { + final public DisplayPositioned getLegend() { return legend; } - public void setLegend(DisplayPositionned legend) { + public void setLegend(DisplayPositioned legend) { this.legend = legend; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java index 45a1724dd..326477de4 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java @@ -46,8 +46,13 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale; +import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; +import net.sourceforge.plantuml.activitydiagram3.gtile.GtileSplit; +import net.sourceforge.plantuml.activitydiagram3.gtile.Gtiles; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; @@ -64,6 +69,7 @@ public class InstructionFork extends WithNote implements Instruction { private String label; boolean finished = false; + @Override public boolean containsBreak() { for (InstructionList fork : forks) { if (fork.containsBreak()) { @@ -86,10 +92,32 @@ public class InstructionFork extends WithNote implements Instruction { return forks.get(forks.size() - 1); } + @Override public CommandExecutionResult add(Instruction ins) { return getLastList().add(ins); } + @Override + public Gtile createGtile(ISkinParam skinParam, StringBounder stringBounder) { + final List all = new ArrayList<>(); + for (InstructionList list : forks) { + Gtile tmp = list.createGtile(skinParam, stringBounder); + tmp = Gtiles.withIncomingArrow(tmp, 20); + tmp = Gtiles.withOutgoingArrow(tmp, 20); + all.add(tmp); + } + + return new GtileSplit(all, swimlaneIn, getInLinkRenderingColor(skinParam).getColor()); + } + + private Rainbow getInLinkRenderingColor(ISkinParam skinParam) { + Rainbow color; + color = Rainbow.build(skinParam); + return color; + } + + + @Override public Ftile createFtile(FtileFactory factory) { final List all = new ArrayList<>(); for (InstructionList list : forks) { @@ -111,10 +139,12 @@ public class InstructionFork extends WithNote implements Instruction { this.forks.add(new InstructionList()); } + @Override final public boolean kill() { return getLastList().kill(); } + @Override public LinkRendering getInLinkRendering() { return inlinkRendering; } @@ -130,6 +160,7 @@ public class InstructionFork extends WithNote implements Instruction { return getLastList().addNote(note, position, type, colors, swimlaneNote); } + @Override public Set getSwimlanes() { final Set result = new HashSet<>(InstructionList.getSwimlanes2(forks)); result.add(swimlaneIn); @@ -137,10 +168,12 @@ public class InstructionFork extends WithNote implements Instruction { return result; } + @Override public Swimlane getSwimlaneIn() { return swimlaneIn; } + @Override public Swimlane getSwimlaneOut() { return swimlaneOut; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java index a8656a443..da18ce51c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java @@ -51,8 +51,8 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale; import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; -import net.sourceforge.plantuml.activitydiagram3.gtile.GtileIfHexagon; import net.sourceforge.plantuml.activitydiagram3.gtile.GtileIfAlone; +import net.sourceforge.plantuml.activitydiagram3.gtile.GtileIfHexagon; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.StringBounder; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java index 420fe5092..0345f8913 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java @@ -48,7 +48,6 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlanes; import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; -import net.sourceforge.plantuml.activitydiagram3.gtile.GtileIfAlone; import net.sourceforge.plantuml.activitydiagram3.gtile.GtileRepeat; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java index 95d77267f..837175892 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java @@ -45,7 +45,6 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; -import net.sourceforge.plantuml.activitydiagram3.gtile.GtileColumns; import net.sourceforge.plantuml.activitydiagram3.gtile.GtileSplit; import net.sourceforge.plantuml.activitydiagram3.gtile.Gtiles; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -55,7 +54,6 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; -import net.sourceforge.plantuml.ugraphic.color.HColorUtils; public class InstructionSplit extends AbstractInstruction implements Instruction { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java index 55fd6f9b7..1dcc79cd8 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java @@ -46,8 +46,11 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; +import net.sourceforge.plantuml.activitydiagram3.gtile.GtileIfHexagon; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; @@ -55,7 +58,7 @@ import net.sourceforge.plantuml.ugraphic.color.HColor; public class InstructionSwitch extends WithNote implements Instruction, InstructionCollection { - private final List branches = new ArrayList<>(); + private final List switches = new ArrayList<>(); private final ISkinParam skinParam; private final Instruction parent; @@ -67,8 +70,9 @@ public class InstructionSwitch extends WithNote implements Instruction, Instruct private final Swimlane swimlane; + @Override public boolean containsBreak() { - for (Branch branch : branches) { + for (Branch branch : switches) { if (branch.containsBreak()) { return true; } @@ -85,6 +89,7 @@ public class InstructionSwitch extends WithNote implements Instruction, Instruct this.swimlane = swimlane; } + @Override public CommandExecutionResult add(Instruction ins) { if (current == null) { return CommandExecutionResult.error("No 'case' in this switch"); @@ -92,42 +97,63 @@ public class InstructionSwitch extends WithNote implements Instruction, Instruct return current.add(ins); } - public Ftile createFtile(FtileFactory factory) { - for (Branch branch : branches) { - branch.updateFtile(factory); + @Override + public Gtile createGtile(ISkinParam skinParam, StringBounder stringBounder) { + for (Branch branch : switches) + branch.updateGtile(skinParam, stringBounder); + + final List gtiles = new ArrayList<>(); + final List branches = new ArrayList<>(); + for (Branch branch : switches) { + gtiles.add(branch.getGtile()); + branches.add(branch); } - return factory.createSwitch(swimlane, branches, afterEndwhile, topInlinkRendering, labelTest); + + return new GtileIfHexagon(swimlane, gtiles, switches); + } + + public Ftile createFtile(FtileFactory factory) { + for (Branch branch : switches) + branch.updateFtile(factory); + + return factory.createSwitch(swimlane, switches, afterEndwhile, topInlinkRendering, labelTest); } + @Override final public boolean kill() { return current.kill(); } + @Override public LinkRendering getInLinkRendering() { return topInlinkRendering; } + @Override public Set getSwimlanes() { final Set result = new HashSet<>(); if (swimlane != null) { result.add(swimlane); } - for (Branch branch : branches) { + for (Branch branch : switches) { result.addAll(branch.getSwimlanes()); } return Collections.unmodifiableSet(result); } + @Override public Swimlane getSwimlaneIn() { return swimlane; } + @Override public Swimlane getSwimlaneOut() { return swimlane; } + @Override public Instruction getLast() { - return branches.get(branches.size() - 1).getLast(); + return switches.get(switches.size() - 1).getLast(); } public boolean switchCase(Display labelCase, LinkRendering nextLinkRenderer) { @@ -136,7 +162,7 @@ public class InstructionSwitch extends WithNote implements Instruction, Instruct this.current = new Branch(skinParam.getCurrentStyleBuilder(), swimlane, LinkRendering.none().withDisplay(labelCase), labelCase, null, LinkRendering.none().withDisplay(labelCase)); - this.branches.add(this.current); + this.switches.add(this.current); return true; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java index 11acd4510..e132dc269 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java @@ -45,9 +45,11 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale; +import net.sourceforge.plantuml.activitydiagram3.gtile.Gtile; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; @@ -94,10 +96,17 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi this.skinParam = skinParam; } + @Override public CommandExecutionResult add(Instruction ins) { return repeatList.add(ins); } + @Override + public Gtile createGtile(ISkinParam skinParam, StringBounder stringBounder) { + return repeatList.createGtile(skinParam, stringBounder); + } + + @Override public Ftile createFtile(FtileFactory factory) { final Ftile back = Display.isNull(backward) ? null : factory.activity(backward, swimlane, boxStyle, Colors.empty(), null); @@ -116,6 +125,7 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi return parent; } + @Override final public boolean kill() { if (testCalled) { this.killed = true; @@ -124,6 +134,7 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi return repeatList.kill(); } + @Override public LinkRendering getInLinkRendering() { return nextLinkRenderer; } @@ -145,18 +156,22 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi } } + @Override public Set getSwimlanes() { return repeatList.getSwimlanes(); } + @Override public Swimlane getSwimlaneIn() { return parent.getSwimlaneIn(); } + @Override public Swimlane getSwimlaneOut() { return parent.getSwimlaneOut(); } + @Override public Instruction getLast() { return repeatList.getLast(); } @@ -165,6 +180,7 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi this.specialOut = special; } + @Override public boolean containsBreak() { return repeatList.containsBreak(); } diff --git a/src/net/sourceforge/plantuml/command/CommandCaption.java b/src/net/sourceforge/plantuml/command/CommandCaption.java index c2d905ab5..732f32389 100644 --- a/src/net/sourceforge/plantuml/command/CommandCaption.java +++ b/src/net/sourceforge/plantuml/command/CommandCaption.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment; @@ -67,7 +67,7 @@ public class CommandCaption extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(TitledDiagram diagram, LineLocation location, RegexResult arg) { final Display s = Display.getWithNewlines(arg.getLazzy("DISPLAY", 0)); - diagram.setCaption(DisplayPositionned.single(s, HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM)); + diagram.setCaption(DisplayPositioned.single(s, HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM)); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/command/CommandLegend.java b/src/net/sourceforge/plantuml/command/CommandLegend.java index a2ee64d62..de11adf2a 100644 --- a/src/net/sourceforge/plantuml/command/CommandLegend.java +++ b/src/net/sourceforge/plantuml/command/CommandLegend.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment; @@ -67,7 +67,7 @@ public class CommandLegend extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(TitledDiagram diagram, LineLocation location, RegexResult arg) { final Display s = Display.getWithNewlines(arg.getLazzy("LEGEND", 0)); - diagram.setLegend(DisplayPositionned.single(s, HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM)); + diagram.setLegend(DisplayPositioned.single(s, HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM)); return CommandExecutionResult.ok(); } } diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesCaption.java b/src/net/sourceforge/plantuml/command/CommandMultilinesCaption.java index 186c930ef..1334e4345 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilinesCaption.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilinesCaption.java @@ -37,7 +37,7 @@ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; @@ -58,7 +58,7 @@ public class CommandMultilinesCaption extends CommandMultilines { lines = lines.removeEmptyColumns(); final Display strings = lines.toDisplay(); if (strings.size() > 0) { - diagram.setCaption(DisplayPositionned.single(strings.replaceBackslashT(), HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM)); + diagram.setCaption(DisplayPositioned.single(strings.replaceBackslashT(), HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM)); return CommandExecutionResult.ok(); } return CommandExecutionResult.error("No caption defined"); diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java b/src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java index 8785d17f9..a06dd0b4d 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java @@ -42,7 +42,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; @@ -88,7 +88,7 @@ public class CommandMultilinesLegend extends CommandMultilines2 { if (alignment == null) { alignment = HorizontalAlignment.CENTER; } - diagram.setLegend(DisplayPositionned.single(strings.replaceBackslashT(), alignment, valignment)); + diagram.setLegend(DisplayPositioned.single(strings.replaceBackslashT(), alignment, valignment)); return CommandExecutionResult.ok(); } return CommandExecutionResult.error("No legend defined"); diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java b/src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java index 65e43b632..523b0b1ad 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java @@ -37,7 +37,7 @@ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; @@ -58,7 +58,7 @@ public class CommandMultilinesTitle extends CommandMultilines { lines = lines.removeEmptyColumns(); final Display strings = lines.toDisplay(); if (strings.size() > 0) { - diagram.setTitle(DisplayPositionned.single(strings.replaceBackslashT(), HorizontalAlignment.CENTER, VerticalAlignment.TOP)); + diagram.setTitle(DisplayPositioned.single(strings.replaceBackslashT(), HorizontalAlignment.CENTER, VerticalAlignment.TOP)); return CommandExecutionResult.ok(); } return CommandExecutionResult.error("No title defined"); diff --git a/src/net/sourceforge/plantuml/command/CommandTitle.java b/src/net/sourceforge/plantuml/command/CommandTitle.java index e212c0734..c5175086d 100644 --- a/src/net/sourceforge/plantuml/command/CommandTitle.java +++ b/src/net/sourceforge/plantuml/command/CommandTitle.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment; @@ -67,7 +67,7 @@ public class CommandTitle extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(TitledDiagram diagram, LineLocation location, RegexResult arg) { final Display s = Display.getWithNewlines(arg.getLazzy("TITLE", 0)); - diagram.setTitle(DisplayPositionned.single(s, HorizontalAlignment.CENTER, VerticalAlignment.TOP)); + diagram.setTitle(DisplayPositioned.single(s, HorizontalAlignment.CENTER, VerticalAlignment.TOP)); return CommandExecutionResult.ok(); } } diff --git a/src/net/sourceforge/plantuml/core/UmlSource.java b/src/net/sourceforge/plantuml/core/UmlSource.java index f2fac7a5b..a86298ace 100644 --- a/src/net/sourceforge/plantuml/core/UmlSource.java +++ b/src/net/sourceforge/plantuml/core/UmlSource.java @@ -149,9 +149,9 @@ final public class UmlSource { return new IteratorCounter2Impl(source); } - public Iterator iteratorRaw() { - return Collections.unmodifiableCollection(rawSource).iterator(); - } +// public Iterator iteratorRaw() { +// return Collections.unmodifiableCollection(rawSource).iterator(); +// } /** * Return the source as a single String with \n as line separator. diff --git a/src/net/sourceforge/plantuml/cucadiagram/DisplayPositionned.java b/src/net/sourceforge/plantuml/cucadiagram/DisplayPositioned.java similarity index 80% rename from src/net/sourceforge/plantuml/cucadiagram/DisplayPositionned.java rename to src/net/sourceforge/plantuml/cucadiagram/DisplayPositioned.java index 95db36242..8c5597501 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/DisplayPositionned.java +++ b/src/net/sourceforge/plantuml/cucadiagram/DisplayPositioned.java @@ -38,26 +38,26 @@ package net.sourceforge.plantuml.cucadiagram; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment; -public class DisplayPositionned { +public class DisplayPositioned { private final Display display; private final HorizontalAlignment horizontalAlignment; private final VerticalAlignment verticalAlignment; - private DisplayPositionned(Display display, HorizontalAlignment horizontalAlignment, + private DisplayPositioned(Display display, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) { this.display = display; this.horizontalAlignment = horizontalAlignment; this.verticalAlignment = verticalAlignment; } - public static DisplayPositionned single(Display display, HorizontalAlignment horizontalAlignment, + public static DisplayPositioned single(Display display, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) { - return new DisplayPositionned(display, horizontalAlignment, verticalAlignment); + return new DisplayPositioned(display, horizontalAlignment, verticalAlignment); } - public static DisplayPositionned none(HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) { - return new DisplayPositionned(Display.NULL, horizontalAlignment, verticalAlignment); + public static DisplayPositioned none(HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) { + return new DisplayPositioned(Display.NULL, horizontalAlignment, verticalAlignment); } public final Display getDisplay() { diff --git a/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java b/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java index 714358510..04845df55 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java +++ b/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java @@ -299,12 +299,12 @@ public class GroupRoot implements IGroup { } @Override - public void setLegend(DisplayPositionned legend) { + public void setLegend(DisplayPositioned legend) { throw new UnsupportedOperationException(); } @Override - public DisplayPositionned getLegend() { + public DisplayPositioned getLegend() { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/IGroup.java b/src/net/sourceforge/plantuml/cucadiagram/IGroup.java index e46beca54..fd27dc306 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/IGroup.java +++ b/src/net/sourceforge/plantuml/cucadiagram/IGroup.java @@ -71,8 +71,8 @@ public interface IGroup extends IEntity { public void setConcurrentSeparator(char separator); - public void setLegend(DisplayPositionned legend); + public void setLegend(DisplayPositioned legend); - public DisplayPositionned getLegend(); + public DisplayPositioned getLegend(); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java index 0bb0b2d43..6f98e69b6 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java +++ b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java @@ -56,7 +56,7 @@ import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.cucadiagram.Bodier; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.cucadiagram.EntityUtils; import net.sourceforge.plantuml.cucadiagram.GroupRoot; @@ -95,7 +95,7 @@ final public class EntityImpl implements ILeaf, IGroup { private final Bodier bodier; private final String uid = StringUtils.getUid("cl", UniqueSequence.getValue()); private Display display = Display.empty(); - private DisplayPositionned legend = null; + private DisplayPositioned legend = null; private LeafType leafType; private Stereotype stereotype; @@ -749,12 +749,12 @@ final public class EntityImpl implements ILeaf, IGroup { return visibility; } - public void setLegend(DisplayPositionned legend) { + public void setLegend(DisplayPositioned legend) { checkGroup(); this.legend = legend; } - public DisplayPositionned getLegend() { + public DisplayPositioned getLegend() { return legend; } diff --git a/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java b/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java index 49f312b54..6d5ad626f 100644 --- a/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java +++ b/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java @@ -88,9 +88,7 @@ public class JsonDiagram extends TitledDiagram { protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { - return createImageBuilder(fileFormatOption) - .drawable(getTextBlock()) - .write(os); + return createImageBuilder(fileFormatOption).drawable(getTextBlock()).write(os); } private void drawInternal(UGraphic ug) { @@ -122,7 +120,7 @@ public class JsonDiagram extends TitledDiagram { } public Dimension2D calculateDimension(StringBounder stringBounder) { - return null; + return TextBlockUtils.getMinMax(getTextBlock(), stringBounder, true).getDimension(); } public HColor getBackcolor() { diff --git a/src/net/sourceforge/plantuml/jsondiagram/JsonDiagramFactory.java b/src/net/sourceforge/plantuml/jsondiagram/JsonDiagramFactory.java index 17ba7768c..daca00169 100644 --- a/src/net/sourceforge/plantuml/jsondiagram/JsonDiagramFactory.java +++ b/src/net/sourceforge/plantuml/jsondiagram/JsonDiagramFactory.java @@ -63,7 +63,7 @@ public class JsonDiagramFactory extends PSystemAbstractFactory { JsonValue json; try { final StringBuilder sb = new StringBuilder(); - styleExtractor = new StyleExtractor(source.iteratorRaw(), source.iterator2()); + styleExtractor = new StyleExtractor(source.iterator2()); final Iterator it = styleExtractor.getIterator(); it.next(); while (true) { diff --git a/src/net/sourceforge/plantuml/jsondiagram/StyleExtractor.java b/src/net/sourceforge/plantuml/jsondiagram/StyleExtractor.java index 93094feef..28fd3fc85 100644 --- a/src/net/sourceforge/plantuml/jsondiagram/StyleExtractor.java +++ b/src/net/sourceforge/plantuml/jsondiagram/StyleExtractor.java @@ -50,33 +50,32 @@ public class StyleExtractor { private final List list = new ArrayList<>(); private final List style = new ArrayList<>(); + private String title = null; - public StyleExtractor(Iterator dataRaw, Iterator data) { - while (dataRaw.hasNext()) { - StringLocated lineRaw = dataRaw.next(); - if (startStyle(lineRaw)) { - while (dataRaw.hasNext()) { - style.add(lineRaw); - if (endStyle(lineRaw)) - break; - lineRaw = dataRaw.next(); - } - } else if (lineRaw.getString().trim().startsWith("!theme ")) { + public StyleExtractor(Iterator data) { + while (data.hasNext()) { + StringLocated line = data.next(); + if (startStyle(line)) { while (data.hasNext()) { - StringLocated line = data.next(); - if (startStyle(line)) - while (data.hasNext()) { - style.add(line); - if (endStyle(line)) - break; - line = data.next(); - } + style.add(line); + if (endStyle(line)) + break; + line = data.next(); + } + } else if (line.getString().trim().startsWith("title ")) { + this.title = line.getString().trim().substring("title ".length()).trim(); + } else if (line.getString().trim().startsWith("skinparam ")) { + if (line.getString().trim().contains("{")) { + while (data.hasNext()) { + if (line.getString().trim().equals("}")) + break; + line = data.next(); + } } } else { - list.add(lineRaw.getString()); + list.add(line.getString()); } } - } private boolean startStyle(StringLocated line) { @@ -101,4 +100,8 @@ public class StyleExtractor { return list.iterator(); } + public String getTitle() { + return title; + } + } diff --git a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java index b70fbd9a2..21d1fae2f 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java +++ b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java @@ -45,7 +45,7 @@ import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.cucadiagram.GroupRoot; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.IGroup; @@ -360,7 +360,7 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram } @Override - public void setLegend(DisplayPositionned legend) { + public void setLegend(DisplayPositioned legend) { final IGroup currentGroup = this.getCurrentGroup(); diff --git a/src/net/sourceforge/plantuml/svek/DecorateEntityImage.java b/src/net/sourceforge/plantuml/svek/DecorateEntityImage.java index b53f710e7..062c14472 100644 --- a/src/net/sourceforge/plantuml/svek/DecorateEntityImage.java +++ b/src/net/sourceforge/plantuml/svek/DecorateEntityImage.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.svek; import java.awt.geom.Dimension2D; +import java.util.Objects; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.graphic.AbstractTextBlock; @@ -82,7 +83,7 @@ public class DecorateEntityImage extends AbstractTextBlock implements TextBlockB private DecorateEntityImage(TextBlock original, TextBlock text1, HorizontalAlignment horizontal1, TextBlock text2, HorizontalAlignment horizontal2) { - this.original = original; + this.original = Objects.requireNonNull(original); this.horizontal1 = horizontal1; this.text1 = text1; this.horizontal2 = horizontal2; @@ -142,8 +143,9 @@ public class DecorateEntityImage extends AbstractTextBlock implements TextBlockB public Dimension2D calculateDimension(StringBounder stringBounder) { final Dimension2D dimOriginal = original.calculateDimension(stringBounder); - final Dimension2D dimText = Dimension2DDouble.mergeTB(getTextDim(text1, stringBounder), - getTextDim(text2, stringBounder)); + final Dimension2D dim1 = getTextDim(text1, stringBounder); + final Dimension2D dim2 = getTextDim(text2, stringBounder); + final Dimension2D dimText = Dimension2DDouble.mergeTB(dim1, dim2); return Dimension2DDouble.mergeTB(dimOriginal, dimText); } diff --git a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java index 104d67192..375522bc4 100644 --- a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java +++ b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java @@ -67,7 +67,7 @@ import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.cucadiagram.GroupRoot; @@ -715,7 +715,7 @@ public final class GeneralImageBuilder { return label.create(fontConfiguration, alignment, dotData.getSkinParam()); } - private TextBlock addLegend(TextBlock original, DisplayPositionned legend) { + private TextBlock addLegend(TextBlock original, DisplayPositioned legend) { if (legend == null || legend.isNull()) { return original; } @@ -725,7 +725,7 @@ public final class GeneralImageBuilder { } private TextBlock getStereoBlock(IGroup g) { - final DisplayPositionned legend = g.getLegend(); + final DisplayPositioned legend = g.getLegend(); return addLegend(getStereoBlockWithoutLegend(g), legend); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java b/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java index b36e53443..19860430c 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java @@ -48,7 +48,7 @@ import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.PortionShower; @@ -137,7 +137,7 @@ public class EntityImageEmptyPackage extends AbstractEntityImage { this.desc = entity.getDisplay().create(titleFontConfiguration, titleHorizontalAlignment, skinParam); - final DisplayPositionned legend = ((EntityImpl) entity).getLegend(); + final DisplayPositioned legend = ((EntityImpl) entity).getLegend(); if (legend != null) { final TextBlock legendBlock = EntityImageLegend.create(legend.getDisplay(), skinParam); stereoBlock = legendBlock; diff --git a/src/net/sourceforge/plantuml/tim/TContext.java b/src/net/sourceforge/plantuml/tim/TContext.java index 68a715cbc..50898cf64 100644 --- a/src/net/sourceforge/plantuml/tim/TContext.java +++ b/src/net/sourceforge/plantuml/tim/TContext.java @@ -86,6 +86,7 @@ import net.sourceforge.plantuml.tim.iterator.CodeIteratorWhile; import net.sourceforge.plantuml.tim.stdlib.AlwaysFalse; import net.sourceforge.plantuml.tim.stdlib.AlwaysTrue; import net.sourceforge.plantuml.tim.stdlib.CallUserFunction; +import net.sourceforge.plantuml.tim.stdlib.Chr; import net.sourceforge.plantuml.tim.stdlib.Darken; import net.sourceforge.plantuml.tim.stdlib.DateFunction; import net.sourceforge.plantuml.tim.stdlib.Dec2hex; @@ -112,6 +113,7 @@ import net.sourceforge.plantuml.tim.stdlib.RetrieveProcedure; import net.sourceforge.plantuml.tim.stdlib.ReverseColor; import net.sourceforge.plantuml.tim.stdlib.ReverseHsluvColor; import net.sourceforge.plantuml.tim.stdlib.SetVariableValue; +import net.sourceforge.plantuml.tim.stdlib.Size; import net.sourceforge.plantuml.tim.stdlib.StringFunction; import net.sourceforge.plantuml.tim.stdlib.Strlen; import net.sourceforge.plantuml.tim.stdlib.Strpos; @@ -175,6 +177,8 @@ public class TContext { functionsSet.addFunction(new Hex2dec()); functionsSet.addFunction(new Dec2hex()); functionsSet.addFunction(new HslColor()); + functionsSet.addFunction(new Chr()); + functionsSet.addFunction(new Size()); // %standard_exists_function // %str_replace // !exit diff --git a/src/net/sourceforge/plantuml/tim/expression/TValue.java b/src/net/sourceforge/plantuml/tim/expression/TValue.java index 0e838939c..cb593229a 100644 --- a/src/net/sourceforge/plantuml/tim/expression/TValue.java +++ b/src/net/sourceforge/plantuml/tim/expression/TValue.java @@ -38,7 +38,7 @@ import java.util.Objects; import net.sourceforge.plantuml.json.JsonValue; -public class TValue { +public final class TValue { private final int intValue; private final String stringValue; @@ -142,6 +142,10 @@ public class TValue { return this.jsonValue != null; } + public boolean isString() { + return this.stringValue != null; + } + public Token toToken() { if (isNumber()) { return new Token(toString(), TokenType.NUMBER, null); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Chr.java b/src/net/sourceforge/plantuml/tim/stdlib/Chr.java new file mode 100644 index 000000000..fd3282084 --- /dev/null +++ b/src/net/sourceforge/plantuml/tim/stdlib/Chr.java @@ -0,0 +1,68 @@ +/* ======================================================================== + * 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.tim.stdlib; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.tim.EaterException; +import net.sourceforge.plantuml.tim.EaterExceptionLocated; +import net.sourceforge.plantuml.tim.TContext; +import net.sourceforge.plantuml.tim.TFunctionSignature; +import net.sourceforge.plantuml.tim.TMemory; +import net.sourceforge.plantuml.tim.expression.TValue; + +public class Chr extends SimpleReturnFunction { + + public TFunctionSignature getSignature() { + return new TFunctionSignature("%chr", 1); + } + + public boolean canCover(int nbArg, Set namedArgument) { + return nbArg == 1; + } + + public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + Map named) throws EaterException, EaterExceptionLocated { + try { + final char value = (char) values.get(0).toInt(); + return TValue.fromString("" + value); + } catch (Throwable t) { + return TValue.fromString("\0"); + } + } +} diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Size.java b/src/net/sourceforge/plantuml/tim/stdlib/Size.java new file mode 100644 index 000000000..49ab5c6c0 --- /dev/null +++ b/src/net/sourceforge/plantuml/tim/stdlib/Size.java @@ -0,0 +1,81 @@ +/* ======================================================================== + * 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.tim.stdlib; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.json.JsonArray; +import net.sourceforge.plantuml.json.JsonObject; +import net.sourceforge.plantuml.json.JsonValue; +import net.sourceforge.plantuml.tim.EaterException; +import net.sourceforge.plantuml.tim.EaterExceptionLocated; +import net.sourceforge.plantuml.tim.TContext; +import net.sourceforge.plantuml.tim.TFunctionSignature; +import net.sourceforge.plantuml.tim.TMemory; +import net.sourceforge.plantuml.tim.expression.TValue; + +public class Size extends SimpleReturnFunction { + + public TFunctionSignature getSignature() { + return new TFunctionSignature("%size", 1); + } + + public boolean canCover(int nbArg, Set namedArgument) { + return nbArg == 1; + } + + public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + Map named) throws EaterException, EaterExceptionLocated { + final TValue value = values.get(0); + if (value.isNumber()) + return TValue.fromInt(0); + if (value.isString()) + return TValue.fromInt(value.toString().length()); + + final JsonValue json = value.toJson(); + if (json instanceof JsonArray) { + final JsonArray array = (JsonArray) json; + return TValue.fromInt(array.size()); + } + if (json instanceof JsonObject) { + final JsonObject object = (JsonObject) json; + return TValue.fromInt(object.size()); + } + return TValue.fromInt(0); + } +} diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 4ae5770a7..0ae1dd2f1 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -80,7 +80,7 @@ public class Version { } public static int beta() { - final int beta = 2; + final int beta = 4; return beta; } diff --git a/src/net/sourceforge/plantuml/vizjs/VizJsEngine.java b/src/net/sourceforge/plantuml/vizjs/VizJsEngine.java index 37be39d5f..f99b72965 100644 --- a/src/net/sourceforge/plantuml/vizjs/VizJsEngine.java +++ b/src/net/sourceforge/plantuml/vizjs/VizJsEngine.java @@ -58,7 +58,6 @@ public class VizJsEngine { final Method mCreate = classVizJS.getMethod("create"); mExecute = classVizJS.getMethod("execute", String.class); this.viz = mCreate.invoke(null); - System.err.println("Creating one engine"); } public String execute(String dot) throws IllegalAccessException, IllegalArgumentException, diff --git a/src/net/sourceforge/plantuml/yaml/YamlDiagramFactory.java b/src/net/sourceforge/plantuml/yaml/YamlDiagramFactory.java index 1173b2975..01c56dd6e 100644 --- a/src/net/sourceforge/plantuml/yaml/YamlDiagramFactory.java +++ b/src/net/sourceforge/plantuml/yaml/YamlDiagramFactory.java @@ -45,6 +45,10 @@ import net.sourceforge.plantuml.command.PSystemAbstractFactory; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.DiagramType; import net.sourceforge.plantuml.core.UmlSource; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositioned; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.jsondiagram.JsonDiagram; import net.sourceforge.plantuml.jsondiagram.StyleExtractor; @@ -62,7 +66,7 @@ public class YamlDiagramFactory extends PSystemAbstractFactory { StyleExtractor styleExtractor = null; try { final List list = new ArrayList<>(); - styleExtractor = new StyleExtractor(source.iteratorRaw(), source.iterator2()); + styleExtractor = new StyleExtractor(source.iterator2()); final Iterator it = styleExtractor.getIterator(); it.next(); while (true) { @@ -83,6 +87,10 @@ public class YamlDiagramFactory extends PSystemAbstractFactory { final JsonDiagram result = new JsonDiagram(source, UmlDiagramType.YAML, yaml, highlighted); if (styleExtractor != null) { styleExtractor.applyStyles(result.getSkinParam()); + final String title = styleExtractor.getTitle(); + if (title != null) + result.setTitle(DisplayPositioned.single(Display.getWithNewlines(title), HorizontalAlignment.CENTER, + VerticalAlignment.CENTER)); } return result; }