1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-24 22:07:33 +00:00

Import version 1.2021.9

This commit is contained in:
Arnaud Roques 2021-07-25 12:41:36 +02:00
parent 671cbc4101
commit 1edafc748d
69 changed files with 1214 additions and 187 deletions

View File

@ -60,6 +60,7 @@ public class Option {
private final List<String> excludes = new ArrayList<>(); private final List<String> excludes = new ArrayList<>();
private final List<String> config = new ArrayList<>(); private final List<String> config = new ArrayList<>();
private final Map<String, String> defines = new LinkedHashMap<String, String>(); private final Map<String, String> defines = new LinkedHashMap<String, String>();
private String charset; private String charset;
private boolean computeurl = false; private boolean computeurl = false;
private boolean decodeurl = false; private boolean decodeurl = false;
@ -305,6 +306,8 @@ public class Option {
manageDefine(s.substring(2)); manageDefine(s.substring(2));
} else if (s.startsWith("-S")) { } else if (s.startsWith("-S")) {
manageSkinParam(s.substring(2)); manageSkinParam(s.substring(2));
} else if (s.startsWith("-P")) {
managePragma(s.substring(2));
} else if (s.equalsIgnoreCase("-testdot")) { } else if (s.equalsIgnoreCase("-testdot")) {
OptionPrint.printTestDot(); OptionPrint.printTestDot();
} else if (s.equalsIgnoreCase("-about") || s.equalsIgnoreCase("-author") } else if (s.equalsIgnoreCase("-about") || s.equalsIgnoreCase("-author")
@ -318,8 +321,6 @@ public class Option {
OptionFlags.getInstance().setGui(true); OptionFlags.getInstance().setGui(true);
} else if (s.equalsIgnoreCase("-encodesprite")) { } else if (s.equalsIgnoreCase("-encodesprite")) {
OptionFlags.getInstance().setEncodesprite(true); OptionFlags.getInstance().setEncodesprite(true);
// } else if (s.equalsIgnoreCase("-nosuggestengine")) {
// OptionFlags.getInstance().setUseSuggestEngine(false);
} else if (s.equalsIgnoreCase("-printfonts")) { } else if (s.equalsIgnoreCase("-printfonts")) {
OptionFlags.getInstance().setPrintFonts(true); OptionFlags.getInstance().setPrintFonts(true);
} else if (s.equalsIgnoreCase("-dumphtmlstats")) { } else if (s.equalsIgnoreCase("-dumphtmlstats")) {
@ -467,19 +468,28 @@ 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) { private void manageSkinParam(String s) {
final Pattern2 p = MyPattern.cmpile("^(\\w+)(?:=(.*))?$"); final Pattern2 p = MyPattern.cmpile("^(\\w+)(?:=(.*))?$");
final Matcher2 m = p.matcher(s); final Matcher2 m = p.matcher(s);
if (m.find()) { if (m.find()) {
skinParam(m.group(1), m.group(2)); final String var = m.group(1);
} final String value = m.group(2);
}
private void skinParam(String var, String value) {
if (var != null && value != null) { if (var != null && value != null) {
config.add("skinparamlocked " + var + " " + value); config.add("skinparamlocked " + var + " " + value);
} }
}
} }
public final File getOutputDir() { public final File getOutputDir() {

View File

@ -122,6 +122,7 @@ public class OptionFlags {
private boolean enableStats = defaultForStats(); private boolean enableStats = defaultForStats();
private boolean stdLib; private boolean stdLib;
private boolean silentlyCompletelyIgnoreErrors; private boolean silentlyCompletelyIgnoreErrors;
private boolean replaceWhiteBackgroundByTransparent;
private boolean extractStdLib; private boolean extractStdLib;
private boolean clipboardLoop; private boolean clipboardLoop;
private boolean clipboard; private boolean clipboard;
@ -367,4 +368,12 @@ public class OptionFlags {
public final void setSilentlyCompletelyIgnoreErrors(boolean silentlyCompletelyIgnoreErrors) { public final void setSilentlyCompletelyIgnoreErrors(boolean silentlyCompletelyIgnoreErrors) {
this.silentlyCompletelyIgnoreErrors = silentlyCompletelyIgnoreErrors; this.silentlyCompletelyIgnoreErrors = silentlyCompletelyIgnoreErrors;
} }
public final boolean isReplaceWhiteBackgroundByTransparent() {
return replaceWhiteBackgroundByTransparent;
}
public final void setReplaceWhiteBackgroundByTransparent(boolean replaceWhiteBackgroundByTransparent) {
this.replaceWhiteBackgroundByTransparent = replaceWhiteBackgroundByTransparent;
}
} }

View File

@ -101,6 +101,7 @@ public class OptionPrint {
System.out.println(" -o[utput] \"dir\"\tTo generate images in the specified directory"); 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(" -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(" -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 // System.out.println(" -config \"file\"\tTo read the provided config file
// before each diagram"); // before each diagram");
final char separator = SFile.separatorChar; final char separator = SFile.separatorChar;

View File

@ -46,8 +46,11 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.net.URL; import java.net.URL;
import java.time.Month;
import java.time.format.TextStyle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -83,6 +86,10 @@ public class Run {
if (argsArray.length > 0 && argsArray[0].equalsIgnoreCase("-headless")) { if (argsArray.length > 0 && argsArray[0].equalsIgnoreCase("-headless")) {
System.setProperty("java.awt.headless", "true"); System.setProperty("java.awt.headless", "true");
} }
if (argsArray.length > 0 && argsArray[0].equalsIgnoreCase("--de")) {
debugGantt();
return;
}
saveCommandLine(argsArray); saveCommandLine(argsArray);
final Option option = new Option(argsArray); final Option option = new Option(argsArray);
ProgressBar.setEnable(option.isTextProgressBar()); ProgressBar.setEnable(option.isTextProgressBar());
@ -577,4 +584,16 @@ public class Run {
error.goOk(); 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 + "'");
}
}
}
} }

View File

@ -151,7 +151,7 @@ public abstract class SourceFileReaderAbstract implements ISourceFileReader {
system = blockUml.getDiagram(); system = blockUml.getDiagram();
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
if (OptionFlags.getInstance().isSilentlyCompletelyIgnoreErrors()) { if (OptionFlags.getInstance().isSilentlyCompletelyIgnoreErrors() || noerror) {
continue; continue;
} }
return getCrashedImage(blockUml, t, suggested.getFile(0)); return getCrashedImage(blockUml, t, suggested.getFile(0));
@ -163,7 +163,7 @@ public abstract class SourceFileReaderAbstract implements ISourceFileReader {
OptionFlags.getInstance().logData(SFile.fromFile(file), system); OptionFlags.getInstance().logData(SFile.fromFile(file), system);
final List<FileImageData> exportDiagrams; final List<FileImageData> exportDiagrams;
if (noerror) { if (noerror && system instanceof PSystemError) {
exportDiagrams = new ArrayList<FileImageData>(); exportDiagrams = new ArrayList<FileImageData>();
exportDiagrams.add( exportDiagrams.add(
new FileImageData(null, new ImageDataSimple(new Dimension2DDouble(0, 0), FileImageData.ERROR))); new FileImageData(null, new ImageDataSimple(new Dimension2DDouble(0, 0), FileImageData.ERROR)));

View File

@ -108,16 +108,22 @@ public class ActivityDiagram3 extends UmlDiagram {
return swinlanes.nextLinkRenderer(); 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(); manageSwimlaneStrategy();
final InstructionSimple ins = new InstructionSimple(activity, nextLinkRenderer(), final InstructionSimple ins = new InstructionSimple(activity, nextLinkRenderer(),
swinlanes.getCurrentSwimlane(), style, url, colors, stereotype); swinlanes.getCurrentSwimlane(), style, url, colors, stereotype);
current().add(ins); final CommandExecutionResult added = current().add(ins);
if (added.isOk() == false) {
return added;
}
setNextLinkRendererInternal(LinkRendering.none()); setNextLinkRendererInternal(LinkRendering.none());
manageHasUrl(activity); manageHasUrl(activity);
if (url != null) { if (url != null) {
hasUrl = true; hasUrl = true;
} }
return CommandExecutionResult.ok();
} }
public void addSpot(String spot, HColor color) { 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 = CompressionXorYBuilder.build(CompressionMode.ON_Y, result, stringBounder);
result = new TextBlockRecentred(result); result = new TextBlockRecentred(result);
return createImageBuilder(fileFormatOption) return createImageBuilder(fileFormatOption).drawable(result).write(os);
.drawable(result)
.write(os);
} }
public void fork() { public void fork() {

View File

@ -44,6 +44,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint; import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.Rainbow;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
@ -105,8 +106,9 @@ public class Branch {
return ftile.getWeldingPoints(); return ftile.getWeldingPoints();
} }
public void add(Instruction ins) { public CommandExecutionResult add(Instruction ins) {
list.add(ins); list.add(ins);
return CommandExecutionResult.ok();
} }
public boolean kill() { public boolean kill() {

View File

@ -39,6 +39,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimable; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimable;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NotePosition;
@ -48,7 +49,7 @@ public interface Instruction extends Swimable {
public Ftile createFtile(FtileFactory factory); public Ftile createFtile(FtileFactory factory);
public void add(Instruction other); public CommandExecutionResult add(Instruction other);
public boolean kill(); public boolean kill();

View File

@ -41,6 +41,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileBreak; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileBreak;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.command.CommandExecutionResult;
public class InstructionBreak extends MonoSwimable implements Instruction { public class InstructionBreak extends MonoSwimable implements Instruction {
@ -55,7 +56,7 @@ public class InstructionBreak extends MonoSwimable implements Instruction {
return new FtileBreak(factory.skinParam(), getSwimlaneIn()); return new FtileBreak(factory.skinParam(), getSwimlaneIn());
} }
public void add(Instruction other) { public CommandExecutionResult add(Instruction other) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -40,6 +40,7 @@ import java.util.Objects;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.command.CommandExecutionResult;
public class InstructionEnd extends MonoSwimable implements Instruction { public class InstructionEnd extends MonoSwimable implements Instruction {
@ -56,7 +57,7 @@ public class InstructionEnd extends MonoSwimable implements Instruction {
return result; return result;
} }
public void add(Instruction other) { public CommandExecutionResult add(Instruction other) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -46,6 +46,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NotePosition;
@ -85,8 +86,8 @@ public class InstructionFork extends WithNote implements Instruction {
return forks.get(forks.size() - 1); return forks.get(forks.size() - 1);
} }
public void add(Instruction ins) { public CommandExecutionResult add(Instruction ins) {
getLastList().add(ins); return getLastList().add(ins);
} }
public Ftile createFtile(FtileFactory factory) { public Ftile createFtile(FtileFactory factory) {

View File

@ -39,6 +39,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGoto; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGoto;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.command.CommandExecutionResult;
public class InstructionGoto extends MonoSwimable implements Instruction { 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); return new FtileGoto(factory.skinParam(), getSwimlaneIn(), name);
} }
public void add(Instruction other) { public CommandExecutionResult add(Instruction other) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -42,6 +42,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNotes; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNotes;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
@ -80,8 +81,8 @@ public class InstructionGroup implements Instruction, InstructionCollection {
this.roundCorner = roundCorner; this.roundCorner = roundCorner;
} }
public void add(Instruction ins) { public CommandExecutionResult add(Instruction ins) {
list.add(ins); return list.add(ins);
} }
public Ftile createFtile(FtileFactory factory) { public Ftile createFtile(FtileFactory factory) {

View File

@ -50,6 +50,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint; import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint;
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NotePosition;
@ -96,8 +97,8 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC
this.current = this.thens.get(0); this.current = this.thens.get(0);
} }
public void add(Instruction ins) { public CommandExecutionResult add(Instruction ins) {
current.add(ins); return current.add(ins);
} }
public Ftile createFtile(FtileFactory factory) { public Ftile createFtile(FtileFactory factory) {

View File

@ -39,6 +39,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileLabel; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileLabel;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.command.CommandExecutionResult;
public class InstructionLabel extends MonoSwimable implements Instruction { 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); return new FtileLabel(factory.skinParam(), getSwimlaneIn(), name);
} }
public void add(Instruction other) { public CommandExecutionResult add(Instruction other) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -47,6 +47,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileEmpty;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint; import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NotePosition;
@ -88,8 +89,9 @@ public class InstructionList extends WithNote implements Instruction, Instructio
this.defaultSwimlane = defaultSwimlane; this.defaultSwimlane = defaultSwimlane;
} }
public void add(Instruction ins) { public CommandExecutionResult add(Instruction ins) {
all.add(ins); all.add(ins);
return CommandExecutionResult.ok();
} }
public Ftile createFtile(FtileFactory factory) { public Ftile createFtile(FtileFactory factory) {

View File

@ -40,6 +40,7 @@ import java.util.Set;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NotePosition;
@ -74,8 +75,8 @@ public class InstructionPartition implements Instruction {
return list.createFtile(factory); return list.createFtile(factory);
} }
public void add(Instruction other) { public CommandExecutionResult add(Instruction other) {
list.add(other); return list.add(other);
} }
public boolean kill() { public boolean kill() {

View File

@ -45,6 +45,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NotePosition;
@ -111,8 +112,8 @@ public class InstructionRepeat implements Instruction {
return this.backward != Display.NULL; return this.backward != Display.NULL;
} }
public void add(Instruction ins) { public CommandExecutionResult add(Instruction ins) {
repeatList.add(ins); return repeatList.add(ins);
} }
public Ftile createFtile(FtileFactory factory) { public Ftile createFtile(FtileFactory factory) {

View File

@ -43,6 +43,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
@ -84,7 +85,7 @@ public class InstructionSimple extends MonoSwimable implements Instruction {
return result; return result;
} }
public void add(Instruction other) { public CommandExecutionResult add(Instruction other) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -43,6 +43,7 @@ import java.util.Set;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NotePosition;
@ -77,8 +78,8 @@ public class InstructionSplit implements Instruction {
return splits.get(splits.size() - 1); return splits.get(splits.size() - 1);
} }
public void add(Instruction ins) { public CommandExecutionResult add(Instruction ins) {
getLast().add(ins); return getLast().add(ins);
} }
public Ftile createFtile(FtileFactory factory) { public Ftile createFtile(FtileFactory factory) {

View File

@ -41,6 +41,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
public class InstructionSpot extends MonoSwimable implements Instruction { public class InstructionSpot extends MonoSwimable implements Instruction {
@ -70,7 +71,7 @@ public class InstructionSpot extends MonoSwimable implements Instruction {
return result; return result;
} }
public void add(Instruction other) { public CommandExecutionResult add(Instruction other) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -40,6 +40,7 @@ import java.util.Objects;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.command.CommandExecutionResult;
public class InstructionStart extends MonoSwimable implements Instruction { public class InstructionStart extends MonoSwimable implements Instruction {
@ -61,7 +62,7 @@ public class InstructionStart extends MonoSwimable implements Instruction {
return result; return result;
} }
public void add(Instruction other) { public CommandExecutionResult add(Instruction other) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -40,6 +40,7 @@ import java.util.Objects;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.command.CommandExecutionResult;
public class InstructionStop extends MonoSwimable implements Instruction { public class InstructionStop extends MonoSwimable implements Instruction {
@ -61,7 +62,7 @@ public class InstructionStop extends MonoSwimable implements Instruction {
return result; return result;
} }
public void add(Instruction other) { public CommandExecutionResult add(Instruction other) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -46,6 +46,7 @@ import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NotePosition;
@ -84,27 +85,18 @@ public class InstructionSwitch extends WithNote implements Instruction, Instruct
this.swimlane = swimlane; this.swimlane = swimlane;
} }
public void add(Instruction ins) { public CommandExecutionResult add(Instruction ins) {
current.add(ins); if (current == null) {
return CommandExecutionResult.error("No 'case' in this switch");
}
return current.add(ins);
} }
public Ftile createFtile(FtileFactory factory) { public Ftile createFtile(FtileFactory factory) {
for (Branch branch : branches) { for (Branch branch : branches) {
branch.updateFtile(factory); branch.updateFtile(factory);
} }
Ftile result = factory.createSwitch(swimlane, branches, afterEndwhile, topInlinkRendering, labelTest); return factory.createSwitch(swimlane, branches, afterEndwhile, topInlinkRendering, labelTest);
// if (getPositionedNotes().size() > 0) {
// result = FtileWithNoteOpale.create(result, getPositionedNotes(), skinParam,
// false);
// }
// final List<WeldingPoint> weldingPoints = new ArrayList<>();
// for (Branch branch : branches) {
// weldingPoints.addAll(branch.getWeldingPoints());
// }
// if (weldingPoints.size() > 0) {
// result = new FtileDecorateWelding(result, weldingPoints);
// }
return result;
} }
final public boolean kill() { final public boolean kill() {
@ -164,9 +156,4 @@ public class InstructionSwitch extends WithNote implements Instruction, Instruct
} }
} }
// public void afterEndwhile(LinkRendering linkRenderer) {
// this.afterEndwhile = linkRenderer;
// }
} }

View File

@ -45,6 +45,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.Rainbow;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
@ -93,8 +94,8 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi
this.skinParam = skinParam; this.skinParam = skinParam;
} }
public void add(Instruction ins) { public CommandExecutionResult add(Instruction ins) {
repeatList.add(ins); return repeatList.add(ins);
} }
public Ftile createFtile(FtileFactory factory) { public Ftile createFtile(FtileFactory factory) {

View File

@ -123,8 +123,7 @@ public class CommandActivity3 extends SingleLineCommand2<ActivityDiagram3> {
} }
final BoxStyle style = BoxStyle.fromChar(arg.get("STYLE", 0).charAt(0)); final BoxStyle style = BoxStyle.fromChar(arg.get("STYLE", 0).charAt(0));
final Display display = Display.getWithNewlines2(arg.get("LABEL", 0)); final Display display = Display.getWithNewlines2(arg.get("LABEL", 0));
diagram.addActivity(display, style, url, colors, stereotype); return diagram.addActivity(display, style, url, colors, stereotype);
return CommandExecutionResult.ok();
} }
} }

View File

@ -62,8 +62,7 @@ public class CommandActivityLegacy1 extends SingleLineCommand2<ActivityDiagram3>
@Override @Override
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) {
diagram.addActivity(Display.getWithNewlines(arg.get("LABEL", 0)), BoxStyle.PLAIN, null, Colors.empty(), null); return diagram.addActivity(Display.getWithNewlines(arg.get("LABEL", 0)), BoxStyle.PLAIN, null, Colors.empty(), null);
return CommandExecutionResult.ok();
} }
} }

View File

@ -84,7 +84,6 @@ public class CommandActivityLong3 extends CommandMultilines2<ActivityDiagram3> {
// 0)); // 0));
final BoxStyle style = BoxStyle.fromChar(lines.getLastChar()); final BoxStyle style = BoxStyle.fromChar(lines.getLastChar());
lines = lines.removeStartingAndEnding(line0.get("DATA", 0), 1); lines = lines.removeStartingAndEnding(line0.get("DATA", 0), 1);
diagram.addActivity(lines.toDisplay(), style, null, colors, null); return diagram.addActivity(lines.toDisplay(), style, null, colors, null);
return CommandExecutionResult.ok();
} }
} }

View File

@ -69,6 +69,7 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.Style;
@ -82,10 +83,9 @@ import net.sourceforge.plantuml.ugraphic.color.HColorNone;
public class FtileBox extends AbstractFtile { public class FtileBox extends AbstractFtile {
private double padding1 = 10; private final ClockwiseTopRightBottomLeft padding;
private double padding2 = 10; private final ClockwiseTopRightBottomLeft margin;
private double paddingTop = 10;
private double paddingBottom = 10;
private final TextBlock tb; private final TextBlock tb;
private double roundCorner = 25; private double roundCorner = 25;
private final double shadowing; private final double shadowing;
@ -130,12 +130,12 @@ public class FtileBox extends AbstractFtile {
class MyStencil implements Stencil { class MyStencil implements Stencil {
public double getStartingX(StringBounder stringBounder, double y) { public double getStartingX(StringBounder stringBounder, double y) {
return -padding1; return -padding.getLeft();
} }
public double getEndingX(StringBounder stringBounder, double y) { public double getEndingX(StringBounder stringBounder, double y) {
final Dimension2D dim = calculateDimension(stringBounder); 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); return new FtileBox(skinParam, label, swimlane, boxStyle, style, styleArrow);
} }
public static FtileBox createWbs(StyleBuilder styleBuilder, ISkinParam skinParam, Display label, // public static TextBlock createWbs(StyleBuilder styleBuilder, ISkinParam skinParam, Display label,
StyleSignature styleDefinition) { // StyleSignature styleDefinition) {
Style style = null; // Style style = null;
Style styleArrow = null; // Style styleArrow = null;
if (UseStyle.useBetaStyle()) { // if (UseStyle.useBetaStyle()) {
style = styleDefinition.getMergedStyle(styleBuilder); // style = styleDefinition.getMergedStyle(styleBuilder);
styleArrow = style; // styleArrow = style;
} // }
return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); // return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow);
} // }
//
public static FtileBox createWbs(Style style, ISkinParam skinParam, Display label) { // public static TextBlock createWbs(Style style, ISkinParam skinParam, Display label) {
Style styleArrow = null; // Style styleArrow = null;
if (UseStyle.useBetaStyle()) { // if (UseStyle.useBetaStyle()) {
styleArrow = style; // styleArrow = style;
} // }
return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); // return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow);
} // }
//
public static FtileBox createMindMap(StyleBuilder styleBuilder, ISkinParam skinParam, Display label, // public static TextBlock createMindMap(StyleBuilder styleBuilder, ISkinParam skinParam, Display label,
StyleSignature styleDefinition) { // StyleSignature styleDefinition) {
final Style style = styleDefinition.getMergedStyle(styleBuilder); // final Style style = styleDefinition.getMergedStyle(styleBuilder);
final Style styleArrow = style; // final Style styleArrow = style;
return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); // return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow);
} // }
private FtileBox(ISkinParam skinParam, Display label, Swimlane swimlane, BoxStyle boxStyle, Style style, private FtileBox(ISkinParam skinParam, Display label, Swimlane swimlane, BoxStyle boxStyle, Style style,
Style styleArrow) { Style styleArrow) {
@ -197,21 +197,21 @@ public class FtileBox extends AbstractFtile {
this.borderColor = style.value(PName.LineColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet()); this.borderColor = style.value(PName.LineColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet());
this.backColor = style.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet()); this.backColor = style.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(), getIHtmlColorSet());
fc = style.getFontConfiguration(skinParam.getThemeStyle(), getIHtmlColorSet()); fc = style.getFontConfiguration(skinParam.getThemeStyle(), getIHtmlColorSet());
horizontalAlignment = style.getHorizontalAlignment(); this.horizontalAlignment = style.getHorizontalAlignment();
this.padding1 = style.getPadding().getLeft(); this.padding = style.getPadding();
this.padding2 = style.getPadding().getRight(); this.margin = style.getMargin();
this.paddingTop = style.getPadding().getTop();
this.paddingBottom = style.getPadding().getBottom();
this.roundCorner = style.value(PName.RoundCorner).asDouble(); this.roundCorner = style.value(PName.RoundCorner).asDouble();
this.shadowing = style.value(PName.Shadowing).asDouble(); this.shadowing = style.value(PName.Shadowing).asDouble();
wrapWidth = style.wrapWidth(); wrapWidth = style.wrapWidth();
this.minimumWidth = style.value(PName.MinimumWidth).asDouble(); this.minimumWidth = style.value(PName.MinimumWidth).asDouble();
} else { } else {
this.padding = ClockwiseTopRightBottomLeft.same(10);
this.margin = ClockwiseTopRightBottomLeft.same(0);
this.inRendering = new LinkRendering(Rainbow.build(skinParam)); this.inRendering = new LinkRendering(Rainbow.build(skinParam));
this.borderColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBorder); this.borderColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBorder);
this.backColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBackground); this.backColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBackground);
fc = new FontConfiguration(skinParam, FontParam.ACTIVITY, null); fc = new FontConfiguration(skinParam, FontParam.ACTIVITY, null);
horizontalAlignment = HorizontalAlignment.LEFT; this.horizontalAlignment = HorizontalAlignment.LEFT;
this.shadowing = skinParam().shadowing(null) ? 3.0 : 0.0; this.shadowing = skinParam().shadowing(null) ? 3.0 : 0.0;
wrapWidth = skinParam.wrapWidth(); wrapWidth = skinParam.wrapWidth();
@ -260,23 +260,25 @@ public class FtileBox extends AbstractFtile {
shape.drawU(ug); shape.drawU(ug);
if (horizontalAlignment == HorizontalAlignment.LEFT) { 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) { } else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); 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) { } else if (horizontalAlignment == HorizontalAlignment.CENTER) {
final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); 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 @Override
protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder) { protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder) {
Dimension2D dim = tb.calculateDimension(stringBounder); Dimension2D dimRaw = tb.calculateDimension(stringBounder);
dim = Dimension2DDouble.delta(dim, padding1 + padding2, paddingBottom + paddingTop); dimRaw = Dimension2DDouble.delta(dimRaw, padding.getLeft() + padding.getRight(),
dim = Dimension2DDouble.atLeast(dim, minimumWidth, 0); padding.getBottom() + padding.getTop());
return new FtileGeometry(dim.getWidth() + boxStyle.getShield(), dim.getHeight(), dim.getWidth() / 2, 0, dimRaw = Dimension2DDouble.atLeast(dimRaw, minimumWidth, 0);
dim.getHeight()); return new FtileGeometry(dimRaw.getWidth() + boxStyle.getShield(), dimRaw.getHeight(), dimRaw.getWidth() / 2, 0,
dimRaw.getHeight());
} }
public Collection<Ftile> getMyChildren() { public Collection<Ftile> getMyChildren() {

View File

@ -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<Swimlane> 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<Ftile> getMyChildren() {
return Collections.emptyList();
}
}

View File

@ -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<Swimlane> 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<Ftile> getMyChildren() {
return Collections.emptyList();
}
}

