diff --git a/src/net/sourceforge/plantuml/Option.java b/src/net/sourceforge/plantuml/Option.java index 4caeb0700..6334c37d2 100644 --- a/src/net/sourceforge/plantuml/Option.java +++ b/src/net/sourceforge/plantuml/Option.java @@ -60,6 +60,7 @@ public class Option { private final List excludes = new ArrayList<>(); private final List config = new ArrayList<>(); private final Map defines = new LinkedHashMap(); + private String charset; private boolean computeurl = false; private boolean decodeurl = false; @@ -305,6 +306,8 @@ public class Option { manageDefine(s.substring(2)); } else if (s.startsWith("-S")) { manageSkinParam(s.substring(2)); + } else if (s.startsWith("-P")) { + managePragma(s.substring(2)); } else if (s.equalsIgnoreCase("-testdot")) { OptionPrint.printTestDot(); } else if (s.equalsIgnoreCase("-about") || s.equalsIgnoreCase("-author") @@ -318,8 +321,6 @@ public class Option { OptionFlags.getInstance().setGui(true); } else if (s.equalsIgnoreCase("-encodesprite")) { OptionFlags.getInstance().setEncodesprite(true); - // } else if (s.equalsIgnoreCase("-nosuggestengine")) { - // OptionFlags.getInstance().setUseSuggestEngine(false); } else if (s.equalsIgnoreCase("-printfonts")) { OptionFlags.getInstance().setPrintFonts(true); } else if (s.equalsIgnoreCase("-dumphtmlstats")) { @@ -467,21 +468,30 @@ public class Option { } } + private void managePragma(String s) { + final Pattern2 p = MyPattern.cmpile("^(\\w+)(?:=(.*))?$"); + final Matcher2 m = p.matcher(s); + if (m.find()) { + final String var = m.group(1); + final String value = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m.group(2)); + if (var != null && value != null) { + config.add("!pragma " + var + " " + value); + } + } + } + private void manageSkinParam(String s) { final Pattern2 p = MyPattern.cmpile("^(\\w+)(?:=(.*))?$"); final Matcher2 m = p.matcher(s); if (m.find()) { - skinParam(m.group(1), m.group(2)); + final String var = m.group(1); + final String value = m.group(2); + if (var != null && value != null) { + config.add("skinparamlocked " + var + " " + value); + } } } - private void skinParam(String var, String value) { - if (var != null && value != null) { - config.add("skinparamlocked " + var + " " + value); - } - - } - public final File getOutputDir() { return outputDir; } diff --git a/src/net/sourceforge/plantuml/OptionFlags.java b/src/net/sourceforge/plantuml/OptionFlags.java index c8b362f00..36a7091f9 100644 --- a/src/net/sourceforge/plantuml/OptionFlags.java +++ b/src/net/sourceforge/plantuml/OptionFlags.java @@ -122,6 +122,7 @@ public class OptionFlags { private boolean enableStats = defaultForStats(); private boolean stdLib; private boolean silentlyCompletelyIgnoreErrors; + private boolean replaceWhiteBackgroundByTransparent; private boolean extractStdLib; private boolean clipboardLoop; private boolean clipboard; @@ -367,4 +368,12 @@ public class OptionFlags { public final void setSilentlyCompletelyIgnoreErrors(boolean silentlyCompletelyIgnoreErrors) { this.silentlyCompletelyIgnoreErrors = silentlyCompletelyIgnoreErrors; } + + public final boolean isReplaceWhiteBackgroundByTransparent() { + return replaceWhiteBackgroundByTransparent; + } + + public final void setReplaceWhiteBackgroundByTransparent(boolean replaceWhiteBackgroundByTransparent) { + this.replaceWhiteBackgroundByTransparent = replaceWhiteBackgroundByTransparent; + } } diff --git a/src/net/sourceforge/plantuml/OptionPrint.java b/src/net/sourceforge/plantuml/OptionPrint.java index e45fe88a7..6e616c9fc 100644 --- a/src/net/sourceforge/plantuml/OptionPrint.java +++ b/src/net/sourceforge/plantuml/OptionPrint.java @@ -101,6 +101,7 @@ public class OptionPrint { System.out.println(" -o[utput] \"dir\"\tTo generate images in the specified directory"); System.out.println(" -DVAR1=value\tTo set a preprocessing variable as if '!define VAR1 value' were used"); System.out.println(" -Sparam1=value\tTo set a skin parameter as if 'skinparam param1 value' were used"); + System.out.println(" -Ppragma1=value\tTo set pragma as if '!pragma pragma1 value' were used"); // System.out.println(" -config \"file\"\tTo read the provided config file // before each diagram"); final char separator = SFile.separatorChar; diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index 4eb53b8af..6b2f5238b 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -46,8 +46,11 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.net.URL; +import java.time.Month; +import java.time.format.TextStyle; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; @@ -83,6 +86,10 @@ public class Run { if (argsArray.length > 0 && argsArray[0].equalsIgnoreCase("-headless")) { System.setProperty("java.awt.headless", "true"); } + if (argsArray.length > 0 && argsArray[0].equalsIgnoreCase("--de")) { + debugGantt(); + return; + } saveCommandLine(argsArray); final Option option = new Option(argsArray); ProgressBar.setEnable(option.isTextProgressBar()); @@ -577,4 +584,16 @@ public class Run { error.goOk(); } + public static void debugGantt() { + final Locale locale = Locale.GERMAN; + for (java.time.Month month : java.time.Month.values()) { + System.err.println("Testing locale " + locale + " " + month); + for (TextStyle style : TextStyle.values()) { + final String s = month.getDisplayName(style, locale); + System.err.println(style + " --> '" + s + "'"); + + } + } + } + } diff --git a/src/net/sourceforge/plantuml/SourceFileReaderAbstract.java b/src/net/sourceforge/plantuml/SourceFileReaderAbstract.java index 86f7074e0..5ab5cf6ca 100644 --- a/src/net/sourceforge/plantuml/SourceFileReaderAbstract.java +++ b/src/net/sourceforge/plantuml/SourceFileReaderAbstract.java @@ -151,7 +151,7 @@ public abstract class SourceFileReaderAbstract implements ISourceFileReader { system = blockUml.getDiagram(); } catch (Throwable t) { t.printStackTrace(); - if (OptionFlags.getInstance().isSilentlyCompletelyIgnoreErrors()) { + if (OptionFlags.getInstance().isSilentlyCompletelyIgnoreErrors() || noerror) { continue; } return getCrashedImage(blockUml, t, suggested.getFile(0)); @@ -163,7 +163,7 @@ public abstract class SourceFileReaderAbstract implements ISourceFileReader { OptionFlags.getInstance().logData(SFile.fromFile(file), system); final List exportDiagrams; - if (noerror) { + if (noerror && system instanceof PSystemError) { exportDiagrams = new ArrayList(); exportDiagrams.add( new FileImageData(null, new ImageDataSimple(new Dimension2DDouble(0, 0), FileImageData.ERROR))); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java index a8a25e86e..5faf9be9f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java @@ -108,16 +108,22 @@ public class ActivityDiagram3 extends UmlDiagram { return swinlanes.nextLinkRenderer(); } - public void addActivity(Display activity, BoxStyle style, Url url, Colors colors, Stereotype stereotype) { + public CommandExecutionResult addActivity(Display activity, BoxStyle style, Url url, Colors colors, + Stereotype stereotype) { manageSwimlaneStrategy(); final InstructionSimple ins = new InstructionSimple(activity, nextLinkRenderer(), swinlanes.getCurrentSwimlane(), style, url, colors, stereotype); - current().add(ins); + final CommandExecutionResult added = current().add(ins); + if (added.isOk() == false) { + return added; + } setNextLinkRendererInternal(LinkRendering.none()); manageHasUrl(activity); if (url != null) { hasUrl = true; } + return CommandExecutionResult.ok(); + } public void addSpot(String spot, HColor color) { @@ -205,9 +211,7 @@ public class ActivityDiagram3 extends UmlDiagram { result = CompressionXorYBuilder.build(CompressionMode.ON_Y, result, stringBounder); result = new TextBlockRecentred(result); - return createImageBuilder(fileFormatOption) - .drawable(result) - .write(os); + return createImageBuilder(fileFormatOption).drawable(result).write(os); } public void fork() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/Branch.java b/src/net/sourceforge/plantuml/activitydiagram3/Branch.java index 79da03e21..7c09ef19f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/Branch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/Branch.java @@ -44,6 +44,7 @@ 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.WeldingPoint; +import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.color.Colors; @@ -105,8 +106,9 @@ public class Branch { return ftile.getWeldingPoints(); } - public void add(Instruction ins) { + public CommandExecutionResult add(Instruction ins) { list.add(ins); + return CommandExecutionResult.ok(); } public boolean kill() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/Instruction.java b/src/net/sourceforge/plantuml/activitydiagram3/Instruction.java index c3f3055a4..aa85025d3 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/Instruction.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/Instruction.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimable; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; @@ -48,7 +49,7 @@ public interface Instruction extends Swimable { public Ftile createFtile(FtileFactory factory); - public void add(Instruction other); + public CommandExecutionResult add(Instruction other); public boolean kill(); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionBreak.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionBreak.java index 211b407f2..0006a72b2 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionBreak.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionBreak.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileBreak; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.command.CommandExecutionResult; public class InstructionBreak extends MonoSwimable implements Instruction { @@ -55,7 +56,7 @@ public class InstructionBreak extends MonoSwimable implements Instruction { return new FtileBreak(factory.skinParam(), getSwimlaneIn()); } - public void add(Instruction other) { + public CommandExecutionResult add(Instruction other) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionEnd.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionEnd.java index c2b8bd119..a80106c95 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionEnd.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionEnd.java @@ -40,6 +40,7 @@ import java.util.Objects; 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.command.CommandExecutionResult; public class InstructionEnd extends MonoSwimable implements Instruction { @@ -56,7 +57,7 @@ public class InstructionEnd extends MonoSwimable implements Instruction { return result; } - public void add(Instruction other) { + public CommandExecutionResult add(Instruction other) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java index 68635fece..45a1724dd 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java @@ -46,6 +46,7 @@ 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.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; @@ -85,8 +86,8 @@ public class InstructionFork extends WithNote implements Instruction { return forks.get(forks.size() - 1); } - public void add(Instruction ins) { - getLastList().add(ins); + public CommandExecutionResult add(Instruction ins) { + return getLastList().add(ins); } public Ftile createFtile(FtileFactory factory) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionGoto.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGoto.java index 2a99e0c8b..48a8e3eba 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionGoto.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGoto.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGoto; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.command.CommandExecutionResult; public class InstructionGoto extends MonoSwimable implements Instruction { @@ -53,7 +54,7 @@ public class InstructionGoto extends MonoSwimable implements Instruction { return new FtileGoto(factory.skinParam(), getSwimlaneIn(), name); } - public void add(Instruction other) { + public CommandExecutionResult add(Instruction other) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java index 4848679a9..f64e06a97 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java @@ -42,6 +42,7 @@ 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.FtileWithNotes; +import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.color.Colors; @@ -80,8 +81,8 @@ public class InstructionGroup implements Instruction, InstructionCollection { this.roundCorner = roundCorner; } - public void add(Instruction ins) { - list.add(ins); + public CommandExecutionResult add(Instruction ins) { + return list.add(ins); } public Ftile createFtile(FtileFactory factory) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java index ad908f6bc..d751d5155 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java @@ -50,6 +50,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; 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.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; @@ -96,8 +97,8 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC this.current = this.thens.get(0); } - public void add(Instruction ins) { - current.add(ins); + public CommandExecutionResult add(Instruction ins) { + return current.add(ins); } public Ftile createFtile(FtileFactory factory) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionLabel.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionLabel.java index 9e89802f6..a1707f0dd 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionLabel.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionLabel.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileLabel; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.command.CommandExecutionResult; public class InstructionLabel extends MonoSwimable implements Instruction { @@ -53,7 +54,7 @@ public class InstructionLabel extends MonoSwimable implements Instruction { return new FtileLabel(factory.skinParam(), getSwimlaneIn(), name); } - public void add(Instruction other) { + public CommandExecutionResult add(Instruction other) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java index f30dcec79..69d5835bd 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java @@ -47,6 +47,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileEmpty; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint; +import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; @@ -88,8 +89,9 @@ public class InstructionList extends WithNote implements Instruction, Instructio this.defaultSwimlane = defaultSwimlane; } - public void add(Instruction ins) { + public CommandExecutionResult add(Instruction ins) { all.add(ins); + return CommandExecutionResult.ok(); } public Ftile createFtile(FtileFactory factory) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionPartition.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionPartition.java index 9d3917a1a..b847e8c7c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionPartition.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionPartition.java @@ -40,6 +40,7 @@ import java.util.Set; 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.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; @@ -74,8 +75,8 @@ public class InstructionPartition implements Instruction { return list.createFtile(factory); } - public void add(Instruction other) { - list.add(other); + public CommandExecutionResult add(Instruction other) { + return list.add(other); } public boolean kill() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java index b66fbac06..19d356e4d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; 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.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; @@ -111,8 +112,8 @@ public class InstructionRepeat implements Instruction { return this.backward != Display.NULL; } - public void add(Instruction ins) { - repeatList.add(ins); + public CommandExecutionResult add(Instruction ins) { + return repeatList.add(ins); } public Ftile createFtile(FtileFactory factory) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java index e3e5713f3..18e2a70ab 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; 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.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.color.Colors; @@ -84,7 +85,7 @@ public class InstructionSimple extends MonoSwimable implements Instruction { return result; } - public void add(Instruction other) { + public CommandExecutionResult add(Instruction other) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java index e59b06970..8818d0b8e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java @@ -43,6 +43,7 @@ import java.util.Set; 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.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; @@ -77,8 +78,8 @@ public class InstructionSplit implements Instruction { return splits.get(splits.size() - 1); } - public void add(Instruction ins) { - getLast().add(ins); + public CommandExecutionResult add(Instruction ins) { + return getLast().add(ins); } public Ftile createFtile(FtileFactory factory) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSpot.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSpot.java index 65c886092..030e47ec6 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSpot.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSpot.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; 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.command.CommandExecutionResult; import net.sourceforge.plantuml.ugraphic.color.HColor; public class InstructionSpot extends MonoSwimable implements Instruction { @@ -70,7 +71,7 @@ public class InstructionSpot extends MonoSwimable implements Instruction { return result; } - public void add(Instruction other) { + public CommandExecutionResult add(Instruction other) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionStart.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionStart.java index 5ee416369..39b7e8325 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionStart.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionStart.java @@ -40,6 +40,7 @@ import java.util.Objects; 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.command.CommandExecutionResult; public class InstructionStart extends MonoSwimable implements Instruction { @@ -61,7 +62,7 @@ public class InstructionStart extends MonoSwimable implements Instruction { return result; } - public void add(Instruction other) { + public CommandExecutionResult add(Instruction other) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java index 5533e84de..2e38e731a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java @@ -40,6 +40,7 @@ import java.util.Objects; 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.command.CommandExecutionResult; public class InstructionStop extends MonoSwimable implements Instruction { @@ -61,7 +62,7 @@ public class InstructionStop extends MonoSwimable implements Instruction { return result; } - public void add(Instruction other) { + public CommandExecutionResult add(Instruction other) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java index d841bdc65..ad7a01778 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java @@ -46,6 +46,7 @@ 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.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; @@ -84,27 +85,18 @@ public class InstructionSwitch extends WithNote implements Instruction, Instruct this.swimlane = swimlane; } - public void add(Instruction ins) { - current.add(ins); + public CommandExecutionResult add(Instruction ins) { + if (current == null) { + return CommandExecutionResult.error("No 'case' in this switch"); + } + return current.add(ins); } public Ftile createFtile(FtileFactory factory) { for (Branch branch : branches) { branch.updateFtile(factory); } - Ftile result = factory.createSwitch(swimlane, branches, afterEndwhile, topInlinkRendering, labelTest); - // if (getPositionedNotes().size() > 0) { - // result = FtileWithNoteOpale.create(result, getPositionedNotes(), skinParam, - // false); - // } - // final List weldingPoints = new ArrayList<>(); - // for (Branch branch : branches) { - // weldingPoints.addAll(branch.getWeldingPoints()); - // } - // if (weldingPoints.size() > 0) { - // result = new FtileDecorateWelding(result, weldingPoints); - // } - return result; + return factory.createSwitch(swimlane, branches, afterEndwhile, topInlinkRendering, labelTest); } final public boolean kill() { @@ -154,7 +146,7 @@ public class InstructionSwitch extends WithNote implements Instruction, Instruct // TODO Auto-generated method stub } - + @Override public boolean addNote(Display note, NotePosition position, NoteType type, Colors colors, Swimlane swimlaneNote) { if (current.isEmpty()) { @@ -164,9 +156,4 @@ public class InstructionSwitch extends WithNote implements Instruction, Instruct } } - - // public void afterEndwhile(LinkRendering linkRenderer) { - // this.afterEndwhile = linkRenderer; - // } - } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java index fd4f3ee48..11acd4510 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java @@ -45,6 +45,7 @@ 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.command.CommandExecutionResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.color.Colors; @@ -93,8 +94,8 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi this.skinParam = skinParam; } - public void add(Instruction ins) { - repeatList.add(ins); + public CommandExecutionResult add(Instruction ins) { + return repeatList.add(ins); } public Ftile createFtile(FtileFactory factory) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java index 8a8e98b13..1974bcc4e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java @@ -123,8 +123,7 @@ public class CommandActivity3 extends SingleLineCommand2 { } final BoxStyle style = BoxStyle.fromChar(arg.get("STYLE", 0).charAt(0)); final Display display = Display.getWithNewlines2(arg.get("LABEL", 0)); - diagram.addActivity(display, style, url, colors, stereotype); - return CommandExecutionResult.ok(); + return diagram.addActivity(display, style, url, colors, stereotype); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLegacy1.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLegacy1.java index a7f651c2b..cf692675f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLegacy1.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLegacy1.java @@ -62,8 +62,7 @@ public class CommandActivityLegacy1 extends SingleLineCommand2 @Override protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { - diagram.addActivity(Display.getWithNewlines(arg.get("LABEL", 0)), BoxStyle.PLAIN, null, Colors.empty(), null); - return CommandExecutionResult.ok(); + return diagram.addActivity(Display.getWithNewlines(arg.get("LABEL", 0)), BoxStyle.PLAIN, null, Colors.empty(), null); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java index c5223ad8a..7fd7735fd 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java @@ -84,7 +84,6 @@ public class CommandActivityLong3 extends CommandMultilines2 { // 0)); final BoxStyle style = BoxStyle.fromChar(lines.getLastChar()); lines = lines.removeStartingAndEnding(line0.get("DATA", 0), 1); - diagram.addActivity(lines.toDisplay(), style, null, colors, null); - return CommandExecutionResult.ok(); + return diagram.addActivity(lines.toDisplay(), style, null, colors, null); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java index 0f154a59a..a3e919c4f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java @@ -69,6 +69,7 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; @@ -82,10 +83,9 @@ import net.sourceforge.plantuml.ugraphic.color.HColorNone; public class FtileBox extends AbstractFtile { - private double padding1 = 10; - private double padding2 = 10; - private double paddingTop = 10; - private double paddingBottom = 10; + private final ClockwiseTopRightBottomLeft padding; + private final ClockwiseTopRightBottomLeft margin; + private final TextBlock tb; private double roundCorner = 25; private final double shadowing; @@ -130,12 +130,12 @@ public class FtileBox extends AbstractFtile { class MyStencil implements Stencil { public double getStartingX(StringBounder stringBounder, double y) { - return -padding1; + return -padding.getLeft(); } public double getEndingX(StringBounder stringBounder, double y) { final Dimension2D dim = calculateDimension(stringBounder); - return dim.getWidth() - padding2; + return dim.getWidth() - padding.getRight(); } } @@ -152,31 +152,31 @@ public class FtileBox extends AbstractFtile { return new FtileBox(skinParam, label, swimlane, boxStyle, style, styleArrow); } - public static FtileBox createWbs(StyleBuilder styleBuilder, ISkinParam skinParam, Display label, - StyleSignature styleDefinition) { - Style style = null; - Style styleArrow = null; - if (UseStyle.useBetaStyle()) { - style = styleDefinition.getMergedStyle(styleBuilder); - styleArrow = style; - } - return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); - } - - public static FtileBox createWbs(Style style, ISkinParam skinParam, Display label) { - Style styleArrow = null; - if (UseStyle.useBetaStyle()) { - styleArrow = style; - } - return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); - } - - public static FtileBox createMindMap(StyleBuilder styleBuilder, ISkinParam skinParam, Display label, - StyleSignature styleDefinition) { - final Style style = styleDefinition.getMergedStyle(styleBuilder); - final Style styleArrow = style; - return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); - } +// public static TextBlock createWbs(StyleBuilder styleBuilder, ISkinParam skinParam, Display label, +// StyleSignature styleDefinition) { +// Style style = null; +// Style styleArrow = null; +// if (UseStyle.useBetaStyle()) { +// style = styleDefinition.getMergedStyle(styleBuilder); +// styleArrow = style; +// } +// return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); +// } +// +// public static TextBlock createWbs(Style style, ISkinParam skinParam, Display label) { +// Style styleArrow = null; +// if (UseStyle.useBetaStyle()) { +// styleArrow = style; +// } +// return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); +// } +// +// public static TextBlock createMindMap(StyleBuilder styleBuilder, ISkinParam skinParam, Display label, +// StyleSignature styleDefinition) { +// final Style style = styleDefinition.getMergedStyle(styleBuilder); +// final Style styleArrow = style; +// return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); +// } private FtileBox(ISkinParam skinParam, Display label, Swimlane swimlane, BoxStyle boxStyle, Style style, Style styleArrow) { @@ -197,21 +197,21 @@ public class FtileBox extends AbstractFtile { this.borderColor = style.value(PName.LineColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet()); this.backColor = style.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet()); fc = style.getFontConfiguration(skinParam.getThemeStyle(), getIHtmlColorSet()); - horizontalAlignment = style.getHorizontalAlignment(); - this.padding1 = style.getPadding().getLeft(); - this.padding2 = style.getPadding().getRight(); - this.paddingTop = style.getPadding().getTop(); - this.paddingBottom = style.getPadding().getBottom(); + this.horizontalAlignment = style.getHorizontalAlignment(); + this.padding = style.getPadding(); + this.margin = style.getMargin(); this.roundCorner = style.value(PName.RoundCorner).asDouble(); this.shadowing = style.value(PName.Shadowing).asDouble(); wrapWidth = style.wrapWidth(); this.minimumWidth = style.value(PName.MinimumWidth).asDouble(); } else { + this.padding = ClockwiseTopRightBottomLeft.same(10); + this.margin = ClockwiseTopRightBottomLeft.same(0); this.inRendering = new LinkRendering(Rainbow.build(skinParam)); this.borderColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBorder); this.backColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBackground); fc = new FontConfiguration(skinParam, FontParam.ACTIVITY, null); - horizontalAlignment = HorizontalAlignment.LEFT; + this.horizontalAlignment = HorizontalAlignment.LEFT; this.shadowing = skinParam().shadowing(null) ? 3.0 : 0.0; wrapWidth = skinParam.wrapWidth(); @@ -260,23 +260,25 @@ public class FtileBox extends AbstractFtile { shape.drawU(ug); if (horizontalAlignment == HorizontalAlignment.LEFT) { - tb.drawU(ug.apply(new UTranslate(padding1, paddingTop))); + tb.drawU(ug.apply(new UTranslate(padding.getLeft(), padding.getTop()))); } else if (horizontalAlignment == HorizontalAlignment.RIGHT) { final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); - tb.drawU(ug.apply(new UTranslate(dimTotal.getWidth() - dimTb.getWidth() - padding2, paddingBottom))); + tb.drawU(ug.apply( + new UTranslate(dimTotal.getWidth() - dimTb.getWidth() - padding.getRight(), padding.getBottom()))); } else if (horizontalAlignment == HorizontalAlignment.CENTER) { final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); - tb.drawU(ug.apply(new UTranslate((dimTotal.getWidth() - dimTb.getWidth()) / 2, paddingBottom))); + tb.drawU(ug.apply(new UTranslate((dimTotal.getWidth() - dimTb.getWidth()) / 2, padding.getBottom()))); } } @Override protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder) { - Dimension2D dim = tb.calculateDimension(stringBounder); - dim = Dimension2DDouble.delta(dim, padding1 + padding2, paddingBottom + paddingTop); - dim = Dimension2DDouble.atLeast(dim, minimumWidth, 0); - return new FtileGeometry(dim.getWidth() + boxStyle.getShield(), dim.getHeight(), dim.getWidth() / 2, 0, - dim.getHeight()); + Dimension2D dimRaw = tb.calculateDimension(stringBounder); + dimRaw = Dimension2DDouble.delta(dimRaw, padding.getLeft() + padding.getRight(), + padding.getBottom() + padding.getTop()); + dimRaw = Dimension2DDouble.atLeast(dimRaw, minimumWidth, 0); + return new FtileGeometry(dimRaw.getWidth() + boxStyle.getShield(), dimRaw.getHeight(), dimRaw.getWidth() / 2, 0, + dimRaw.getHeight()); } public Collection getMyChildren() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox2.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox2.java new file mode 100644 index 000000000..a4172342f --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox2.java @@ -0,0 +1,273 @@ +/* ======================================================================== + * 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.activitydiagram3.ftile.vertical; + +import java.awt.geom.Dimension2D; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; + +import net.sourceforge.plantuml.ColorParam; +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.SkinParamColors; +import net.sourceforge.plantuml.SkinParamUtils; +import net.sourceforge.plantuml.UseStyle; +import net.sourceforge.plantuml.activitydiagram3.LinkRendering; +import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; +import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; +import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.creole.Parser; +import net.sourceforge.plantuml.creole.Sheet; +import net.sourceforge.plantuml.creole.SheetBlock1; +import net.sourceforge.plantuml.creole.SheetBlock2; +import net.sourceforge.plantuml.creole.Stencil; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.Stereotype; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleBuilder; +import net.sourceforge.plantuml.style.StyleSignature; +import net.sourceforge.plantuml.ugraphic.UEmpty; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.HColorNone; + +public class FtileBox2 extends AbstractFtile { + + private final ClockwiseTopRightBottomLeft padding; + private final ClockwiseTopRightBottomLeft margin; + + private final TextBlock tb; + private double roundCorner = 25; + private final double shadowing; + private final HorizontalAlignment horizontalAlignment; + private double minimumWidth = 0; + + private final LinkRendering inRendering; + private final Swimlane swimlane; + private final BoxStyle boxStyle; + + private final HColor borderColor; + private final HColor backColor; + private final Style style; + + static public StyleSignature getDefaultStyleDefinitionActivity() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity); + } + + static public StyleSignature getDefaultStyleDefinitionArrow() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow); + } + + final public LinkRendering getInLinkRendering() { + return inRendering; + } + + public Set getSwimlanes() { + if (swimlane == null) { + return Collections.emptySet(); + } + return Collections.singleton(swimlane); + } + + public Swimlane getSwimlaneIn() { + return swimlane; + } + + public Swimlane getSwimlaneOut() { + return swimlane; + } + + class MyStencil implements Stencil { + + public double getStartingX(StringBounder stringBounder, double y) { + return -padding.getLeft(); + } + + public double getEndingX(StringBounder stringBounder, double y) { + final Dimension2D dim = calculateDimension(stringBounder); + return dim.getWidth() - padding.getRight(); + } + + } + + public static FtileBox2 create(ISkinParam skinParam, Display label, Swimlane swimlane, BoxStyle boxStyle, + Stereotype stereotype) { + Style style = null; + Style styleArrow = null; + if (UseStyle.useBetaStyle()) { + style = getDefaultStyleDefinitionActivity().with(stereotype) + .getMergedStyle(skinParam.getCurrentStyleBuilder()); + styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam.getCurrentStyleBuilder()); + } + return new FtileBox2(skinParam, label, swimlane, boxStyle, style, styleArrow); + } + + private FtileBox2(ISkinParam skinParam, Display label, Swimlane swimlane, BoxStyle boxStyle, Style style, + Style styleArrow) { + super(skinParam); + this.style = style; + this.boxStyle = boxStyle; + this.swimlane = swimlane; + final FontConfiguration fc; + final LineBreakStrategy wrapWidth; + if (UseStyle.useBetaStyle()) { + this.inRendering = new LinkRendering( + Rainbow.build(styleArrow, getIHtmlColorSet(), skinParam.getThemeStyle())); + Colors specBack = null; + if (skinParam instanceof SkinParamColors) { + specBack = ((SkinParamColors) skinParam).getColors(); + } + style = style.eventuallyOverride(specBack); + this.borderColor = style.value(PName.LineColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet()); + this.backColor = style.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet()); + fc = style.getFontConfiguration(skinParam.getThemeStyle(), getIHtmlColorSet()); + this.horizontalAlignment = style.getHorizontalAlignment(); + this.padding = style.getPadding(); + this.margin = style.getMargin(); + this.roundCorner = style.value(PName.RoundCorner).asDouble(); + this.shadowing = style.value(PName.Shadowing).asDouble(); + wrapWidth = style.wrapWidth(); + this.minimumWidth = style.value(PName.MinimumWidth).asDouble(); + } else { + this.padding = ClockwiseTopRightBottomLeft.same(10); + this.margin = ClockwiseTopRightBottomLeft.same(0); + this.inRendering = new LinkRendering(Rainbow.build(skinParam)); + this.borderColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBorder); + this.backColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBackground); + fc = new FontConfiguration(skinParam, FontParam.ACTIVITY, null); + this.horizontalAlignment = HorizontalAlignment.LEFT; + this.shadowing = skinParam().shadowing(null) ? 3.0 : 0.0; + wrapWidth = skinParam.wrapWidth(); + + } + final Sheet sheet = Parser + .build(fc, skinParam.getDefaultTextAlignment(horizontalAlignment), skinParam, CreoleMode.FULL) + .createSheet(label); + this.tb = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, skinParam.getPadding()), new MyStencil(), + new UStroke(1)); + this.print = label.toString(); + + } + + final private String print; + + @Override + public String toString() { + return print; + } + + public void drawU(UGraphic ug) { + final Dimension2D dimRaw = getDimRaw(ug.getStringBounder()); + final double widthTotal = dimRaw.getWidth(); + final double heightTotal = dimRaw.getHeight(); + final UDrawable shape = boxStyle.getUDrawable(widthTotal, heightTotal, shadowing, roundCorner); + + final Dimension2D dimTotal = calculateDimension(ug.getStringBounder()); + ug.draw(new UEmpty(dimTotal)); + + final UStroke thickness; + if (UseStyle.useBetaStyle()) { + thickness = style.getStroke(); + } else { + thickness = getThickness(); + } + + if (borderColor == null) { + ug = ug.apply(new HColorNone()); + } else { + ug = ug.apply(borderColor); + } + if (backColor == null) { + ug = ug.apply(new HColorNone().bg()); + } else { + ug = ug.apply(backColor.bg()); + } + + ug = ug.apply(thickness); + ug = ug.apply(new UTranslate(margin.getLeft(), margin.getTop())); + shape.drawU(ug); + + if (horizontalAlignment == HorizontalAlignment.LEFT) { + tb.drawU(ug.apply(new UTranslate(padding.getLeft(), padding.getTop()))); + } else if (horizontalAlignment == HorizontalAlignment.RIGHT) { + final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); + tb.drawU(ug.apply( + new UTranslate(dimRaw.getWidth() - dimTb.getWidth() - padding.getRight(), padding.getBottom()))); + } else if (horizontalAlignment == HorizontalAlignment.CENTER) { + final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); + tb.drawU(ug.apply(new UTranslate((dimRaw.getWidth() - dimTb.getWidth()) / 2, padding.getBottom()))); + } + } + + @Override + protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder) { + Dimension2D dimRaw = getDimRaw(stringBounder); + return new FtileGeometry(dimRaw.getWidth() + margin.getLeft() + margin.getRight(), + dimRaw.getHeight() + margin.getTop() + margin.getBottom(), margin.getLeft() + dimRaw.getWidth() / 2, + margin.getTop(), margin.getTop() + dimRaw.getHeight()); + } + + private Dimension2D getDimRaw(StringBounder stringBounder) { + Dimension2D dimRaw = tb.calculateDimension(stringBounder); + dimRaw = Dimension2DDouble.delta(dimRaw, padding.getLeft() + padding.getRight() + boxStyle.getShield(), + padding.getBottom() + padding.getTop()); + dimRaw = Dimension2DDouble.atLeast(dimRaw, minimumWidth, 0); + return dimRaw; + } + + public Collection getMyChildren() { + return Collections.emptyList(); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBoxOld.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBoxOld.java new file mode 100644 index 000000000..fc7d9e43a --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBoxOld.java @@ -0,0 +1,285 @@ +/* ======================================================================== + * 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.activitydiagram3.ftile.vertical; + +import java.awt.geom.Dimension2D; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; + +import net.sourceforge.plantuml.ColorParam; +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.SkinParamColors; +import net.sourceforge.plantuml.SkinParamUtils; +import net.sourceforge.plantuml.UseStyle; +import net.sourceforge.plantuml.activitydiagram3.LinkRendering; +import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; +import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; +import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; +import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; +import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.creole.Parser; +import net.sourceforge.plantuml.creole.Sheet; +import net.sourceforge.plantuml.creole.SheetBlock1; +import net.sourceforge.plantuml.creole.SheetBlock2; +import net.sourceforge.plantuml.creole.Stencil; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.Stereotype; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleBuilder; +import net.sourceforge.plantuml.style.StyleSignature; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.HColorNone; + +public class FtileBoxOld extends AbstractFtile { + + private final ClockwiseTopRightBottomLeft padding; + + private final TextBlock tb; + private double roundCorner = 25; + private final double shadowing; + private final HorizontalAlignment horizontalAlignment; + private double minimumWidth = 0; + + private final LinkRendering inRendering; + private final Swimlane swimlane; + private final BoxStyle boxStyle; + + private final HColor borderColor; + private final HColor backColor; + private final Style style; + + static public StyleSignature getDefaultStyleDefinitionActivity() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity); + } + + static public StyleSignature getDefaultStyleDefinitionArrow() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow); + } + + final public LinkRendering getInLinkRendering() { + return inRendering; + } + + public Set getSwimlanes() { + if (swimlane == null) { + return Collections.emptySet(); + } + return Collections.singleton(swimlane); + } + + public Swimlane getSwimlaneIn() { + return swimlane; + } + + public Swimlane getSwimlaneOut() { + return swimlane; + } + + class MyStencil implements Stencil { + + public double getStartingX(StringBounder stringBounder, double y) { + return -padding.getLeft(); + } + + public double getEndingX(StringBounder stringBounder, double y) { + final Dimension2D dim = calculateDimension(stringBounder); + return dim.getWidth() - padding.getRight(); + } + + } + + public static FtileBoxOld create(ISkinParam skinParam, Display label, Swimlane swimlane, BoxStyle boxStyle, + Stereotype stereotype) { + Style style = null; + Style styleArrow = null; + if (UseStyle.useBetaStyle()) { + style = getDefaultStyleDefinitionActivity().with(stereotype) + .getMergedStyle(skinParam.getCurrentStyleBuilder()); + styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam.getCurrentStyleBuilder()); + } + return new FtileBoxOld(skinParam, label, swimlane, boxStyle, style, styleArrow); + } + + public static TextBlock createWbs(StyleBuilder styleBuilder, ISkinParam skinParam, Display label, + StyleSignature styleDefinition) { + Style style = null; + Style styleArrow = null; + if (UseStyle.useBetaStyle()) { + style = styleDefinition.getMergedStyle(styleBuilder); + styleArrow = style; + } + return new FtileBoxOld(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); + } + + public static TextBlock createWbs(Style style, ISkinParam skinParam, Display label) { + Style styleArrow = null; + if (UseStyle.useBetaStyle()) { + styleArrow = style; + } + return new FtileBoxOld(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); + } + + public static TextBlock createMindMap(StyleBuilder styleBuilder, ISkinParam skinParam, Display label, + StyleSignature styleDefinition) { + final Style style = styleDefinition.getMergedStyle(styleBuilder); + final Style styleArrow = style; + return new FtileBoxOld(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); + } + + private FtileBoxOld(ISkinParam skinParam, Display label, Swimlane swimlane, BoxStyle boxStyle, Style style, + Style styleArrow) { + super(skinParam); + this.style = style; + this.boxStyle = boxStyle; + this.swimlane = swimlane; + final FontConfiguration fc; + final LineBreakStrategy wrapWidth; + if (UseStyle.useBetaStyle()) { + this.inRendering = new LinkRendering( + Rainbow.build(styleArrow, getIHtmlColorSet(), skinParam.getThemeStyle())); + Colors specBack = null; + if (skinParam instanceof SkinParamColors) { + specBack = ((SkinParamColors) skinParam).getColors(); + } + style = style.eventuallyOverride(specBack); + this.borderColor = style.value(PName.LineColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet()); + this.backColor = style.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet()); + fc = style.getFontConfiguration(skinParam.getThemeStyle(), getIHtmlColorSet()); + this.horizontalAlignment = style.getHorizontalAlignment(); + this.padding = style.getPadding(); + this.roundCorner = style.value(PName.RoundCorner).asDouble(); + this.shadowing = style.value(PName.Shadowing).asDouble(); + wrapWidth = style.wrapWidth(); + this.minimumWidth = style.value(PName.MinimumWidth).asDouble(); + } else { + this.padding = ClockwiseTopRightBottomLeft.same(10); + this.inRendering = new LinkRendering(Rainbow.build(skinParam)); + this.borderColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBorder); + this.backColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBackground); + fc = new FontConfiguration(skinParam, FontParam.ACTIVITY, null); + this.horizontalAlignment = HorizontalAlignment.LEFT; + this.shadowing = skinParam().shadowing(null) ? 3.0 : 0.0; + wrapWidth = skinParam.wrapWidth(); + + } + final Sheet sheet = Parser + .build(fc, skinParam.getDefaultTextAlignment(horizontalAlignment), skinParam, CreoleMode.FULL) + .createSheet(label); + this.tb = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, skinParam.getPadding()), new MyStencil(), + new UStroke(1)); + this.print = label.toString(); + + } + + final private String print; + + @Override + public String toString() { + return print; + } + + public void drawU(UGraphic ug) { + final Dimension2D dimTotal = calculateDimension(ug.getStringBounder()); + final double widthTotal = dimTotal.getWidth(); + final double heightTotal = dimTotal.getHeight(); + final UDrawable shape = boxStyle.getUDrawable(widthTotal, heightTotal, shadowing, roundCorner); + + final UStroke thickness; + if (UseStyle.useBetaStyle()) { + thickness = style.getStroke(); + } else { + thickness = getThickness(); + } + + if (borderColor == null) { + ug = ug.apply(new HColorNone()); + } else { + ug = ug.apply(borderColor); + } + if (backColor == null) { + ug = ug.apply(new HColorNone().bg()); + } else { + ug = ug.apply(backColor.bg()); + } + + ug = ug.apply(thickness); + shape.drawU(ug); + + if (horizontalAlignment == HorizontalAlignment.LEFT) { + tb.drawU(ug.apply(new UTranslate(padding.getLeft(), padding.getTop()))); + } else if (horizontalAlignment == HorizontalAlignment.RIGHT) { + final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); + tb.drawU(ug.apply( + new UTranslate(dimTotal.getWidth() - dimTb.getWidth() - padding.getRight(), padding.getBottom()))); + } else if (horizontalAlignment == HorizontalAlignment.CENTER) { + final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); + tb.drawU(ug.apply(new UTranslate((dimTotal.getWidth() - dimTb.getWidth()) / 2, padding.getBottom()))); + } + } + + @Override + protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder) { + Dimension2D dimRaw = tb.calculateDimension(stringBounder); + dimRaw = Dimension2DDouble.delta(dimRaw, padding.getLeft() + padding.getRight(), + padding.getBottom() + padding.getTop()); + dimRaw = Dimension2DDouble.atLeast(dimRaw, minimumWidth, 0); + return new FtileGeometry(dimRaw.getWidth() + boxStyle.getShield(), dimRaw.getHeight(), dimRaw.getWidth() / 2, 0, + dimRaw.getHeight()); + } + + public Collection getMyChildren() { + return Collections.emptyList(); + } + +} diff --git a/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java index 13c471788..280c7e902 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java +++ b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java @@ -40,6 +40,7 @@ import java.awt.geom.Rectangle2D; import java.util.Map; import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.EmbeddedDiagram; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Url; @@ -185,9 +186,12 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlock, return new TextBlockTracer(m, bloc); } - TextBlock bloc = Display.getWithNewlines(cs.toString()).create8(config, align, skinParam, - CreoleMode.SIMPLE_LINE, skinParam.wrapWidth()); - return bloc; + if (cs instanceof EmbeddedDiagram) { + return ((EmbeddedDiagram) cs).asDraw(skinParam); + } + + return Display.getWithNewlines(cs.toString()).create8(config, align, skinParam, CreoleMode.SIMPLE_LINE, + skinParam.wrapWidth()); } diff --git a/src/net/sourceforge/plantuml/mindmap/FingerImpl.java b/src/net/sourceforge/plantuml/mindmap/FingerImpl.java index 71d07dac4..0598efd54 100644 --- a/src/net/sourceforge/plantuml/mindmap/FingerImpl.java +++ b/src/net/sourceforge/plantuml/mindmap/FingerImpl.java @@ -43,7 +43,7 @@ import java.util.List; import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.SkinParamColors; -import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBox; +import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBoxOld; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.StringBounder; @@ -237,7 +237,7 @@ public class FingerImpl implements Finger, UDrawable { } if (shape == IdeaShape.BOX) { final ISkinParam foo = new SkinParamColors(skinParam, Colors.empty().add(ColorType.BACK, backColor)); - final FtileBox box = FtileBox.createMindMap(styleBuilder, foo, label, getDefaultStyleDefinitionNode()); + final TextBlock box = FtileBoxOld.createMindMap(styleBuilder, foo, label, getDefaultStyleDefinitionNode()); return TextBlockUtils.withMargin(box, 0, 0, marginTop, marginBottom); } diff --git a/src/net/sourceforge/plantuml/project/core/Task.java b/src/net/sourceforge/plantuml/project/core/Task.java index f541a5887..df4ce3cef 100644 --- a/src/net/sourceforge/plantuml/project/core/Task.java +++ b/src/net/sourceforge/plantuml/project/core/Task.java @@ -55,7 +55,7 @@ public interface Task extends Moment { public void setEnd(Day end); - public void setColors(CenterBorderColor colors); + public void setColors(CenterBorderColor... colors); public void addResource(Resource resource, int percentage); diff --git a/src/net/sourceforge/plantuml/project/core/TaskImpl.java b/src/net/sourceforge/plantuml/project/core/TaskImpl.java index 091d44730..61b54b7b1 100644 --- a/src/net/sourceforge/plantuml/project/core/TaskImpl.java +++ b/src/net/sourceforge/plantuml/project/core/TaskImpl.java @@ -71,7 +71,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { private Display note; private Url url; - private CenterBorderColor colors; + private CenterBorderColor[] colors; public void setUrl(Url url) { this.url = url; @@ -211,7 +211,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { solver.setData(TaskAttribute.END, end); } - public void setColors(CenterBorderColor colors) { + public void setColors(CenterBorderColor... colors) { this.colors = colors; } @@ -236,7 +236,13 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { } public final CenterBorderColor getColors() { - return colors; + if (colors == null) { + return null; + } + if (colors.length == 1) { + return colors[0]; + } + return colors[0].linearTo(colors[1], completion); } public final int getCompletion() { diff --git a/src/net/sourceforge/plantuml/project/core/TaskSeparator.java b/src/net/sourceforge/plantuml/project/core/TaskSeparator.java index ac99f44e7..aea34e301 100644 --- a/src/net/sourceforge/plantuml/project/core/TaskSeparator.java +++ b/src/net/sourceforge/plantuml/project/core/TaskSeparator.java @@ -68,7 +68,7 @@ public class TaskSeparator extends AbstractTask implements Task { throw new UnsupportedOperationException(); } - public void setColors(CenterBorderColor colors) { + public void setColors(CenterBorderColor... colors) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java b/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java index be9b2f7bf..1d67a7138 100644 --- a/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java +++ b/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java @@ -58,7 +58,8 @@ import net.sourceforge.plantuml.ugraphic.color.HColorSet; public abstract class AbstractTaskDraw implements TaskDraw { - protected CenterBorderColor colors; + private CenterBorderColor colors; + protected int completion = 100; protected Url url; protected Display note; @@ -173,4 +174,8 @@ public abstract class AbstractTaskDraw implements TaskDraw { return colorSet; } + protected CenterBorderColor getColors() { + return colors; + } + } diff --git a/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java b/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java index 37ebd0ef1..c83c64501 100644 --- a/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java +++ b/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java @@ -47,6 +47,7 @@ import net.sourceforge.plantuml.project.LabelStrategy; import net.sourceforge.plantuml.project.ToTaskDraw; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.core.TaskAttribute; +import net.sourceforge.plantuml.project.lang.CenterBorderColor; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.real.Real; @@ -144,8 +145,9 @@ public class TaskDrawDiamond extends AbstractTaskDraw { } private UGraphic applyColors(UGraphic ug) { - if (colors != null && colors.isOk()) { - return colors.apply(ug); + final CenterBorderColor col = this.getColors(); + if (col != null && col.isOk()) { + return col.apply(ug); } return ug.apply(getLineColor()).apply(getBackgroundColor().bg()); } diff --git a/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java b/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java index 20474b6af..04b19f972 100644 --- a/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java +++ b/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java @@ -58,6 +58,7 @@ import net.sourceforge.plantuml.project.ToTaskDraw; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.core.TaskAttribute; import net.sourceforge.plantuml.project.core.TaskImpl; +import net.sourceforge.plantuml.project.lang.CenterBorderColor; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.real.Real; @@ -243,8 +244,9 @@ public class TaskDrawRegular extends AbstractTaskDraw { } private UGraphic applyColors(UGraphic ug) { - if (colors != null && colors.isOk()) { - return colors.apply(ug); + final CenterBorderColor col = this.getColors(); + if (col != null && col.isOk()) { + return col.apply(ug); } return ug.apply(getLineColor()).apply(getBackgroundColor().bg()); } diff --git a/src/net/sourceforge/plantuml/project/lang/CenterBorderColor.java b/src/net/sourceforge/plantuml/project/lang/CenterBorderColor.java index 19ef120df..30dd38424 100644 --- a/src/net/sourceforge/plantuml/project/lang/CenterBorderColor.java +++ b/src/net/sourceforge/plantuml/project/lang/CenterBorderColor.java @@ -37,6 +37,7 @@ package net.sourceforge.plantuml.project.lang; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.HColorUtils; public class CenterBorderColor { @@ -78,4 +79,18 @@ public class CenterBorderColor { public final String getStyle() { return style; } + + public CenterBorderColor linearTo(CenterBorderColor other, int completion) { + if (completion == 0) { + return this; + } + if (completion == 100) { + return other; + } + + final HColor newCenter = HColorUtils.linear(this.center, other.center, completion); + final HColor newBorder = HColorUtils.linear(this.border, other.border, completion); + + return new CenterBorderColor(newCenter, newBorder, style); + } } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementInColorsFromTo.java b/src/net/sourceforge/plantuml/project/lang/ComplementInColorsFromTo.java new file mode 100644 index 000000000..4847bcca6 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/ComplementInColorsFromTo.java @@ -0,0 +1,69 @@ +/* ======================================================================== + * 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.project.lang; + +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.project.Failable; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.ugraphic.color.HColor; + +public class ComplementInColorsFromTo implements Something { + + public IRegex toRegex(String suffix) { + return new RegexLeaf("COMPLEMENT" + suffix, + "from[%s]+(#?\\w+)(?:/(#?\\w+))?[%s]+to[%s]+(#?\\w+)(?:/(#?\\w+))?"); + } + + public Failable getMe(GanttDiagram diagram, RegexResult arg, String suffix) { + final String arg0 = arg.get("COMPLEMENT" + suffix, 0); + final String arg1 = arg.get("COMPLEMENT" + suffix, 1); + final String arg2 = arg.get("COMPLEMENT" + suffix, 2); + final String arg3 = arg.get("COMPLEMENT" + suffix, 3); + final HColor from0 = arg0 == null ? null + : diagram.getIHtmlColorSet().getColorOrWhite(diagram.getSkinParam().getThemeStyle(), arg0); + final HColor from1 = arg1 == null ? null + : diagram.getIHtmlColorSet().getColorOrWhite(diagram.getSkinParam().getThemeStyle(), arg1); + final HColor to0 = arg2 == null ? null + : diagram.getIHtmlColorSet().getColorOrWhite(diagram.getSkinParam().getThemeStyle(), arg2); + final HColor to1 = arg3 == null ? null + : diagram.getIHtmlColorSet().getColorOrWhite(diagram.getSkinParam().getThemeStyle(), arg3); + final CenterBorderColor result[] = new CenterBorderColor[] { new CenterBorderColor(from0, from1), + new CenterBorderColor(to0, to1) }; + return Failable.ok(result); + } +} diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceIsColoredForCompletion.java b/src/net/sourceforge/plantuml/project/lang/SentenceIsColoredForCompletion.java new file mode 100644 index 000000000..f902ac85f --- /dev/null +++ b/src/net/sourceforge/plantuml/project/lang/SentenceIsColoredForCompletion.java @@ -0,0 +1,56 @@ +/* ======================================================================== + * 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.project.lang; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Task; + +public class SentenceIsColoredForCompletion extends SentenceSimple { + + public SentenceIsColoredForCompletion() { + super(new SubjectTask(), Verbs.isColoredForCompletion(), new ComplementInColorsFromTo()); + } + + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final CenterBorderColor[] colors = (CenterBorderColor[]) complement; + task.setColors(colors); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectTask.java b/src/net/sourceforge/plantuml/project/lang/SubjectTask.java index aa1da4393..ab22cef53 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectTask.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectTask.java @@ -77,9 +77,10 @@ public class SubjectTask implements Subject { public Collection getSentences() { return Arrays.asList(new SentenceLasts(), new SentenceTaskStarts(), new SentenceTaskStartsWithColor(), new SentenceTaskStartsAbsolute(), new SentenceHappens(), new SentenceHappensDate(), new SentenceEnds(), - new SentenceTaskEndsAbsolute(), new SentenceIsColored(), new SentenceIsDeleted(), - new SentenceIsForTask(), new SentenceLinksTo(), new SentenceOccurs(), new SentenceDisplayOnSameRowAs(), - new SentencePausesDate(), new SentencePausesDates(), new SentencePausesDayOfWeek()); + new SentenceTaskEndsAbsolute(), new SentenceIsColored(), new SentenceIsColoredForCompletion(), + new SentenceIsDeleted(), new SentenceIsForTask(), new SentenceLinksTo(), new SentenceOccurs(), + new SentenceDisplayOnSameRowAs(), new SentencePausesDate(), new SentencePausesDates(), + new SentencePausesDayOfWeek()); } public IRegex toRegex() { diff --git a/src/net/sourceforge/plantuml/project/lang/Verbs.java b/src/net/sourceforge/plantuml/project/lang/Verbs.java index 089166963..90d9cf9c6 100644 --- a/src/net/sourceforge/plantuml/project/lang/Verbs.java +++ b/src/net/sourceforge/plantuml/project/lang/Verbs.java @@ -83,6 +83,10 @@ public class Verbs { return new RegexLeaf("is[%s]+colou?red"); } + public static IRegex isColoredForCompletion() { + return new RegexLeaf("is[%s]+colou?red[%s]+for[%s]+completion"); + } + public static IRegex isOff() { return new RegexConcat(new RegexLeaf("is"), // RegexLeaf.spaceOneOrMore(), // diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java index ff35b429f..dc637dbab 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java @@ -60,7 +60,8 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; abstract class CommandExoArrowAny extends SingleLineCommand2 { - protected static final String SHORT = "SHORT"; + protected static final String ARROW_SUPPCIRCLE1 = "ARROW_SUPPCIRCLE1"; + protected static final String ARROW_SUPPCIRCLE2 = "ARROW_SUPPCIRCLE2"; public CommandExoArrowAny(IRegex pattern) { super(pattern); @@ -107,34 +108,33 @@ abstract class CommandExoArrowAny extends SingleLineCommand2 { } if (messageExoType == MessageExoType.TO_RIGHT || messageExoType == MessageExoType.TO_LEFT) { - if (containsSymbolExterior(arg, "o")) { + if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "o")) { + config = config.withDecoration1(ArrowDecoration.CIRCLE); + } + if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "x")) { + config = config.withHead1(ArrowHead.CROSSX); + } + if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "o")) { config = config.withDecoration2(ArrowDecoration.CIRCLE); } - if (containsSymbol(arg, "o")) { - config = config.withDecoration1(ArrowDecoration.CIRCLE); + if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "x")) { + config = config.withHead2(ArrowHead.CROSSX); } } else { - if (containsSymbolExterior(arg, "o")) { + if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "o")) { config = config.withDecoration1(ArrowDecoration.CIRCLE); } - if (containsSymbol(arg, "o")) { + if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "x")) { + config = config.withHead1(ArrowHead.CROSSX); + } + if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "o")) { config = config.withDecoration2(ArrowDecoration.CIRCLE); } + if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "x")) { + config = config.withHead2(ArrowHead.CROSSX); + } } - if (containsSymbolExterior(arg, "x") || containsSymbol(arg, "x")) { - config = config.withHead2(ArrowHead.CROSSX); - } - // if (messageExoType.getDirection() == 1) { - // if (containsSymbolExterior(arg2, "x") || containsSymbol(arg2, "x")) { - // config = config.withHead2(ArrowHead.CROSSX); - // } - // } else { - // if (containsSymbolExterior(arg2, "x") || containsSymbol(arg2, "x")) { - // config = config.withHead2(ArrowHead.CROSSX); - // } - // } - final MessageExo msg = new MessageExo(diagram.getSkinParam().getCurrentStyleBuilder(), p, messageExoType, labels, config, diagram.getNextMessageNumber(), isShortArrow(arg)); if (arg.get("URL", 0) != null) { @@ -206,23 +206,15 @@ abstract class CommandExoArrowAny extends SingleLineCommand2 { abstract MessageExoType getMessageExoType(RegexResult arg2); private boolean isShortArrow(RegexResult arg2) { - final String s = arg2.get(SHORT, 0); + final String s = arg2.get(ARROW_SUPPCIRCLE2, 0); if (s != null && s.contains("?")) { return true; } return false; } - private boolean containsSymbolExterior(RegexResult arg2, String symbol) { - final String s = arg2.get(SHORT, 0); - if (s != null && s.contains(symbol)) { - return true; - } - return false; - } - - private boolean containsSymbol(RegexResult arg2, String symbol) { - final String s = arg2.get("ARROW_SUPPCIRCLE", 0); + private boolean containsSymbol(String suppCircle, RegexResult arg2, String symbol) { + final String s = arg2.get(suppCircle, 0); if (s != null && s.contains(symbol)) { return true; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java index 73f4191b7..a485deff0 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java @@ -54,7 +54,7 @@ public class CommandExoArrowLeft extends CommandExoArrowAny { return RegexConcat.build(CommandExoArrowLeft.class.getName(), RegexLeaf.start(), // new RegexLeaf("PARALLEL", "(&[%s]*)?"), // new RegexLeaf("ANCHOR", CommandArrow.ANCHOR), // - new RegexLeaf(SHORT, "([?\\[\\]][ox]?)?"), // + new RegexLeaf(ARROW_SUPPCIRCLE2, "([?\\[\\]][ox]?)?"), // new RegexOr( // new RegexConcat( // new RegexLeaf("ARROW_BOTHDRESSING", "(< namedArgument) { + return nbArg == 1; + } + + public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + Map named) throws EaterException, EaterExceptionLocated { + try { + return TValue.fromString("" + Integer.toHexString(values.get(0).toInt())); + } catch (Throwable t) { + return TValue.fromString(""); + } + } +} diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Hex2dec.java b/src/net/sourceforge/plantuml/tim/stdlib/Hex2dec.java new file mode 100644 index 000000000..30008049d --- /dev/null +++ b/src/net/sourceforge/plantuml/tim/stdlib/Hex2dec.java @@ -0,0 +1,67 @@ +/* ======================================================================== + * 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 Hex2dec extends SimpleReturnFunction { + + public TFunctionSignature getSignature() { + return new TFunctionSignature("%hex2dec", 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 { + return TValue.fromInt(Integer.parseInt(values.get(0).toString(), 16)); + } catch (Throwable t) { + return TValue.fromInt(0); + } + } +} diff --git a/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java b/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java new file mode 100644 index 000000000..f1aec7fb5 --- /dev/null +++ b/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java @@ -0,0 +1,78 @@ +/* ======================================================================== + * 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.awt.Color; +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; +import net.sourceforge.plantuml.ugraphic.color.HColorSimple; +import net.sourceforge.plantuml.ugraphic.color.HSLColor; + +public class HslColor extends SimpleReturnFunction { + + public TFunctionSignature getSignature() { + return new TFunctionSignature("%hsl_color", 3); + } + + public boolean canCover(int nbArg, Set namedArgument) { + return nbArg == 3 || nbArg == 4; + } + + public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + Map named) throws EaterException, EaterExceptionLocated { + final int h = values.get(0).toInt(); + final int s = values.get(1).toInt(); + final int l = values.get(2).toInt(); + if (values.size() == 3) { + final HSLColor color = new HSLColor(h, s, l); + final Color rgb = color.getRGB(); + return TValue.fromString(new HColorSimple(rgb, false).asString()); + } + final int a = values.get(3).toInt(); + final HSLColor color = new HSLColor(h, s, l, (float) (a / 100.0)); + final Color rgb = color.getRGB(); + return TValue.fromString(new HColorSimple(rgb, false).asString()); + + } +} diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Lower.java b/src/net/sourceforge/plantuml/tim/stdlib/Lower.java index 901228fb8..bd795f8fe 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Lower.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Lower.java @@ -47,7 +47,7 @@ import net.sourceforge.plantuml.tim.expression.TValue; public class Lower extends SimpleReturnFunction { public TFunctionSignature getSignature() { - return new TFunctionSignature("%lower", 3); + return new TFunctionSignature("%lower", 1); } public boolean canCover(int nbArg, Set namedArgument) { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java b/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java index 6df295c1c..c7c64bcef 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java @@ -52,7 +52,7 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class ReverseColor extends SimpleReturnFunction { public TFunctionSignature getSignature() { - return new TFunctionSignature("%reverse_color", 2); + return new TFunctionSignature("%reverse_color", 1); } public boolean canCover(int nbArg, Set namedArgument) { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java b/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java index ee35c8037..79d9f40e3 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java @@ -52,7 +52,7 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class ReverseHsluvColor extends SimpleReturnFunction { public TFunctionSignature getSignature() { - return new TFunctionSignature("%reverse_hsluv_color", 2); + return new TFunctionSignature("%reverse_hsluv_color", 1); } public boolean canCover(int nbArg, Set namedArgument) { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/StringFunction.java b/src/net/sourceforge/plantuml/tim/stdlib/StringFunction.java index 2db00cea3..b7ad336ff 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/StringFunction.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/StringFunction.java @@ -47,7 +47,7 @@ import net.sourceforge.plantuml.tim.expression.TValue; public class StringFunction extends SimpleReturnFunction { public TFunctionSignature getSignature() { - return new TFunctionSignature("%string", 3); + return new TFunctionSignature("%string", 1); } public boolean canCover(int nbArg, Set namedArgument) { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Upper.java b/src/net/sourceforge/plantuml/tim/stdlib/Upper.java index 62b4d225a..8e1ea2c69 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Upper.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Upper.java @@ -47,7 +47,7 @@ import net.sourceforge.plantuml.tim.expression.TValue; public class Upper extends SimpleReturnFunction { public TFunctionSignature getSignature() { - return new TFunctionSignature("%upper", 3); + return new TFunctionSignature("%upper", 1); } public boolean canCover(int nbArg, Set namedArgument) { diff --git a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java index 68a774a12..301a52dad 100644 --- a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java +++ b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java @@ -64,6 +64,7 @@ import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileUtils; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineParam; +import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.Scale; import net.sourceforge.plantuml.SvgCharSizeHack; import net.sourceforge.plantuml.TitledDiagram; @@ -95,6 +96,7 @@ import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorBackground; import net.sourceforge.plantuml.ugraphic.color.HColorGradient; +import net.sourceforge.plantuml.ugraphic.color.HColorNone; import net.sourceforge.plantuml.ugraphic.color.HColorSimple; import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.debug.UGraphicDebug; @@ -111,7 +113,7 @@ public class ImageBuilder { private Animation animation; private boolean annotations; - private HColor backcolor = HColorUtils.WHITE; + private HColor backcolor = getDefaultHBackColor(); private ColorMapper colorMapper = new ColorMapperIdentity(); private Dimension2D dimension; private final FileFormatOption fileFormatOption; @@ -453,13 +455,19 @@ public class ImageBuilder { private UGraphic2 createUGraphicPNG(double scaleFactor, final Dimension2D dim, Animation affineTransforms, double dx, double dy, String watermark) { - Color backColor = Color.WHITE; // TODO simplify backcolor some more in a future PR + Color backColor = getDefaultBackColor(); + if (this.backcolor instanceof HColorSimple) { backColor = colorMapper.toColor(this.backcolor); - } else if (this.backcolor instanceof HColorBackground) { + } else if (this.backcolor instanceof HColorBackground || this.backcolor instanceof HColorNone) { backColor = null; } + if (OptionFlags.getInstance().isReplaceWhiteBackgroundByTransparent() && backColor != null + && backColor.equals(Color.WHITE)) { + backColor = new Color(0, 0, 0, 0); + } + final EmptyImageBuilder builder = new EmptyImageBuilder(watermark, (int) (dim.getWidth() * scaleFactor), (int) (dim.getHeight() * scaleFactor), backColor); final Graphics2D graphics2D = builder.getGraphics2D(); @@ -476,6 +484,14 @@ public class ImageBuilder { return ug; } + static private Color getDefaultBackColor() { + return Color.WHITE; + } + + static private HColor getDefaultHBackColor() { + return HColorUtils.WHITE; + } + private String getHoverPathColorRGB() { if (fileFormatOption.getHoverColor() != null) { return fileFormatOption.getHoverColor(); diff --git a/src/net/sourceforge/plantuml/ugraphic/color/HColorSimple.java b/src/net/sourceforge/plantuml/ugraphic/color/HColorSimple.java index 2b6fbe64e..aed07125b 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/HColorSimple.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/HColorSimple.java @@ -65,7 +65,7 @@ public class HColorSimple extends HColorAbstract implements HColor { if (color.getAlpha() == 255) { return DotStringFactory.sharp000000(color.getRGB()); } - return super.asString(); + return "#" + Integer.toHexString(color.getRGB()); } @Override @@ -142,4 +142,29 @@ public class HColorSimple extends HColorAbstract implements HColor { return monochrome; } + public static HColorSimple linear(HColorSimple color1, HColorSimple color2, int completion) { + final HSLColor col1 = new HSLColor(color1.color); + final HSLColor col2 = new HSLColor(color2.color); + + final float[] hsl1 = col1.getHSL(); + final float[] hsl2 = col2.getHSL(); + + final float[] hsl = linear(completion, hsl1, hsl2); + + final HSLColor col = new HSLColor(hsl); + + return new HColorSimple(col.getRGB(), color1.monochrome); + } + + private static float[] linear(int completion, float[] hsl1, float[] hsl2) { + final float h = linear(completion, hsl1[0], hsl2[0]); + final float s = linear(completion, hsl1[1], hsl2[1]); + final float l = linear(completion, hsl1[2], hsl2[2]); + return new float[] { h, s, l }; + } + + private static float linear(int completion, float x, float y) { + return x + (y - x) * completion / 100; + } + } diff --git a/src/net/sourceforge/plantuml/ugraphic/color/HColorUtils.java b/src/net/sourceforge/plantuml/ugraphic/color/HColorUtils.java index ead06dbec..64593c54e 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/HColorUtils.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/HColorUtils.java @@ -152,4 +152,11 @@ public class HColorUtils { return false; } + public static HColor linear(HColor color1, HColor color2, int completion) { + if (color1 instanceof HColorSimple && color2 instanceof HColorSimple) { + return HColorSimple.linear((HColorSimple) color1, (HColorSimple) color2, completion); + } + return color1; + } + } diff --git a/src/net/sourceforge/plantuml/utils/words.txt b/src/net/sourceforge/plantuml/utils/words.txt index 2b02b41e2..518cd0748 100644 --- a/src/net/sourceforge/plantuml/utils/words.txt +++ b/src/net/sourceforge/plantuml/utils/words.txt @@ -2114,4 +2114,4 @@ youthful zeal zenith zest -zippy +zippy \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 9ca8b0f37..f12d84c0d 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -44,7 +44,7 @@ public class Version { private static final int MAJOR_SEPARATOR = 1000000; public static int version() { - return 1202108; + return 1202109; } public static int versionPatched() { @@ -93,7 +93,7 @@ public class Version { } public static long compileTime() { - return 1624695659217L; + return 1627208036416L; } public static String compileTimeString() { diff --git a/src/net/sourceforge/plantuml/wbs/ITFLeaf.java b/src/net/sourceforge/plantuml/wbs/ITFLeaf.java index c18859b92..c321f5e32 100644 --- a/src/net/sourceforge/plantuml/wbs/ITFLeaf.java +++ b/src/net/sourceforge/plantuml/wbs/ITFLeaf.java @@ -39,7 +39,7 @@ import java.awt.geom.Dimension2D; import java.awt.geom.Point2D; import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBox; +import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBoxOld; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.AbstractTextBlock; @@ -56,7 +56,7 @@ class ITFLeaf extends AbstractTextBlock implements ITF { public ITFLeaf(Style style, ISkinParam skinParam, Display label, IdeaShape shape) { if (shape == IdeaShape.BOX) { - this.box = FtileBox.createWbs(style, skinParam, label); + this.box = FtileBoxOld.createWbs(style, skinParam, label); } else { final TextBlock text = label.create0( style.getFontConfiguration(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet()), diff --git a/src/net/sourceforge/plantuml/wbs/WBSTextBlock.java b/src/net/sourceforge/plantuml/wbs/WBSTextBlock.java index 90515da15..d57d749da 100644 --- a/src/net/sourceforge/plantuml/wbs/WBSTextBlock.java +++ b/src/net/sourceforge/plantuml/wbs/WBSTextBlock.java @@ -40,7 +40,7 @@ import java.awt.geom.Point2D; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.UseStyle; -import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBox; +import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBoxOld; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.AbstractTextBlock; @@ -72,8 +72,7 @@ abstract class WBSTextBlock extends AbstractTextBlock { final ULine line = new ULine(p1, p2); if (UseStyle.useBetaStyle()) { getStyleUsed().applyStrokeAndLineColor(ug.apply(new UTranslate(p1)), skinParam.getIHtmlColorSet(), - skinParam.getThemeStyle()) - .draw(line); + skinParam.getThemeStyle()).draw(line); } else { final HColor color = ColorParam.activityBorder.getDefaultValue(); ug.apply(new UTranslate(p1)).apply(color).draw(line); @@ -96,8 +95,7 @@ abstract class WBSTextBlock extends AbstractTextBlock { final Display label = idea.getLabel(); final Style style = idea.getStyle(); if (idea.getShape() == IdeaShape.BOX) { - final FtileBox box = FtileBox.createWbs(style, idea.withBackColor(skinParam), label); - return box; + return FtileBoxOld.createWbs(style, idea.withBackColor(skinParam), label); } final TextBlock text = label.create0( style.getFontConfiguration(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet()), diff --git a/stdlib/archimate-abx.repx b/stdlib/archimate-abx.repx index c09ca9c6c..10a075e7c 100644 Binary files a/stdlib/archimate-abx.repx and b/stdlib/archimate-abx.repx differ diff --git a/stdlib/azure-abx.repx b/stdlib/azure-abx.repx index 5dd612ca7..19718bea9 100644 Binary files a/stdlib/azure-abx.repx and b/stdlib/azure-abx.repx differ diff --git a/stdlib/c4-abx.repx b/stdlib/c4-abx.repx index 09535b9b2..58944ccf1 100644 Binary files a/stdlib/c4-abx.repx and b/stdlib/c4-abx.repx differ diff --git a/stdlib/cloudinsight-abx.repx b/stdlib/cloudinsight-abx.repx index b72613854..bb721e9df 100644 Binary files a/stdlib/cloudinsight-abx.repx and b/stdlib/cloudinsight-abx.repx differ diff --git a/stdlib/kubernetes-abx.repx b/stdlib/kubernetes-abx.repx index 7aa1f2aae..60fc5d9bb 100644 Binary files a/stdlib/kubernetes-abx.repx and b/stdlib/kubernetes-abx.repx differ diff --git a/stdlib/logos-abx.repx b/stdlib/logos-abx.repx index 1543c9fe2..a45d56c2e 100644 Binary files a/stdlib/logos-abx.repx and b/stdlib/logos-abx.repx differ