mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-22 21:15:09 +00:00
wip
This commit is contained in:
parent
471c71d5ae
commit
5599f8fc82
@ -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() {
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<Gtile> 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<Ftile> 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<Swimlane> getSwimlanes() {
|
||||
final Set<Swimlane> 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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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<Branch> branches = new ArrayList<>();
|
||||
private final List<Branch> 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);
|
||||
}
|
||||
return factory.createSwitch(swimlane, branches, afterEndwhile, topInlinkRendering, labelTest);
|
||||
@Override
|
||||
public Gtile createGtile(ISkinParam skinParam, StringBounder stringBounder) {
|
||||
for (Branch branch : switches)
|
||||
branch.updateGtile(skinParam, stringBounder);
|
||||
|
||||
final List<Gtile> gtiles = new ArrayList<>();
|
||||
final List<Branch> branches = new ArrayList<>();
|
||||
for (Branch branch : switches) {
|
||||
gtiles.add(branch.getGtile());
|
||||
branches.add(branch);
|
||||
}
|
||||
|
||||
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<Swimlane> getSwimlanes() {
|
||||
final Set<Swimlane> 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;
|
||||
}
|
||||
|
||||
|
@ -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<Swimlane> 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();
|
||||
}
|
||||
|
@ -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<TitledDiagram> {
|
||||
@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();
|
||||
}
|
||||
|
||||
|
@ -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<TitledDiagram> {
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
@ -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<TitledDiagram> {
|
||||
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");
|
||||
|
@ -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<TitledDiagram> {
|
||||
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");
|
||||
|
@ -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<TitledDiagram> {
|
||||
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");
|
||||
|
@ -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<TitledDiagram> {
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
@ -149,9 +149,9 @@ final public class UmlSource {
|
||||
return new IteratorCounter2Impl(source);
|
||||
}
|
||||
|
||||
public Iterator<StringLocated> iteratorRaw() {
|
||||
return Collections.unmodifiableCollection(rawSource).iterator();
|
||||
}
|
||||
// public Iterator<StringLocated> iteratorRaw() {
|
||||
// return Collections.unmodifiableCollection(rawSource).iterator();
|
||||
// }
|
||||
|
||||
/**
|
||||
* Return the source as a single String with <code>\n</code> as line separator.
|
||||
|
@ -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() {
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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<String> it = styleExtractor.getIterator();
|
||||
it.next();
|
||||
while (true) {
|
||||
|
@ -50,33 +50,32 @@ public class StyleExtractor {
|
||||
|
||||
private final List<String> list = new ArrayList<>();
|
||||
private final List<StringLocated> style = new ArrayList<>();
|
||||
private String title = null;
|
||||
|
||||
public StyleExtractor(Iterator<StringLocated> dataRaw, Iterator<StringLocated> 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<StringLocated> data) {
|
||||
while (data.hasNext()) {
|
||||
StringLocated line = data.next();
|
||||
if (startStyle(line))
|
||||
if (startStyle(line)) {
|
||||
while (data.hasNext()) {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
68
src/net/sourceforge/plantuml/tim/stdlib/Chr.java
Normal file
68
src/net/sourceforge/plantuml/tim/stdlib/Chr.java
Normal file
@ -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<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
try {
|
||||
final char value = (char) values.get(0).toInt();
|
||||
return TValue.fromString("" + value);
|
||||
} catch (Throwable t) {
|
||||
return TValue.fromString("\0");
|
||||
}
|
||||
}
|
||||
}
|
81
src/net/sourceforge/plantuml/tim/stdlib/Size.java
Normal file
81
src/net/sourceforge/plantuml/tim/stdlib/Size.java
Normal file
@ -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<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> 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);
|
||||
}
|
||||
}
|
@ -80,7 +80,7 @@ public class Version {
|
||||
}
|
||||
|
||||
public static int beta() {
|
||||
final int beta = 2;
|
||||
final int beta = 4;
|
||||
return beta;
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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<String> list = new ArrayList<>();
|
||||
styleExtractor = new StyleExtractor(source.iteratorRaw(), source.iterator2());
|
||||
styleExtractor = new StyleExtractor(source.iterator2());
|
||||
final Iterator<String> 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user