View File

@ -40,6 +40,7 @@ import java.awt.geom.Rectangle2D;
import java.util.Map; import java.util.Map;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.EmbeddedDiagram;
import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
@ -185,9 +186,12 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlock,
return new TextBlockTracer(m, bloc); return new TextBlockTracer(m, bloc);
} }
TextBlock bloc = Display.getWithNewlines(cs.toString()).create8(config, align, skinParam, if (cs instanceof EmbeddedDiagram) {
CreoleMode.SIMPLE_LINE, skinParam.wrapWidth()); return ((EmbeddedDiagram) cs).asDraw(skinParam);
return bloc; }
return Display.getWithNewlines(cs.toString()).create8(config, align, skinParam, CreoleMode.SIMPLE_LINE,
skinParam.wrapWidth());
} }

View File

@ -43,7 +43,7 @@ import java.util.List;
import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.SkinParamColors; 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.creole.CreoleMode;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
@ -237,7 +237,7 @@ public class FingerImpl implements Finger, UDrawable {
} }
if (shape == IdeaShape.BOX) { if (shape == IdeaShape.BOX) {
final ISkinParam foo = new SkinParamColors(skinParam, Colors.empty().add(ColorType.BACK, backColor)); 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); return TextBlockUtils.withMargin(box, 0, 0, marginTop, marginBottom);
} }

