mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-21 12:35:10 +00:00
feat: timing set background color of concise
https://forum.plantuml.net/18682/timing-set-background-color-of-concise https://forum.plantuml.net/18676/supporting-markdown-syntax
This commit is contained in:
parent
2a49ef06da
commit
a0be1ed677
@ -1,4 +1,4 @@
|
||||
# Warning, "version" should be the same in gradle.properties and Version.java
|
||||
# Any idea anyone how to magically synchronize those :-) ?
|
||||
version = 1.2024.4beta5
|
||||
version = 1.2024.4beta6
|
||||
org.gradle.workers.max = 3
|
@ -127,10 +127,16 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
|
||||
new RegexLeaf("LINECOLOR", "(?:\\[(dotted|dashed|bold)\\])?(\\w+)?"))), //
|
||||
new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(),
|
||||
new RegexLeaf("EXTENDS",
|
||||
"(extends)[%s]+(" + CommandCreateClassMultilines.CODES + "|[%g]([^%g]+)[%g])"))), //
|
||||
"(extends)[%s]+(" + CommandCreateClassMultilines.CODES + "|[%g]([^%g]+)[%g])"),
|
||||
new RegexOptional(new RegexConcat(RegexLeaf.spaceZeroOrMore(),
|
||||
new RegexLeaf("\\<(" + GenericRegexProducer.PATTERN + ")\\>"))) //
|
||||
)), //
|
||||
new RegexOptional(new RegexConcat(RegexLeaf.spaceOneOrMore(),
|
||||
new RegexLeaf("IMPLEMENTS",
|
||||
"(implements)[%s]+(" + CommandCreateClassMultilines.CODES + "|[%g]([^%g]+)[%g])"))), //
|
||||
"(implements)[%s]+(" + CommandCreateClassMultilines.CODES + "|[%g]([^%g]+)[%g])"),
|
||||
new RegexOptional(new RegexConcat(RegexLeaf.spaceZeroOrMore(),
|
||||
new RegexLeaf("\\<(" + GenericRegexProducer.PATTERN + ")\\>"))) //
|
||||
)), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexLeaf("\\{"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
|
@ -53,13 +53,13 @@ public class CommandMindMapDirection extends SingleLineCommand2<MindMapDiagram>
|
||||
|
||||
static IRegex getRegexConcat() {
|
||||
return RegexConcat.build(CommandMindMapDirection.class.getName(), RegexLeaf.start(), //
|
||||
new RegexLeaf("[^*]*"), //
|
||||
new RegexLeaf("[^*#]*"), //
|
||||
new RegexLeaf("\\b"), //
|
||||
new RegexLeaf("DIRECTION", "(left|right|top|bottom)"), //
|
||||
new RegexLeaf("\\b"), //
|
||||
new RegexLeaf("[^*]*"), //
|
||||
new RegexLeaf("[^*#]*"), //
|
||||
new RegexLeaf("(side|direction)"), //
|
||||
new RegexLeaf("[^*]*"), //
|
||||
new RegexLeaf("[^*#]*"), //
|
||||
RegexLeaf.end());
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class CommandMindMapOrgmode extends SingleLineCommand2<MindMapDiagram> {
|
||||
|
||||
static IRegex getRegexConcat() {
|
||||
return RegexConcat.build(CommandMindMapOrgmode.class.getName(), RegexLeaf.start(), //
|
||||
new RegexLeaf("TYPE", "([ \t]*\\*+)"), //
|
||||
new RegexLeaf("TYPE", "([ \t]*[*#]+)"), //
|
||||
new RegexOptional(new RegexLeaf("BACKCOLOR", "\\[(#\\w+)\\]")), //
|
||||
new RegexLeaf("SHAPE", "(_)?"), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
|
@ -60,7 +60,7 @@ public class CommandMindMapOrgmodeMultiline extends CommandMultilines2<MindMapDi
|
||||
|
||||
static IRegex getRegexConcat() {
|
||||
return RegexConcat.build(CommandMindMapOrgmodeMultiline.class.getName(), RegexLeaf.start(), //
|
||||
new RegexLeaf("TYPE", "(\\*+)"), //
|
||||
new RegexLeaf("TYPE", "([*#]+)"), //
|
||||
new RegexOptional(new RegexLeaf("BACKCOLOR", "\\[(#\\w+)\\]")), //
|
||||
new RegexLeaf("SHAPE", "(_)?"), //
|
||||
new RegexLeaf(":"), //
|
||||
|
@ -62,8 +62,11 @@ public abstract class Player implements TimeProjected {
|
||||
private final Display title;
|
||||
protected int suggestedHeight;
|
||||
protected final Stereotype stereotype;
|
||||
private final HColor generalBackgroundColor;
|
||||
|
||||
public Player(String title, ISkinParam skinParam, TimingRuler ruler, boolean compact, Stereotype stereotype) {
|
||||
public Player(String title, ISkinParam skinParam, TimingRuler ruler, boolean compact, Stereotype stereotype,
|
||||
HColor generalBackgroundColor) {
|
||||
this.generalBackgroundColor = generalBackgroundColor;
|
||||
this.stereotype = stereotype;
|
||||
this.skinParam = skinParam;
|
||||
this.compact = compact;
|
||||
@ -75,6 +78,10 @@ public abstract class Player implements TimeProjected {
|
||||
return compact;
|
||||
}
|
||||
|
||||
public HColor getGeneralBackgroundColor() {
|
||||
return generalBackgroundColor;
|
||||
}
|
||||
|
||||
protected abstract StyleSignature getStyleSignature();
|
||||
|
||||
final protected Style getStyle() {
|
||||
|
@ -76,7 +76,7 @@ public class PlayerAnalog extends Player {
|
||||
private Integer ticksEvery;
|
||||
|
||||
public PlayerAnalog(String code, ISkinParam skinParam, TimingRuler ruler, boolean compact, Stereotype stereotype) {
|
||||
super(code, skinParam, ruler, compact, stereotype);
|
||||
super(code, skinParam, ruler, compact, stereotype, null);
|
||||
this.suggestedHeight = 100;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class PlayerBinary extends Player {
|
||||
private final List<TimingNote> notes = new ArrayList<>();
|
||||
|
||||
public PlayerBinary(String code, ISkinParam skinParam, TimingRuler ruler, boolean compact, Stereotype stereotype) {
|
||||
super(code, skinParam, ruler, compact, stereotype);
|
||||
super(code, skinParam, ruler, compact, stereotype, null);
|
||||
this.suggestedHeight = 30;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class PlayerClock extends Player {
|
||||
|
||||
public PlayerClock(String title, ISkinParam skinParam, TimingRuler ruler, int period, int pulse, int offset,
|
||||
boolean compact) {
|
||||
super(title, skinParam, ruler, compact, null);
|
||||
super(title, skinParam, ruler, compact, null, null);
|
||||
this.displayTitle = title.length() > 0;
|
||||
this.period = period;
|
||||
this.pulse = pulse;
|
||||
|
@ -43,6 +43,7 @@ import java.util.TreeSet;
|
||||
|
||||
import net.sourceforge.plantuml.klimt.UTranslate;
|
||||
import net.sourceforge.plantuml.klimt.color.Colors;
|
||||
import net.sourceforge.plantuml.klimt.color.HColor;
|
||||
import net.sourceforge.plantuml.klimt.creole.Display;
|
||||
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
|
||||
import net.sourceforge.plantuml.klimt.font.StringBounder;
|
||||
@ -50,6 +51,7 @@ import net.sourceforge.plantuml.klimt.geom.XDimension2D;
|
||||
import net.sourceforge.plantuml.klimt.shape.AbstractTextBlock;
|
||||
import net.sourceforge.plantuml.klimt.shape.TextBlock;
|
||||
import net.sourceforge.plantuml.klimt.shape.UDrawable;
|
||||
import net.sourceforge.plantuml.klimt.shape.URectangle;
|
||||
import net.sourceforge.plantuml.skin.ArrowConfiguration;
|
||||
import net.sourceforge.plantuml.stereo.Stereotype;
|
||||
import net.sourceforge.plantuml.style.ISkinParam;
|
||||
@ -77,8 +79,8 @@ public final class PlayerRobustConcise extends Player {
|
||||
private Colors initialColors;
|
||||
|
||||
public PlayerRobustConcise(TimingStyle type, String full, ISkinParam skinParam, TimingRuler ruler, boolean compact,
|
||||
Stereotype stereotype) {
|
||||
super(full, skinParam, ruler, compact, stereotype);
|
||||
Stereotype stereotype, HColor generalBackgroundColor) {
|
||||
super(full, skinParam, ruler, compact, stereotype, generalBackgroundColor);
|
||||
this.type = type;
|
||||
this.suggestedHeight = 0;
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ import net.sourceforge.plantuml.klimt.UStroke;
|
||||
import net.sourceforge.plantuml.klimt.UTranslate;
|
||||
import net.sourceforge.plantuml.klimt.color.Colors;
|
||||
import net.sourceforge.plantuml.klimt.color.HColor;
|
||||
import net.sourceforge.plantuml.klimt.color.HColors;
|
||||
import net.sourceforge.plantuml.klimt.creole.Display;
|
||||
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
|
||||
import net.sourceforge.plantuml.klimt.font.StringBounder;
|
||||
@ -62,6 +63,7 @@ import net.sourceforge.plantuml.klimt.geom.XDimension2D;
|
||||
import net.sourceforge.plantuml.klimt.shape.AbstractTextBlock;
|
||||
import net.sourceforge.plantuml.klimt.shape.TextBlock;
|
||||
import net.sourceforge.plantuml.klimt.shape.ULine;
|
||||
import net.sourceforge.plantuml.klimt.shape.URectangle;
|
||||
import net.sourceforge.plantuml.skin.UmlDiagramType;
|
||||
import net.sourceforge.plantuml.stereo.Stereotype;
|
||||
import net.sourceforge.plantuml.style.PName;
|
||||
@ -133,6 +135,15 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
||||
ruler.ensureNotEmpty();
|
||||
final StringBounder stringBounder = ug.getStringBounder();
|
||||
final double part1MaxWidth = getPart1MaxWidth(stringBounder);
|
||||
|
||||
for (Player player : players.values()) {
|
||||
final UGraphic ugPlayer = ug.apply(getUTranslateForPlayer(player, stringBounder));
|
||||
final HColor generalBackgroundColor = player.getGeneralBackgroundColor();
|
||||
if (generalBackgroundColor != null)
|
||||
ugPlayer.apply(generalBackgroundColor).apply(generalBackgroundColor.bg())
|
||||
.draw(URectangle.build(getWidthTotal(stringBounder), player.getFullHeight(stringBounder)));
|
||||
}
|
||||
|
||||
final UTranslate widthPart1 = UTranslate.dx(part1MaxWidth);
|
||||
if (compactByDefault == false)
|
||||
drawBorder(ug);
|
||||
@ -146,6 +157,7 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
||||
for (Player player : players.values()) {
|
||||
final UGraphic ugPlayer = ug.apply(getUTranslateForPlayer(player, stringBounder));
|
||||
final double caption = getHeightForCaptions(stringBounder);
|
||||
|
||||
if (first) {
|
||||
if (player.isCompact() == false)
|
||||
drawHorizontalSeparator(ugPlayer);
|
||||
@ -279,9 +291,9 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
||||
}
|
||||
|
||||
public CommandExecutionResult createRobustConcise(String code, String full, TimingStyle type, boolean compact,
|
||||
Stereotype stereotype) {
|
||||
Stereotype stereotype, HColor backColor) {
|
||||
final Player player = new PlayerRobustConcise(type, full, getSkinParam(), ruler, compactByDefault || compact,
|
||||
stereotype);
|
||||
stereotype, backColor);
|
||||
players.put(code, player);
|
||||
lastPlayer = player;
|
||||
return CommandExecutionResult.ok();
|
||||
|
@ -37,10 +37,15 @@ package net.sourceforge.plantuml.timingdiagram.command;
|
||||
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.SingleLineCommand2;
|
||||
import net.sourceforge.plantuml.klimt.color.ColorParser;
|
||||
import net.sourceforge.plantuml.klimt.color.ColorType;
|
||||
import net.sourceforge.plantuml.klimt.color.Colors;
|
||||
import net.sourceforge.plantuml.klimt.color.NoSuchColorException;
|
||||
import net.sourceforge.plantuml.regex.IRegex;
|
||||
import net.sourceforge.plantuml.regex.RegexConcat;
|
||||
import net.sourceforge.plantuml.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.regex.RegexOptional;
|
||||
import net.sourceforge.plantuml.regex.RegexOr;
|
||||
import net.sourceforge.plantuml.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.stereo.Stereotype;
|
||||
import net.sourceforge.plantuml.stereo.StereotypePattern;
|
||||
@ -70,11 +75,18 @@ public class CommandRobustConcise extends SingleLineCommand2<TimingDiagram> {
|
||||
RegexLeaf.spaceOneOrMore())), //
|
||||
new RegexLeaf("CODE", "([%pLN_.@]+)"), //
|
||||
StereotypePattern.optional("STEREOTYPE2"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexOr(color().getRegex()), //
|
||||
RegexLeaf.end());
|
||||
}
|
||||
|
||||
private static ColorParser color() {
|
||||
return ColorParser.simpleColor(ColorType.BACK);
|
||||
}
|
||||
|
||||
@Override
|
||||
final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) {
|
||||
final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg)
|
||||
throws NoSuchColorException {
|
||||
final String compact = arg.get("COMPACT", 0);
|
||||
final String code = arg.get("CODE", 0);
|
||||
String full = arg.get("FULL", 0);
|
||||
@ -88,7 +100,10 @@ public class CommandRobustConcise extends SingleLineCommand2<TimingDiagram> {
|
||||
stereotype = Stereotype.build(arg.get("STEREOTYPE2", 0));
|
||||
|
||||
final TimingStyle type = TimingStyle.valueOf(arg.get("TYPE", 0).toUpperCase());
|
||||
return diagram.createRobustConcise(code, full, type, compact != null, stereotype);
|
||||
final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
|
||||
|
||||
return diagram.createRobustConcise(code, full, type, compact != null, stereotype,
|
||||
colors.getColor(ColorType.BACK));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class Version {
|
||||
|
||||
// Warning, "version" should be the same in gradle.properties and Version.java
|
||||
// Any idea anyone how to magically synchronize those :-) ?
|
||||
private static final String version = "1.2024.4beta5";
|
||||
private static final String version = "1.2024.4beta6";
|
||||
|
||||
public static String versionString() {
|
||||
return version;
|
||||
|
Loading…
Reference in New Issue
Block a user