From 87cbe82cd03ccfa34be89eb1148453f652d11a09 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Thu, 24 Feb 2022 19:18:19 +0100 Subject: [PATCH] wip --- .../plantuml/ditaa/PSystemDitaa.java | 10 ++++- .../plantuml/ditaa/PSystemDitaaFactory.java | 20 ++++++--- .../plantuml/elk/CucaDiagramFileMakerElk.java | 2 +- .../plantuml/graphic/SymbolContext.java | 11 +++-- .../plantuml/graphic/USymbolRectangle.java | 2 +- .../sourceforge/plantuml/mindmap/Branch.java | 6 +-- .../plantuml/mindmap/FingerImpl.java | 29 ++++++------- .../sourceforge/plantuml/mindmap/Idea.java | 5 ++- .../plantuml/mindmap/MindMapDiagram.java | 28 ++++++------ .../plantuml/mindmap/StripeFrontier.java | 43 +++++++++---------- .../mindmap/SymetricalTeePositioned.java | 8 ++-- .../sourceforge/plantuml/mindmap/Tetris.java | 24 +++++------ .../skin/rose/ComponentRoseParticipant.java | 5 ++- .../plantuml/style/FromSkinparamToStyle.java | 2 + .../plantuml/style/StyleLoader.java | 2 +- .../plantuml/style/StyleSignature.java | 2 +- .../sourceforge/plantuml/svek/Cluster.java | 19 ++++---- .../plantuml/svek/ClusterDecoration.java | 8 ++-- .../plantuml/svek/GeneralImageBuilder.java | 11 ++++- .../svek/image/EntityImageEmptyPackage.java | 6 ++- .../plantuml/ugraphic/svg/DriverTextSvg.java | 3 ++ .../sourceforge/plantuml/version/Version.java | 2 +- 22 files changed, 144 insertions(+), 104 deletions(-) diff --git a/src/net/sourceforge/plantuml/ditaa/PSystemDitaa.java b/src/net/sourceforge/plantuml/ditaa/PSystemDitaa.java index 9fd9f422c..eb3dcd11d 100644 --- a/src/net/sourceforge/plantuml/ditaa/PSystemDitaa.java +++ b/src/net/sourceforge/plantuml/ditaa/PSystemDitaa.java @@ -62,18 +62,23 @@ public class PSystemDitaa extends AbstractPSystem { private final String data; private final float scale; private final boolean performSeparationOfCommonEdges; + private final boolean allCornersAreRound; - public PSystemDitaa(UmlSource source, String data, boolean performSeparationOfCommonEdges, boolean dropShadows, float scale) { + public PSystemDitaa(UmlSource source, String data, boolean performSeparationOfCommonEdges, boolean dropShadows, + boolean allCornersAreRound, float scale) { super(source); this.data = data; this.dropShadows = dropShadows; this.performSeparationOfCommonEdges = performSeparationOfCommonEdges; + this.allCornersAreRound = allCornersAreRound; try { this.processingOptions = Class.forName("org.stathissideris.ascii2image.core.ProcessingOptions") .newInstance(); // this.processingOptions.setPerformSeparationOfCommonEdges(performSeparationOfCommonEdges); this.processingOptions.getClass().getMethod("setPerformSeparationOfCommonEdges", boolean.class) .invoke(this.processingOptions, performSeparationOfCommonEdges); + this.processingOptions.getClass().getMethod("setAllCornersAreRound", boolean.class) + .invoke(this.processingOptions, allCornersAreRound); } catch (Exception e) { e.printStackTrace(); this.processingOptions = null; @@ -82,7 +87,8 @@ public class PSystemDitaa extends AbstractPSystem { } PSystemDitaa add(String line) { - return new PSystemDitaa(getSource(), data + line + BackSlash.NEWLINE, performSeparationOfCommonEdges, dropShadows, scale); + return new PSystemDitaa(getSource(), data + line + BackSlash.NEWLINE, performSeparationOfCommonEdges, + dropShadows, allCornersAreRound, scale); } public DiagramDescription getDescription() { diff --git a/src/net/sourceforge/plantuml/ditaa/PSystemDitaaFactory.java b/src/net/sourceforge/plantuml/ditaa/PSystemDitaaFactory.java index daa3a3451..12fa22a23 100644 --- a/src/net/sourceforge/plantuml/ditaa/PSystemDitaaFactory.java +++ b/src/net/sourceforge/plantuml/ditaa/PSystemDitaaFactory.java @@ -65,14 +65,18 @@ public class PSystemDitaaFactory extends PSystemBasicFactory { if (startLine != null && (startLine.contains("-S") || startLine.contains("--no-shadows"))) dropShadows = false; + boolean allCornersAreRound = false; + if (startLine != null && (startLine.contains("-r") || startLine.contains("--round-corners"))) + allCornersAreRound = true; + final float scale = extractScale(startLine); - if (getDiagramType() == DiagramType.UML) { + if (getDiagramType() == DiagramType.UML) return null; - } else if (getDiagramType() == DiagramType.DITAA) { - return new PSystemDitaa(source, "", performSeparationOfCommonEdges, dropShadows, scale); - } else { + else if (getDiagramType() == DiagramType.DITAA) + return new PSystemDitaa(source, "", performSeparationOfCommonEdges, dropShadows, allCornersAreRound, scale); + else throw new IllegalStateException(getDiagramType().name()); - } + } @Override @@ -86,8 +90,12 @@ public class PSystemDitaaFactory extends PSystemBasicFactory { if (line.contains("-S") || line.contains("--no-shadows")) dropShadows = false; + boolean allCornersAreRound = false; + if (line.contains("-r") || line.contains("--round-corners")) + allCornersAreRound = true; + final float scale = extractScale(line); - return new PSystemDitaa(source, "", performSeparationOfCommonEdges, dropShadows, scale); + return new PSystemDitaa(source, "", performSeparationOfCommonEdges, dropShadows, allCornersAreRound, scale); } if (system == null) return null; diff --git a/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java b/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java index 0a18d80c6..8d3ead6b8 100644 --- a/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java +++ b/src/net/sourceforge/plantuml/elk/CucaDiagramFileMakerElk.java @@ -290,7 +290,7 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker { final HColor borderColor = HColorUtils.BLACK; decoration.drawU(ug.apply(new UTranslate(corner)), backColor, borderColor, shadowing, roundCorner, skinParam.getHorizontalAlignment(AlignmentParam.packageTitleAlignment, null, false, null), - skinParam.getStereotypeAlignment()); + skinParam.getStereotypeAlignment(), 0); // // Print a simple rectangle right now // ug.apply(HColorUtils.BLACK).apply(new UStroke(1.5)).apply(new UTranslate(corner)).draw(rect); diff --git a/src/net/sourceforge/plantuml/graphic/SymbolContext.java b/src/net/sourceforge/plantuml/graphic/SymbolContext.java index a1f7e0d9b..e5db6c7f0 100644 --- a/src/net/sourceforge/plantuml/graphic/SymbolContext.java +++ b/src/net/sourceforge/plantuml/graphic/SymbolContext.java @@ -72,12 +72,15 @@ public class SymbolContext { } public UGraphic applyColors(UGraphic ug) { - ug = ug.apply(foreColor); - if (backColor == null) { + if (foreColor == null) + ug = ug.apply(new HColorNone()); + else + ug = ug.apply(foreColor); + if (backColor == null) ug = ug.apply(new HColorNone().bg()); - } else { + else ug = ug.apply(backColor.bg()); - } + return ug; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolRectangle.java b/src/net/sourceforge/plantuml/graphic/USymbolRectangle.java index 3d322254d..3311e1c80 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolRectangle.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolRectangle.java @@ -108,7 +108,7 @@ class USymbolRectangle extends USymbol { final Dimension2D dim = calculateDimension(ug.getStringBounder()); ug = symbolContext.apply(ug); drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.getDeltaShadow(), - symbolContext.getRoundCorner(), 0); + symbolContext.getRoundCorner(), symbolContext.getDiagonalCorner()); final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder()); final double posStereoX; final double posStereoY; diff --git a/src/net/sourceforge/plantuml/mindmap/Branch.java b/src/net/sourceforge/plantuml/mindmap/Branch.java index bd6eff0d1..54d820443 100644 --- a/src/net/sourceforge/plantuml/mindmap/Branch.java +++ b/src/net/sourceforge/plantuml/mindmap/Branch.java @@ -51,7 +51,7 @@ class Branch implements UDrawable { private Finger finger; void initRoot(StyleBuilder styleBuilder, HColor backColor, Display label, IdeaShape shape, String stereotype) { - root = new Idea(styleBuilder, backColor, label, shape, stereotype); + root = Idea.createIdeaSimple(styleBuilder, backColor, label, shape, stereotype); last = root; } @@ -61,9 +61,9 @@ class Branch implements UDrawable { Idea getParentOfLast(int nb) { Idea result = last; - for (int i = 0; i < nb; i++) { + for (int i = 0; i < nb; i++) result = result.getParent(); - } + return result; } diff --git a/src/net/sourceforge/plantuml/mindmap/FingerImpl.java b/src/net/sourceforge/plantuml/mindmap/FingerImpl.java index 272295760..33df5f1c2 100644 --- a/src/net/sourceforge/plantuml/mindmap/FingerImpl.java +++ b/src/net/sourceforge/plantuml/mindmap/FingerImpl.java @@ -114,10 +114,9 @@ public class FingerImpl implements Finger, UDrawable { public static FingerImpl build(Idea idea, ISkinParam skinParam, Direction direction) { final FingerImpl result = new FingerImpl(idea.getStyleBuilder(), idea.getBackColor(), idea.getLabel(), skinParam, idea.getShape(), direction, idea.getLevel(), idea.getStereotype()); - for (Idea child : idea.getChildren()) { + for (Idea child : idea.getChildren()) result.addInNail(build(child, skinParam, direction)); - } - // System.err.println("End of build for " + idea); + return result; } @@ -156,7 +155,7 @@ public class FingerImpl implements Finger, UDrawable { for (int i = 0; i < nail.size(); i++) { final FingerImpl child = nail.get(i); - final SymetricalTeePositioned stp = tetris(stringBounder).getElements().get(i); + final SymetricalTeePositioned stp = getTetris(stringBounder).getElements().get(i); final double x = direction == Direction.RIGHT ? dimPhalanx.getWidth() + getX12() : -dimPhalanx.getWidth() - getX12(); final Point2D p2 = new Point2D.Double(x, stp.getY()); @@ -189,12 +188,12 @@ public class FingerImpl implements Finger, UDrawable { ug.draw(path); } - private Tetris tetris(StringBounder stringBounder) { + private Tetris getTetris(StringBounder stringBounder) { if (tetris == null) { tetris = new Tetris(label.toString()); - for (FingerImpl child : nail) { + for (FingerImpl child : nail) tetris.add(child.asSymetricalTee(stringBounder)); - } + tetris.balance(); } return tetris; @@ -203,9 +202,9 @@ public class FingerImpl implements Finger, UDrawable { private SymetricalTee asSymetricalTee(StringBounder stringBounder) { final double thickness1 = getPhalanxThickness(stringBounder); final double elongation1 = getPhalanxElongation(stringBounder); - if (nail.size() == 0) { + if (nail.size() == 0) return new SymetricalTee(thickness1, elongation1, 0, 0); - } + final double thickness2 = getNailThickness(stringBounder); final double elongation2 = getNailElongation(stringBounder); return new SymetricalTee(thickness1, elongation1 + getX1(), thickness2, getX2() + elongation2); @@ -232,9 +231,9 @@ public class FingerImpl implements Finger, UDrawable { } private TextBlock getPhalanx() { - if (drawPhalanx == false) { + if (drawPhalanx == false) return TextBlockUtils.empty(0, 0); - } + if (shape == IdeaShape.BOX) { final ISkinParam foo = new SkinParamColors(skinParam, Colors.empty().add(ColorType.BACK, backColor)); final TextBlock box = FtileBoxOld.createMindMap(styleBuilder, foo, label, getDefaultStyleDefinitionNode()); @@ -246,18 +245,18 @@ public class FingerImpl implements Finger, UDrawable { final TextBlock text = label.create0( styleNode.getFontConfiguration(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet()), styleNode.getHorizontalAlignment(), skinParam, styleNode.wrapWidth(), CreoleMode.FULL, null, null); - if (direction == Direction.RIGHT) { + if (direction == Direction.RIGHT) return TextBlockUtils.withMargin(text, 3, 0, 1, 1); - } + return TextBlockUtils.withMargin(text, 0, 3, 1, 1); } public double getNailThickness(StringBounder stringBounder) { - return tetris(stringBounder).getHeight(); + return getTetris(stringBounder).getHeight(); } public double getNailElongation(StringBounder stringBounder) { - return tetris(stringBounder).getWidth(); + return getTetris(stringBounder).getWidth(); } public double getFullThickness(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/mindmap/Idea.java b/src/net/sourceforge/plantuml/mindmap/Idea.java index 7e3fc0d78..b5fd48ced 100644 --- a/src/net/sourceforge/plantuml/mindmap/Idea.java +++ b/src/net/sourceforge/plantuml/mindmap/Idea.java @@ -55,8 +55,9 @@ class Idea { private final StyleBuilder styleBuilder; private final String stereotype; - public Idea(StyleBuilder styleBuilder, HColor backColor, Display label, IdeaShape shape, String stereotype) { - this(styleBuilder, backColor, 0, null, label, shape, stereotype); + public static Idea createIdeaSimple(StyleBuilder styleBuilder, HColor backColor, Display label, IdeaShape shape, + String stereotype) { + return new Idea(styleBuilder, backColor, 0, null, label, shape, stereotype); } public Idea createIdea(StyleBuilder styleBuilder, HColor backColor, int newLevel, Display newDisplay, diff --git a/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java b/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java index ad117afb1..aabb0726c 100644 --- a/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java +++ b/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java @@ -134,9 +134,9 @@ public class MindMapDiagram extends UmlDiagram { public CommandExecutionResult addIdea(HColor backColor, int level, Display label, IdeaShape shape, Direction direction) { String stereotype = label.getEndingStereotype(); - if (stereotype != null) { + if (stereotype != null) label = label.removeEndingStereotype(); - } + if (last().isFull(level)) this.mindmaps.add(new MindMap(getSkinParam())); @@ -154,25 +154,25 @@ public class MindMapDiagram extends UmlDiagram { private String first; public int getSmartLevel(String type) { - if (first == null) { + if (first == null) first = type; - } - if (type.endsWith("**")) { + + if (type.endsWith("**")) type = type.replace('\t', ' ').trim(); - } + type = type.replace('\t', ' '); - if (type.contains(" ") == false) { + if (type.contains(" ") == false) return type.length() - 1; - } - if (type.endsWith(first)) { + + if (type.endsWith(first)) return type.length() - first.length(); - } - if (type.trim().length() == 1) { + + if (type.trim().length() == 1) return type.length() - 1; - } - if (type.startsWith(first)) { + + if (type.startsWith(first)) return type.length() - first.length(); - } + throw new UnsupportedOperationException("type=<" + type + ">[" + first + "]"); } diff --git a/src/net/sourceforge/plantuml/mindmap/StripeFrontier.java b/src/net/sourceforge/plantuml/mindmap/StripeFrontier.java index 263188e29..3f1c78398 100644 --- a/src/net/sourceforge/plantuml/mindmap/StripeFrontier.java +++ b/src/net/sourceforge/plantuml/mindmap/StripeFrontier.java @@ -57,20 +57,19 @@ public class StripeFrontier { } public boolean contains(double x, double y) { - for (Stripe stripe : stripes) { - if (stripe.contains(x)) { + for (Stripe stripe : stripes) + if (stripe.contains(x)) return y <= stripe.getValue(); - } - } + throw new UnsupportedOperationException(); } public double getContact(double x1, double x2) { final SortedSet collisions = collisionning(x1, x2); double result = -Double.MAX_VALUE; - for (Stripe strip : collisions) { + for (Stripe strip : collisions) result = Math.max(result, strip.getValue()); - } + return result; } @@ -104,35 +103,35 @@ public class StripeFrontier { } private void addSingleInternal(double x1, double x2, double value, final Stripe touch) { - if (value <= touch.getValue()) { + if (value <= touch.getValue()) return; - } + final boolean ok = this.stripes.remove(touch); assert ok; - if (touch.getStart() != x1) { + if (touch.getStart() != x1) this.stripes.add(new Stripe(touch.getStart(), x1, touch.getValue())); - } + this.stripes.add(new Stripe(x1, x2, value)); - if (x2 != touch.getEnd()) { + if (x2 != touch.getEnd()) this.stripes.add(new Stripe(x2, touch.getEnd(), touch.getValue())); - } + assert checkConsistent(); } private boolean checkConsistent() { Stripe last = null; for (Stripe stripe : stripes) { - if (last == null && stripe.getStart() != -Double.MAX_VALUE) { + if (last == null && stripe.getStart() != -Double.MAX_VALUE) return false; - } - if (last != null && last.getEnd() != stripe.getStart()) { + + if (last != null && last.getEnd() != stripe.getStart()) return false; - } + last = stripe; } - if (last.getEnd() != Double.MAX_VALUE) { + if (last.getEnd() != Double.MAX_VALUE) return false; - } + return true; } @@ -140,13 +139,13 @@ public class StripeFrontier { final SortedSet result = new TreeSet<>(); for (Iterator it = stripes.iterator(); it.hasNext();) { Stripe stripe = it.next(); - if (x1 >= stripe.getEnd()) { + if (x1 >= stripe.getEnd()) continue; - } + result.add(stripe); - if (x2 <= stripe.getEnd()) { + if (x2 <= stripe.getEnd()) return result; - } + } throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/mindmap/SymetricalTeePositioned.java b/src/net/sourceforge/plantuml/mindmap/SymetricalTeePositioned.java index eac58ea5b..9b5853325 100644 --- a/src/net/sourceforge/plantuml/mindmap/SymetricalTeePositioned.java +++ b/src/net/sourceforge/plantuml/mindmap/SymetricalTeePositioned.java @@ -105,12 +105,12 @@ public class SymetricalTeePositioned { } public SymetricalTeePositioned getMax(SymetricalTeePositioned other) { - if (this.tee != other.tee) { + if (this.tee != other.tee) throw new IllegalArgumentException(); - } - if (other.y > this.y) { + + if (other.y > this.y) return other; - } + return this; } diff --git a/src/net/sourceforge/plantuml/mindmap/Tetris.java b/src/net/sourceforge/plantuml/mindmap/Tetris.java index 29df6a59a..2285b0a85 100644 --- a/src/net/sourceforge/plantuml/mindmap/Tetris.java +++ b/src/net/sourceforge/plantuml/mindmap/Tetris.java @@ -58,35 +58,35 @@ public class Tetris { } public void balance() { - if (elements.size() == 0) { + if (elements.size() == 0) return; - } - if (minY != Double.MAX_VALUE) { + + if (minY != Double.MAX_VALUE) throw new IllegalStateException(); - } + for (SymetricalTeePositioned element : elements) { minY = Math.min(minY, element.getMinY()); maxY = Math.max(maxY, element.getMaxY()); } final double mean = (minY + maxY) / 2; - for (SymetricalTeePositioned stp : elements) { + for (SymetricalTeePositioned stp : elements) stp.move(-mean); - } + // System.err.println("Balanced=" + this + " " + elements); } public double getHeight() { - if (elements.size() == 0) { + if (elements.size() == 0) return 0; - } + return maxY - minY; } public double getWidth() { double result = 0; - for (SymetricalTeePositioned tee : elements) { + for (SymetricalTeePositioned tee : elements) result = Math.max(result, tee.getMaxX()); - } + return result; } @@ -126,9 +126,9 @@ public class Tetris { assert b1.getY1() == b1.getY2(); final Line2D b2 = result.getSegmentB2(); - if (b2.getX1() != b2.getX2()) { + if (b2.getX1() != b2.getX2()) frontier.addSegment(b2.getX1(), b2.getX2(), b2.getY1()); - } + assert b2.getY1() == b2.getY2(); } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseParticipant.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseParticipant.java index 2f1b61f13..02c625555 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseParticipant.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseParticipant.java @@ -96,7 +96,10 @@ public class ComponentRoseParticipant extends AbstractTextualComponent { protected void drawInternalU(UGraphic ug, Area area) { final StringBounder stringBounder = ug.getStringBounder(); ug = ug.apply(UTranslate.dx(padding)); - ug = ug.apply(back.bg()).apply(foregroundColor); + if (foregroundColor != null) + ug = ug.apply(foregroundColor); + if (back != null) + ug = ug.apply(back.bg()); ug = ug.apply(stroke); final Shadowable rect = new URectangle(getTextWidth(stringBounder), getTextHeight(stringBounder)) .rounded(roundCorner).diagonalCorner(diagonalCorner); diff --git a/src/net/sourceforge/plantuml/style/FromSkinparamToStyle.java b/src/net/sourceforge/plantuml/style/FromSkinparamToStyle.java index 414cd679e..7bc20351c 100644 --- a/src/net/sourceforge/plantuml/style/FromSkinparamToStyle.java +++ b/src/net/sourceforge/plantuml/style/FromSkinparamToStyle.java @@ -216,6 +216,8 @@ public class FromSkinparamToStyle { addConvert(cleanName + "BackgroundColor", PName.BackGroundColor, sname); addConvert(cleanName + "BorderColor", PName.LineColor, sname); addConvert(cleanName + "BorderThickness", PName.LineThickness, sname); + addConvert(cleanName + "RoundCorner", PName.RoundCorner, sname); + addConvert(cleanName + "DiagonalCorner", PName.DiagonalCorner, sname); addConFont(cleanName, sname); } diff --git a/src/net/sourceforge/plantuml/style/StyleLoader.java b/src/net/sourceforge/plantuml/style/StyleLoader.java index d19136563..50811428a 100644 --- a/src/net/sourceforge/plantuml/style/StyleLoader.java +++ b/src/net/sourceforge/plantuml/style/StyleLoader.java @@ -110,7 +110,7 @@ public class StyleLoader { } - private final static String KEYNAMES = "[.\\w(), ]+?"; + private final static String KEYNAMES = "[-.\\w(), ]+?"; private final static Pattern2 keyName = MyPattern.cmpile("^[:]?(" + KEYNAMES + ")([%s]+\\*)?[%s]*\\{$"); private final static Pattern2 propertyAndValue = MyPattern.cmpile("^([\\w]+):?[%s]+(.*?);?$"); private final static Pattern2 closeBracket = MyPattern.cmpile("^\\}$"); diff --git a/src/net/sourceforge/plantuml/style/StyleSignature.java b/src/net/sourceforge/plantuml/style/StyleSignature.java index b9720863f..e5c6ece01 100644 --- a/src/net/sourceforge/plantuml/style/StyleSignature.java +++ b/src/net/sourceforge/plantuml/style/StyleSignature.java @@ -86,7 +86,7 @@ public class StyleSignature { if (s == null) return this; - if (s.contains("*") || s.contains("&") || s.contains("-")) + if (s.contains("*") || s.contains("&")) throw new IllegalArgumentException(); final Set result = new LinkedHashSet<>(names); diff --git a/src/net/sourceforge/plantuml/svek/Cluster.java b/src/net/sourceforge/plantuml/svek/Cluster.java index 987774968..7bb69127c 100644 --- a/src/net/sourceforge/plantuml/svek/Cluster.java +++ b/src/net/sourceforge/plantuml/svek/Cluster.java @@ -318,6 +318,7 @@ public class Cluster implements Moveable { HColor borderColor; Style style = null; final double rounded; + final double diagonalCorner; final double shadowing; if (UseStyle.useBetaStyle()) { final USymbol uSymbol = group.getUSymbol() == null ? USymbols.PACKAGE : group.getUSymbol(); @@ -329,10 +330,8 @@ public class Cluster implements Moveable { else borderColor = style.value(PName.LineColor).asColor(skinParam2.getThemeStyle(), skinParam2.getIHtmlColorSet()); - if (umlDiagramType == UmlDiagramType.STATE) - rounded = style.value(PName.RoundCorner).asDouble(); - else - rounded = IEntityImage.CORNER; + rounded = style.value(PName.RoundCorner).asDouble(); + diagonalCorner = style.value(PName.DiagonalCorner).asDouble(); } else { if (group.getUSymbol() == null) @@ -347,10 +346,10 @@ public class Cluster implements Moveable { borderColor = getColor(ColorParam.packageBorder, skinParam, group.getStereotype()); else borderColor = getColor(ColorParam.packageBorder, skinParam, group.getStereotype()); + diagonalCorner = 0; } - ug.startGroup(Collections.singletonMap(UGroupType.ID, "cluster_" + fullName)); final Url url = group.getUrl99(); @@ -399,14 +398,18 @@ public class Cluster implements Moveable { backColor = getBackColor(backColor, skinParam2, group.getStereotype(), umlDiagramType.getStyleName(), group.getUSymbol()); if (ztitle != null || zstereo != null) { - final double roundCorner = group.getUSymbol() == null ? 0 - : group.getUSymbol().getSkinParameter().getRoundCorner(skinParam, group.getStereotype()); + final double roundCorner; + if (UseStyle.useBetaStyle()) + roundCorner = rounded; + else + roundCorner = group.getUSymbol() == null ? 0 + : group.getUSymbol().getSkinParameter().getRoundCorner(skinParam, group.getStereotype()); final ClusterDecoration decoration = new ClusterDecoration(packageStyle, group.getUSymbol(), ztitle, zstereo, minX, minY, maxX, maxY, stroke); decoration.drawU(ug, backColor, borderColor, shadowing, roundCorner, skinParam2.getHorizontalAlignment(AlignmentParam.packageTitleAlignment, null, false, null), - skinParam2.getStereotypeAlignment()); + skinParam2.getStereotypeAlignment(), diagonalCorner); return; } final URectangle rect = new URectangle(maxX - minX, maxY - minY); diff --git a/src/net/sourceforge/plantuml/svek/ClusterDecoration.java b/src/net/sourceforge/plantuml/svek/ClusterDecoration.java index 07f9956c0..1a159784b 100644 --- a/src/net/sourceforge/plantuml/svek/ClusterDecoration.java +++ b/src/net/sourceforge/plantuml/svek/ClusterDecoration.java @@ -77,13 +77,13 @@ public class ClusterDecoration { } public void drawU(UGraphic ug, HColor backColor, HColor borderColor, double shadowing, double roundCorner, - HorizontalAlignment titleAlignment, HorizontalAlignment stereoAlignment) { + HorizontalAlignment titleAlignment, HorizontalAlignment stereoAlignment, double diagonalCorner) { final SymbolContext biColor = new SymbolContext(backColor, borderColor); - if (symbol == null) { + if (symbol == null) throw new UnsupportedOperationException(); - } + final SymbolContext symbolContext = biColor.withShadow(shadowing).withStroke(defaultStroke) - .withCorner(roundCorner, 0); + .withCorner(roundCorner, diagonalCorner); symbol.asBig(title, titleAlignment, stereo, maxX - minX, maxY - minY, symbolContext, stereoAlignment) .drawU(ug.apply(new UTranslate(minX, minY))); } diff --git a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java index e1caaf1cf..517dc754a 100644 --- a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java +++ b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java @@ -101,6 +101,7 @@ import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.USymbolHexagon; import net.sourceforge.plantuml.graphic.USymbolInterface; +import net.sourceforge.plantuml.graphic.USymbols; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; @@ -705,10 +706,18 @@ public final class GeneralImageBuilder { final FontConfiguration fontConfiguration; if (UseStyle.useBetaStyle()) { final SName sname = dotData.getUmlDiagramType().getStyleName(); - final Style style = StyleSignature.of(SName.root, SName.element, sname, SName.title) // + final StyleSignature signature; + final USymbol uSymbol = g.getUSymbol(); + if (uSymbol == USymbols.RECTANGLE) + signature = StyleSignature.of(SName.root, SName.element, sname, uSymbol.getSName(), SName.title); + else + signature = StyleSignature.of(SName.root, SName.element, sname, SName.title); + + final Style style = signature // .with(g.getStereotype()) // .with(g.getStereostyles()) // .getMergedStyle(skinParam.getCurrentStyleBuilder()); + fontConfiguration = style.getFontConfiguration(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet()); } else fontConfiguration = g.getFontConfigurationForTitle(skinParam); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java b/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java index 088d6f8e2..1d4547647 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java @@ -88,6 +88,7 @@ public class EntityImageEmptyPackage extends AbstractEntityImage { private final HColor borderColor; private final UStroke stroke; private final double roundCorner; + private final double diagonalCorner; private final HColor back; private Style getStyle() { @@ -117,6 +118,7 @@ public class EntityImageEmptyPackage extends AbstractEntityImage { this.shadowing = style.value(PName.Shadowing).asDouble(); this.stroke = style.getStroke(colors); this.roundCorner = style.value(PName.RoundCorner).asDouble(); + this.diagonalCorner = style.value(PName.DiagonalCorner).asDouble(); if (specificBackColor == null) { this.back = style.value(PName.BackGroundColor).asColor(getSkinParam().getThemeStyle(), getSkinParam().getIHtmlColorSet()); @@ -127,6 +129,7 @@ public class EntityImageEmptyPackage extends AbstractEntityImage { getSkinParam().getIHtmlColorSet()); titleHorizontalAlignment = style.getHorizontalAlignment(); } else { + this.diagonalCorner = 0; this.borderColor = SkinParamUtils.getColor(getSkinParam(), getStereo(), ColorParam.packageBorder); this.shadowing = getSkinParam().shadowing(getEntity().getStereotype()) ? 3 : 0; this.stroke = GeneralImageBuilder.getForcedStroke(getEntity().getStereotype(), getSkinParam()); @@ -182,7 +185,8 @@ public class EntityImageEmptyPackage extends AbstractEntityImage { .getHorizontalAlignment(AlignmentParam.packageTitleAlignment, null, false, null); final HorizontalAlignment stereotypeAlignment = getSkinParam().getStereotypeAlignment(); - decoration.drawU(ug, back, borderColor, shadowing, roundCorner, horizontalAlignment, stereotypeAlignment); + decoration.drawU(ug, back, borderColor, shadowing, roundCorner, horizontalAlignment, stereotypeAlignment, + diagonalCorner); if (url != null) { ug.closeUrl(); diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java index 3c17eb150..2a7f0aff4 100644 --- a/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java +++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java @@ -95,6 +95,9 @@ public class DriverTextSvg implements UDriver { } String text = shape.getText(); + if (text.matches("^\\s*$")) + text = text.replace(' ', (char)160); + if (text.startsWith(" ")) { final double space = stringBounder.calculateDimension(font, " ").getWidth(); while (text.startsWith(" ")) { diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 3a1ed81fa..2c4e5a4f9 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -80,7 +80,7 @@ public class Version { } public static int beta() { - final int beta = 6; + final int beta = 8; return beta; }