View File

@ -55,7 +55,7 @@ public interface Task extends Moment {
public void setEnd(Day end); public void setEnd(Day end);
public void setColors(CenterBorderColor colors); public void setColors(CenterBorderColor... colors);
public void addResource(Resource resource, int percentage); public void addResource(Resource resource, int percentage);

View File

@ -71,7 +71,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable {
private Display note; private Display note;
private Url url; private Url url;
private CenterBorderColor colors; private CenterBorderColor[] colors;
public void setUrl(Url url) { public void setUrl(Url url) {
this.url = url; this.url = url;
@ -211,7 +211,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable {
solver.setData(TaskAttribute.END, end); solver.setData(TaskAttribute.END, end);
} }
public void setColors(CenterBorderColor colors) { public void setColors(CenterBorderColor... colors) {
this.colors = colors; this.colors = colors;
} }
@ -236,7 +236,13 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable {
} }
public final CenterBorderColor getColors() { 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() { public final int getCompletion() {

View File

@ -68,7 +68,7 @@ public class TaskSeparator extends AbstractTask implements Task {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public void setColors(CenterBorderColor colors) { public void setColors(CenterBorderColor... colors) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -58,7 +58,8 @@ import net.sourceforge.plantuml.ugraphic.color.HColorSet;
public abstract class AbstractTaskDraw implements TaskDraw { public abstract class AbstractTaskDraw implements TaskDraw {
protected CenterBorderColor colors; private CenterBorderColor colors;
protected int completion = 100; protected int completion = 100;
protected Url url; protected Url url;
protected Display note; protected Display note;
@ -173,4 +174,8 @@ public abstract class AbstractTaskDraw implements TaskDraw {
return colorSet; return colorSet;
} }
protected CenterBorderColor getColors() {
return colors;
}
} }

View File

@ -47,6 +47,7 @@ import net.sourceforge.plantuml.project.LabelStrategy;
import net.sourceforge.plantuml.project.ToTaskDraw; import net.sourceforge.plantuml.project.ToTaskDraw;
import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.core.Task;
import net.sourceforge.plantuml.project.core.TaskAttribute; 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.time.Day;
import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.project.timescale.TimeScale;
import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.real.Real;
@ -144,8 +145,9 @@ public class TaskDrawDiamond extends AbstractTaskDraw {
} }
private UGraphic applyColors(UGraphic ug) { private UGraphic applyColors(UGraphic ug) {
if (colors != null && colors.isOk()) { final CenterBorderColor col = this.getColors();
return colors.apply(ug); if (col != null && col.isOk()) {
return col.apply(ug);
} }
return ug.apply(getLineColor()).apply(getBackgroundColor().bg()); return ug.apply(getLineColor()).apply(getBackgroundColor().bg());
} }

View File

@ -58,6 +58,7 @@ import net.sourceforge.plantuml.project.ToTaskDraw;
import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.core.Task;
import net.sourceforge.plantuml.project.core.TaskAttribute; import net.sourceforge.plantuml.project.core.TaskAttribute;
import net.sourceforge.plantuml.project.core.TaskImpl; 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.time.Day;
import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.project.timescale.TimeScale;
import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.real.Real;
@ -243,8 +244,9 @@ public class TaskDrawRegular extends AbstractTaskDraw {
} }
private UGraphic applyColors(UGraphic ug) { private UGraphic applyColors(UGraphic ug) {
if (colors != null && colors.isOk()) { final CenterBorderColor col = this.getColors();
return colors.apply(ug); if (col != null && col.isOk()) {
return col.apply(ug);
} }
return ug.apply(getLineColor()).apply(getBackgroundColor().bg()); return ug.apply(getLineColor()).apply(getBackgroundColor().bg());
} }

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml.project.lang;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class CenterBorderColor { public class CenterBorderColor {
@ -78,4 +79,18 @@ public class CenterBorderColor {
public final String getStyle() { public final String getStyle() {
return style; 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);
}
} }

View File

@ -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<CenterBorderColor[]> 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);
}
}

View File

@ -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();
}
}

