From 6e2c2c32c961fe5952a04f7dbbe689216d42e87a Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Thu, 29 Sep 2016 21:51:18 +0200 Subject: [PATCH] version 8048 --- pom.xml | 2 +- .../sourceforge/plantuml/AbstractPSystem.java | 15 +-- src/net/sourceforge/plantuml/ColorParam.java | 1 + src/net/sourceforge/plantuml/FileFormat.java | 12 +- .../plantuml/FileFormatOption.java | 110 ------------------ .../plantuml/LineConfigurable.java | 2 - src/net/sourceforge/plantuml/LineParam.java | 1 + src/net/sourceforge/plantuml/OptionFlags.java | 5 + src/net/sourceforge/plantuml/OptionPrint.java | 52 +++++++-- .../sourceforge/plantuml/PSystemUtils.java | 8 +- src/net/sourceforge/plantuml/Run.java | 13 +++ src/net/sourceforge/plantuml/SkinParam.java | 29 +++++ src/net/sourceforge/plantuml/UmlDiagram.java | 2 + .../command/CommandPartition.java | 48 ++++++-- .../activitydiagram3/ActivityDiagram3.java | 4 +- .../plantuml/activitydiagram3/Branch.java | 11 +- .../activitydiagram3/InstructionIf.java | 13 ++- .../activitydiagram3/PositionedNote.java | 5 + .../command/CommandElseIf2.java | 8 +- .../command/CommandPartition3.java | 17 ++- .../ftile/EntityImageLegend.java | 23 +++- .../activitydiagram3/ftile/FtileMarged.java | 6 + .../FtileFactoryDelegatorAddNote.java | 14 +-- .../ftile/vcompact/FtileGroup.java | 15 ++- .../ftile/vcompact/FtileIfDown.java | 11 +- .../ftile/vcompact/FtileIfLongHorizontal.java | 31 +++-- .../vcompact/cond/ConditionalBuilder.java | 61 +++++----- .../command/CommandLinkClass.java | 10 +- .../plantuml/code/CompressionZlib.java | 5 +- .../plantuml/cucadiagram/BodyEnhanced.java | 12 +- .../plantuml/cucadiagram/Link.java | 17 ++- .../plantuml/cucadiagram/LinkDecor.java | 6 +- .../cucadiagram/NoteLinkStrategy.java | 49 ++++++++ .../plantuml/cucadiagram/Stereotype.java | 101 +++++++++------- .../plantuml/ditaa/PSystemDitaa.java | 7 +- .../plantuml/ditaa/PSystemDitaaFactory.java | 21 +++- .../plantuml/donors/PSystemDonors.java | 2 +- .../plantuml/eggs/PSystemMemorial.java | 5 +- .../plantuml/graph/EntityImageFactory.java | 80 ------------- .../plantuml/graphic/DateEventUtils.java | 10 +- .../plantuml/graphic/FontStyle.java | 7 +- .../plantuml/graphic/HtmlColorUtils.java | 2 + .../plantuml/graphic/TextBlockUtils.java | 14 --- .../plantuml/graphic/TextBlockVertical2.java | 3 +- .../plantuml/graphic/USymbolFrame.java | 10 +- .../plantuml/graphic/color/ColorParser.java | 4 + .../plantuml/graphic/color/Colors.java | 4 + .../AbstractClassOrObjectDiagram.java | 17 ++- .../sequencediagram/graphic/DrawableSet.java | 9 +- .../teoz/SequenceDiagramFileMakerTeoz.java | 81 ++++++++----- .../plantuml/svek/DotDataImageBuilder.java | 2 +- src/net/sourceforge/plantuml/svek/Line.java | 20 +++- src/net/sourceforge/plantuml/svek/Ports.java | 5 + .../ExtremityFactoryNotNavigable.java | 50 ++++++++ .../svek/extremity/ExtremityNotNavigable.java | 67 +++++++++++ .../svek/image/EntityImageClassHeader2.java | 4 +- .../svek/image/EntityImageEmptyPackage.java | 34 ++++-- .../plantuml/svek/image/EntityImageNote.java | 19 ++- .../svek/image/EntityImageObject.java | 2 +- .../sourceforge/plantuml/svg/SvgGraphics.java | 4 +- .../plantuml/syntax/SyntaxChecker.java | 1 + .../plantuml/ugraphic/ImageBuilder.java | 59 +++++++--- .../sourceforge/plantuml/ugraphic/UClip.java | 4 + .../sourceforge/plantuml/ugraphic/UPath.java | 29 ++++- .../plantuml/ugraphic/USegment.java | 20 ++++ .../ugraphic/g2d/DriverRectangleG2d.java | 27 +++-- .../plantuml/ugraphic/g2d/DriverTextG2d.java | 26 +++-- .../plantuml/ugraphic/svg/DriverPathSvg.java | 6 + .../plantuml/ugraphic/svg/DriverTextSvg.java | 31 +++-- .../plantuml/version/PSystemVersion.java | 13 ++- .../sourceforge/plantuml/version/Version.java | 4 +- 71 files changed, 912 insertions(+), 510 deletions(-) create mode 100644 src/net/sourceforge/plantuml/cucadiagram/NoteLinkStrategy.java delete mode 100644 src/net/sourceforge/plantuml/graph/EntityImageFactory.java create mode 100644 src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryNotNavigable.java create mode 100644 src/net/sourceforge/plantuml/svek/extremity/ExtremityNotNavigable.java diff --git a/pom.xml b/pom.xml index 27ceffa8e..b5c98ef18 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ net.sourceforge.plantuml plantuml - 8048-SNAPSHOT + 8049-SNAPSHOT jar PlantUML diff --git a/src/net/sourceforge/plantuml/AbstractPSystem.java b/src/net/sourceforge/plantuml/AbstractPSystem.java index e4a8b52cc..c19efdda4 100644 --- a/src/net/sourceforge/plantuml/AbstractPSystem.java +++ b/src/net/sourceforge/plantuml/AbstractPSystem.java @@ -56,14 +56,10 @@ public abstract class AbstractPSystem implements Diagram { toAppend.append("(" + Version.compileTimeString() + ")\n"); toAppend.append("(" + License.getCurrent() + " source distribution)\n"); final Properties p = System.getProperties(); - toAppend.append(p.getProperty("java.runtime.name")); - toAppend.append('\n'); - toAppend.append(p.getProperty("java.vm.name")); - toAppend.append('\n'); - toAppend.append(p.getProperty("java.runtime.version")); - toAppend.append('\n'); - toAppend.append(p.getProperty("os.name")); - + for (String name : OptionPrint.interestingProperties()) { + toAppend.append(p.getProperty(name)); + toAppend.append('\n'); + } return toAppend.toString(); } @@ -96,12 +92,11 @@ public abstract class AbstractPSystem implements Diagram { public String getWarningOrError() { return null; } - + public String checkFinalError() { return null; } - public void makeDiagramReady() { } diff --git a/src/net/sourceforge/plantuml/ColorParam.java b/src/net/sourceforge/plantuml/ColorParam.java index 07034c0bc..deb31ee81 100644 --- a/src/net/sourceforge/plantuml/ColorParam.java +++ b/src/net/sourceforge/plantuml/ColorParam.java @@ -59,6 +59,7 @@ public enum ColorParam { classBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK), classBorder(HtmlColorUtils.MY_RED, ColorType.LINE), stereotypeCBackground(HtmlColorUtils.COL_ADD1B2), + stereotypeNBackground(HtmlColorUtils.COL_E3664A), stereotypeABackground(HtmlColorUtils.COL_A9DCDF), stereotypeIBackground(HtmlColorUtils.COL_B4A7E5), stereotypeEBackground(HtmlColorUtils.COL_EB937F), diff --git a/src/net/sourceforge/plantuml/FileFormat.java b/src/net/sourceforge/plantuml/FileFormat.java index f0236af77..82ae0575a 100644 --- a/src/net/sourceforge/plantuml/FileFormat.java +++ b/src/net/sourceforge/plantuml/FileFormat.java @@ -78,8 +78,8 @@ public enum FileFormat { return "." + StringUtils.goLowerCase(name()); } - final static BufferedImage imDummy = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB); - final static Graphics2D gg = imDummy.createGraphics(); + final static private BufferedImage imDummy = new BufferedImage(800, 100, BufferedImage.TYPE_INT_RGB); + final static private Graphics2D gg = imDummy.createGraphics(); public StringBounder getDefaultStringBounder() { if (this == BRAILLE_PNG) { @@ -96,11 +96,8 @@ public enum FileFormat { } return new StringBounder() { public Dimension2D calculateDimension(UFont font, String text) { - // Log.info("FileFormat::calculateDimension text="+text); final FontMetrics fm = gg.getFontMetrics(font.getFont()); - // Log.info("FileFormat::calculateDimension fm="+fm); final Rectangle2D rect = fm.getStringBounds(text, gg); - // Log.info("FileFormat::calculateDimension rect="+rect); return new Dimension2DDouble(rect.getWidth(), rect.getHeight()); } }; @@ -142,10 +139,6 @@ public enum FileFormat { } final File dir = pngFile.getParentFile(); return new File(dir, computeFilename(pngFile.getName(), i)); - // String name = pngFile.getName(); - // name = name.replaceAll("\\" + getFileSuffix() + "$", "_" + String.format("%03d", i) + getFileSuffix()); - // return new File(dir, name); - } public String computeFilename(String name, int i) { @@ -154,5 +147,4 @@ public enum FileFormat { } return name.replaceAll("\\" + getFileSuffix() + "$", "_" + String.format("%03d", i) + getFileSuffix()); } - } diff --git a/src/net/sourceforge/plantuml/FileFormatOption.java b/src/net/sourceforge/plantuml/FileFormatOption.java index f9e13396b..5b1fe04f9 100644 --- a/src/net/sourceforge/plantuml/FileFormatOption.java +++ b/src/net/sourceforge/plantuml/FileFormatOption.java @@ -30,30 +30,10 @@ */ package net.sourceforge.plantuml; -import java.awt.Color; -import java.awt.Graphics2D; import java.awt.geom.AffineTransform; -import java.awt.geom.Dimension2D; -import java.awt.image.BufferedImage; import java.io.Serializable; -import net.sourceforge.plantuml.eps.EpsStrategy; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorGradient; -import net.sourceforge.plantuml.graphic.HtmlColorSimple; -import net.sourceforge.plantuml.graphic.HtmlColorTransparent; import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.ugraphic.ColorMapper; -import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UGraphic2; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps; -import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d; -import net.sourceforge.plantuml.ugraphic.html5.UGraphicHtml5; -import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg; -import net.sourceforge.plantuml.ugraphic.tikz.UGraphicTikz; -import net.sourceforge.plantuml.ugraphic.visio.UGraphicVdx; /** * A FileFormat with some parameters. @@ -121,96 +101,6 @@ public class FileFormatOption implements Serializable { return affineTransform; } - /** - * Create a UGraphic corresponding to this FileFormatOption - * - * @param colorMapper - * @param dpiFactor - * 1.0 for a standard dot per inch - * @param dim - * @param mybackcolor - * @param rotation - * @return - */ - public UGraphic2 createUGraphic(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim, - HtmlColor mybackcolor, boolean rotation) { - switch (fileFormat) { - case PNG: - return createUGraphicPNG(colorMapper, dpiFactor, dim, mybackcolor, rotation); - case SVG: - return createUGraphicSVG(colorMapper, dpiFactor, dim, mybackcolor, rotation); - case EPS: - return new UGraphicEps(colorMapper, EpsStrategy.getDefault2()); - case EPS_TEXT: - return new UGraphicEps(colorMapper, EpsStrategy.WITH_MACRO_AND_TEXT); - case HTML5: - return new UGraphicHtml5(colorMapper); - case VDX: - return new UGraphicVdx(colorMapper); - case LATEX: - return new UGraphicTikz(colorMapper, true); - case LATEX_NO_PREAMBLE: - return new UGraphicTikz(colorMapper, false); - default: - throw new UnsupportedOperationException(fileFormat.toString()); - } - } - - public UGraphic2 createUGraphic(final Dimension2D dim) { - return createUGraphic(new ColorMapperIdentity(), 1.0, dim, null, false); - } - - private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, HtmlColor mybackcolor, - boolean rotation) { - Color backColor = Color.WHITE; - if (mybackcolor instanceof HtmlColorSimple) { - backColor = colorMapper.getMappedColor(mybackcolor); - } - final UGraphicSvg ug; - if (mybackcolor instanceof HtmlColorGradient) { - ug = new UGraphicSvg(colorMapper, (HtmlColorGradient) mybackcolor, false, scale, getSvgLinkTarget()); - } else if (backColor == null || backColor.equals(Color.WHITE)) { - ug = new UGraphicSvg(colorMapper, false, scale, getSvgLinkTarget()); - } else { - ug = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(backColor), false, scale, getSvgLinkTarget()); - } - return ug; - - } - - private UGraphic2 createUGraphicPNG(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim, - HtmlColor mybackcolor, boolean rotation) { - Color backColor = Color.WHITE; - if (mybackcolor instanceof HtmlColorSimple) { - backColor = colorMapper.getMappedColor(mybackcolor); - } else if (mybackcolor instanceof HtmlColorTransparent) { - backColor = null; - } - - final EmptyImageBuilder builder; - final Graphics2D graphics2D; - if (rotation) { - builder = new EmptyImageBuilder((int) (dim.getHeight() * dpiFactor), (int) (dim.getWidth() * dpiFactor), - backColor); - graphics2D = builder.getGraphics2D(); - graphics2D.rotate(-Math.PI / 2); - graphics2D.translate(-builder.getBufferedImage().getHeight(), 0); - } else { - builder = new EmptyImageBuilder((int) (dim.getWidth() * dpiFactor), (int) (dim.getHeight() * dpiFactor), - backColor); - graphics2D = builder.getGraphics2D(); - - } - final UGraphicG2d ug = new UGraphicG2d(colorMapper, graphics2D, dpiFactor); - ug.setBufferedImage(builder.getBufferedImage()); - final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage(); - if (mybackcolor instanceof HtmlColorGradient) { - ug.apply(new UChangeBackColor(mybackcolor)).draw(new URectangle(im.getWidth(), im.getHeight())); - } - - return ug; - } - public final boolean isUseRedForError() { return useRedForError; } diff --git a/src/net/sourceforge/plantuml/LineConfigurable.java b/src/net/sourceforge/plantuml/LineConfigurable.java index eddcc5487..335bdc2e7 100644 --- a/src/net/sourceforge/plantuml/LineConfigurable.java +++ b/src/net/sourceforge/plantuml/LineConfigurable.java @@ -40,8 +40,6 @@ public interface LineConfigurable { public void setSpecificColorTOBEREMOVED(ColorType type, HtmlColor color); -// public void setSpecificLineStroke(UStroke specificLineStroke); - } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/LineParam.java b/src/net/sourceforge/plantuml/LineParam.java index efc1bbd42..af3bcf5ea 100644 --- a/src/net/sourceforge/plantuml/LineParam.java +++ b/src/net/sourceforge/plantuml/LineParam.java @@ -39,6 +39,7 @@ public enum LineParam { // sequenceReferenceBorder(0.1), sequenceLifeLineBorder, sequenceParticipantBorder, noteBorder, sequenceGroupBorder, sequenceReferenceBorder, + legendBorder, sequenceArrow, classBorder, objectBorder, partitionBorder, diff --git a/src/net/sourceforge/plantuml/OptionFlags.java b/src/net/sourceforge/plantuml/OptionFlags.java index 7f80ba402..b9947d775 100644 --- a/src/net/sourceforge/plantuml/OptionFlags.java +++ b/src/net/sourceforge/plantuml/OptionFlags.java @@ -38,6 +38,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils; +import net.sourceforge.plantuml.ugraphic.ImageBuilder; public class OptionFlags { @@ -46,6 +47,10 @@ public class OptionFlags { // static public final boolean TRACE_DOT = false; static public boolean ALLOW_INCLUDE = true; + + static public void setMaxPixel(int max) { + ImageBuilder.setMaxPixel(max); + } static public final boolean USE_HECTOR = false; static public boolean ADD_NICE_FOR_DOT = false; diff --git a/src/net/sourceforge/plantuml/OptionPrint.java b/src/net/sourceforge/plantuml/OptionPrint.java index 5150f9a0c..da18d2f50 100644 --- a/src/net/sourceforge/plantuml/OptionPrint.java +++ b/src/net/sourceforge/plantuml/OptionPrint.java @@ -32,6 +32,12 @@ package net.sourceforge.plantuml; import java.io.File; import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Locale; import java.util.Properties; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils; @@ -94,7 +100,8 @@ public class OptionPrint { System.out.println(" -testdot\t\tTo test the installation of graphviz"); System.out.println(" -graphvizdot \"exe\"\tTo specify dot executable"); System.out.println(" -p[ipe]\t\tTo use stdin for PlantUML source and stdout for PNG/SVG/EPS generation"); - System.out.println(" -encodesprite 4|8|16[z] \"file\"\tTo encode a sprite at gray level (z for compression) from an image"); + System.out + .println(" -encodesprite 4|8|16[z] \"file\"\tTo encode a sprite at gray level (z for compression) from an image"); System.out.println(" -computeurl|-encodeurl\tTo compute the encoded URL of a PlantUML source file"); System.out.println(" -decodeurl\t\tTo retrieve the PlantUML source from an encoded URL"); System.out.println(" -syntax\t\tTo report any syntax error from standard input without generating images"); @@ -130,14 +137,15 @@ public class OptionPrint { } public static void printVersion() throws InterruptedException { - System.out - .println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")"); + System.out.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")"); System.out.println("(" + License.getCurrent() + " source distribution)"); final Properties p = System.getProperties(); - System.out.println(p.getProperty("java.runtime.name")); - System.out.println(p.getProperty("java.vm.name")); - System.out.println(p.getProperty("java.runtime.version")); - System.out.println(p.getProperty("os.name")); + for (String name : interestingProperties()) { + System.out.println(p.getProperty(name)); + } + for (String v : interestingValues()) { + System.out.println(v); + } System.out.println(); for (String s : GraphvizUtils.getTestDotStrings(false)) { System.out.println(s); @@ -145,9 +153,32 @@ public class OptionPrint { exit(); } + public static Collection interestingProperties() { + return Arrays.asList("java.runtime.name", "java.vm.name", "java.runtime.version", "os.name", "file.encoding"); + } + + public static Collection interestingValues() { + final List strings = new ArrayList(); + strings.add("Processors: " + Runtime.getRuntime().availableProcessors()); + final long freeMemory = Runtime.getRuntime().freeMemory(); + final long maxMemory = Runtime.getRuntime().maxMemory(); + final long totalMemory = Runtime.getRuntime().totalMemory(); + final long usedMemory = totalMemory - freeMemory; + final int threadActiveCount = Thread.activeCount(); + strings.add("Max Memory: " + format(maxMemory)); + strings.add("Total Memory: " + format(totalMemory)); + strings.add("Free Memory: " + format(freeMemory)); + strings.add("Used Memory: " + format(usedMemory)); + strings.add("Thread Active Count: " + threadActiveCount); + return Collections.unmodifiableCollection(strings); + } + + private static String format(final long value) { + return String.format(Locale.US, "%,d", value); + } + public static void checkVersion() throws InterruptedException { - System.out - .println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")"); + System.out.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")"); System.out.println(); final int lastversion = PSystemVersion.extractDownloadableVersion(null, null); if (lastversion == -1) { @@ -172,8 +203,7 @@ public class OptionPrint { public static void printAbout() throws InterruptedException { // Duplicate in PSystemVersion - System.out - .println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")"); + System.out.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")"); System.out.println(); System.out.println("Original idea: Arnaud Roques"); System.out.println("Word Macro: Alain Bertucat & Matthieu Sabatier"); diff --git a/src/net/sourceforge/plantuml/PSystemUtils.java b/src/net/sourceforge/plantuml/PSystemUtils.java index 4b0ddb027..3c76d386f 100644 --- a/src/net/sourceforge/plantuml/PSystemUtils.java +++ b/src/net/sourceforge/plantuml/PSystemUtils.java @@ -52,10 +52,10 @@ public class PSystemUtils { public static List exportDiagrams(Diagram system, File suggestedFile, FileFormatOption fileFormatOption) throws IOException { - if (system instanceof UmlDiagram) { - final ISkinParam skinParam = ((UmlDiagram) system).getSkinParam(); - fileFormatOption = fileFormatOption.withSvgLinkTarget(skinParam.getSvgLinkTarget()); - } + // if (system instanceof UmlDiagram) { + // final ISkinParam skinParam = ((UmlDiagram) system).getSkinParam(); + // fileFormatOption = fileFormatOption.withSvgLinkTarget(skinParam.getSvgLinkTarget()); + // } if (system instanceof NewpagedDiagram) { return exportDiagramsNewpaged((NewpagedDiagram) system, suggestedFile, fileFormatOption); } diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index 1eab75e2a..1ce65fdb5 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -31,7 +31,10 @@ package net.sourceforge.plantuml; import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; import java.awt.GraphicsEnvironment; +import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.BufferedReader; import java.io.File; @@ -94,6 +97,7 @@ public class Run { return; } + forceOpenJdkResourceLoad(); boolean error = false; boolean forceQuit = false; if (option.isPattern()) { @@ -148,6 +152,15 @@ public class Run { } } + public static void forceOpenJdkResourceLoad() { + final BufferedImage imDummy = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB); + final Graphics2D gg = imDummy.createGraphics(); + final String text = "Alice"; + final Font font = new Font("SansSerif", Font.PLAIN, 12); + final FontMetrics fm = gg.getFontMetrics(font); + final Rectangle2D rect = fm.getStringBounds(text, gg); + } + private static void encodeSprite(List result) throws IOException { SpriteGrayLevel level = SpriteGrayLevel.GRAY_16; boolean compressed = false; diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index 867fbebc0..402a0adb5 100644 --- a/src/net/sourceforge/plantuml/SkinParam.java +++ b/src/net/sourceforge/plantuml/SkinParam.java @@ -342,6 +342,35 @@ public class SkinParam implements ISkinParam { result.add("DefaultFontStyle"); result.add("DefaultFontSize"); result.add("DefaultFontColor"); + result.add("MinClassWidth"); + result.add("MinClassWidth"); + result.add("Dpi"); + result.add("DefaultTextAlignment"); + result.add("Shadowing"); + result.add("NoteShadowing"); + result.add("Handwritten"); + result.add("CircledCharacterRadius"); + result.add("ClassAttributeIconSize"); + result.add("Linetype"); + result.add("PackageStyle"); + result.add("ComponentStyle"); + result.add("StereotypePosition"); + result.add("Nodesep"); + result.add("Ranksep"); + result.add("RoundCorner"); + result.add("MaxMessageSize"); + result.add("Style"); + result.add("SequenceParticipant"); + result.add("ConditionStyle"); + result.add("SameClassWidth"); + result.add("HyperlinkUnderline"); + result.add("Padding"); + result.add("Guillemet"); + result.add("SvglinkTarget"); + result.add("DefaultMonospacedFontName"); + result.add("TabSize"); + result.add("MaxAsciiMessageLength"); + result.add("ColorArrowSeparationSpace"); for (FontParam p : EnumSet.allOf(FontParam.class)) { final String h = humanName(p.name()); result.add(h + "FontStyle"); diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java index b92123209..69876151f 100644 --- a/src/net/sourceforge/plantuml/UmlDiagram.java +++ b/src/net/sourceforge/plantuml/UmlDiagram.java @@ -216,6 +216,8 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann final public ImageData exportDiagram(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { + fileFormatOption = fileFormatOption.withSvgLinkTarget(getSkinParam().getSvgLinkTarget()); + if (fileFormatOption.getFileFormat() == FileFormat.PDF) { return exportDiagramInternalPdf(os, index); } diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java index d38e04741..e14b252ce 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java @@ -30,35 +30,63 @@ */ package net.sourceforge.plantuml.activitydiagram.command; -import java.util.List; - import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.activitydiagram.ActivityDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.SingleLineCommand; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOr; +import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.IGroup; +import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; +import net.sourceforge.plantuml.graphic.color.Colors; -public class CommandPartition extends SingleLineCommand { +public class CommandPartition extends SingleLineCommand2 { public CommandPartition() { - super("(?i)^partition[%s]+([%g][^%g]+[%g]|\\S+)[%s]*(#[0-9a-fA-F]{6}|#?\\w+)?[%s]*\\{?$"); + super(getRegexConcat()); + } + + private static RegexConcat getRegexConcat() { + return new RegexConcat(// + new RegexLeaf("^"), // + new RegexLeaf("partition"), // + new RegexLeaf("[%s]+"), // + new RegexLeaf("NAME", "([%g][^%g]+[%g]|\\S+)"), // + new RegexLeaf("[%s]*"), // + new RegexOr(// + color().getRegex(), // + new RegexLeaf("LEGACYCOLORIGNORED", "(#[0-9a-fA-F]{6}|#?\\w+)?")), // + new RegexLeaf("[%s]*\\{?$")); + } + + private static ColorParser color() { + return ColorParser.simpleColor(ColorType.BACK); } @Override - protected CommandExecutionResult executeArg(ActivityDiagram diagram, List arg) { - final Code code = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0))); + protected CommandExecutionResult executeArg(ActivityDiagram diagram, RegexResult arg) { + final Code code = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0))); final IGroup currentPackage = diagram.getCurrentGroup(); final IEntity p = diagram.getOrCreateGroup(code, Display.getWithNewlines(code), GroupType.PACKAGE, currentPackage); - final String color = arg.get(1); - if (color != null) { - p.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color)); + + final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); + if (colors.isEmpty() == false) { + p.setColors(colors); } + + // final String color = arg.get("COLOR", 0); + // if (color != null) { + // p.setSpecificColorTOBEREMOVED(ColorType.BACK, + // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color)); + // } return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java index 04b3522b5..4261ba112 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java @@ -259,9 +259,9 @@ public class ActivityDiagram3 extends UmlDiagram { setCurrent(instructionIf); } - public CommandExecutionResult elseIf(Display test, Display whenThen, HtmlColor color) { + public CommandExecutionResult elseIf(Display inlabel, Display test, Display whenThen, HtmlColor color) { if (current() instanceof InstructionIf) { - final boolean ok = ((InstructionIf) current()).elseIf(test, whenThen, nextLinkRenderer(), color); + final boolean ok = ((InstructionIf) current()).elseIf(inlabel, test, whenThen, nextLinkRenderer(), color); if (ok == false) { return CommandExecutionResult.error("You cannot put an elseIf here"); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/Branch.java b/src/net/sourceforge/plantuml/activitydiagram3/Branch.java index 6cd1c155e..3b6a01a07 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/Branch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/Branch.java @@ -48,18 +48,23 @@ public class Branch { private final InstructionList list; private final Display labelTest; private final Display labelPositive; + private final Display inlabel; private final HtmlColor color; private LinkRendering inlinkRendering = LinkRendering.none(); private Ftile ftile; - public Branch(Swimlane swimlane, Display labelPositive, Display labelTest, HtmlColor color) { + public Branch(Swimlane swimlane, Display labelPositive, Display labelTest, HtmlColor color, Display inlabel) { if (labelPositive == null) { throw new IllegalArgumentException(); } if (labelTest == null) { throw new IllegalArgumentException(); } + if (inlabel == null) { + throw new IllegalArgumentException(); + } + this.inlabel = inlabel; this.list = new InstructionList(swimlane); this.labelTest = labelTest; this.labelPositive = labelPositive; @@ -109,6 +114,10 @@ public class Branch { return inlinkRendering == null ? null : inlinkRendering.getRainbow(); } + public Display getInlabel() { + return inlabel; + } + public final Ftile getFtile() { return ftile; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java index 5febd7661..a3a81a7d0 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java @@ -71,7 +71,7 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC throw new IllegalArgumentException(); } this.swimlane = swimlane; - this.thens.add(new Branch(swimlane, whenThen, labelTest, color)); + this.thens.add(new Branch(swimlane, whenThen, labelTest, color, Display.NULL)); this.current = this.thens.get(0); } @@ -84,7 +84,7 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC branch.updateFtile(factory); } if (elseBranch == null) { - this.elseBranch = new Branch(swimlane, Display.NULL, Display.NULL, null); + this.elseBranch = new Branch(swimlane, Display.NULL, Display.NULL, null, Display.NULL); } elseBranch.updateFtile(factory); Ftile result = factory.createIf(swimlane, thens, elseBranch, afterEndwhile, topInlinkRendering); @@ -103,17 +103,18 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC return false; } this.current.setInlinkRendering(nextLinkRenderer); - this.elseBranch = new Branch(swimlane, whenElse, Display.NULL, null); + this.elseBranch = new Branch(swimlane, whenElse, Display.NULL, null, Display.NULL); this.current = elseBranch; return true; } - public boolean elseIf(Display test, Display whenThen, LinkRendering nextLinkRenderer, HtmlColor color) { + public boolean elseIf(Display inlabel, Display test, Display whenThen, LinkRendering nextLinkRenderer, + HtmlColor color) { if (elseBranch != null) { return false; } this.current.setInlinkRendering(nextLinkRenderer); - this.current = new Branch(swimlane, whenThen, test, color); + this.current = new Branch(swimlane, whenThen, test, color, inlabel); this.thens.add(current); return true; @@ -122,7 +123,7 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC public void endif(LinkRendering nextLinkRenderer) { endifCalled = true; if (elseBranch == null) { - this.elseBranch = new Branch(swimlane, Display.NULL, Display.NULL, null); + this.elseBranch = new Branch(swimlane, Display.NULL, Display.NULL, null, Display.NULL); } this.current.setInlinkRendering(nextLinkRenderer); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/PositionedNote.java b/src/net/sourceforge/plantuml/activitydiagram3/PositionedNote.java index e1daaeb6a..c49758cbd 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/PositionedNote.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/PositionedNote.java @@ -49,6 +49,11 @@ public class PositionedNote { this.colors = colors; } + @Override + public String toString() { + return "type=" + type + " notePosition=" + notePosition + " " + display; + } + public PositionedNote(Display note, NotePosition position, NoteType type) { this(note, position, type, null); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java index 15de00954..4bdcf8e93 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java @@ -49,6 +49,9 @@ public class CommandElseIf2 extends SingleLineCommand2 { static RegexConcat getRegexConcat() { return new RegexConcat(new RegexLeaf("^"), // ColorParser.exp4(), // + new RegexLeaf("[%s]*"), // + new RegexLeaf("INLABEL", "(?:\\((.+?)\\))?"), // + new RegexLeaf("[%s]*"), // new RegexLeaf("else[%s]*if"), // new RegexLeaf("[%s]*"), // new RegexLeaf("TEST", "\\((.*?)\\)"), // @@ -66,7 +69,10 @@ public class CommandElseIf2 extends SingleLineCommand2 { test = null; } - return diagram.elseIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color); + final String inlabel = arg.get("INLABEL", 0); + + return diagram.elseIf(Display.getWithNewlines(inlabel), Display.getWithNewlines(test), + Display.getWithNewlines(arg.get("WHEN", 0)), color); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java index 667bb0a4e..3b6af3529 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java @@ -37,10 +37,14 @@ import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.HtmlColorUtils; +import net.sourceforge.plantuml.graphic.color.ColorParser; +import net.sourceforge.plantuml.graphic.color.ColorType; +import net.sourceforge.plantuml.graphic.color.Colors; public class CommandPartition3 extends SingleLineCommand2 { @@ -52,23 +56,32 @@ public class CommandPartition3 extends SingleLineCommand2 { return new RegexConcat(new RegexLeaf("^"), // new RegexLeaf("partition"), // new RegexLeaf("[%s]+"), // - new RegexLeaf("BACKCOLOR", "(?:(#\\w+)[%s]+)?"), // + new RegexOptional(// + new RegexConcat( // + color().getRegex(),// + new RegexLeaf("[%s]+"))), // new RegexLeaf("TITLECOLOR", "(?:(#\\w+)[%s]+)?"), // new RegexLeaf("NAME", "([%g][^%g]+[%g]|\\S+)"), // new RegexLeaf("[%s]*\\{?$")); } + private static ColorParser color() { + return ColorParser.simpleColor(ColorType.BACK); + } + @Override protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) { final String partitionTitle = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0)); final HtmlColor titleColor = diagram.getSkinParam().getIHtmlColorSet() .getColorIfValid(arg.get("TITLECOLOR", 0)); + final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); + final HtmlColor backColorInSkinparam = diagram.getSkinParam().getHtmlColor(ColorParam.partitionBackground, null, false); final HtmlColor backColor; if (backColorInSkinparam == null) { - backColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("BACKCOLOR", 0)); + backColor = colors.getColor(ColorType.BACK); } else { backColor = backColorInSkinparam; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java index d70d23a5a..ea6146824 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java @@ -36,6 +36,7 @@ import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -49,25 +50,28 @@ import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPolygon; +import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; public class EntityImageLegend extends AbstractTextBlock implements TextBlock { private final int cornersize = 10; - private final HtmlColor noteBackgroundColor; - private final HtmlColor borderColor; + private final HtmlColor legendBackgroundColor; + private final HtmlColor legendColor; private final int marginX = 6; private final int marginY = 5; private final boolean withShadow; + private final ISkinParam skinParam; private final TextBlock textBlock; private EntityImageLegend(Display note, ISkinParam skinParam) { this.withShadow = false; final Rose rose = new Rose(); + this.skinParam = skinParam; - noteBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.legendBackground); - borderColor = rose.getHtmlColor(skinParam, ColorParam.legendBorder); + legendBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.legendBackground); + legendColor = rose.getHtmlColor(skinParam, ColorParam.legendBorder); this.textBlock = note.create(new FontConfiguration(skinParam, FontParam.LEGEND, null), HorizontalAlignment.LEFT, skinParam); @@ -97,13 +101,22 @@ public class EntityImageLegend extends AbstractTextBlock implements TextBlock { return new Dimension2DDouble(width + 1, height + 1); } + private UGraphic applyStroke(UGraphic ug) { + final UStroke stroke = skinParam.getThickness(LineParam.legendBorder, null); + if (stroke == null) { + return ug; + } + return ug.apply(stroke); + } + public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); final UPolygon polygon = getPolygonNormal(stringBounder); if (withShadow) { polygon.setDeltaShadow(4); } - ug = ug.apply(new UChangeBackColor(noteBackgroundColor)).apply(new UChangeColor(borderColor)); + ug = ug.apply(new UChangeBackColor(legendBackgroundColor)).apply(new UChangeColor(legendColor)); + ug = applyStroke(ug); ug.draw(polygon); textBlock.drawU(ug.apply(new UTranslate(marginX, marginY))); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMarged.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMarged.java index 36a35b79e..f9a4c56d9 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMarged.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMarged.java @@ -78,6 +78,12 @@ public class FtileMarged extends AbstractFtile { orig.getInY(), orig.getOutY()); } + public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) { + UTranslate result = tile.getTranslateFor(child, stringBounder); + result = result.compose(new UTranslate(margin1, 0)); + return result; + } + public void drawU(UGraphic ug) { ug.apply(new UTranslate(margin1, 0)).draw(tile); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAddNote.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAddNote.java index eac0dce0d..25737d2e3 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAddNote.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAddNote.java @@ -51,15 +51,15 @@ public class FtileFactoryDelegatorAddNote extends FtileFactoryDelegator { if (notes.size() == 0) { throw new IllegalArgumentException(); } - if (notes.size() > 1) { - throw new IllegalArgumentException(); - } + // if (notes.size() > 1) { + // throw new IllegalArgumentException(); + // } ISkinParam skinParam = skinParam(); - final PositionedNote note = notes.iterator().next(); - if (note.getColors() != null) { - skinParam = note.getColors().mute(skinParam); - } if (ftile == null) { + final PositionedNote note = notes.iterator().next(); + if (note.getColors() != null) { + skinParam = note.getColors().mute(skinParam); + } return new FtileNoteAlone(skinParam.shadowing(), note.getDisplay(), skinParam, note.getType() == NoteType.NOTE, swimlane); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java index 73d5dc6d3..8f4f63e74 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java @@ -68,10 +68,10 @@ public class FtileGroup extends AbstractFtile { private final Ftile inner; private final TextBlock name; private final TextBlock headerNote; - private final HtmlColor arrowColor; + // private final HtmlColor arrowColor; private final HtmlColor borderColor; private final HtmlColor backColor; - private final HtmlColor titleColor; + // private final HtmlColor titleColor; private final UStroke stroke; public FtileGroup(Ftile inner, Display title, Display displayNote, HtmlColor arrowColor, HtmlColor backColor, @@ -79,12 +79,11 @@ public class FtileGroup extends AbstractFtile { super(inner.skinParam()); this.backColor = backColor == null ? HtmlColorUtils.WHITE : backColor; this.inner = FtileUtils.addHorizontalMargin(inner, 10); - this.arrowColor = arrowColor; - this.titleColor = titleColor; + // this.arrowColor = arrowColor; + // this.titleColor = titleColor; this.borderColor = backColor == null ? HtmlColorUtils.BLACK : borderColor; final UFont font = skinParam.getFont(null, false, FontParam.PARTITION); - // final UFont font = new UFont("Serif", Font.PLAIN, 14); - // final HtmlColor fontColor = HtmlColorUtils.BLACK; + final HtmlColor fontColor = skinParam.getFontHtmlColor(null, FontParam.PARTITION); final FontConfiguration fc = new FontConfiguration(font, fontColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink(), skinParam.getTabSize()); @@ -182,8 +181,8 @@ public class FtileGroup extends AbstractFtile { final StringBounder stringBounder = ug.getStringBounder(); final Dimension2D dimTotal = calculateDimension(stringBounder); - final SymbolContext symbolContext = new SymbolContext(backColor, borderColor).withShadow(skinParam().shadowing()) - .withStroke(stroke); + final SymbolContext symbolContext = new SymbolContext(backColor, borderColor).withShadow( + skinParam().shadowing()).withStroke(stroke); USymbol.FRAME.asBig(name, TextBlockUtils.empty(0, 0), dimTotal.getWidth(), dimTotal.getHeight(), symbolContext) .drawU(ug); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java index ed236042f..9ba9e999b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfDown.java @@ -74,7 +74,7 @@ public class FtileIfDown extends AbstractFtile { } public Swimlane getSwimlaneOut() { - if (optionalStop==null) { + if (optionalStop == null) { return getSwimlaneIn(); } return thenBlock.getSwimlaneOut(); @@ -89,8 +89,9 @@ public class FtileIfDown extends AbstractFtile { } public static Ftile create(Ftile diamond1, Ftile diamond2, Swimlane swimlane, Ftile thenBlock, Rainbow arrowColor, - FtileFactory ftileFactory, Ftile optionalStop) { + FtileFactory ftileFactory, Ftile optionalStop, Rainbow elseColor) { + elseColor = elseColor.withDefault(arrowColor); final FtileIfDown result = new FtileIfDown(thenBlock, diamond1, optionalStop == null ? diamond2 : new FtileEmpty(ftileFactory.skinParam()), optionalStop); @@ -99,12 +100,12 @@ public class FtileIfDown extends AbstractFtile { final boolean hasPointOut1 = thenBlock.calculateDimension(ftileFactory.getStringBounder()).hasPointOut(); if (optionalStop == null) { if (hasPointOut1) { - conns.add(result.new ConnectionElse(thenBlock.getInLinkRendering().getRainbow(arrowColor))); + conns.add(result.new ConnectionElse(elseColor)); } else { - conns.add(result.new ConnectionElseNoDiamond(thenBlock.getInLinkRendering().getRainbow(arrowColor))); + conns.add(result.new ConnectionElseNoDiamond(elseColor)); } } - conns.add(result.new ConnectionOut(arrowColor)); + conns.add(result.new ConnectionOut(thenBlock.getOutLinkRendering().getRainbow(arrowColor))); return FtileUtils.addConnection(result, conns); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java index 57d00801d..63097694c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java @@ -57,6 +57,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.FtileIfWithLinks; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside2; +import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; @@ -78,13 +79,16 @@ class FtileIfLongHorizontal extends AbstractFtile { private final Rainbow arrowColor; - private FtileIfLongHorizontal(List diamonds, List tiles, Ftile tile2, Rainbow arrowColor) { + private FtileIfLongHorizontal(List diamonds, List inlabelSizes, List tiles, Ftile tile2, + Rainbow arrowColor) { super(tiles.get(0).skinParam()); if (diamonds.size() != tiles.size()) { throw new IllegalArgumentException(); } for (int i = 0; i < diamonds.size(); i++) { - couples.add(new FtileAssemblySimple(diamonds.get(i), tiles.get(i))); + final Ftile diamond = diamonds.get(i); + final FtileAssemblySimple tmp = new FtileAssemblySimple(diamond, tiles.get(i)); + couples.add(FtileUtils.addHorizontalMargin(tmp, inlabelSizes.get(i), 0)); } this.tile2 = tile2; this.diamonds = new ArrayList(diamonds); @@ -145,11 +149,24 @@ class FtileIfLongHorizontal extends AbstractFtile { final Ftile tile2 = new FtileMinWidth(branch2.getFtile(), 30); List diamonds = new ArrayList(); + List inlabelSizes = new ArrayList(); for (Branch branch : thens) { - final TextBlock tb1 = branch.getLabelPositive().create(fc, HorizontalAlignment.LEFT, ftileFactory.skinParam()); - final TextBlock tbTest = branch.getLabelTest().create(fc, HorizontalAlignment.LEFT, ftileFactory.skinParam()); - FtileDiamondInside2 diamond = new FtileDiamondInside2(branch.skinParam(), backColor, borderColor, swimlane, - tbTest); + final TextBlock tb1 = branch.getLabelPositive().create(fc, HorizontalAlignment.LEFT, + ftileFactory.skinParam()); + final TextBlock tbTest = branch.getLabelTest().create(fc, HorizontalAlignment.LEFT, + ftileFactory.skinParam()); + final HtmlColor diamondColor = branch.getColor() == null ? backColor : branch.getColor(); + + FtileDiamondInside2 diamond = new FtileDiamondInside2(branch.skinParam(), diamondColor, borderColor, + swimlane, tbTest); + TextBlock tbInlabel = null; + if (Display.isNull(branch.getInlabel())) { + inlabelSizes.add(0.0); + } else { + tbInlabel = branch.getInlabel().create(fc, HorizontalAlignment.LEFT, ftileFactory.skinParam()); + inlabelSizes.add(tbInlabel.calculateDimension(ftileFactory.getStringBounder()).getWidth()); + diamond = diamond.withWest(tbInlabel); + } diamond = diamond.withNorth(tb1); diamonds.add(diamond); } @@ -160,7 +177,7 @@ class FtileIfLongHorizontal extends AbstractFtile { diamonds = alignDiamonds(diamonds, ftileFactory.getStringBounder()); - final FtileIfLongHorizontal result = new FtileIfLongHorizontal(diamonds, tiles, tile2, arrowColor); + final FtileIfLongHorizontal result = new FtileIfLongHorizontal(diamonds, inlabelSizes, tiles, tile2, arrowColor); final List conns = new ArrayList(); for (int i = 0; i < thens.size(); i++) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java index 818ad8909..d9deca238 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java @@ -103,16 +103,16 @@ public class ConditionalBuilder { final ConditionalBuilder builder = new ConditionalBuilder(swimlane, borderColor, backColor, arrowColor, ftileFactory, conditionStyle, branch1, branch2, skinParam, stringBounder, fcArrow, fcTest); // if (isEmptyOrOnlySingleStop(branch2) && isEmptyOrOnlySingleStop(branch1) == false) { -// return builder.createDown(builder.getLabelBranch1(), builder.getLabelBranch2()); +// return builder.createDown(builder.branch1, builder.branch2); // } // if (branch1.isEmpty() && branch2.isOnlySingleStop()) { -// return builder.createDown(builder.getLabelBranch1(), builder.getLabelBranch2()); +// return builder.createDown(builder.branch1, builder.branch2); // } // if (isEmptyOrOnlySingleStop(branch1) && isEmptyOrOnlySingleStop(branch2) == false) { -// return builder.createDown(builder.getLabelBranch2(), builder.getLabelBranch1()); +// return builder.createDown(builder.branch2, builder.branch1); // } // if (branch2.isEmpty() && branch1.isOnlySingleStop()) { -// return builder.createDown(builder.getLabelBranch2(), builder.getLabelBranch1()); +// return builder.createDown(builder.branch2, builder.branch1); // } return builder.createWithLinks(); // return builder.createWithDiamonds(); @@ -123,23 +123,27 @@ public class ConditionalBuilder { return branch.isEmpty() || branch.isOnlySingleStop(); } - private Ftile createDown(TextBlock tb1, TextBlock tb2) { + private Ftile createDown(Branch branch1, Branch branch2) { + final Ftile tile1 = new FtileMinWidth(branch1.getFtile(), 30); + final Ftile tile2 = new FtileMinWidth(branch2.getFtile(), 30); + final TextBlock tb1 = getLabelPositive(branch1); + final TextBlock tb2 = getLabelPositive(branch2); final Ftile diamond1 = getDiamond1(false, tb1, tb2); - final Ftile diamond2 = getDiamond2(); + final Ftile diamond2 = getDiamond2(branch1, branch2, true); if (branch2.isOnlySingleStop()) { return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile1, 10), - arrowColor, ftileFactory, branch2.getFtile()); + arrowColor, ftileFactory, branch2.getFtile(), branch2.getInlinkRenderingColorAndStyle()); } if (branch1.isOnlySingleStop()) { return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile2, 10), - arrowColor, ftileFactory, branch1.getFtile()); + arrowColor, ftileFactory, branch1.getFtile(), branch1.getInlinkRenderingColorAndStyle()); } if (branch1.isEmpty()) { return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile2, 10), - arrowColor, ftileFactory, null); + arrowColor, ftileFactory, null, null); } return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile1, 10), arrowColor, - ftileFactory, null); + ftileFactory, null, branch2.getInlinkRenderingColorAndStyle()); } private Ftile createNude() { @@ -149,11 +153,11 @@ public class ConditionalBuilder { private Ftile createWithDiamonds() { final Ftile diamond1 = getDiamond1(true); - final Ftile diamond2 = getDiamond2(); + final Ftile diamond2 = getDiamond2(branch1, branch2, false); final FtileIfWithDiamonds ftile = new FtileIfWithDiamonds(diamond1, tile1, tile2, diamond2, swimlane, stringBounder); - final Dimension2D label1 = getLabelBranch1().calculateDimension(stringBounder); - final Dimension2D label2 = getLabelBranch2().calculateDimension(stringBounder); + final Dimension2D label1 = getLabelPositive(branch1).calculateDimension(stringBounder); + final Dimension2D label2 = getLabelPositive(branch2).calculateDimension(stringBounder); final double diff1 = ftile.computeMarginNeedForBranchLabe1(stringBounder, label1); final double diff2 = ftile.computeMarginNeedForBranchLabe2(stringBounder, label2); Ftile result = FtileUtils.addHorizontalMargin(ftile, diff1, diff2); @@ -164,13 +168,13 @@ public class ConditionalBuilder { private Ftile createWithLinks() { final Ftile diamond1 = getDiamond1(true); - final Ftile diamond2 = getDiamond2(); + final Ftile diamond2 = getDiamond2(branch1, branch2, false); final Ftile tmp1 = FtileUtils.addHorizontalMargin(tile1, 10); final Ftile tmp2 = FtileUtils.addHorizontalMargin(tile2, 10); final FtileIfWithLinks ftile = new FtileIfWithLinks(diamond1, tmp1, tmp2, diamond2, swimlane, arrowColor, stringBounder); - final Dimension2D label1 = getLabelBranch1().calculateDimension(stringBounder); - final Dimension2D label2 = getLabelBranch2().calculateDimension(stringBounder); + final Dimension2D label1 = getLabelPositive(branch1).calculateDimension(stringBounder); + final Dimension2D label2 = getLabelPositive(branch2).calculateDimension(stringBounder); final double diff1 = ftile.computeMarginNeedForBranchLabe1(stringBounder, label1); final double diff2 = ftile.computeMarginNeedForBranchLabe2(stringBounder, label2); final double suppHeight = ftile.computeVerticalMarginNeedForBranchs(stringBounder, label1, label2); @@ -181,7 +185,7 @@ public class ConditionalBuilder { } private Ftile getDiamond1(boolean eastWest) { - return getDiamond1(eastWest, getLabelBranch1(), getLabelBranch2()); + return getDiamond1(eastWest, getLabelPositive(branch1), getLabelPositive(branch2)); } private Ftile getDiamond1(boolean eastWest, TextBlock tb1, TextBlock tb2) { @@ -215,19 +219,12 @@ public class ConditionalBuilder { return diamond1; } - private TextBlock getLabelBranch2() { - final TextBlock tb2 = branch2.getLabelPositive().create(fontArrow, HorizontalAlignment.LEFT, - ftileFactory.skinParam(), CreoleMode.SIMPLE_LINE); - return tb2; + private TextBlock getLabelPositive(Branch branch) { + return branch.getLabelPositive().create(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam(), + CreoleMode.SIMPLE_LINE); } - private TextBlock getLabelBranch1() { - final TextBlock tb1 = branch1.getLabelPositive().create(fontArrow, HorizontalAlignment.LEFT, - ftileFactory.skinParam(), CreoleMode.SIMPLE_LINE); - return tb1; - } - - private Ftile getDiamond2() { + private Ftile getDiamond2(Branch branch1, Branch branch2, boolean useNorth) { final Ftile diamond2; if (hasTwoBranches()) { final Display out1 = branch1.getFtile().getOutLinkRendering().getDisplay(); @@ -236,11 +233,11 @@ public class ConditionalBuilder { final Display out2 = branch2.getFtile().getOutLinkRendering().getDisplay(); final TextBlock tbout2 = out2 == null ? null : out2.create(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam(), CreoleMode.SIMPLE_LINE); - diamond2 = new FtileDiamond(tile1.skinParam(), backColor, borderColor, swimlane).withWest(tbout1).withEast( - tbout2); + FtileDiamond tmp = new FtileDiamond(tile1.skinParam(), backColor, borderColor, swimlane); + tmp = useNorth ? tmp.withNorth(tbout1) : tmp.withWest(tbout1); + tmp = tmp.withEast(tbout2); + diamond2 = tmp; } else { - // diamond2 = new FtileEmpty(tile1.shadowing(), Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2, - // swimlane, swimlane); diamond2 = new FtileEmpty(tile1.skinParam(), 0, Diamond.diamondHalfSize / 2, swimlane, swimlane); } return diamond2; diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java index 79c20181c..36b3d3b44 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java @@ -80,7 +80,7 @@ final public class CommandLinkClass extends SingleLineCommand2*+^]|\\|[>\\]])?")), // + new RegexLeaf("ARROW_HEAD2", "([ox][%s]+|[#\\]>*+^]|\\|[>\\]])?")), // new RegexLeaf("[%s]*"), // new RegexLeaf("SECOND_LABEL", "(?:[%g]([^%g]+)[%g])?"), @@ -427,6 +427,9 @@ final public class CommandLinkClass extends SingleLineCommand2\\>"); - private final String label; - private final HtmlColor htmlColor; - private final char character; - private final String sprite; private final double radius; private final UFont circledFont; private final boolean automaticPackageStyle; + private String label; + private HtmlColor htmlColor; + private char character; + private String sprite; + public Stereotype(String label, double radius, UFont circledFont, IHtmlColorSet htmlColorSet) { this(label, radius, circledFont, true, htmlColorSet); } @@ -78,34 +79,41 @@ public class Stereotype implements CharSequence, Hideable { this.automaticPackageStyle = automaticPackageStyle; this.radius = radius; this.circledFont = circledFont; - final Matcher2 mCircleChar = circleChar.matcher(label); - final Matcher2 mCircleSprite = circleSprite.matcher(label); - if (mCircleSprite.find()) { - if (StringUtils.isNotEmpty(mCircleSprite.group(3))) { - this.label = "<<" + mCircleSprite.group(3) + ">>"; - } else { - this.label = null; + + final StringBuilder tmpLabel = new StringBuilder(); + + final List list = cutLabels(label, false); + for (String local : list) { + final Matcher2 mCircleChar = circleChar.matcher(local); + final Matcher2 mCircleSprite = circleSprite.matcher(local); + if (mCircleSprite.find()) { + if (StringUtils.isNotEmpty(mCircleSprite.group(3))) { + local = "<<" + mCircleSprite.group(3) + ">>"; + } else { + local = null; + } + final String colName = mCircleSprite.group(2); + final HtmlColor col = htmlColorSet.getColorIfValid(colName); + this.htmlColor = col == null ? HtmlColorUtils.BLACK : col; + this.sprite = mCircleSprite.group(1); + this.character = '\0'; + } else if (mCircleChar.find()) { + if (StringUtils.isNotEmpty(mCircleChar.group(3))) { + local = "<<" + mCircleChar.group(3) + ">>"; + } else { + local = null; + } + final String colName = mCircleChar.group(2); + this.htmlColor = htmlColorSet.getColorIfValid(colName); + this.character = mCircleChar.group(1).charAt(0); + this.sprite = null; } - final String colName = mCircleSprite.group(2); - final HtmlColor col = htmlColorSet.getColorIfValid(colName); - this.htmlColor = col == null ? HtmlColorUtils.BLACK : col; - this.sprite = mCircleSprite.group(1); - this.character = '\0'; - } else if (mCircleChar.find()) { - if (StringUtils.isNotEmpty(mCircleChar.group(3))) { - this.label = "<<" + mCircleChar.group(3) + ">>"; - } else { - this.label = null; + if (local != null) { + tmpLabel.append(local); } - final String colName = mCircleChar.group(2); - this.htmlColor = htmlColorSet.getColorIfValid(colName); - this.character = mCircleChar.group(1).charAt(0); - this.sprite = null; - } else { - this.label = label; - this.character = '\0'; - this.htmlColor = null; - this.sprite = null; + } + if (tmpLabel.length() > 0) { + this.label = tmpLabel.toString(); } } @@ -143,17 +151,6 @@ public class Stereotype implements CharSequence, Hideable { return "<>".equalsIgnoreCase(label); } - public String getLabel(boolean withGuillement) { - assert label == null || label.length() > 0; - if (isWithOOSymbol()) { - return null; - } - if (withGuillement) { - return StringUtils.manageGuillemet(label); - } - return label; - } - public List getMultipleLabels() { final List result = new ArrayList(); if (label != null) { @@ -201,13 +198,29 @@ public class Stereotype implements CharSequence, Hideable { return circledFont; } - public List getLabels(boolean useGuillemet) { - if (getLabel(false) == null) { + public String getLabel(boolean withGuillement) { + assert label == null || label.length() > 0; + if (isWithOOSymbol()) { return null; } + if (withGuillement) { + return StringUtils.manageGuillemet(label); + } + return label; + } + + public List getLabels(boolean useGuillemet) { + final String labelLocal = getLabel(false); + if (labelLocal == null) { + return null; + } + return cutLabels(labelLocal, useGuillemet); + } + + private static List cutLabels(final String label, boolean useGuillemet) { final List result = new ArrayList(); final Pattern2 p = MyPattern.cmpile("\\<\\<.*?\\>\\>"); - final Matcher2 m = p.matcher(getLabel(false)); + final Matcher2 m = p.matcher(label); while (m.find()) { if (useGuillemet) { result.add(StringUtils.manageGuillemetStrict(m.group())); diff --git a/src/net/sourceforge/plantuml/ditaa/PSystemDitaa.java b/src/net/sourceforge/plantuml/ditaa/PSystemDitaa.java index 8fe34797d..2b5d8655c 100644 --- a/src/net/sourceforge/plantuml/ditaa/PSystemDitaa.java +++ b/src/net/sourceforge/plantuml/ditaa/PSystemDitaa.java @@ -54,15 +54,17 @@ public class PSystemDitaa extends AbstractPSystem { private final ProcessingOptions processingOptions = new ProcessingOptions(); private final boolean dropShadows; private final String data; + private final float scale; - public PSystemDitaa(String data, boolean performSeparationOfCommonEdges, boolean dropShadows) { + public PSystemDitaa(String data, boolean performSeparationOfCommonEdges, boolean dropShadows, float scale) { this.data = data; this.dropShadows = dropShadows; this.processingOptions.setPerformSeparationOfCommonEdges(performSeparationOfCommonEdges); + this.scale = scale; } PSystemDitaa add(String line) { - return new PSystemDitaa(data + line + "\n", processingOptions.performSeparationOfCommonEdges(), dropShadows); + return new PSystemDitaa(data + line + "\n", processingOptions.performSeparationOfCommonEdges(), dropShadows, scale); } public DiagramDescription getDescription() { @@ -76,6 +78,7 @@ public class PSystemDitaa extends AbstractPSystem { } // ditaa can only export png so file format is mostly ignored final ConversionOptions options = new ConversionOptions(); + options.renderingOptions.setScale(scale); options.setDropShadows(dropShadows); final TextGrid grid = new TextGrid(); grid.initialiseWithText(data, null); diff --git a/src/net/sourceforge/plantuml/ditaa/PSystemDitaaFactory.java b/src/net/sourceforge/plantuml/ditaa/PSystemDitaaFactory.java index 63f78e9e2..1125b1094 100644 --- a/src/net/sourceforge/plantuml/ditaa/PSystemDitaaFactory.java +++ b/src/net/sourceforge/plantuml/ditaa/PSystemDitaaFactory.java @@ -29,6 +29,9 @@ */ package net.sourceforge.plantuml.ditaa; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import net.sourceforge.plantuml.command.PSystemBasicFactory; import net.sourceforge.plantuml.core.DiagramType; @@ -54,10 +57,11 @@ public class PSystemDitaaFactory extends PSystemBasicFactory { if (startLine != null && (startLine.contains("-S") || startLine.contains("--no-shadows"))) { dropShadows = false; } + final float scale = extractScale(startLine); if (getDiagramType() == DiagramType.UML) { return null; } else if (getDiagramType() == DiagramType.DITAA) { - return new PSystemDitaa("", performSeparationOfCommonEdges, dropShadows); + return new PSystemDitaa("", performSeparationOfCommonEdges, dropShadows, scale); } else { throw new IllegalStateException(getDiagramType().name()); } @@ -74,7 +78,8 @@ public class PSystemDitaaFactory extends PSystemBasicFactory { if (line.contains("-S") || line.contains("--no-shadows")) { dropShadows = false; } - return new PSystemDitaa("", performSeparationOfCommonEdges, dropShadows); + final float scale = extractScale(line); + return new PSystemDitaa("", performSeparationOfCommonEdges, dropShadows, scale); } if (system == null) { return null; @@ -82,4 +87,16 @@ public class PSystemDitaaFactory extends PSystemBasicFactory { return system.add(line); } + private float extractScale(String line) { + if (line == null) { + return 1; + } + final Pattern p = Pattern.compile("scale=([\\d.]+)"); + final Matcher m = p.matcher(line); + if (m.find()) { + final String number = m.group(1); + return Float.parseFloat(number); + } + return 1; + } } diff --git a/src/net/sourceforge/plantuml/donors/PSystemDonors.java b/src/net/sourceforge/plantuml/donors/PSystemDonors.java index 51c378785..3b76eca14 100644 --- a/src/net/sourceforge/plantuml/donors/PSystemDonors.java +++ b/src/net/sourceforge/plantuml/donors/PSystemDonors.java @@ -55,7 +55,7 @@ import net.sourceforge.plantuml.version.PSystemVersion; public class PSystemDonors extends AbstractPSystem { - public static final String DONORS = "UDfTKyjosp0ClEChUDQa7w5OYLlvaOoTfZEvmH9YqQ88bPIKoj_MMt-iK5gPj7aYXdZiBfQfIVuVSl1C7JcLsewjnW9UA0c76rXp29s7T2x50onTUA8HzdH0tscqQikLXTIMxDIIgJlJT7r_bumv7IsiCHfaEyZq76W3QMZD0-px0664fKwkZsN8PvIzXtr7RKLMBPXRuPVDSyZ3ghafPGSBDjgg7VUU8EzltfCJ2v4vQ3Li8jJOnA6CIWtzGbkAd8jAIzSZkb6OxYwqxH6sCVhk34z63rAGwQ8Mv9SNRU71NrhR24H20sJdHdTkL6kik4J89z7VAfJsKLv29gnBJZsAJ1OxoHDyWYl_1vxgArQsbD0LeiaZ7jnOyuUljJGoKlRaEds6ho6xPDZeeYAZxb6RCMPWpZ4Oxs-XvOJsIux5pvwyolg3Grcj2VHV-THHKQcLGuy1uP74iT42FoQZIOfQyQ1ZttmwvtlWhn5saPUd4J7jv2JLRUGohYUXxjcXHTFUgJVga5iFE-6BhbGhFMqQ7WsxIVxDdz_6V7eW-CD4NXLthI_kSZYBFvcWkcRa8yDCGZtZx9sTleAV6gtsYANyAtSazOFiaToTsgGlt_Pfy7t25fPqzPzY7MmX_cdKgt38nD6haEbeMhlyf3KHR4CDDV0mn9zaGFWBXv0VcW00"; + public static final String DONORS = "UDfTKqjosp0CtUCKN6lIGoXMx5R-96EdwKnsi8HOj2d29IcbyjcwwyKAfPL9XojX183lnzna_myvUA90JkKsiDLOmJDbyN0BAuwbyv1FexY7XOk_Q80TxT47ZLPjkB6GsvgTMZ252usVRs_ICRMZXHKc5za0XPuARI2Fgxc7NHSX3B3GsUsn3EM4ilEm2tHkoAePyrdu5TCzv67PVXfb1pCssgejTvwWx3xzpuuiHARYh66TeCOsBUMgtD0ljBN8EMkqR3sW6uJfzahR7c2JeWyNU3Iwbu52LoT1VlsZBJpuwsgRWCYeX-BIwk06jSA6QuHo5FsrGLcVz6LaebroJeF8P358d-0JNEK_y7IwOMLhALqbcinnxuOJl_kJbaL6nXvTq1Vu6hjhXhMk6ZBg7hKPKWRcaeBn7af2-wN4wcT7NXNTtg5uQIBV5pu6gXgrTEWnGZgGH3Hnx7rCbhIe9VSw3Sf7LBv7mXfXcuHtl2BbcHrb-fp4Ya-ZClViqA8vtwbN2iXd3riXYAvMIprQ2tF3RjHx_UUtCH-cnq2O99mIfzKrJWudjKVNcrj6Fad8QDeJJc7PwXlukT5gXrZBGt87KZ_87iZTgNN-_6sNnw1dR651DmyerS5M4fXMlGY7GYAyZ9sEHf_bwQo8uA5Ftq6Fi8bBg9r0PWcfHQSb9LrBQiuTXQXsvM6U-ZHo-Giz_Inc"; public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException { final GraphicStrings result = getGraphicStrings(); diff --git a/src/net/sourceforge/plantuml/eggs/PSystemMemorial.java b/src/net/sourceforge/plantuml/eggs/PSystemMemorial.java index c6d03164c..0ef62b6ea 100644 --- a/src/net/sourceforge/plantuml/eggs/PSystemMemorial.java +++ b/src/net/sourceforge/plantuml/eggs/PSystemMemorial.java @@ -58,6 +58,7 @@ import net.sourceforge.plantuml.webp.Portrait; public class PSystemMemorial extends AbstractPSystem { + public static final String PARIS = "A thought for those who died in Paris the 13th November 2015."; private Portrait portrait; PSystemMemorial(Portrait portrait) { @@ -78,9 +79,7 @@ public class PSystemMemorial extends AbstractPSystem { final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLACK, true); - final TextBlock top = DateEventUtils.getComment( - Arrays.asList("A thought for those who died in Paris the 13th November 2015."), - HtmlColorUtils.BLACK); + final TextBlock top = DateEventUtils.getComment(Arrays.asList(PARIS), HtmlColorUtils.BLACK); final TextBlock tb = Display.create(name, age, quote).create(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); diff --git a/src/net/sourceforge/plantuml/graph/EntityImageFactory.java b/src/net/sourceforge/plantuml/graph/EntityImageFactory.java deleted file mode 100644 index dd7f009f8..000000000 --- a/src/net/sourceforge/plantuml/graph/EntityImageFactory.java +++ /dev/null @@ -1,80 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * 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.graph; - -import net.sourceforge.plantuml.cucadiagram.IEntity; - -public class EntityImageFactory { - - public AbstractEntityImage createEntityImage(IEntity entity) { - throw new UnsupportedOperationException(); -// if (entity.getEntityType() == LeafType.CLASS || entity.getEntityType() == LeafType.ANNOTATION -// || entity.getEntityType() == LeafType.ABSTRACT_CLASS || entity.getEntityType() == LeafType.INTERFACE -// || entity.getEntityType() == LeafType.ENUM) { -// return new EntityImageClass(entity); -// } -// if (entity.getEntityType() == LeafType.ACTIVITY) { -// return new EntityImageActivity(entity); -// } -// if (entity.getEntityType() == LeafType.NOTE) { -// return new EntityImageNote(entity); -// } -// if (entity.getEntityType() == LeafType.POINT_FOR_ASSOCIATION) { -// return new EntityImageActivityCircle(entity, 4, 4); -// } -// if (entity.getEntityType() == LeafType.CIRCLE_START) { -// return new EntityImageActivityCircle(entity, 18, 18); -// } -// if (entity.getEntityType() == LeafType.CIRCLE_END) { -// return new EntityImageActivityCircle(entity, 18, 11); -// } -// if (entity.getEntityType() == LeafType.BRANCH) { -// return new EntityImageActivityBranch(entity); -// } -// if (entity.getEntityType() == LeafType.SYNCHRO_BAR) { -// return new EntityImageActivityBar(entity); -// } -// if (entity.getEntityType() == LeafType.USECASE) { -// return new EntityImageUsecase(entity); -// } -// if (entity.getEntityType() == LeafType.ACTOR) { -// return new EntityImageActor(entity); -// } -// if (entity.getEntityType() == LeafType.CIRCLE_INTERFACE) { -// return new EntityImageCircleInterface(entity); -// } -// if (entity.getEntityType() == LeafType.COMPONENT) { -// return new EntityImageComponent(entity); -// } -// return new EntityImageDefault(entity); - } - -} diff --git a/src/net/sourceforge/plantuml/graphic/DateEventUtils.java b/src/net/sourceforge/plantuml/graphic/DateEventUtils.java index 6559661b2..2215edb4c 100644 --- a/src/net/sourceforge/plantuml/graphic/DateEventUtils.java +++ b/src/net/sourceforge/plantuml/graphic/DateEventUtils.java @@ -44,6 +44,7 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.SpriteContainerEmpty; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.eggs.PSystemMemorial; import net.sourceforge.plantuml.ugraphic.LimitFinder; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UGraphic; @@ -106,8 +107,7 @@ public class DateEventUtils { new SpriteContainerEmpty()); comment = TextBlockUtils.withMinWidth(TextBlockUtils.withMargin(comment, 4, 4), 800, HorizontalAlignment.LEFT); - final TextBlock bottom0 = getComment( - Arrays.asList("A thought for those who died in Paris the 13th November 2015."), color); + final TextBlock bottom0 = getComment(Arrays.asList(PSystemMemorial.PARIS), color); final TextBlock bottom1 = new AbstractTextBlock() { private double margin = 10; @@ -127,7 +127,11 @@ public class DateEventUtils { final TextBlock bottom = TextBlockUtils.mergeTB(bottom0, TextBlockUtils.mergeLR(bottom1, comment, VerticalAlignment.CENTER), HorizontalAlignment.LEFT); final TextBlock mergeTB = TextBlockUtils.mergeTB(textBlock, bottom, HorizontalAlignment.LEFT); + return addMajesty(mergeTB, color); + } + public static TextBlock addMajesty(TextBlock block, HtmlColor color) { + final UFont font12 = new UFont("SansSerif", Font.BOLD, 12); final String arabic1 = "\u0625\u0646 \u0627\u0644\u0625\u0631\u0647\u0627\u0628\u064A\u064A\u0646 \u0628\u0627\u0633\u0645 \u0627\u0644\u0625\u0633\u0644\u0627\u0645 \u0644\u064A\u0633\u0648\u0627 \u0645\u0633\u0644\u0645\u064A\u0646\u060C \u0648\u0644\u0627 \u064A\u0631\u0628\u0637\u0647\u0645 \u0628\u0627\u0644\u0625\u0633\u0644\u0627\u0645 \u0625\u0644\u0627 \u0627\u0644\u062F\u0648\u0627\u0641\u0639 \u0627\u0644\u062A\u064A \u064A\u0631\u0643\u0628\u0648\u0646 \u0639\u0644\u064A\u0647\u0627 \u0644\u062A\u0628\u0631\u064A\u0631 \u062C\u0631\u0627\u0626\u0645\u0647\u0645 \u0648\u062D\u0645\u0627\u0642\u0627\u062A\u0647\u0645."; final String arabic2 = "\u0641\u0647\u0645 \u0642\u0648\u0645 \u0636\u0627\u0644\u0648\u0646\u060C \u0645\u0635\u064A\u0631\u0647\u0645 \u062C\u0647\u0646\u0645 \u062E\u0627\u0644\u062F\u064A\u0646 \u0641\u064A\u0647\u0627 \u0623\u0628\u062F\u0627."; final String english1 = "Those who engage in terrorism, in the name of Islam, are not Muslims."; @@ -144,7 +148,7 @@ public class DateEventUtils { "-- His Majesty the King Mohammed the Sixth, Commander of the Faithful").create( new FontConfiguration(font12, color, HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, new SpriteContainerEmpty()); - return TextBlockUtils.mergeTB(mergeTB, TextBlockUtils.mergeTB(arabic, english, HorizontalAlignment.LEFT), + return TextBlockUtils.mergeTB(block, TextBlockUtils.mergeTB(arabic, english, HorizontalAlignment.LEFT), HorizontalAlignment.LEFT); } diff --git a/src/net/sourceforge/plantuml/graphic/FontStyle.java b/src/net/sourceforge/plantuml/graphic/FontStyle.java index 5923e25ec..019d1668d 100644 --- a/src/net/sourceforge/plantuml/graphic/FontStyle.java +++ b/src/net/sourceforge/plantuml/graphic/FontStyle.java @@ -64,14 +64,15 @@ public enum FontStyle { return "\\<[wW](?::(#[0-9a-fA-F]{6}|\\w+))?\\>"; } if (this == BACKCOLOR) { - return "\\<[bB][aA][cC][kK](?::(#[0-9a-fA-F]{6}|\\w+))?\\>"; + // return "\\<[bB][aA][cC][kK](?::(#[0-9a-fA-F]{6}|\\w+))?\\>"; + return "\\<[bB][aA][cC][kK](?::(#?\\w+(?:[-\\\\|/]#?\\w+)?))?\\>"; } if (this == STRIKE) { return "\\<(?:s|S|strike|STRIKE|del|DEL)(?::(#[0-9a-fA-F]{6}|\\w+))?\\>"; } return null; } - + public boolean canHaveExtendedColor() { if (this == UNDERLINE) { return true; @@ -88,7 +89,6 @@ public enum FontStyle { return false; } - public String getCreoleSyntax() { if (this == ITALIC) { return "//"; @@ -154,5 +154,4 @@ public enum FontStyle { throw new IllegalArgumentException(line); } - } diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java b/src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java index 39466c641..cd5cd6414 100644 --- a/src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java +++ b/src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java @@ -58,6 +58,7 @@ public class HtmlColorUtils { public static final HtmlColor COL_FBFB77; public static final HtmlColor COL_ADD1B2; public static final HtmlColor COL_A9DCDF; + public static final HtmlColor COL_E3664A; public static final HtmlColor COL_EB937F; public static final HtmlColor COL_B4A7E5; public static final HtmlColor COL_527BC6; @@ -96,6 +97,7 @@ public class HtmlColorUtils { COL_FBFB77 = set.getColorIfValid("#FBFB77"); COL_ADD1B2 = set.getColorIfValid("#ADD1B2"); COL_A9DCDF = set.getColorIfValid("#A9DCDF"); + COL_E3664A = set.getColorIfValid("#E3664A"); COL_EB937F = set.getColorIfValid("#EB937F"); COL_B4A7E5 = set.getColorIfValid("#B4A7E5"); COL_527BC6 = set.getColorIfValid("#527BC6"); diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java b/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java index bec91e393..ab66e170e 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java @@ -93,12 +93,10 @@ public class TextBlockUtils { } private static final Graphics2D gg; -// private static final StringBounder dummyStringBounder; static { final BufferedImage imDummy = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB); gg = imDummy.createGraphics(); -// dummyStringBounder = StringBounderUtils.asStringBounder(); } public static boolean isEmpty(TextBlock text, StringBounder dummyStringBounder) { @@ -109,22 +107,10 @@ public class TextBlockUtils { return dim.getHeight() == 0 && dim.getWidth() == 0; } -// public static StringBounder getDummyStringBounder() { -// return dummyStringBounder; -// } - public static FontRenderContext getFontRenderContext() { return gg.getFontRenderContext(); } -// public static MinMax getMinMax(TextBlock tb) { -// return getMinMax(tb, dummyStringBounder); -// } - -// public static Dimension2D getDimension(TextBlock tb) { -// return tb.calculateDimension(dummyStringBounder); -// } - public static LineMetrics getLineMetrics(UFont font, String text) { return font.getLineMetrics(gg, text); } diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java b/src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java index fface4acd..4a7fa07d0 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java @@ -94,8 +94,9 @@ public class TextBlockVertical2 extends AbstractTextBlock implements TextBlock, final Ports result = new Ports(); for (TextBlock block : blocks) { final Dimension2D dimb = block.calculateDimension(stringBounder); + final Ports tmp = ((WithPorts) block).getPorts(stringBounder).translateY(y); + result.addThis(tmp); y += dimb.getHeight(); - result.addThis(((WithPorts) block).getPorts(stringBounder)); } return result; } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolFrame.java b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java index 8ae4145ab..be4e06701 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolFrame.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java @@ -33,6 +33,7 @@ package net.sourceforge.plantuml.graphic; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.UPath; @@ -47,7 +48,6 @@ class USymbolFrame extends USymbol { return SkinParameter.FRAME; } - private void drawFrame(UGraphic ug, double width, double height, Dimension2D dimTitle, boolean shadowing) { final URectangle shape = new URectangle(width, height); if (shadowing) { @@ -74,7 +74,7 @@ class USymbolFrame extends USymbol { polygon.lineTo(textWidth - cornersize, textHeight); polygon.lineTo(0, textHeight); - ug.draw(polygon); + ug.apply(new UChangeBackColor(null)).draw(polygon); } @@ -89,7 +89,8 @@ class USymbolFrame extends USymbol { return new Margin(10 + 5, 20 + 5, 15 + 5, 5 + 5); } - public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) { + public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, + final SymbolContext symbolContext) { return new AbstractTextBlock() { public void drawU(UGraphic ug) { @@ -133,11 +134,10 @@ class USymbolFrame extends USymbol { } }; } - + @Override public boolean manageHorizontalLine() { return true; } - } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/graphic/color/ColorParser.java b/src/net/sourceforge/plantuml/graphic/color/ColorParser.java index 267b41f8b..2b8ab71b1 100644 --- a/src/net/sourceforge/plantuml/graphic/color/ColorParser.java +++ b/src/net/sourceforge/plantuml/graphic/color/ColorParser.java @@ -68,6 +68,10 @@ public class ColorParser { return new ColorParser("COLOR", new RegexLeaf("COLOR", "(" + COLORS_REGEXP + ")?"), mainType); } + public static ColorParser mandatoryColor(ColorType mainType) { + return new ColorParser("COLOR", new RegexLeaf("COLOR", "(" + COLORS_REGEXP + ")"), mainType); + } + public static ColorParser simpleColor(String optPrefix, ColorType mainType) { return new ColorParser("COLOR", new RegexLeaf("COLOR", "(?:" + optPrefix + " (" + COLORS_REGEXP + "))?"), mainType); diff --git a/src/net/sourceforge/plantuml/graphic/color/Colors.java b/src/net/sourceforge/plantuml/graphic/color/Colors.java index 2059f06ac..8174b815d 100644 --- a/src/net/sourceforge/plantuml/graphic/color/Colors.java +++ b/src/net/sourceforge/plantuml/graphic/color/Colors.java @@ -61,6 +61,10 @@ public class Colors { return new Colors(); } + public boolean isEmpty() { + return map.isEmpty(); + } + private Colors copy() { final Colors result = new Colors(); result.map.putAll(this.map); diff --git a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java index 10a715a29..624cca661 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java +++ b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkType; +import net.sourceforge.plantuml.cucadiagram.NoteLinkStrategy; import net.sourceforge.plantuml.utils.UniqueSequence; public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram { @@ -157,8 +158,10 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram removeLink(existingLink); } - final IEntity entity1real = existingLink.isInverted() ? existingLink.getEntity2() : existingLink.getEntity1(); - final IEntity entity2real = existingLink.isInverted() ? existingLink.getEntity1() : existingLink.getEntity2(); + final IEntity entity1real = existingLink.isInverted() ? existingLink.getEntity2() : existingLink + .getEntity1(); + final IEntity entity2real = existingLink.isInverted() ? existingLink.getEntity1() : existingLink + .getEntity2(); entity1ToPoint = new Link(entity1real, point, existingLink.getType().getPart2(), existingLink.getLabel(), existingLink.getLength(), existingLink.getQualifier1(), null, existingLink.getLabeldistance(), @@ -167,8 +170,6 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram pointToEntity2 = new Link(point, entity2real, existingLink.getType().getPart1(), Display.NULL, existingLink.getLength(), null, existingLink.getQualifier2(), existingLink.getLabeldistance(), existingLink.getLabelangle()); - addLink(entity1ToPoint); - addLink(pointToEntity2); int length = 1; if (existingLink.getLength() == 1 && entity1 != entity2) { @@ -177,6 +178,14 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram if (existingLink.getLength() == 2 && entity1 == entity2) { length = 2; } + if (length == 1) { + entity1ToPoint.addNoteFrom(existingLink, NoteLinkStrategy.NORMAL); + } else { + entity1ToPoint.addNoteFrom(existingLink, NoteLinkStrategy.HALF_PRINTED_FULL); + pointToEntity2.addNoteFrom(existingLink, NoteLinkStrategy.HALF_NOT_PRINTED); + } + addLink(entity1ToPoint); + addLink(pointToEntity2); if (mode == 1) { pointToAssocied = new Link(point, associed, linkType, label, length); diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java index 6298f1b0e..b365853b0 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java @@ -61,6 +61,7 @@ import net.sourceforge.plantuml.ugraphic.UClip; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt; public class DrawableSet { @@ -265,6 +266,8 @@ public class DrawableSet { } private void drawLineU22(UGraphic ug, boolean showTail, Page page) { + // http://plantuml.sourceforge.net/qa/?qa=4826/lifelines-broken-for-txt-seq-diagrams-when-create-is-used + final boolean isTxt = ug instanceof UGraphicTxt; for (LivingParticipantBox box : getAllLivingParticipantBox()) { final double create = box.getCreate(); final double startMin = page.getBodyRelativePosition() - box.magicMargin(ug.getStringBounder()); @@ -275,7 +278,11 @@ public class DrawableSet { continue; } if (create >= page.getNewpage1() && create < page.getNewpage2()) { - start += create - page.getNewpage1() + 2 * box.magicMargin(ug.getStringBounder()); + if (isTxt) { + start = (int) create; + } else { + start += create - page.getNewpage1() + 2 * box.magicMargin(ug.getStringBounder()); + } } } final double myDelta = page.getNewpage1() - page.getHeaderHeight(); diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java index 24fd49aec..7c26a6ca3 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java @@ -39,7 +39,6 @@ import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; -import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; @@ -48,6 +47,7 @@ import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.png.PngTitler; import net.sourceforge.plantuml.real.Real; @@ -60,10 +60,9 @@ import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.SimpleContext2D; import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UGraphic2; import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.ugraphic.hand.UGraphicHandwritten; import net.sourceforge.plantuml.utils.MathUtils; public class SequenceDiagramFileMakerTeoz implements FileMaker { @@ -118,43 +117,61 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { private final LivingSpaces livingSpaces = new LivingSpaces(); private final double heightEnglober1; private final double heightEnglober2; + + private double oneOf(double a, double b) { + if (a == 1) { + return b; + } + return a; + } + public ImageData createOne(OutputStream os, int index, boolean isWithMetadata) throws IOException { final UTranslate min1translate = new UTranslate(-min1.getCurrentValue(), 0); final double dpiFactor = diagram.getDpiFactor(fileFormatOption, dimTotal); - final UGraphic2 ug2 = (UGraphic2) fileFormatOption.createUGraphic(getSkinParam().getColorMapper(), dpiFactor, - dimTotal, getSkinParam().getBackgroundColor(), false).apply(min1translate); - UGraphic ug = getSkinParam().handwritten() ? new UGraphicHandwritten(ug2) : ug2; - englobers.drawEnglobers(goDownForEnglobers(ug), main.calculateDimension(stringBounder).getHeight() - + this.heightEnglober1 + this.heightEnglober2 / 2, new SimpleContext2D(true)); + final double scale = 1; + final String metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null; - printAligned(ug, diagram.getFooterOrHeaderTeoz(FontParam.HEADER).getHorizontalAlignment(), header); - ug = goDown(ug, header); + final ImageBuilder imageBuilder = new ImageBuilder(diagram.getSkinParam().getColorMapper(), oneOf(scale, + dpiFactor), diagram.getSkinParam().getBackgroundColor(), metadata, null, 3, 10, diagram.getAnimation(), + diagram.getSkinParam().handwritten()); + + imageBuilder.setUDrawable(new UDrawable() { + + public void drawU(UGraphic ug) { + ug = ug.apply(min1translate); + englobers.drawEnglobers(goDownForEnglobers(ug), main.calculateDimension(stringBounder).getHeight() + + heightEnglober1 + heightEnglober2 / 2, new SimpleContext2D(true)); - printAligned(ug, HorizontalAlignment.CENTER, title); - ug = goDown(ug, title); + printAligned(ug, diagram.getFooterOrHeaderTeoz(FontParam.HEADER).getHorizontalAlignment(), header); + ug = goDown(ug, header); + + printAligned(ug, HorizontalAlignment.CENTER, title); + ug = goDown(ug, title); + + if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.TOP) { + printAligned(ug, diagram.getLegend().getHorizontalAlignment(), legend); + ug = goDown(ug, legend); + } + + ug = ug.apply(new UTranslate(0, heightEnglober1)); + printAligned(ug, HorizontalAlignment.CENTER, main); + ug = goDown(ug, main); + ug = ug.apply(new UTranslate(0, heightEnglober2)); + + if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.BOTTOM) { + printAligned(ug, diagram.getLegend().getHorizontalAlignment(), legend); + ug = goDown(ug, legend); + } + + printAligned(ug, diagram.getFooterOrHeaderTeoz(FontParam.FOOTER).getHorizontalAlignment(), footer); + + + } + }); + return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os); - if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.TOP) { - printAligned(ug, diagram.getLegend().getHorizontalAlignment(), legend); - ug = goDown(ug, legend); - } - - ug = ug.apply(new UTranslate(0, this.heightEnglober1)); - printAligned(ug, HorizontalAlignment.CENTER, main); - ug = goDown(ug, main); - ug = ug.apply(new UTranslate(0, this.heightEnglober2)); - - if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.BOTTOM) { - printAligned(ug, diagram.getLegend().getHorizontalAlignment(), legend); - ug = goDown(ug, legend); - } - - printAligned(ug, diagram.getFooterOrHeaderTeoz(FontParam.FOOTER).getHorizontalAlignment(), footer); - - ug2.writeImageTOBEMOVED(os, isWithMetadata ? diagram.getMetadata() : null, diagram.getDpi(fileFormatOption)); - - return new ImageDataSimple(dimTotal); } private UGraphic goDownForEnglobers(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/svek/DotDataImageBuilder.java b/src/net/sourceforge/plantuml/svek/DotDataImageBuilder.java index f50826554..e8a8dab78 100644 --- a/src/net/sourceforge/plantuml/svek/DotDataImageBuilder.java +++ b/src/net/sourceforge/plantuml/svek/DotDataImageBuilder.java @@ -405,7 +405,7 @@ public final class DotDataImageBuilder { return new EntityImageDescription(leaf, new SkinParamForecolored(skinParam, HtmlColorUtils.BLACK), portionShower); } - return new EntityImageEmptyPackage(leaf, skinParam); + return new EntityImageEmptyPackage(leaf, skinParam, portionShower); } if (leaf.getEntityType() == LeafType.ASSOCIATION) { return new EntityImageAssociation(leaf, skinParam); diff --git a/src/net/sourceforge/plantuml/svek/Line.java b/src/net/sourceforge/plantuml/svek/Line.java index ecba505e7..0573556fe 100644 --- a/src/net/sourceforge/plantuml/svek/Line.java +++ b/src/net/sourceforge/plantuml/svek/Line.java @@ -35,6 +35,7 @@ import java.awt.geom.Point2D; import java.util.Collection; import java.util.List; +import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.Hideable; import net.sourceforge.plantuml.ISkinParam; @@ -52,6 +53,7 @@ import net.sourceforge.plantuml.cucadiagram.LinkArrow; import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkMiddleDecor; import net.sourceforge.plantuml.cucadiagram.LinkType; +import net.sourceforge.plantuml.cucadiagram.NoteLinkStrategy; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -94,6 +96,7 @@ public class Line implements Moveable, Hideable { private final TextBlock startTailText; private final TextBlock endHeadText; private final TextBlock labelText; + private boolean divideLabelWidthByTwo = false; private final int lineColor; private final int noteLabelColor; @@ -266,6 +269,10 @@ public class Line implements Moveable, Hideable { noteOnly = null; } else { noteOnly = new EntityImageNoteLink(link.getNote(), link.getNoteColors(), skinParam); + if (link.getNoteLinkStrategy() == NoteLinkStrategy.HALF_NOT_PRINTED + || link.getNoteLinkStrategy() == NoteLinkStrategy.HALF_PRINTED_FULL) { + divideLabelWidthByTwo = true; + } } if (labelOnly != null && noteOnly != null) { @@ -347,7 +354,8 @@ public class Line implements Moveable, Hideable { } else { sb.append("label=<"); } - appendTable(sb, labelText.calculateDimension(stringBounder), noteLabelColor, graphvizVersion); + appendTable(sb, eventuallyDivideByTwo(labelText.calculateDimension(stringBounder)), noteLabelColor, + graphvizVersion); sb.append(">"); // sb.append(",labelfloat=true"); } @@ -384,6 +392,13 @@ public class Line implements Moveable, Hideable { SvekUtils.println(sb); } + private Dimension2D eventuallyDivideByTwo(Dimension2D dim) { + if (divideLabelWidthByTwo) { + return new Dimension2DDouble(dim.getWidth() / 2, dim.getHeight()); + } + return dim; + } + public String rankSame() { // if (graphvizVersion == GraphvizVersion.V2_34_0) { // return null; @@ -662,7 +677,8 @@ public class Line implements Moveable, Hideable { // System.err.println("Line::draw EXTREMITY2"); this.extremity1.drawU(ug.apply(new UTranslate(x, y))); } - if (this.labelText != null && this.labelXY != null) { + if (this.labelText != null && this.labelXY != null + && link.getNoteLinkStrategy() != NoteLinkStrategy.HALF_NOT_PRINTED) { this.labelText.drawU(ug.apply(new UTranslate(x + this.labelXY.getPosition().getX(), y + this.labelXY.getPosition().getY()))); } diff --git a/src/net/sourceforge/plantuml/svek/Ports.java b/src/net/sourceforge/plantuml/svek/Ports.java index 655276785..9e6c028c5 100644 --- a/src/net/sourceforge/plantuml/svek/Ports.java +++ b/src/net/sourceforge/plantuml/svek/Ports.java @@ -40,6 +40,11 @@ public class Ports { public void addThis(Ports other) { all.putAll(other.all); } + + @Override + public String toString() { + return all.toString(); + } public Ports translateY(double deltaY) { final Ports result = new Ports(); diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryNotNavigable.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryNotNavigable.java new file mode 100644 index 000000000..448cc1947 --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryNotNavigable.java @@ -0,0 +1,50 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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.svek.extremity; + +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.svek.AbstractExtremityFactory; + +public class ExtremityFactoryNotNavigable extends AbstractExtremityFactory implements ExtremityFactory { + + @Override + public UDrawable createUDrawable(Point2D p0, double angle) { + return new ExtremityNotNavigable(p0, angle - Math.PI / 2); + } + + public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) { + final double ortho = atan2(p0, p2); + return new ExtremityNotNavigable(p1, ortho); + } + +} diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityNotNavigable.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityNotNavigable.java new file mode 100644 index 000000000..d48c5cc8b --- /dev/null +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityNotNavigable.java @@ -0,0 +1,67 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * 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.svek.extremity; + +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UPath; + +class ExtremityNotNavigable extends Extremity { + + private UPath path = new UPath(); + private final Point2D contact; + + @Override + public Point2D somePoint() { + return contact; + } + + public ExtremityNotNavigable(Point2D p1, double angle) { + this.contact = new Point2D.Double(p1.getX(), p1.getY()); + angle = manageround(angle); + + final double size = 4; + final double move = 5; + path.moveTo(-size, 0); + path.lineTo(size, 2 * size); + path.moveTo(size, 0); + path.lineTo(-size, 2 * size); + path = path.translate(0, move); + path = path.rotate(angle + Math.PI); + path = path.translate(p1.getX(), p1.getY()); + } + + public void drawU(UGraphic ug) { + ug.draw(path); + } + +} diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java index 39e4b8fc5..66385bfd4 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java @@ -69,7 +69,7 @@ public class EntityImageClassHeader2 extends AbstractEntityImage { final boolean italic = entity.getEntityType() == LeafType.ABSTRACT_CLASS || entity.getEntityType() == LeafType.INTERFACE; - final HtmlColor color = SkinParamUtils.getFontColor(getSkinParam(), FontParam.CLASS, getStereo()); + // final HtmlColor color = SkinParamUtils.getFontColor(getSkinParam(), FontParam.CLASS, getStereo()); final Stereotype stereotype = entity.getStereotype(); final String generic = entity.getGeneric(); FontConfiguration fontConfigurationName = new FontConfiguration(getSkinParam(), FontParam.CLASS, stereotype); @@ -142,7 +142,7 @@ public class EntityImageClassHeader2 extends AbstractEntityImage { } if (entity.getEntityType() == LeafType.ANNOTATION) { return new CircledCharacter('@', getSkinParam().getCircledCharacterRadius(), font, SkinParamUtils.getColor( - getSkinParam(), ColorParam.stereotypeABackground, stereotype), classBorder, + getSkinParam(), ColorParam.stereotypeNBackground, stereotype), classBorder, SkinParamUtils.getFontColor(getSkinParam(), FontParam.CIRCLED_CHARACTER, null)); } if (entity.getEntityType() == LeafType.ABSTRACT_CLASS) { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java b/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java index f84a275cd..f1ad3dd06 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage.java @@ -38,7 +38,10 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.SkinParamUtils; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.ILeaf; +import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -61,20 +64,34 @@ public class EntityImageEmptyPackage extends AbstractEntityImage { final private HtmlColor specificBackColor; final private ISkinParam skinParam; final private Stereotype stereotype; + final TextBlock stereoBlock; - public EntityImageEmptyPackage(ILeaf entity, ISkinParam skinParam) { + public EntityImageEmptyPackage(ILeaf entity, ISkinParam skinParam, PortionShower portionShower) { super(entity, skinParam); this.skinParam = skinParam; this.specificBackColor = entity.getColors(skinParam).getColor(ColorType.BACK); this.stereotype = entity.getStereotype(); - this.desc = entity.getDisplay().create( - new FontConfiguration(getSkinParam(), FontParam.PACKAGE, stereotype), + this.desc = entity.getDisplay().create(new FontConfiguration(getSkinParam(), FontParam.PACKAGE, stereotype), HorizontalAlignment.CENTER, skinParam); + + if (stereotype == null || stereotype.getLabel(false) == null + || portionShower.showPortion(EntityPortion.STEREOTYPE, entity) == false) { + stereoBlock = TextBlockUtils.empty(0, 0); + } else { + stereoBlock = TextBlockUtils.withMargin( + Display.create(stereotype.getLabels(skinParam.useGuillemet())).create( + new FontConfiguration(getSkinParam(), FontParam.PACKAGE_STEREOTYPE, stereotype), + HorizontalAlignment.CENTER, skinParam), 1, 0); + } + } public Dimension2D calculateDimension(StringBounder stringBounder) { - final Dimension2D dim = desc.calculateDimension(stringBounder); - return Dimension2DDouble.delta(dim, MARGIN * 2, MARGIN * 2 + dim.getHeight() * 2); + final Dimension2D dimDesc = desc.calculateDimension(stringBounder); + Dimension2D dim = TextBlockUtils.mergeTB(desc, stereoBlock, HorizontalAlignment.LEFT).calculateDimension( + stringBounder); + dim = Dimension2DDouble.atLeast(dim, 0, 2 * dimDesc.getHeight()); + return Dimension2DDouble.delta(dim, MARGIN * 2, MARGIN * 2); } private UStroke getStroke() { @@ -95,10 +112,11 @@ public class EntityImageEmptyPackage extends AbstractEntityImage { final HtmlColor back = Cluster.getBackColor(specificBackColor, skinParam, stereotype); final ClusterDecoration decoration = new ClusterDecoration(getSkinParam().getPackageStyle(), null, desc, - TextBlockUtils.empty(0, 0), 0, 0, widthTotal, heightTotal, getStroke()); + stereoBlock, 0, 0, widthTotal, heightTotal, getStroke()); + + decoration.drawU(ug, back, SkinParamUtils.getColor(getSkinParam(), ColorParam.packageBorder, getStereo()), + getSkinParam().shadowing()); - decoration.drawU(ug, back, - SkinParamUtils.getColor(getSkinParam(), ColorParam.packageBorder, getStereo()), getSkinParam().shadowing()); } public ShapeType getShapeType() { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java b/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java index 8fe55fd4a..0ed2a76ed 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.SkinParamBackcolored; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; @@ -206,7 +207,8 @@ public class EntityImageNote extends AbstractEntityImage implements Stencil { -shape.getMinY()); final Opale opale = new Opale(borderColor, noteBackgroundColor, textBlock, skinParam.shadowing(), true); opale.setOpale(strategy, pp1, projection); - opale.drawU(Colors.applyStroke(ug2, getEntity().getColors(skinParam))); + final UGraphic stroked = applyStroke(ug2); + opale.drawU(Colors.applyStroke(stroked, getEntity().getColors(skinParam))); } if (url != null) { ug.closeAction(); @@ -224,13 +226,22 @@ public class EntityImageNote extends AbstractEntityImage implements Stencil { polygon.setDeltaShadow(4); } ug = ug.apply(new UChangeBackColor(noteBackgroundColor)).apply(new UChangeColor(borderColor)); - ug.draw(polygon); + final UGraphic stroked = applyStroke(ug); + stroked.draw(polygon); - ug.apply(new UTranslate(getTextWidth(stringBounder) - cornersize, 0)).draw(new ULine(0, cornersize)); - ug.apply(new UTranslate(getTextWidth(stringBounder), cornersize)).draw(new ULine(-cornersize, 0)); + stroked.apply(new UTranslate(getTextWidth(stringBounder) - cornersize, 0)).draw(new ULine(0, cornersize)); + stroked.apply(new UTranslate(getTextWidth(stringBounder), cornersize)).draw(new ULine(-cornersize, 0)); getTextBlock().drawU(ug.apply(new UTranslate(marginX1, marginY))); } + private UGraphic applyStroke(UGraphic ug) { + final UStroke stroke = skinParam.getThickness(LineParam.noteBorder, null); + if (stroke == null) { + return ug; + } + return ug.apply(stroke); + } + private UPolygon getPolygonNormal(final StringBounder stringBounder) { final UPolygon polygon = new UPolygon(); polygon.addPoint(0, 0); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java b/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java index 2d822d4b0..01ab1f89e 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java @@ -87,7 +87,7 @@ public class EntityImageObject extends AbstractEntityImage implements Stencil { if (stereotype == null || stereotype.getLabel(false) == null) { this.stereo = null; } else { - this.stereo = Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())).create( + this.stereo = Display.create(stereotype.getLabels(skinParam.useGuillemet())).create( new FontConfiguration(getSkinParam(), FontParam.OBJECT_STEREOTYPE, stereotype), HorizontalAlignment.CENTER, skinParam); } diff --git a/src/net/sourceforge/plantuml/svg/SvgGraphics.java b/src/net/sourceforge/plantuml/svg/SvgGraphics.java index e792671ed..dac3d9fcd 100644 --- a/src/net/sourceforge/plantuml/svg/SvgGraphics.java +++ b/src/net/sourceforge/plantuml/svg/SvgGraphics.java @@ -98,6 +98,7 @@ public class SvgGraphics { private final double scale; private final String filterUid; private final String shadowId; + private final String gradientId; final protected void ensureVisible(double x, double y) { if (x > maxX) { @@ -128,6 +129,7 @@ public class SvgGraphics { final Random rnd = new Random(); this.filterUid = "b" + getRandomString(rnd); this.shadowId = "f" + getRandomString(rnd); + this.gradientId = "g" + getRandomString(rnd); } catch (ParserConfigurationException e) { e.printStackTrace(); throw new IllegalStateException(e); @@ -252,7 +254,7 @@ public class SvgGraphics { elt.setAttribute("x2", "100%"); elt.setAttribute("y2", "100%"); } - id = "gr" + gradients.size(); + id = gradientId + gradients.size(); gradients.put(key, id); elt.setAttribute("id", id); diff --git a/src/net/sourceforge/plantuml/syntax/SyntaxChecker.java b/src/net/sourceforge/plantuml/syntax/SyntaxChecker.java index ae624cb1e..f8e530364 100644 --- a/src/net/sourceforge/plantuml/syntax/SyntaxChecker.java +++ b/src/net/sourceforge/plantuml/syntax/SyntaxChecker.java @@ -93,6 +93,7 @@ public class SyntaxChecker { final PSystemError sys = (PSystemError) system; result.setErrorLinePosition(sys.getHigherErrorPosition()); result.setLineLocation(sys.getLineLocation()); + result.setSystemError(sys); for (ErrorUml er : sys.getErrorsUml()) { result.addErrorText(er.getError()); } diff --git a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java index 1f0645d4d..6c48cb139 100644 --- a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java +++ b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java @@ -42,6 +42,7 @@ import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.util.Set; +import java.util.concurrent.Semaphore; import javax.imageio.ImageIO; import javax.swing.ImageIcon; @@ -68,7 +69,6 @@ import net.sourceforge.plantuml.graphic.HtmlColorGradient; import net.sourceforge.plantuml.graphic.HtmlColorSimple; import net.sourceforge.plantuml.graphic.HtmlColorTransparent; import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.mjpeg.MJPEGGenerator; import net.sourceforge.plantuml.ugraphic.crossing.UGraphicCrossing; @@ -121,6 +121,23 @@ public class ImageBuilder { return writeImageInternal(fileFormatOption, os, animation); } + private static Semaphore SEMAPHORE; + private static int MAX_PRICE = 0; + + public static void setMaxPixel(int max) { + MAX_PRICE = max; + SEMAPHORE = new Semaphore(MAX_PRICE, true); + } + + private int getPrice(FileFormatOption fileFormatOption, Dimension2D dim) { + if (fileFormatOption.getFileFormat() != FileFormat.PNG) { + return 0; + } + final int price = Math.min(MAX_PRICE, ((int) (dim.getHeight() * dpiFactor)) + * ((int) (dim.getWidth() * dpiFactor))); + return price; + } + private ImageData writeImageInternal(FileFormatOption fileFormatOption, OutputStream os, Animation animationArg) throws IOException { Dimension2D dim = getFinalDimension(fileFormatOption.getDefaultStringBounder()); @@ -134,22 +151,38 @@ public class ImageBuilder { dy = -minmax.getMinY(); } - final UGraphic2 ug = createUGraphic(fileFormatOption, dim, animationArg, dx, dy); - final UGraphic ugDecored = handwritten(ug.apply(new UTranslate(margin1, margin1))); - udrawable.drawU(ugDecored); - ugDecored.flushUg(); - ug.writeImageTOBEMOVED(os, metadata, 96); - os.flush(); + int price = 0; + if (SEMAPHORE != null) { + price = getPrice(fileFormatOption, dim); + try { + SEMAPHORE.acquire(price); + } catch (InterruptedException e) { + e.printStackTrace(); + throw new IOException(e); + } + } + try { + final UGraphic2 ug = createUGraphic(fileFormatOption, dim, animationArg, dx, dy); + final UGraphic ugDecored = handwritten(ug.apply(new UTranslate(margin1, margin1))); + udrawable.drawU(ugDecored); + ugDecored.flushUg(); + ug.writeImageTOBEMOVED(os, metadata, 96); + os.flush(); - if (ug instanceof UGraphicG2d) { - final Set urls = ((UGraphicG2d) ug).getAllUrlsEncountered(); - if (urls.size() > 0) { - final CMapData cmap = CMapData.cmapString(urls, dpiFactor); - return new ImageDataComplex(dim, cmap, warningOrError); + if (ug instanceof UGraphicG2d) { + final Set urls = ((UGraphicG2d) ug).getAllUrlsEncountered(); + if (urls.size() > 0) { + final CMapData cmap = CMapData.cmapString(urls, dpiFactor); + return new ImageDataComplex(dim, cmap, warningOrError); + } + } + return new ImageDataSimple(dim); + } finally { + if (SEMAPHORE != null) { + SEMAPHORE.release(price); } } - return new ImageDataSimple(dim); } public Dimension2D getFinalDimension(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/ugraphic/UClip.java b/src/net/sourceforge/plantuml/ugraphic/UClip.java index 253a765d1..1cf3ede61 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UClip.java +++ b/src/net/sourceforge/plantuml/ugraphic/UClip.java @@ -150,4 +150,8 @@ public class UClip implements UChange { return yp; } + public boolean isInside(double x, double y, UPath shape) { + return isInside(x + shape.getMinX(), y + shape.getMinY()) && isInside(x + shape.getMaxX(), y + shape.getMaxY()); + } + } diff --git a/src/net/sourceforge/plantuml/ugraphic/UPath.java b/src/net/sourceforge/plantuml/ugraphic/UPath.java index dcf37a3b8..e7dcf08fb 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UPath.java +++ b/src/net/sourceforge/plantuml/ugraphic/UPath.java @@ -43,11 +43,16 @@ public class UPath extends AbstractShadowable implements Iterable { private boolean isOpenIconic; public void add(double[] coord, USegmentType pathType) { - segments.add(new USegment(coord, pathType)); - if (pathType == USegmentType.SEG_ARCTO) { + addInternal(new USegment(coord, pathType)); + } + + private void addInternal(USegment segment) { + segments.add(segment); + final double coord[] = segment.getCoord(); + if (segment.getSegmentType() == USegmentType.SEG_ARCTO) { minmax = minmax.addPoint(coord[5], coord[6]); -// minmax = minmax.addPoint(coord[5] + coord[0], coord[6] + coord[1]); -// minmax = minmax.addPoint(coord[5] - coord[0], coord[6] - coord[1]); + // minmax = minmax.addPoint(coord[5] + coord[0], coord[6] + coord[1]); + // minmax = minmax.addPoint(coord[5] - coord[0], coord[6] - coord[1]); } else { for (int i = 0; i < coord.length; i += 2) { minmax = minmax.addPoint(coord[i], coord[i + 1]); @@ -55,6 +60,22 @@ public class UPath extends AbstractShadowable implements Iterable { } } + public UPath translate(double dx, double dy) { + final UPath result = new UPath(); + for (USegment seg : segments) { + result.addInternal(seg.translate(dx, dy)); + } + return result; + } + + public UPath rotate(double theta) { + final UPath result = new UPath(); + for (USegment seg : segments) { + result.addInternal(seg.rotate(theta)); + } + return result; + } + public void moveTo(Point2D pt) { moveTo(pt.getX(), pt.getY()); } diff --git a/src/net/sourceforge/plantuml/ugraphic/USegment.java b/src/net/sourceforge/plantuml/ugraphic/USegment.java index 47a210e76..266f51e6a 100644 --- a/src/net/sourceforge/plantuml/ugraphic/USegment.java +++ b/src/net/sourceforge/plantuml/ugraphic/USegment.java @@ -30,6 +30,8 @@ */ package net.sourceforge.plantuml.ugraphic; +import java.awt.geom.AffineTransform; +import java.awt.geom.Point2D; import java.util.Arrays; public class USegment { @@ -55,4 +57,22 @@ public class USegment { return pathType; } + public USegment translate(double dx, double dy) { + if (coord.length != 2) { + throw new UnsupportedOperationException(); + } + Point2D p1 = new Point2D.Double(coord[0] + dx, coord[1] + dy); + return new USegment(new double[] { p1.getX(), p1.getY() }, pathType); + } + + public USegment rotate(double theta) { + if (coord.length != 2) { + throw new UnsupportedOperationException(); + } + Point2D p1 = new Point2D.Double(coord[0], coord[1]); + final AffineTransform rotate = AffineTransform.getRotateInstance(theta); + rotate.transform(p1, p1); + return new USegment(new double[] { p1.getX(), p1.getY() }, pathType); + } + } diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverRectangleG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverRectangleG2d.java index 8b72c7bf8..414fc3606 100644 --- a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverRectangleG2d.java +++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverRectangleG2d.java @@ -110,25 +110,30 @@ public class DriverRectangleG2d extends DriverShadowedG2d implements UDriver { final UFont font = fontConfiguration.getFont().scaled(param.getScale()); final Dimension2D dimBack = calculateDimension(FileFormat.PNG.getDefaultStringBounder(), font, shape.getText()); + final HtmlColor extended = fontConfiguration.getExtendedColor(); if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) { - final Color extended = mapper.getMappedColor(fontConfiguration.getExtendedColor()); - if (extended != null) { - g2d.setColor(extended); - g2d.setBackground(extended); - g2d.fill(new Rectangle2D.Double(x, y - dimBack.getHeight() + 1.5, dimBack.getWidth(), dimBack - .getHeight())); + final Rectangle2D.Double area = new Rectangle2D.Double(x, y - dimBack.getHeight() + 1.5, + dimBack.getWidth(), dimBack.getHeight()); + if (extended instanceof HtmlColorGradient) { + final GradientPaint paint = DriverRectangleG2d.getPaintGradient(x, y, mapper, dimBack.getWidth(), + dimBack.getHeight(), extended); + g2d.setPaint(paint); + g2d.fill(area); + } else { + final Color backColor = mapper.getMappedColor(extended); + if (backColor != null) { + g2d.setColor(backColor); + g2d.setBackground(backColor); + g2d.fill(area); + } } } visible.ensureVisible(x, y - dimBack.getHeight() + 1.5); @@ -93,7 +104,6 @@ public class DriverTextG2d implements UDriver { g2d.drawString(shape.getText(), (float) x, (float) y); if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) { - final HtmlColor extended = fontConfiguration.getExtendedColor(); if (extended != null) { g2d.setColor(mapper.getMappedColor(extended)); } @@ -106,7 +116,6 @@ public class DriverTextG2d implements UDriver { if (fontConfiguration.containsStyle(FontStyle.WAVE)) { final Dimension2D dim = calculateDimension(FileFormat.PNG.getDefaultStringBounder(), font, shape.getText()); final int ypos = (int) (y + 2.5) - 1; - final HtmlColor extended = fontConfiguration.getExtendedColor(); if (extended != null) { g2d.setColor(mapper.getMappedColor(extended)); } @@ -119,7 +128,6 @@ public class DriverTextG2d implements UDriver { final Dimension2D dim = calculateDimension(FileFormat.PNG.getDefaultStringBounder(), font, shape.getText()); final FontMetrics fm = g2d.getFontMetrics(font.getFont()); final int ypos = (int) (y - fm.getDescent() - 0.5); - final HtmlColor extended = fontConfiguration.getExtendedColor(); if (extended != null) { g2d.setColor(mapper.getMappedColor(extended)); } diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverPathSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverPathSvg.java index b827a338e..aced211f1 100644 --- a/src/net/sourceforge/plantuml/ugraphic/svg/DriverPathSvg.java +++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverPathSvg.java @@ -35,6 +35,7 @@ import net.sourceforge.plantuml.graphic.HtmlColorGradient; import net.sourceforge.plantuml.svg.SvgGraphics; import net.sourceforge.plantuml.ugraphic.ClipContainer; import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UClip; import net.sourceforge.plantuml.ugraphic.UDriver; import net.sourceforge.plantuml.ugraphic.UParam; import net.sourceforge.plantuml.ugraphic.UPath; @@ -52,6 +53,11 @@ public class DriverPathSvg extends DriverShadowedG2d implements UDriver { textDecoration = "line-through"; } - String backColor = null; - if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) { - backColor = StringUtils.getAsHtml(mapper.getMappedColor(fontConfiguration.getExtendedColor())); - } - - svg.setFillColor(StringUtils.getAsHtml(mapper.getMappedColor(fontConfiguration.getColor()))); String text = shape.getText(); if (text.startsWith(" ")) { final double space = stringBounder.calculateDimension(font, " ").getWidth(); @@ -97,7 +93,28 @@ public class DriverTextSvg implements UDriver { } text = StringUtils.trin(text); final Dimension2D dim = stringBounder.calculateDimension(font, text); + + String backColor = null; + final double width = dim.getWidth(); + final double height = dim.getHeight(); + if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) { + final HtmlColor back = fontConfiguration.getExtendedColor(); + if (back instanceof HtmlColorGradient) { + final HtmlColorGradient gr = (HtmlColorGradient) back; + final String id = svg.createSvgGradient(StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor1())), + StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor2())), gr.getPolicy()); + svg.setFillColor("url(#" + id + ")"); + svg.setStrokeColor(null); + final double deltaPatch = 2; + svg.svgRectangle(x, y - height + deltaPatch, width, height, 0, 0, 0); + + } else { + backColor = StringUtils.getAsHtml(mapper.getMappedColor(back)); + } + } + + svg.setFillColor(StringUtils.getAsHtml(mapper.getMappedColor(fontConfiguration.getColor()))); svg.text(text, x, y, font.getFamily(UFontContext.SVG), font.getSize(), fontWeight, fontStyle, textDecoration, - dim.getWidth(), fontConfiguration.getAttributes(), backColor); + width, fontConfiguration.getAttributes(), backColor); } } diff --git a/src/net/sourceforge/plantuml/version/PSystemVersion.java b/src/net/sourceforge/plantuml/version/PSystemVersion.java index 530465789..7ac6c6de8 100644 --- a/src/net/sourceforge/plantuml/version/PSystemVersion.java +++ b/src/net/sourceforge/plantuml/version/PSystemVersion.java @@ -50,6 +50,7 @@ import javax.imageio.ImageIO; import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.Log; +import net.sourceforge.plantuml.OptionPrint; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescriptionImpl; import net.sourceforge.plantuml.core.ImageData; @@ -150,11 +151,13 @@ public class PSystemVersion extends AbstractPSystem { strings.addAll(GraphvizUtils.getTestDotStrings(true)); strings.add(" "); final Properties p = System.getProperties(); - strings.add(p.getProperty("java.runtime.name")); - strings.add(p.getProperty("java.vm.name")); - strings.add(p.getProperty("java.runtime.version")); - strings.add(p.getProperty("os.name")); - strings.add("Processors: " + Runtime.getRuntime().availableProcessors()); + for (String name : OptionPrint.interestingProperties()) { + strings.add(p.getProperty(name)); + } + for (String v : OptionPrint.interestingValues()) { + strings.add(v); + } + return new PSystemVersion(true, strings); } diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index bb4095d4c..ae76c0586 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -36,7 +36,7 @@ import java.util.Date; public class Version { public static int version() { - return 8047; + return 8048; } public static String versionString() { @@ -68,7 +68,7 @@ public class Version { } public static long compileTime() { - return 1472140770579L; + return 1475168642530L; } public static String compileTimeString() {