From a5fe482b594110525b876c7edce669312067417e Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Tue, 29 Mar 2022 23:13:46 +0200 Subject: [PATCH] Version 1.2022.3 --- skin/plantuml.skin | 6 ++ .../activitydiagram3/MonoSwimable.java | 4 +- .../ftile/TextBlockInterceptorUDrawable.java | 7 +- .../sourceforge/plantuml/core/UmlSource.java | 8 +- .../plantuml/style/FromSkinparamToStyle.java | 3 + src/net/sourceforge/plantuml/style/SName.java | 1 + .../plantuml/timingdiagram/PlayerBinary.java | 86 ++++++++++++++----- .../timingdiagram/graphic/Histogram.java | 4 +- .../sourceforge/plantuml/version/Version.java | 6 +- 9 files changed, 95 insertions(+), 30 deletions(-) diff --git a/skin/plantuml.skin b/skin/plantuml.skin index 36024a082..18ce558ee 100644 --- a/skin/plantuml.skin +++ b/skin/plantuml.skin @@ -432,6 +432,12 @@ timingDiagram { LineThickness 2 BackgroundColor: var(--grey-blue); } + binary { + FontStyle plain + FontSize 12 + LineColor darkgreen + LineThickness 2 + } highlight { BackgroundColor #e LineThickness 2 diff --git a/src/net/sourceforge/plantuml/activitydiagram3/MonoSwimable.java b/src/net/sourceforge/plantuml/activitydiagram3/MonoSwimable.java index 1de8f4634..3307a11c1 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/MonoSwimable.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/MonoSwimable.java @@ -50,7 +50,9 @@ abstract class MonoSwimable extends WithNote implements Swimable { } final public Set getSwimlanes() { - return swimlane == null ? Collections.emptySet() : Collections.singleton(swimlane); + if (swimlane == null) + return Collections.emptySet(); + return Collections.singleton(swimlane); } final public Swimlane getSwimlaneIn() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/TextBlockInterceptorUDrawable.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/TextBlockInterceptorUDrawable.java index 3f7776823..52e17102c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/TextBlockInterceptorUDrawable.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/TextBlockInterceptorUDrawable.java @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; public class TextBlockInterceptorUDrawable extends AbstractTextBlock implements TextBlock { @@ -52,10 +53,14 @@ public class TextBlockInterceptorUDrawable extends AbstractTextBlock implements } public void drawU(UGraphic ug) { - new UGraphicInterceptorUDrawable2(ug, new HashMap<>()).draw(textBlock); + new UGraphicInterceptorUDrawable2(ug, emptyHashMap()).draw(textBlock); ug.flushUg(); } + private HashMap emptyHashMap() { + return new HashMap<>(); + } + public Dimension2D calculateDimension(StringBounder stringBounder) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/core/UmlSource.java b/src/net/sourceforge/plantuml/core/UmlSource.java index 7c4a883ed..0005d1b60 100755 --- a/src/net/sourceforge/plantuml/core/UmlSource.java +++ b/src/net/sourceforge/plantuml/core/UmlSource.java @@ -96,7 +96,7 @@ final public class UmlSource { } public static UmlSource create(List source, boolean checkEndingBackslash) { - return createWithRaw(source, checkEndingBackslash, new ArrayList<>()); + return createWithRaw(source, checkEndingBackslash, emptyArrayList()); } /** @@ -109,11 +109,15 @@ final public class UmlSource { */ public static UmlSource createWithRaw(List source, boolean checkEndingBackslash, List rawSource) { - final UmlSource result = new UmlSource(new ArrayList(), rawSource); + final UmlSource result = new UmlSource(emptyArrayList(), rawSource); result.loadInternal(source, checkEndingBackslash); return result; } + private static ArrayList emptyArrayList() { + return new ArrayList<>(); + } + private void loadInternal(List source, boolean checkEndingBackslash) { if (checkEndingBackslash) { final StringBuilder pending = new StringBuilder(); diff --git a/src/net/sourceforge/plantuml/style/FromSkinparamToStyle.java b/src/net/sourceforge/plantuml/style/FromSkinparamToStyle.java index 46908a2b3..70ecd4fd0 100644 --- a/src/net/sourceforge/plantuml/style/FromSkinparamToStyle.java +++ b/src/net/sourceforge/plantuml/style/FromSkinparamToStyle.java @@ -292,6 +292,9 @@ public class FromSkinparamToStyle { } else if (read.startsWith("line.dashed")) { for (Data data : datas) addStyle(PName.LineStyle, ValueImpl.regular("7;7", counter), data.styleNames); + } else if (read.toLowerCase().contains("bold")) { + for (Data data : datas) + addStyle(PName.LineThickness, ValueImpl.regular("2", counter), data.styleNames); } } diff --git a/src/net/sourceforge/plantuml/style/SName.java b/src/net/sourceforge/plantuml/style/SName.java index dd5f80852..048174af5 100644 --- a/src/net/sourceforge/plantuml/style/SName.java +++ b/src/net/sourceforge/plantuml/style/SName.java @@ -44,6 +44,7 @@ public enum SName { archimate, // arrow, // artifact, // + binary, // boundary, // box, // boxless, // diff --git a/src/net/sourceforge/plantuml/timingdiagram/PlayerBinary.java b/src/net/sourceforge/plantuml/timingdiagram/PlayerBinary.java index 5f4478020..5fd2c4928 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/PlayerBinary.java +++ b/src/net/sourceforge/plantuml/timingdiagram/PlayerBinary.java @@ -43,32 +43,44 @@ import java.util.SortedMap; import java.util.TreeMap; import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.command.Position; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.AbstractTextBlock; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.timingdiagram.graphic.IntricatedPoint; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULine; 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.HColorUtils; public class PlayerBinary extends Player { + private static final String LOW_STRING = "0"; + private static final String HIGH_STRING = "1"; + private final List constraints = new ArrayList<>(); - private final SortedMap values = new TreeMap(); - private Boolean initialState; + private final SortedMap values = new TreeMap<>(); + private ChangeState initialState; + private final Style style; public PlayerBinary(String code, ISkinParam skinParam, TimingRuler ruler, boolean compact) { super(code, skinParam, ruler, compact); + this.style = getStyleSignature().getMergedStyle(skinParam.getCurrentStyleBuilder()); this.suggestedHeight = 30; } @@ -82,18 +94,28 @@ public class PlayerBinary extends Player { @Override protected StyleSignatureBasic getStyleSignature() { - return StyleSignatureBasic.of(SName.root, SName.element, SName.timingDiagram, SName.clock); + return StyleSignatureBasic.of(SName.root, SName.element, SName.timingDiagram, SName.binary); } @Override protected SymbolContext getContextLegacy() { - return new SymbolContext(HColorUtils.COL_D7E0F2, HColorUtils.COL_038048).withStroke(new UStroke(1.5)); + + if (UseStyle.useBetaStyle() == false) + return new SymbolContext(HColorUtils.COL_D7E0F2, HColorUtils.COL_038048).withStroke(new UStroke(2)); + + final HColor lineColor = style.value(PName.LineColor).asColor(skinParam.getThemeStyle(), + skinParam.getIHtmlColorSet()); + final HColor backgroundColor = style.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(), + skinParam.getIHtmlColorSet()); + + return new SymbolContext(backgroundColor, lineColor).withStroke(getStroke()); + } public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) { final double x = ruler.getPosInPixel(tick); - return new IntricatedPoint(new Point2D.Double(x, getYpos(stringBounder, false)), - new Point2D.Double(x, getYpos(stringBounder, true))); + return new IntricatedPoint(new Point2D.Double(x, getYpos(stringBounder, HIGH_STRING)), + new Point2D.Double(x, getYpos(stringBounder, HIGH_STRING))); } public void addNote(TimeTick now, Display note, Position position) { @@ -105,16 +127,18 @@ public class PlayerBinary extends Player { } public void setState(TimeTick now, String comment, Colors color, String... states) { - final boolean state = getState(states[0]); - if (now == null) { - this.initialState = state; - } else { - this.values.put(now, state); - } + final ChangeState cs = new ChangeState(now, comment, color, convert(states[0])); + if (now == null) + this.initialState = cs; + else + this.values.put(now, cs); + } - private boolean getState(String value) { - return "1".equals(value) || "high".equalsIgnoreCase(value); + private String[] convert(String value) { + if ("1".equals(value) || "high".equalsIgnoreCase(value)) + return new String[] { HIGH_STRING }; + return new String[] { LOW_STRING }; } public void createConstraint(TimeTick tick1, TimeTick tick2, String message) { @@ -123,8 +147,10 @@ public class PlayerBinary extends Player { private final double ymargin = 8; - private double getYpos(StringBounder stringBounder, boolean state) { - return state ? getYhigh(stringBounder) : getYlow(stringBounder); + private double getYpos(StringBounder stringBounder, String state) { + if (state.equalsIgnoreCase(LOW_STRING)) + return getYlow(stringBounder); + return getYhigh(stringBounder); } private double getYlow(StringBounder stringBounder) { @@ -158,17 +184,25 @@ public class PlayerBinary extends Player { public void drawU(UGraphic ug) { ug = getContext().apply(ug); double lastx = 0; - boolean lastValue = initialState == null ? false : initialState; + String lastValue = initialState == null ? LOW_STRING : initialState.getState(); final StringBounder stringBounder = ug.getStringBounder(); final ULine vline = ULine.vline(getYlow(stringBounder) - getYhigh(stringBounder)); - for (Map.Entry ent : values.entrySet()) { + for (Map.Entry ent : values.entrySet()) { + final ChangeState value = ent.getValue(); final double x = ruler.getPosInPixel(ent.getKey()); + ug.apply(new UTranslate(lastx, getYpos(stringBounder, lastValue))).draw(ULine.hline(x - lastx)); - if (lastValue != ent.getValue()) { + if (lastValue.equalsIgnoreCase(value.getState()) == false) ug.apply(new UTranslate(x, getYhigh(stringBounder))).draw(vline); + + if (value.getComment() != null) { + final TextBlock label = getTextBlock(value.getComment()); + // final Dimension2D dim = label.calculateDimension(ug.getStringBounder()); + label.drawU(ug.apply(new UTranslate(x + 2, getYhigh(stringBounder)))); } + lastx = x; - lastValue = ent.getValue(); + lastValue = value.getState(); } ug.apply(new UTranslate(lastx, getYpos(stringBounder, lastValue))) .draw(ULine.hline(ruler.getWidth() - lastx)); @@ -179,6 +213,18 @@ public class PlayerBinary extends Player { }; } + final protected FontConfiguration getCommentFontConfiguration() { + if (UseStyle.useBetaStyle() == false) + return FontConfiguration.create(skinParam, FontParam.TIMING, null); + return FontConfiguration.create(skinParam, + getStyleSignature().getMergedStyle(skinParam.getCurrentStyleBuilder())); + } + + private TextBlock getTextBlock(String value) { + final Display display = Display.getWithNewlines(value); + return display.create(getCommentFontConfiguration(), HorizontalAlignment.LEFT, skinParam); + } + private void drawConstraints(final UGraphic ug) { for (TimeConstraint constraint : constraints) { constraint.drawU(ug, ruler); diff --git a/src/net/sourceforge/plantuml/timingdiagram/graphic/Histogram.java b/src/net/sourceforge/plantuml/timingdiagram/graphic/Histogram.java index 31977064c..182fdc293 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/graphic/Histogram.java +++ b/src/net/sourceforge/plantuml/timingdiagram/graphic/Histogram.java @@ -34,7 +34,6 @@ */ package net.sourceforge.plantuml.timingdiagram.graphic; -import net.sourceforge.plantuml.awt.geom.Dimension2D; import java.awt.geom.Point2D; import java.util.ArrayList; import java.util.Arrays; @@ -46,6 +45,7 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.UseStyle; +import net.sourceforge.plantuml.awt.geom.Dimension2D; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -56,9 +56,7 @@ import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.style.PName; -import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; -import net.sourceforge.plantuml.style.StyleSignatureBasic; import net.sourceforge.plantuml.timingdiagram.ChangeState; import net.sourceforge.plantuml.timingdiagram.TimeConstraint; import net.sourceforge.plantuml.timingdiagram.TimeTick; diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index e42e6f315..d2e0c5ef4 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -44,7 +44,7 @@ public class Version { private static final int MAJOR_SEPARATOR = 1000000; public static int version() { - return 1202202; + return 1202203; } public static int versionPatched() { @@ -80,7 +80,7 @@ public class Version { } public static int beta() { - final int beta = 4; + final int beta = 0; return beta; } @@ -93,7 +93,7 @@ public class Version { } public static long compileTime() { - return 1646497819191L; + return 1648570257787L; } public static String compileTimeString() {