View File

@ -77,9 +77,10 @@ public class SubjectTask implements Subject {
public Collection<? extends SentenceSimple> getSentences() { public Collection<? extends SentenceSimple> getSentences() {
return Arrays.asList(new SentenceLasts(), new SentenceTaskStarts(), new SentenceTaskStartsWithColor(), return Arrays.asList(new SentenceLasts(), new SentenceTaskStarts(), new SentenceTaskStartsWithColor(),
new SentenceTaskStartsAbsolute(), new SentenceHappens(), new SentenceHappensDate(), new SentenceEnds(), new SentenceTaskStartsAbsolute(), new SentenceHappens(), new SentenceHappensDate(), new SentenceEnds(),
new SentenceTaskEndsAbsolute(), new SentenceIsColored(), new SentenceIsDeleted(), new SentenceTaskEndsAbsolute(), new SentenceIsColored(), new SentenceIsColoredForCompletion(),
new SentenceIsForTask(), new SentenceLinksTo(), new SentenceOccurs(), new SentenceDisplayOnSameRowAs(), new SentenceIsDeleted(), new SentenceIsForTask(), new SentenceLinksTo(), new SentenceOccurs(),
new SentencePausesDate(), new SentencePausesDates(), new SentencePausesDayOfWeek()); new SentenceDisplayOnSameRowAs(), new SentencePausesDate(), new SentencePausesDates(),
new SentencePausesDayOfWeek());
} }
public IRegex toRegex() { public IRegex toRegex() {

View File

@ -83,6 +83,10 @@ public class Verbs {
return new RegexLeaf("is[%s]+colou?red"); 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() { public static IRegex isOff() {
return new RegexConcat(new RegexLeaf("is"), // return new RegexConcat(new RegexLeaf("is"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //

View File

@ -60,7 +60,8 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> { abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
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) { public CommandExoArrowAny(IRegex pattern) {
super(pattern); super(pattern);
@ -107,33 +108,32 @@ abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
} }
if (messageExoType == MessageExoType.TO_RIGHT || messageExoType == MessageExoType.TO_LEFT) { if (messageExoType == MessageExoType.TO_RIGHT || messageExoType == MessageExoType.TO_LEFT) {
if (containsSymbolExterior(arg, "o")) { if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "o")) {
config = config.withDecoration2(ArrowDecoration.CIRCLE);
}
if (containsSymbol(arg, "o")) {
config = config.withDecoration1(ArrowDecoration.CIRCLE); config = config.withDecoration1(ArrowDecoration.CIRCLE);
} }
} else { if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "x")) {
if (containsSymbolExterior(arg, "o")) { config = config.withHead1(ArrowHead.CROSSX);
config = config.withDecoration1(ArrowDecoration.CIRCLE);
} }
if (containsSymbol(arg, "o")) { if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "o")) {
config = config.withDecoration2(ArrowDecoration.CIRCLE); config = config.withDecoration2(ArrowDecoration.CIRCLE);
} }
} if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "x")) {
if (containsSymbolExterior(arg, "x") || containsSymbol(arg, "x")) {
config = config.withHead2(ArrowHead.CROSSX); config = config.withHead2(ArrowHead.CROSSX);
} }
// if (messageExoType.getDirection() == 1) { } else {
// if (containsSymbolExterior(arg2, "x") || containsSymbol(arg2, "x")) { if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "o")) {
// config = config.withHead2(ArrowHead.CROSSX); config = config.withDecoration1(ArrowDecoration.CIRCLE);
// } }
// } else { if (containsSymbol(ARROW_SUPPCIRCLE2, arg, "x")) {
// if (containsSymbolExterior(arg2, "x") || containsSymbol(arg2, "x")) { config = config.withHead1(ArrowHead.CROSSX);
// config = config.withHead2(ArrowHead.CROSSX); }
// } if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "o")) {
// } config = config.withDecoration2(ArrowDecoration.CIRCLE);
}
if (containsSymbol(ARROW_SUPPCIRCLE1, arg, "x")) {
config = config.withHead2(ArrowHead.CROSSX);
}
}
final MessageExo msg = new MessageExo(diagram.getSkinParam().getCurrentStyleBuilder(), p, messageExoType, final MessageExo msg = new MessageExo(diagram.getSkinParam().getCurrentStyleBuilder(), p, messageExoType,
labels, config, diagram.getNextMessageNumber(), isShortArrow(arg)); labels, config, diagram.getNextMessageNumber(), isShortArrow(arg));
@ -206,23 +206,15 @@ abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
abstract MessageExoType getMessageExoType(RegexResult arg2); abstract MessageExoType getMessageExoType(RegexResult arg2);
private boolean isShortArrow(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("?")) { if (s != null && s.contains("?")) {
return true; return true;
} }
return false; return false;
} }
private boolean containsSymbolExterior(RegexResult arg2, String symbol) { private boolean containsSymbol(String suppCircle, RegexResult arg2, String symbol) {
final String s = arg2.get(SHORT, 0); final String s = arg2.get(suppCircle, 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);
if (s != null && s.contains(symbol)) { if (s != null && s.contains(symbol)) {
return true; return true;
} }

View File

@ -54,7 +54,7 @@ public class CommandExoArrowLeft extends CommandExoArrowAny {
return RegexConcat.build(CommandExoArrowLeft.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandExoArrowLeft.class.getName(), RegexLeaf.start(), //
new RegexLeaf("PARALLEL", "(&[%s]*)?"), // new RegexLeaf("PARALLEL", "(&[%s]*)?"), //
new RegexLeaf("ANCHOR", CommandArrow.ANCHOR), // new RegexLeaf("ANCHOR", CommandArrow.ANCHOR), //
new RegexLeaf(SHORT, "([?\\[\\]][ox]?)?"), // new RegexLeaf(ARROW_SUPPCIRCLE2, "([?\\[\\]][ox]?)?"), //
new RegexOr( // new RegexOr( //
new RegexConcat( // new RegexConcat( //
new RegexLeaf("ARROW_BOTHDRESSING", "(<<?|//?|\\\\\\\\?)?"), // new RegexLeaf("ARROW_BOTHDRESSING", "(<<?|//?|\\\\\\\\?)?"), //
@ -67,7 +67,7 @@ public class CommandExoArrowLeft extends CommandExoArrowAny {
new RegexLeaf("ARROW_BODYB2", "(-*)"), // new RegexLeaf("ARROW_BODYB2", "(-*)"), //
new RegexLeaf("ARROW_STYLE2", CommandArrow.getColorOrStylePattern()), // new RegexLeaf("ARROW_STYLE2", CommandArrow.getColorOrStylePattern()), //
new RegexLeaf("ARROW_BODYA2", "(-+)"))), // new RegexLeaf("ARROW_BODYA2", "(-+)"))), //
new RegexLeaf("ARROW_SUPPCIRCLE", "([ox][%s]+)?"), // new RegexLeaf(ARROW_SUPPCIRCLE1, "([ox][%s]+)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("PARTICIPANT", "([%pLN_.@]+|[%g][^%g]+[%g])"), // new RegexLeaf("PARTICIPANT", "([%pLN_.@]+|[%g][^%g]+[%g])"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -87,7 +87,7 @@ public class CommandExoArrowLeft extends CommandExoArrowAny {
@Override @Override
MessageExoType getMessageExoType(RegexResult arg2) { MessageExoType getMessageExoType(RegexResult arg2) {
final String start = arg2.get(SHORT, 0); final String start = arg2.get(ARROW_SUPPCIRCLE2, 0);
final String dressing1 = arg2.get("ARROW_DRESSING1", 0); final String dressing1 = arg2.get("ARROW_DRESSING1", 0);
final String dressing2 = arg2.get("ARROW_DRESSING2", 0); final String dressing2 = arg2.get("ARROW_DRESSING2", 0);
if (start != null && start.contains("]")) { if (start != null && start.contains("]")) {

View File

@ -56,7 +56,7 @@ public class CommandExoArrowRight extends CommandExoArrowAny {
new RegexLeaf("ANCHOR", CommandArrow.ANCHOR), // new RegexLeaf("ANCHOR", CommandArrow.ANCHOR), //
new RegexLeaf("PARTICIPANT", "([%pLN_.@]+|[%g][^%g]+[%g])"), // new RegexLeaf("PARTICIPANT", "([%pLN_.@]+|[%g][^%g]+[%g])"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("ARROW_SUPPCIRCLE", "([%s]+[ox])?"), // new RegexLeaf(ARROW_SUPPCIRCLE1, "([%s]+[ox])?"), //
new RegexOr( // new RegexOr( //
new RegexConcat( // new RegexConcat( //
new RegexLeaf("ARROW_BOTHDRESSING", "(<<?|//?|\\\\\\\\?)?"), // new RegexLeaf("ARROW_BOTHDRESSING", "(<<?|//?|\\\\\\\\?)?"), //
@ -69,7 +69,7 @@ public class CommandExoArrowRight extends CommandExoArrowAny {
new RegexLeaf("ARROW_BODYB2", "(-*)"), // new RegexLeaf("ARROW_BODYB2", "(-*)"), //
new RegexLeaf("ARROW_STYLE2", CommandArrow.getColorOrStylePattern()), // new RegexLeaf("ARROW_STYLE2", CommandArrow.getColorOrStylePattern()), //
new RegexLeaf("ARROW_BODYA2", "(-+)"))), // new RegexLeaf("ARROW_BODYA2", "(-+)"))), //
new RegexLeaf(SHORT, "([ox]?[?\\]\\[])?"), // new RegexLeaf(ARROW_SUPPCIRCLE2, "([ox]?[?\\]\\[])?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("ACTIVATION", "(?:([+*!-]+)?)"), // new RegexLeaf("ACTIVATION", "(?:([+*!-]+)?)"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -87,7 +87,7 @@ public class CommandExoArrowRight extends CommandExoArrowAny {
@Override @Override
MessageExoType getMessageExoType(RegexResult arg2) { MessageExoType getMessageExoType(RegexResult arg2) {
final String start = arg2.get(SHORT, 0); final String start = arg2.get(ARROW_SUPPCIRCLE2, 0);
final String dressing1 = arg2.get("ARROW_DRESSING1", 0); final String dressing1 = arg2.get("ARROW_DRESSING1", 0);
final String dressing2 = arg2.get("ARROW_DRESSING2", 0); final String dressing2 = arg2.get("ARROW_DRESSING2", 0);
if (start != null && start.contains("[")) { if (start != null && start.contains("[")) {

View File

@ -85,6 +85,7 @@ import net.sourceforge.plantuml.tim.stdlib.AlwaysTrue;
import net.sourceforge.plantuml.tim.stdlib.CallUserFunction; import net.sourceforge.plantuml.tim.stdlib.CallUserFunction;
import net.sourceforge.plantuml.tim.stdlib.Darken; import net.sourceforge.plantuml.tim.stdlib.Darken;
import net.sourceforge.plantuml.tim.stdlib.DateFunction; import net.sourceforge.plantuml.tim.stdlib.DateFunction;
import net.sourceforge.plantuml.tim.stdlib.Dec2hex;
import net.sourceforge.plantuml.tim.stdlib.Dirpath; import net.sourceforge.plantuml.tim.stdlib.Dirpath;
import net.sourceforge.plantuml.tim.stdlib.Eval; import net.sourceforge.plantuml.tim.stdlib.Eval;
import net.sourceforge.plantuml.tim.stdlib.Feature; import net.sourceforge.plantuml.tim.stdlib.Feature;
@ -94,6 +95,8 @@ import net.sourceforge.plantuml.tim.stdlib.FunctionExists;
import net.sourceforge.plantuml.tim.stdlib.GetVariableValue; import net.sourceforge.plantuml.tim.stdlib.GetVariableValue;
import net.sourceforge.plantuml.tim.stdlib.GetVersion; import net.sourceforge.plantuml.tim.stdlib.GetVersion;
import net.sourceforge.plantuml.tim.stdlib.Getenv; import net.sourceforge.plantuml.tim.stdlib.Getenv;
import net.sourceforge.plantuml.tim.stdlib.Hex2dec;
import net.sourceforge.plantuml.tim.stdlib.HslColor;
import net.sourceforge.plantuml.tim.stdlib.IntVal; import net.sourceforge.plantuml.tim.stdlib.IntVal;
import net.sourceforge.plantuml.tim.stdlib.InvokeProcedure; import net.sourceforge.plantuml.tim.stdlib.InvokeProcedure;
import net.sourceforge.plantuml.tim.stdlib.IsDark; import net.sourceforge.plantuml.tim.stdlib.IsDark;
@ -166,6 +169,9 @@ public class TContext {
functionsSet.addFunction(new ReverseHsluvColor()); functionsSet.addFunction(new ReverseHsluvColor());
functionsSet.addFunction(new ReverseColor()); functionsSet.addFunction(new ReverseColor());
functionsSet.addFunction(new Eval()); functionsSet.addFunction(new Eval());
functionsSet.addFunction(new Hex2dec());
functionsSet.addFunction(new Dec2hex());
functionsSet.addFunction(new HslColor());
// %standard_exists_function // %standard_exists_function
// %str_replace // %str_replace
// !exit // !exit

View File

@ -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 Dec2hex extends SimpleReturnFunction {
public TFunctionSignature getSignature() {
return new TFunctionSignature("%dec2hex", 1);
}
public boolean canCover(int nbArg, Set<String> namedArgument) {
return nbArg == 1;
}
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
try {
return TValue.fromString("" + Integer.toHexString(values.get(0).toInt()));
} catch (Throwable t) {
return TValue.fromString("");
}
}
}

View File

@ -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<String> namedArgument) {
return nbArg == 1;
}
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
try {
return TValue.fromInt(Integer.parseInt(values.get(0).toString(), 16));
} catch (Throwable t) {
return TValue.fromInt(0);
}
}
}

View File

@ -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<String> namedArgument) {
return nbArg == 3 || nbArg == 4;
}
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
Map<String, TValue> 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());
}
}

View File

@ -47,7 +47,7 @@ import net.sourceforge.plantuml.tim.expression.TValue;
public class Lower extends SimpleReturnFunction { public class Lower extends SimpleReturnFunction {
public TFunctionSignature getSignature() { public TFunctionSignature getSignature() {
return new TFunctionSignature("%lower", 3); return new TFunctionSignature("%lower", 1);
} }
public boolean canCover(int nbArg, Set<String> namedArgument) { public boolean canCover(int nbArg, Set<String> namedArgument) {

View File

@ -52,7 +52,7 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class ReverseColor extends SimpleReturnFunction { public class ReverseColor extends SimpleReturnFunction {
public TFunctionSignature getSignature() { public TFunctionSignature getSignature() {
return new TFunctionSignature("%reverse_color", 2); return new TFunctionSignature("%reverse_color", 1);
} }
public boolean canCover(int nbArg, Set<String> namedArgument) { public boolean canCover(int nbArg, Set<String> namedArgument) {

View File

@ -52,7 +52,7 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class ReverseHsluvColor extends SimpleReturnFunction { public class ReverseHsluvColor extends SimpleReturnFunction {
public TFunctionSignature getSignature() { public TFunctionSignature getSignature() {
return new TFunctionSignature("%reverse_hsluv_color", 2); return new TFunctionSignature("%reverse_hsluv_color", 1);
} }
public boolean canCover(int nbArg, Set<String> namedArgument) { public boolean canCover(int nbArg, Set<String> namedArgument) {

View File

@ -47,7 +47,7 @@ import net.sourceforge.plantuml.tim.expression.TValue;
public class StringFunction extends SimpleReturnFunction { public class StringFunction extends SimpleReturnFunction {
public TFunctionSignature getSignature() { public TFunctionSignature getSignature() {
return new TFunctionSignature("%string", 3); return new TFunctionSignature("%string", 1);
} }
public boolean canCover(int nbArg, Set<String> namedArgument) { public boolean canCover(int nbArg, Set<String> namedArgument) {

View File

@ -47,7 +47,7 @@ import net.sourceforge.plantuml.tim.expression.TValue;
public class Upper extends SimpleReturnFunction { public class Upper extends SimpleReturnFunction {
public TFunctionSignature getSignature() { public TFunctionSignature getSignature() {
return new TFunctionSignature("%upper", 3); return new TFunctionSignature("%upper", 1);
} }
public boolean canCover(int nbArg, Set<String> namedArgument) { public boolean canCover(int nbArg, Set<String> namedArgument) {

View File

@ -64,6 +64,7 @@ import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.FileUtils; import net.sourceforge.plantuml.FileUtils;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.Scale; import net.sourceforge.plantuml.Scale;
import net.sourceforge.plantuml.SvgCharSizeHack; import net.sourceforge.plantuml.SvgCharSizeHack;
import net.sourceforge.plantuml.TitledDiagram; 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.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorBackground; import net.sourceforge.plantuml.ugraphic.color.HColorBackground;
import net.sourceforge.plantuml.ugraphic.color.HColorGradient; 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.HColorSimple;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import net.sourceforge.plantuml.ugraphic.debug.UGraphicDebug; import net.sourceforge.plantuml.ugraphic.debug.UGraphicDebug;
@ -111,7 +113,7 @@ public class ImageBuilder {
private Animation animation; private Animation animation;
private boolean annotations; private boolean annotations;
private HColor backcolor = HColorUtils.WHITE; private HColor backcolor = getDefaultHBackColor();
private ColorMapper colorMapper = new ColorMapperIdentity(); private ColorMapper colorMapper = new ColorMapperIdentity();
private Dimension2D dimension; private Dimension2D dimension;
private final FileFormatOption fileFormatOption; private final FileFormatOption fileFormatOption;
@ -453,13 +455,19 @@ public class ImageBuilder {
private UGraphic2 createUGraphicPNG(double scaleFactor, final Dimension2D dim, Animation affineTransforms, private UGraphic2 createUGraphicPNG(double scaleFactor, final Dimension2D dim, Animation affineTransforms,
double dx, double dy, String watermark) { 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) { if (this.backcolor instanceof HColorSimple) {
backColor = colorMapper.toColor(this.backcolor); backColor = colorMapper.toColor(this.backcolor);
} else if (this.backcolor instanceof HColorBackground) { } else if (this.backcolor instanceof HColorBackground || this.backcolor instanceof HColorNone) {
backColor = null; 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), final EmptyImageBuilder builder = new EmptyImageBuilder(watermark, (int) (dim.getWidth() * scaleFactor),
(int) (dim.getHeight() * scaleFactor), backColor); (int) (dim.getHeight() * scaleFactor), backColor);
final Graphics2D graphics2D = builder.getGraphics2D(); final Graphics2D graphics2D = builder.getGraphics2D();
@ -476,6 +484,14 @@ public class ImageBuilder {
return ug; return ug;
} }
static private Color getDefaultBackColor() {
return Color.WHITE;
}
static private HColor getDefaultHBackColor() {
return HColorUtils.WHITE;
}
private String getHoverPathColorRGB() { private String getHoverPathColorRGB() {
if (fileFormatOption.getHoverColor() != null) { if (fileFormatOption.getHoverColor() != null) {
return fileFormatOption.getHoverColor(); return fileFormatOption.getHoverColor();

View File

@ -65,7 +65,7 @@ public class HColorSimple extends HColorAbstract implements HColor {
if (color.getAlpha() == 255) { if (color.getAlpha() == 255) {
return DotStringFactory.sharp000000(color.getRGB()); return DotStringFactory.sharp000000(color.getRGB());
} }
return super.asString(); return "#" + Integer.toHexString(color.getRGB());
} }
@Override @Override
@ -142,4 +142,29 @@ public class HColorSimple extends HColorAbstract implements HColor {
return monochrome; 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;
}
} }

View File

@ -152,4 +152,11 @@ public class HColorUtils {
return false; 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;
}
} }

View File

@ -44,7 +44,7 @@ public class Version {
private static final int MAJOR_SEPARATOR = 1000000; private static final int MAJOR_SEPARATOR = 1000000;
public static int version() { public static int version() {
return 1202108; return 1202109;
} }
public static int versionPatched() { public static int versionPatched() {
@ -93,7 +93,7 @@ public class Version {
} }
public static long compileTime() { public static long compileTime() {
return 1624695659217L; return 1627208036416L;
} }
public static String compileTimeString() { public static String compileTimeString() {

View File

@ -39,7 +39,7 @@ import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import net.sourceforge.plantuml.ISkinParam; 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.creole.CreoleMode;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.AbstractTextBlock; 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) { public ITFLeaf(Style style, ISkinParam skinParam, Display label, IdeaShape shape) {
if (shape == IdeaShape.BOX) { if (shape == IdeaShape.BOX) {
this.box = FtileBox.createWbs(style, skinParam, label); this.box = FtileBoxOld.createWbs(style, skinParam, label);
} else { } else {
final TextBlock text = label.create0( final TextBlock text = label.create0(
style.getFontConfiguration(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet()), style.getFontConfiguration(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet()),

View File

@ -40,7 +40,7 @@ import java.awt.geom.Point2D;
import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.UseStyle; 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.creole.CreoleMode;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.AbstractTextBlock;
@ -72,8 +72,7 @@ abstract class WBSTextBlock extends AbstractTextBlock {
final ULine line = new ULine(p1, p2); final ULine line = new ULine(p1, p2);
if (UseStyle.useBetaStyle()) { if (UseStyle.useBetaStyle()) {
getStyleUsed().applyStrokeAndLineColor(ug.apply(new UTranslate(p1)), skinParam.getIHtmlColorSet(), getStyleUsed().applyStrokeAndLineColor(ug.apply(new UTranslate(p1)), skinParam.getIHtmlColorSet(),
skinParam.getThemeStyle()) skinParam.getThemeStyle()).draw(line);
.draw(line);
} else { } else {
final HColor color = ColorParam.activityBorder.getDefaultValue(); final HColor color = ColorParam.activityBorder.getDefaultValue();
ug.apply(new UTranslate(p1)).apply(color).draw(line); ug.apply(new UTranslate(p1)).apply(color).draw(line);
@ -96,8 +95,7 @@ abstract class WBSTextBlock extends AbstractTextBlock {
final Display label = idea.getLabel(); final Display label = idea.getLabel();
final Style style = idea.getStyle(); final Style style = idea.getStyle();
if (idea.getShape() == IdeaShape.BOX) { if (idea.getShape() == IdeaShape.BOX) {
final FtileBox box = FtileBox.createWbs(style, idea.withBackColor(skinParam), label); return FtileBoxOld.createWbs(style, idea.withBackColor(skinParam), label);
return box;
} }
final TextBlock text = label.create0( final TextBlock text = label.create0(
style.getFontConfiguration(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet()), style.getFontConfiguration(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet()),

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.