From 38877c5420bfaf2885bf9e37e428e5045591f1d6 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Sun, 21 Nov 2021 12:09:15 +0100 Subject: [PATCH] wip --- .../sourceforge/plantuml/AbstractPSystem.java | 5 + .../sourceforge/plantuml/EmbeddedDiagram.java | 2 +- .../sourceforge/plantuml/TitledDiagram.java | 12 +- .../sourceforge/plantuml/api/ApiStable.java | 15 ++ .../sourceforge/plantuml/api/ApiWarning.java | 2 +- .../sourceforge/plantuml/core/Diagram.java | 23 +-- .../cucadiagram/DisplayPositionned.java | 3 + .../sourceforge/plantuml/mindmap/Branch.java | 129 +++++++++++++++++ .../sourceforge/plantuml/mindmap/MindMap.java | 135 ++++++++++++++++++ .../plantuml/mindmap/MindMapDiagram.java | 129 +---------------- .../plantuml/picoweb/PicoWebServer.java | 11 +- .../plantuml/svek/GeneralImageBuilder.java | 2 +- .../svek/image/EntityImageStateCommon.java | 10 +- .../svek/image/EntityImageSynchroBar.java | 14 +- 14 files changed, 344 insertions(+), 148 deletions(-) create mode 100644 src/net/sourceforge/plantuml/api/ApiStable.java create mode 100644 src/net/sourceforge/plantuml/mindmap/Branch.java create mode 100644 src/net/sourceforge/plantuml/mindmap/MindMap.java diff --git a/src/net/sourceforge/plantuml/AbstractPSystem.java b/src/net/sourceforge/plantuml/AbstractPSystem.java index cf3f0b2bd..f5dd1edc9 100644 --- a/src/net/sourceforge/plantuml/AbstractPSystem.java +++ b/src/net/sourceforge/plantuml/AbstractPSystem.java @@ -203,5 +203,10 @@ public abstract class AbstractPSystem implements Diagram { public ClockwiseTopRightBottomLeft getDefaultMargins() { return ClockwiseTopRightBottomLeft.same(0); } + + @Override + public Display getTitleDisplay() { + return null; + } } diff --git a/src/net/sourceforge/plantuml/EmbeddedDiagram.java b/src/net/sourceforge/plantuml/EmbeddedDiagram.java index f3d07ff6b..0200ab50b 100644 --- a/src/net/sourceforge/plantuml/EmbeddedDiagram.java +++ b/src/net/sourceforge/plantuml/EmbeddedDiagram.java @@ -206,4 +206,4 @@ public class EmbeddedDiagram implements CharSequence { } } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/TitledDiagram.java b/src/net/sourceforge/plantuml/TitledDiagram.java index 26059fafc..c4cbc90e6 100644 --- a/src/net/sourceforge/plantuml/TitledDiagram.java +++ b/src/net/sourceforge/plantuml/TitledDiagram.java @@ -39,6 +39,7 @@ import java.io.IOException; import net.sourceforge.plantuml.anim.Animation; import net.sourceforge.plantuml.anim.AnimationDecoder; +import net.sourceforge.plantuml.api.ApiStable; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.UmlSource; @@ -166,9 +167,8 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, // } final public void setTitle(DisplayPositioned title) { - if (title.isNull() || title.getDisplay().isWhite()) { + if (title.isNull() || title.getDisplay().isWhite()) return; - } this.title = title; } @@ -177,6 +177,14 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, return title; } + @Override + @ApiStable + final public Display getTitleDisplay() { + if (title == null) + return null; + return title.getDisplay(); + } + final public void setMainFrame(Display mainFrame) { this.mainFrame = mainFrame; } diff --git a/src/net/sourceforge/plantuml/api/ApiStable.java b/src/net/sourceforge/plantuml/api/ApiStable.java new file mode 100644 index 000000000..aa0016580 --- /dev/null +++ b/src/net/sourceforge/plantuml/api/ApiStable.java @@ -0,0 +1,15 @@ +package net.sourceforge.plantuml.api; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * This indicates that an element will be stable over PlantUML version. + * Third party tools can then use it safely. + */ +@Retention(RetentionPolicy.SOURCE) +@Target({ ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE }) +public @interface ApiStable { +} diff --git a/src/net/sourceforge/plantuml/api/ApiWarning.java b/src/net/sourceforge/plantuml/api/ApiWarning.java index 2d6553a38..ece0f976f 100644 --- a/src/net/sourceforge/plantuml/api/ApiWarning.java +++ b/src/net/sourceforge/plantuml/api/ApiWarning.java @@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(RetentionPolicy.SOURCE) -@Target({ ElementType.CONSTRUCTOR, ElementType.METHOD }) +@Target({ ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE }) public @interface ApiWarning { String willBeRemoved() default ""; diff --git a/src/net/sourceforge/plantuml/core/Diagram.java b/src/net/sourceforge/plantuml/core/Diagram.java index 74372a608..cf9ec20fd 100644 --- a/src/net/sourceforge/plantuml/core/Diagram.java +++ b/src/net/sourceforge/plantuml/core/Diagram.java @@ -39,24 +39,27 @@ import java.io.IOException; import java.io.OutputStream; import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.api.ApiStable; +import net.sourceforge.plantuml.cucadiagram.Display; /** - * Represents a single diagram. A Diagram could be a UML (sequence diagram, class diagram...) or an non-UML diagram. + * Represents a single diagram. A Diagram could be a UML (sequence diagram, + * class diagram...) or an non-UML diagram. * * @author Arnaud Roques */ +@ApiStable public interface Diagram { /** - * Export the diagram as an image to some format. Note that a diagram could be drawn as several images (think about - * new page for sequence diagram for example). + * Export the diagram as an image to some format. Note that a diagram could be + * drawn as several images (think about new page for sequence + * diagram for example). * - * @param os - * where to write the image - * @param num - * usually 0 (index of the image to be exported for this diagram). - * @param fileFormat - * file format to use + * @param os where to write the image + * @param num usually 0 (index of the image to be exported for this + * diagram). + * @param fileFormat file format to use * * @return a description of the generated image * @@ -95,4 +98,6 @@ public interface Diagram { */ public boolean hasUrl(); + public Display getTitleDisplay(); + } diff --git a/src/net/sourceforge/plantuml/cucadiagram/DisplayPositionned.java b/src/net/sourceforge/plantuml/cucadiagram/DisplayPositionned.java index 88b199d14..12d39165c 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/DisplayPositionned.java +++ b/src/net/sourceforge/plantuml/cucadiagram/DisplayPositionned.java @@ -35,6 +35,8 @@ */ package net.sourceforge.plantuml.cucadiagram; +import net.sourceforge.plantuml.api.ApiWarning; + /** * * There is a typo in this class name. @@ -44,6 +46,7 @@ package net.sourceforge.plantuml.cucadiagram; * */ @Deprecated +@ApiWarning(willBeRemoved = "use DisplayPositioned instead") public class DisplayPositionned { public Display getDisplay() { diff --git a/src/net/sourceforge/plantuml/mindmap/Branch.java b/src/net/sourceforge/plantuml/mindmap/Branch.java new file mode 100644 index 000000000..bd6eff0d1 --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/Branch.java @@ -0,0 +1,129 @@ +/* ======================================================================== + * 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.mindmap; + +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.style.StyleBuilder; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.color.HColor; + +class Branch implements UDrawable { + private Idea root; + private Idea last; + private Finger finger; + + void initRoot(StyleBuilder styleBuilder, HColor backColor, Display label, IdeaShape shape, String stereotype) { + root = new Idea(styleBuilder, backColor, label, shape, stereotype); + last = root; + } + + void initFinger(ISkinParam skinParam, Direction direction) { + finger = FingerImpl.build(root, skinParam, direction); + } + + Idea getParentOfLast(int nb) { + Idea result = last; + for (int i = 0; i < nb; i++) { + result = result.getParent(); + } + return result; + } + + CommandExecutionResult add(StyleBuilder styleBuilder, HColor backColor, int level, Display label, IdeaShape shape, + String stereotype) { + if (last == null) + return CommandExecutionResult.error("Check your indentation ?"); + + if (level == last.getLevel() + 1) { + final Idea newIdea = last.createIdea(styleBuilder, backColor, level, label, shape, stereotype); + last = newIdea; + return CommandExecutionResult.ok(); + } + if (level <= last.getLevel()) { + final int diff = last.getLevel() - level + 1; + final Idea newIdea = getParentOfLast(diff).createIdea(styleBuilder, backColor, level, label, shape, + stereotype); + last = newIdea; + return CommandExecutionResult.ok(); + } + return CommandExecutionResult.error("error42L"); + } + + public boolean hasFinger() { + return finger != null; + } + + public void drawU(UGraphic ug) { + if (finger != null) + finger.drawU(ug); + } + + public double getHalfThickness(StringBounder stringBounder) { + if (finger == null) + return 0; + return finger.getFullThickness(stringBounder) / 2; + } + + public double getFullElongation(StringBounder stringBounder) { + if (finger == null) + return 0; + return finger.getFullElongation(stringBounder); + } + + public boolean hasChildren() { + return root.hasChildren(); + } + + public boolean hasRoot() { + return root != null; + } + + public void doNotDrawFirstPhalanx() { + finger.doNotDrawFirstPhalanx(); + } + + public double getX12(StringBounder stringBounder) { + if (finger == null) + return 0; + return finger.getFullElongation(stringBounder) + ((FingerImpl) finger).getX12(); + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/MindMap.java b/src/net/sourceforge/plantuml/mindmap/MindMap.java new file mode 100644 index 000000000..bcef737d4 --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/MindMap.java @@ -0,0 +1,135 @@ +/* ======================================================================== + * 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.mindmap; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.style.NoStyleAvailableException; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.color.HColor; + +public class MindMap implements UDrawable { + + private final Branch left = new Branch(); + private final Branch right = new Branch(); + + private final ISkinParam skinParam; + + public MindMap(ISkinParam skinParam) { + this.skinParam = skinParam; + } + + private void computeFinger() { + if (this.left.hasFinger() == false && this.right.hasFinger() == false) { + if (this.left.hasChildren()) + left.initFinger(skinParam, Direction.LEFT); + + if (this.left.hasFinger() == false || this.right.hasChildren()) + right.initFinger(skinParam, Direction.RIGHT); + + if (this.left.hasFinger() && this.right.hasFinger()) + this.left.doNotDrawFirstPhalanx(); + + } + } + + Dimension2D calculateDimension(StringBounder stringBounder) { + this.computeFinger(); + final double y1 = this.right.getHalfThickness(stringBounder); + final double y2 = this.left.getHalfThickness(stringBounder); + final double y = Math.max(y1, y2); + + final double x = this.left.getFullElongation(stringBounder); + + final double width = x + this.right.getFullElongation(stringBounder); + final double height = y + + Math.max(this.left.getHalfThickness(stringBounder), this.right.getHalfThickness(stringBounder)); + return new Dimension2DDouble(width, height); + + } + + @Override + public void drawU(UGraphic ug) { + if (this.left.hasRoot() == false && this.right.hasRoot() == false) + return; + + this.computeFinger(); + + final StringBounder stringBounder = ug.getStringBounder(); + final double y1 = this.right.getHalfThickness(stringBounder); + final double y2 = this.left.getHalfThickness(stringBounder); + final double y = Math.max(y1, y2); + + final double x = this.left.getX12(stringBounder); + this.right.drawU(ug.apply(new UTranslate(x, y))); + this.left.drawU(ug.apply(new UTranslate(x, y))); + } + + CommandExecutionResult addIdeaInternal(String stereotype, HColor backColor, int level, Display label, + IdeaShape shape, Direction direction) { + + if (level == 0 && this.right.hasRoot()) + return CommandExecutionResult.error( + "I don't know how to draw multi-root diagram. You should suggest an image so that the PlantUML team implements it :-)"); + + try { + if (this.left.hasRoot() == false && this.right.hasRoot() == false) + level = 0; + + if (level == 0) { + this.right.initRoot(skinParam.getCurrentStyleBuilder(), backColor, label, shape, stereotype); + this.left.initRoot(skinParam.getCurrentStyleBuilder(), backColor, label, shape, stereotype); + return CommandExecutionResult.ok(); + } + if (direction == Direction.LEFT) + return this.left.add(skinParam.getCurrentStyleBuilder(), backColor, level, label, shape, stereotype); + + return this.right.add(skinParam.getCurrentStyleBuilder(), backColor, level, label, shape, stereotype); + } catch (NoStyleAvailableException e) { + // e.printStackTrace(); + return CommandExecutionResult.error("General failure: no style available."); + } + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java b/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java index f11a6b44f..a1e401a6b 100644 --- a/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java +++ b/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java @@ -40,7 +40,6 @@ import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.OutputStream; -import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.UmlDiagram; @@ -52,18 +51,14 @@ import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.style.NoStyleAvailableException; -import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; public class MindMapDiagram extends UmlDiagram { - private Branch left = new Branch(); - private Branch right = new Branch(); + private final MindMap mindmap; private Direction defaultDirection = Direction.RIGHT; @@ -77,6 +72,7 @@ public class MindMapDiagram extends UmlDiagram { public MindMapDiagram(UmlSource source) { super(source, UmlDiagramType.MINDMAP); + this.mindmap = new MindMap(getSkinParam()); } @Override @@ -90,7 +86,7 @@ public class MindMapDiagram extends UmlDiagram { return new TextBlockBackcolored() { public void drawU(UGraphic ug) { - drawMe(ug); + mindmap.drawU(ug); } public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) { @@ -98,19 +94,7 @@ public class MindMapDiagram extends UmlDiagram { } public Dimension2D calculateDimension(StringBounder stringBounder) { - computeFinger(); - final double y1 = right.finger == null ? 0 : right.finger.getFullThickness(stringBounder) / 2; - final double y2 = left.finger == null ? 0 : left.finger.getFullThickness(stringBounder) / 2; - final double y = Math.max(y1, y2); - - final double x = left.finger == null ? 0 : left.finger.getFullElongation(stringBounder); - - final double width = right.finger == null ? x : x + right.finger.getFullElongation(stringBounder); - final double height = y - + Math.max(left.finger == null ? 0 : left.finger.getFullThickness(stringBounder) / 2, - right.finger == null ? 0 : right.finger.getFullThickness(stringBounder) / 2); - return new Dimension2DDouble(width, height); - + return mindmap.calculateDimension(stringBounder); } public MinMax getMinMax(StringBounder stringBounder) { @@ -123,41 +107,6 @@ public class MindMapDiagram extends UmlDiagram { }; } - private void drawMe(UGraphic ug) { - if (left.root == null && right.root == null) { - return; - } - computeFinger(); - - final StringBounder stringBounder = ug.getStringBounder(); - final double y1 = right.finger == null ? 0 : right.finger.getFullThickness(stringBounder) / 2; - final double y2 = left.finger == null ? 0 : left.finger.getFullThickness(stringBounder) / 2; - final double y = Math.max(y1, y2); - - final double x = left.finger == null ? 0 - : left.finger.getFullElongation(stringBounder) + ((FingerImpl) left.finger).getX12(); - if (right.finger != null) { - right.finger.drawU(ug.apply(new UTranslate(x, y))); - } - if (left.finger != null) { - left.finger.drawU(ug.apply(new UTranslate(x, y))); - } - } - - private void computeFinger() { - if (left.finger == null && right.finger == null) { - if (left.root.hasChildren()) { - left.finger = FingerImpl.build(left.root, getSkinParam(), Direction.LEFT); - } - if (left.finger == null || right.root.hasChildren()) { - right.finger = FingerImpl.build(right.root, getSkinParam(), Direction.RIGHT); - } - if (left.finger != null && right.finger != null) { - left.finger.doNotDrawFirstPhalanx(); - } - } - } - public CommandExecutionResult addIdea(HColor backColor, int level, Display label, IdeaShape shape) { return addIdea(backColor, level, label, shape, defaultDirection); } @@ -168,78 +117,12 @@ public class MindMapDiagram extends UmlDiagram { if (stereotype != null) { label = label.removeEndingStereotype(); } - return addIdeaInternal(stereotype, backColor, level, label, shape, direction); + return mindmap.addIdeaInternal(stereotype, backColor, level, label, shape, direction); } public CommandExecutionResult addIdea(String stereotype, HColor backColor, int level, Display label, IdeaShape shape) { - return addIdeaInternal(stereotype, backColor, level, label, shape, defaultDirection); - } - - private CommandExecutionResult addIdeaInternal(String stereotype, HColor backColor, int level, Display label, - IdeaShape shape, Direction direction) { - try { - if (left.root == null && right.root == null) { - level = 0; - } - if (level == 0) { - if (this.right.root != null) { - return CommandExecutionResult.error( - "I don't know how to draw multi-root diagram. You should suggest an image so that the PlantUML team implements it :-)"); - } - right.initRoot(getSkinParam().getCurrentStyleBuilder(), backColor, label, shape, stereotype); - left.initRoot(getSkinParam().getCurrentStyleBuilder(), backColor, label, shape, stereotype); - return CommandExecutionResult.ok(); - } - if (direction == Direction.LEFT) { - return left.add(getSkinParam().getCurrentStyleBuilder(), backColor, level, label, shape, stereotype); - } - return right.add(getSkinParam().getCurrentStyleBuilder(), backColor, level, label, shape, stereotype); - } catch (NoStyleAvailableException e) { - // e.printStackTrace(); - return CommandExecutionResult.error("General failure: no style available."); - } - } - - static class Branch { - private Idea root; - private Idea last; - private Finger finger; - - private void initRoot(StyleBuilder styleBuilder, HColor backColor, Display label, IdeaShape shape, - String stereotype) { - root = new Idea(styleBuilder, backColor, label, shape, stereotype); - last = root; - } - - private Idea getParentOfLast(int nb) { - Idea result = last; - for (int i = 0; i < nb; i++) { - result = result.getParent(); - } - return result; - } - - private CommandExecutionResult add(StyleBuilder styleBuilder, HColor backColor, int level, Display label, - IdeaShape shape, String stereotype) { - if (last == null) { - return CommandExecutionResult.error("Check your indentation ?"); - } - if (level == last.getLevel() + 1) { - final Idea newIdea = last.createIdea(styleBuilder, backColor, level, label, shape, stereotype); - last = newIdea; - return CommandExecutionResult.ok(); - } - if (level <= last.getLevel()) { - final int diff = last.getLevel() - level + 1; - final Idea newIdea = getParentOfLast(diff).createIdea(styleBuilder, backColor, level, label, shape, - stereotype); - last = newIdea; - return CommandExecutionResult.ok(); - } - return CommandExecutionResult.error("error42L"); - } - + return mindmap.addIdeaInternal(stereotype, backColor, level, label, shape, defaultDirection); } private String first; diff --git a/src/net/sourceforge/plantuml/picoweb/PicoWebServer.java b/src/net/sourceforge/plantuml/picoweb/PicoWebServer.java index f6d55aec2..3c7f8fc85 100644 --- a/src/net/sourceforge/plantuml/picoweb/PicoWebServer.java +++ b/src/net/sourceforge/plantuml/picoweb/PicoWebServer.java @@ -48,6 +48,7 @@ import java.io.PrintWriter; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; +import java.net.URLEncoder; import java.util.Collections; import java.util.Date; import java.util.List; @@ -175,10 +176,10 @@ public class PicoWebServer implements Runnable { } catch (Exception e) { throw new BadRequest400("Error parsing request json: " + e.getMessage(), e); } - + handleRenderRequest(renderRequest, out); } - + public void handleRenderRequest(RenderRequest renderRequest, BufferedOutputStream out) throws Exception { final Option option = new Option(renderRequest.getOptions()); @@ -226,6 +227,12 @@ public class PicoWebServer implements Runnable { write(out, "X-PlantUML-Diagram-Error-Line: " + (1 + err.getLineLocation().getPosition())); } } + if (system.getTitleDisplay() != null && system.getTitleDisplay().size() == 1) { + final String encode = URLEncoder.encode(system.getTitleDisplay().toString(), "UTF-8"); + if (encode.length() < 256) + write(out, "X-PlantUML-Diagram-Title: " + encode); + } + write(out, "X-Patreon: Support us on https://plantuml.com/patreon"); write(out, "X-Donate: https://plantuml.com/paypal"); write(out, "X-Quote: " + StringUtils.rot(QuoteUtils.getSomeQuote())); diff --git a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java index 375522bc4..9f752eb18 100644 --- a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java +++ b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java @@ -240,7 +240,7 @@ public final class GeneralImageBuilder { return new EntityImageMap(leaf, skinParam, portionShower); } if (leaf.getLeafType() == LeafType.SYNCHRO_BAR || leaf.getLeafType() == LeafType.STATE_FORK_JOIN) { - return new EntityImageSynchroBar(leaf, skinParam); + return new EntityImageSynchroBar(leaf, skinParam, umlDiagramType.getStyleName()); } if (leaf.getLeafType() == LeafType.ARC_CIRCLE) { return new EntityImageArcCircle(leaf, skinParam); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageStateCommon.java b/src/net/sourceforge/plantuml/svek/image/EntityImageStateCommon.java index 0fe71e9c6..37f256816 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageStateCommon.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageStateCommon.java @@ -130,15 +130,15 @@ public abstract class EntityImageStateCommon extends AbstractEntityImage { final protected UGraphic applyColor(UGraphic ug) { - HColor classBorder = lineConfig.getColors().getColor(ColorType.LINE); - if (classBorder == null) { + HColor border = lineConfig.getColors().getColor(ColorType.LINE); + if (border == null) { if (UseStyle.useBetaStyle()) - classBorder = getStyleState().value(PName.LineColor).asColor(getSkinParam().getThemeStyle(), + border = getStyleState().value(PName.LineColor).asColor(getSkinParam().getThemeStyle(), getSkinParam().getIHtmlColorSet()); else - classBorder = SkinParamUtils.getColor(getSkinParam(), getStereo(), ColorParam.stateBorder); + border = SkinParamUtils.getColor(getSkinParam(), getStereo(), ColorParam.stateBorder); } - ug = ug.apply(getStroke()).apply(classBorder); + ug = ug.apply(getStroke()).apply(border); HColor backcolor = getEntity().getColors().getColor(ColorType.BACK); if (backcolor == null) { if (UseStyle.useBetaStyle()) diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageSynchroBar.java b/src/net/sourceforge/plantuml/svek/image/EntityImageSynchroBar.java index c9f2390d2..ffc32671f 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageSynchroBar.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageSynchroBar.java @@ -59,12 +59,17 @@ import net.sourceforge.plantuml.ugraphic.color.HColorNone; public class EntityImageSynchroBar extends AbstractEntityImage { - public EntityImageSynchroBar(ILeaf entity, ISkinParam skinParam) { + // private final SName styleName; + + public EntityImageSynchroBar(ILeaf entity, ISkinParam skinParam, SName styleName) { super(entity, skinParam); + // this.styleName = styleName; } public StyleSignature getDefaultStyleDefinitionBar() { - return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activityBar); + // return StyleSignature.of(SName.root, SName.element, styleName, + // SName.activityBar); + return StyleSignature.of(SName.root, SName.element, SName.activityBar); } public Dimension2D calculateDimension(StringBounder stringBounder) { @@ -83,8 +88,9 @@ public class EntityImageSynchroBar extends AbstractEntityImage { } HColor color = SkinParamUtils.getColor(getSkinParam(), getStereo(), ColorParam.activityBar); if (UseStyle.useBetaStyle()) { - final Style style = getDefaultStyleDefinitionBar().getMergedStyle(getSkinParam().getCurrentStyleBuilder()); - color = style.value(PName.LineColor).asColor(getSkinParam().getThemeStyle(), + final Style style = getDefaultStyleDefinitionBar().with(getEntity().getStereotype()) + .getMergedStyle(getSkinParam().getCurrentStyleBuilder()); + color = style.value(PName.BackGroundColor).asColor(getSkinParam().getThemeStyle(), getSkinParam().getIHtmlColorSet()); shadowing = style.value(PName.Shadowing).asDouble(); }