From 274a1fa43e617fee4d8ba8c34a3574f15d1d76f6 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Sun, 7 Feb 2016 22:13:01 +0100 Subject: [PATCH] version 8036 --- .../plantuml/EmptyImageBuilder.java | 5 +- src/net/sourceforge/plantuml/ISkinParam.java | 2 + src/net/sourceforge/plantuml/OptionFlags.java | 3 +- .../sourceforge/plantuml/ScaleMaxHeight.java | 51 +++++ .../sourceforge/plantuml/ScaleMaxWidth.java | 51 +++++ src/net/sourceforge/plantuml/SkinParam.java | 10 +- .../plantuml/SkinParamDelegator.java | 4 + .../ftile/CollisionDetector.java | 2 - .../ftile/vcompact/FtileIfLongHorizontal.java | 40 +++- .../plantuml/asciiart/ComponentTextArrow.java | 14 +- .../plantuml/asciiart/TextSkin.java | 4 +- .../plantuml/asciiart/UmlCharAreaImpl.java | 5 +- .../command/CommandCreateClass.java | 3 +- .../command/CommandCreateClassMultilines.java | 3 +- .../command/CommandLinkClass.java | 6 +- .../command/CommandLinkLollipop.java | 2 +- .../plantuml/command/CommandNamespace.java | 2 +- .../command/CommandScaleMaxHeight.java | 54 +++++ .../command/CommandScaleMaxWidth.java | 54 +++++ .../plantuml/command/UmlDiagramFactory.java | 2 + .../plantuml/creole/CommandCreoleImg.java | 13 +- .../cucadiagram/dot/GraphvizUtils.java | 14 +- .../plantuml/cute/CrossingSegment.java | 71 +++++++ .../plantuml/cute/InfiniteLine.java | 5 + .../plantuml/geom/AbstractLineSegment.java | 33 ++- .../plantuml/geom/LineSegmentDouble.java | 18 +- .../sourceforge/plantuml/posimo/DotPath.java | 22 +- .../plantuml/preproc/PreprocessorInclude.java | 5 +- .../graphic/DrawableSetInitializer.java | 5 +- .../graphic/ParticipantBox.java | 7 +- .../plantuml/ugraphic/ImageBuilder.java | 20 +- .../ugraphic/crossing/UGraphicCrossing.java | 191 ++++++++++++++++++ .../sourceforge/plantuml/version/Version.java | 6 +- 33 files changed, 671 insertions(+), 56 deletions(-) create mode 100644 src/net/sourceforge/plantuml/ScaleMaxHeight.java create mode 100644 src/net/sourceforge/plantuml/ScaleMaxWidth.java create mode 100644 src/net/sourceforge/plantuml/command/CommandScaleMaxHeight.java create mode 100644 src/net/sourceforge/plantuml/command/CommandScaleMaxWidth.java create mode 100644 src/net/sourceforge/plantuml/cute/CrossingSegment.java create mode 100644 src/net/sourceforge/plantuml/ugraphic/crossing/UGraphicCrossing.java diff --git a/src/net/sourceforge/plantuml/EmptyImageBuilder.java b/src/net/sourceforge/plantuml/EmptyImageBuilder.java index de788ec00..b0608a64b 100644 --- a/src/net/sourceforge/plantuml/EmptyImageBuilder.java +++ b/src/net/sourceforge/plantuml/EmptyImageBuilder.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18906 $ * */ package net.sourceforge.plantuml; @@ -38,6 +38,7 @@ import java.awt.Graphics2D; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; +import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils; import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; import net.sourceforge.plantuml.ugraphic.UAntiAliasing; import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d; @@ -46,7 +47,7 @@ public class EmptyImageBuilder { private final BufferedImage im; private final Graphics2D g2d; - static final private int LIMIT = 4096; + static final private int LIMIT = GraphvizUtils.getenvImageLimit(); public EmptyImageBuilder(double width, double height, Color background) { this((int) width, (int) height, background); diff --git a/src/net/sourceforge/plantuml/ISkinParam.java b/src/net/sourceforge/plantuml/ISkinParam.java index 5d53e1924..e0e5994c4 100644 --- a/src/net/sourceforge/plantuml/ISkinParam.java +++ b/src/net/sourceforge/plantuml/ISkinParam.java @@ -127,5 +127,7 @@ public interface ISkinParam extends ISkinSimple { public String getSvgLinkTarget(); public int getTabSize(); + + public int maxAsciiMessageLength(); } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/OptionFlags.java b/src/net/sourceforge/plantuml/OptionFlags.java index 8c623e081..681962769 100644 --- a/src/net/sourceforge/plantuml/OptionFlags.java +++ b/src/net/sourceforge/plantuml/OptionFlags.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18910 $ * */ package net.sourceforge.plantuml; @@ -60,6 +60,7 @@ public class OptionFlags { static public final boolean USE_INTERFACE_EYE2 = false; static public final boolean SWI2 = false; static public final boolean USE_COMPOUND = false; + static public final boolean OMEGA_CROSSING = false; public void reset() { reset(false); diff --git a/src/net/sourceforge/plantuml/ScaleMaxHeight.java b/src/net/sourceforge/plantuml/ScaleMaxHeight.java new file mode 100644 index 000000000..f6a1dfaf9 --- /dev/null +++ b/src/net/sourceforge/plantuml/ScaleMaxHeight.java @@ -0,0 +1,51 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 5401 $ + * + */ +package net.sourceforge.plantuml; + +public class ScaleMaxHeight implements Scale { + + private final double maxHeight; + + public ScaleMaxHeight(double maxHeight) { + this.maxHeight = maxHeight; + } + + public double getScale(double width, double height) { + final double result = maxHeight / height; + if (result > 1) { + return 1; + } + return result; + } +} diff --git a/src/net/sourceforge/plantuml/ScaleMaxWidth.java b/src/net/sourceforge/plantuml/ScaleMaxWidth.java new file mode 100644 index 000000000..4f5136779 --- /dev/null +++ b/src/net/sourceforge/plantuml/ScaleMaxWidth.java @@ -0,0 +1,51 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 5401 $ + * + */ +package net.sourceforge.plantuml; + +public class ScaleMaxWidth implements Scale { + + private final double maxWidth; + + public ScaleMaxWidth(double maxWidth) { + this.maxWidth = maxWidth; + } + + public double getScale(double width, double height) { + final double result = maxWidth / width; + if (result > 1) { + return 1; + } + return result; + } +} diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index b88045f92..98ee63fd6 100644 --- a/src/net/sourceforge/plantuml/SkinParam.java +++ b/src/net/sourceforge/plantuml/SkinParam.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18309 $ + * Revision $Revision: 18917 $ * */ package net.sourceforge.plantuml; @@ -725,4 +725,12 @@ public class SkinParam implements ISkinParam { return 8; } + public int maxAsciiMessageLength() { + final String value = getValue("maxasciimessagelength"); + if (value != null && value.matches("\\d+")) { + return Integer.parseInt(value); + } + return -1; + } + } diff --git a/src/net/sourceforge/plantuml/SkinParamDelegator.java b/src/net/sourceforge/plantuml/SkinParamDelegator.java index c8330639c..b804749f8 100644 --- a/src/net/sourceforge/plantuml/SkinParamDelegator.java +++ b/src/net/sourceforge/plantuml/SkinParamDelegator.java @@ -233,4 +233,8 @@ public class SkinParamDelegator implements ISkinParam { return shadowingForNote(stereotype); } + public int maxAsciiMessageLength() { + return skinParam.maxAsciiMessageLength(); + } + } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/CollisionDetector.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/CollisionDetector.java index 9fd682b29..27c4d52c7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/CollisionDetector.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/CollisionDetector.java @@ -34,8 +34,6 @@ package net.sourceforge.plantuml.activitydiagram3.ftile; import java.awt.geom.Line2D; -import java.io.IOException; -import java.io.OutputStream; import java.util.ArrayList; import java.util.List; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java index 5614735fa..bc0d805c2 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLongHorizontal.java @@ -48,6 +48,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; import net.sourceforge.plantuml.activitydiagram3.ftile.Connection; +import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; @@ -58,9 +59,11 @@ 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; +import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.svek.ConditionStyle; @@ -180,6 +183,7 @@ class FtileIfLongHorizontal extends AbstractFtile { conns.add(result.new ConnectionLastElseOut(arrowColor)); final HtmlColor horizontalOutColor = LinkRendering.getColor(afterEndwhile, arrowColor); conns.add(result.new ConnectionHline(horizontalOutColor)); + // conns.add(result.new ConnectionHline(HtmlColorUtils.BLUE)); return FtileUtils.addConnection(result, conns); } @@ -304,7 +308,7 @@ class FtileIfLongHorizontal extends AbstractFtile { } - class ConnectionVerticalIn extends AbstractConnection { + class ConnectionVerticalIn extends AbstractConnection implements ConnectionTranslatable { private final HtmlColor color; @@ -334,6 +338,22 @@ class FtileIfLongHorizontal extends AbstractFtile { return getTranslate1(getFtile2(), stringBounder).getTranslated(p); } + public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { + final Point2D p1 = getP1(ug.getStringBounder()); + final Point2D p2 = getP2(ug.getStringBounder()); + + final Snake snake = new Snake(color, Arrows.asToDown()); + + final Point2D mp1a = translate1.getTranslated(p1); + final Point2D mp2b = translate2.getTranslated(p2); + final double middle = mp1a.getY() + 4; + snake.addPoint(mp1a); + snake.addPoint(mp1a.getX(), middle); + snake.addPoint(mp2b.getX(), middle); + snake.addPoint(mp2b); + ug.draw(snake); + } + } class ConnectionVerticalOut extends AbstractConnection { @@ -384,19 +404,37 @@ class FtileIfLongHorizontal extends AbstractFtile { final StringBounder stringBounder = ug.getStringBounder(); final Dimension2D totalDim = calculateDimensionInternal(stringBounder); + final Swimlane intoSw; + if (ug instanceof UGraphicInterceptorOneSwimlane) { + intoSw = ((UGraphicInterceptorOneSwimlane) ug).getSwimlane(); + } else { + intoSw = null; + } + final List all = new ArrayList(couples); all.add(tile2); double minX = totalDim.getWidth() / 2; double maxX = totalDim.getWidth() / 2; + boolean atLeastOne = false; for (Ftile tmp : all) { if (tmp.calculateDimension(stringBounder).hasPointOut() == false) { continue; } + if (intoSw != null && tmp.getSwimlanes().contains(intoSw) == false) { + continue; + } + if (intoSw != null && tmp.getSwimlaneOut() != intoSw) { + continue; + } + atLeastOne = true; final UTranslate ut = getTranslateFor(tmp, stringBounder); final double out = tmp.calculateDimension(stringBounder).translate(ut).getLeft(); minX = Math.min(minX, out); maxX = Math.max(maxX, out); } + if (atLeastOne == false) { + return; + } final Snake s = new Snake(arrowColor); s.goUnmergeable(); diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java index 67ed0a660..0b18b3035 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java @@ -36,18 +36,17 @@ package net.sourceforge.plantuml.asciiart; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.FileFormat; +import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.sequencediagram.MessageNumber; import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.skin.ArrowDirection; -import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt; -import net.sourceforge.plantuml.StringUtils; public class ComponentTextArrow extends AbstractComponentText { @@ -55,9 +54,11 @@ public class ComponentTextArrow extends AbstractComponentText { private final Display stringsToDisplay; private final FileFormat fileFormat; private final ArrowConfiguration config; + private final int maxAsciiMessageLength; public ComponentTextArrow(ComponentType type, ArrowConfiguration config, Display stringsToDisplay, - FileFormat fileFormat) { + FileFormat fileFormat, int maxAsciiMessageLength) { + this.maxAsciiMessageLength = maxAsciiMessageLength; this.type = type; this.config = config; this.stringsToDisplay = clean(stringsToDisplay); @@ -107,6 +108,7 @@ public class ComponentTextArrow extends AbstractComponentText { } else { throw new UnsupportedOperationException(); } + // final int position = Math.max(0, (width - textWidth) / 2); charArea.drawStringsLR(stringsToDisplay.as(), (width - textWidth) / 2, 0); } @@ -115,7 +117,11 @@ public class ComponentTextArrow extends AbstractComponentText { } public double getPreferredWidth(StringBounder stringBounder) { - return StringUtils.getWidth(stringsToDisplay) + 2; + final int width = StringUtils.getWidth(stringsToDisplay) + 2; + if (maxAsciiMessageLength > 0) { + return Math.min(maxAsciiMessageLength, width); + } + return width; } } diff --git a/src/net/sourceforge/plantuml/asciiart/TextSkin.java b/src/net/sourceforge/plantuml/asciiart/TextSkin.java index c8708c482..a60f818bc 100644 --- a/src/net/sourceforge/plantuml/asciiart/TextSkin.java +++ b/src/net/sourceforge/plantuml/asciiart/TextSkin.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18917 $ * */ package net.sourceforge.plantuml.asciiart; @@ -61,7 +61,7 @@ public class TextSkin implements Skin { } if (type.isArrow() && ((config.getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) || (config.getArrowDirection() == ArrowDirection.RIGHT_TO_LEFT_REVERSE))) { - return new ComponentTextArrow(type, config, stringsToDisplay, fileFormat); + return new ComponentTextArrow(type, config, stringsToDisplay, fileFormat, param.maxAsciiMessageLength()); } if (type.isArrow() && config.isSelfArrow()) { return new ComponentTextSelfArrow(type, config, stringsToDisplay, fileFormat); diff --git a/src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java b/src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java index bfe0fc5c0..b71492c2e 100644 --- a/src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java +++ b/src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18917 $ * */ package net.sourceforge.plantuml.asciiart; @@ -84,6 +84,9 @@ public class UmlCharAreaImpl extends BasicCharAreaImpl implements UmlCharArea { public void drawStringsLR(Collection strings, int x, int y) { int i = 0; + if (x < 0) { + x = 0; + } for (CharSequence s : strings) { this.drawStringLR(s.toString(), x, y + i); i++; diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java index 7b9478803..07232ea8d 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java @@ -49,12 +49,11 @@ import net.sourceforge.plantuml.cucadiagram.Code; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.LeafType; -import net.sourceforge.plantuml.cucadiagram.LinkStyle; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.color.ColorParser; -import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.ColorType; +import net.sourceforge.plantuml.graphic.color.Colors; public class CommandCreateClass extends SingleLineCommand2 { diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java index 454f93c8e..523396e3a 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java @@ -64,7 +64,8 @@ import net.sourceforge.plantuml.skin.VisibilityModifier; public class CommandCreateClassMultilines extends CommandMultilines2 { - private static final String CODE = "(?:\\.|::)?[\\p{L}0-9_]+(?:(?:\\.|::)[\\p{L}0-9_]+)*"; + private static final String CODE = CommandLinkClass.getSeparator() + "?[\\p{L}0-9_]+" + "(?:" + + CommandLinkClass.getSeparator() + "[\\p{L}0-9_]+)*"; public static final String CODES = CODE + "(?:\\s*,\\s*" + CODE + ")*"; enum Mode { diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java index aea28d975..f87df1e02 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java @@ -38,7 +38,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import net.sourceforge.plantuml.Direction; -import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -57,7 +56,6 @@ import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkArrow; import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkType; -import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.HtmlColorSet; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; @@ -118,8 +116,8 @@ final public class CommandLinkClass extends SingleLineCommand2 { diff --git a/src/net/sourceforge/plantuml/command/CommandNamespace.java b/src/net/sourceforge/plantuml/command/CommandNamespace.java index 8a89144a5..0ffc1aa1e 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespace.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespace.java @@ -54,7 +54,7 @@ public class CommandNamespace extends SingleLineCommand2 { private static RegexConcat getRegexConcat() { return new RegexConcat(new RegexLeaf("^namespace[%s]+"), // - new RegexLeaf("NAME", "([\\p{L}0-9_][\\p{L}0-9_.:]*)"), // + new RegexLeaf("NAME", "([\\p{L}0-9_][\\p{L}0-9_.:\\\\]*)"), // new RegexLeaf("[%s]*"), // new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // new RegexLeaf("[%s]*"), // diff --git a/src/net/sourceforge/plantuml/command/CommandScaleMaxHeight.java b/src/net/sourceforge/plantuml/command/CommandScaleMaxHeight.java new file mode 100644 index 000000000..e69b21e76 --- /dev/null +++ b/src/net/sourceforge/plantuml/command/CommandScaleMaxHeight.java @@ -0,0 +1,54 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 4762 $ + * + */ +package net.sourceforge.plantuml.command; + +import java.util.List; + +import net.sourceforge.plantuml.ScaleMaxHeight; +import net.sourceforge.plantuml.UmlDiagram; + +public class CommandScaleMaxHeight extends SingleLineCommand { + + public CommandScaleMaxHeight() { + super("(?i)^scale[%s]+max[%s]+([0-9.]+)[%s]+height$"); + } + + @Override + protected CommandExecutionResult executeArg(UmlDiagram diagram, List arg) { + final double height = Double.parseDouble(arg.get(0)); + diagram.setScale(new ScaleMaxHeight(height)); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/command/CommandScaleMaxWidth.java b/src/net/sourceforge/plantuml/command/CommandScaleMaxWidth.java new file mode 100644 index 000000000..fa0d410b6 --- /dev/null +++ b/src/net/sourceforge/plantuml/command/CommandScaleMaxWidth.java @@ -0,0 +1,54 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 4762 $ + * + */ +package net.sourceforge.plantuml.command; + +import java.util.List; + +import net.sourceforge.plantuml.ScaleMaxWidth; +import net.sourceforge.plantuml.UmlDiagram; + +public class CommandScaleMaxWidth extends SingleLineCommand { + + public CommandScaleMaxWidth() { + super("(?i)^scale[%s]+max[%s]+([0-9.]+)[%s]+width$"); + } + + @Override + protected CommandExecutionResult executeArg(UmlDiagram diagram, List arg) { + final double width = Double.parseDouble(arg.get(0)); + diagram.setScale(new ScaleMaxWidth(width)); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java b/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java index fbe8bc495..bea776f8e 100644 --- a/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java +++ b/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java @@ -281,6 +281,8 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory { cmds.add(new CommandScale()); cmds.add(new CommandScaleWidthAndHeight()); cmds.add(new CommandScaleWidthOrHeight()); + cmds.add(new CommandScaleMaxWidth()); + cmds.add(new CommandScaleMaxHeight()); cmds.add(new CommandScaleMaxWidthAndHeight()); cmds.add(new CommandAffineTransform()); cmds.add(new CommandAffineTransformMultiline()); diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleImg.java b/src/net/sourceforge/plantuml/creole/CommandCreoleImg.java index f7a2bafe6..3f16efd51 100644 --- a/src/net/sourceforge/plantuml/creole/CommandCreoleImg.java +++ b/src/net/sourceforge/plantuml/creole/CommandCreoleImg.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.creole; import java.util.regex.Matcher; import java.util.regex.Pattern; +import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.graphic.Splitter; @@ -64,14 +65,12 @@ public class CommandCreoleImg implements Command { if (m.find() == false) { throw new IllegalStateException(); } - // final int size = Integer.parseInt(m.group(2)); - // final FontConfiguration fc1 = stripe.getActualFontConfiguration(); - // final FontConfiguration fc2 = fc1.changeSize(size); - // stripe.setActualFontConfiguration(fc2); - // stripe.analyzeAndAdd(m.group(3)); - final String src = m.group(2); + String src = m.group(2); + if (src.toLowerCase().startsWith("src=")) { + src = src.substring(4); + } + src = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(src, "\""); stripe.addImage(src); - // stripe.setActualFontConfiguration(fc1); return line.substring(m.group(1).length()); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java index 8d819a216..bb64dcce8 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18909 $ * */ package net.sourceforge.plantuml.cucadiagram.dot; @@ -87,6 +87,18 @@ public class GraphvizUtils { return null; } + public static int getenvImageLimit() { + final String env = System.getProperty("PLANTUML_LIMIT_SIZE"); + if (StringUtils.isNotEmpty(env) && env.matches("\\d+")) { + return Integer.parseInt(env); + } + final String getenv = System.getenv("PLANTUML_LIMIT_SIZE"); + if (StringUtils.isNotEmpty(getenv) && getenv.matches("\\d+")) { + return Integer.parseInt(getenv); + } + return 4096; + } + public static String getenvLogData() { final String env = System.getProperty("PLANTUML_LOGDATA"); if (StringUtils.isNotEmpty(env)) { diff --git a/src/net/sourceforge/plantuml/cute/CrossingSegment.java b/src/net/sourceforge/plantuml/cute/CrossingSegment.java new file mode 100644 index 000000000..f4d9cf286 --- /dev/null +++ b/src/net/sourceforge/plantuml/cute/CrossingSegment.java @@ -0,0 +1,71 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 4041 $ + * + */ +package net.sourceforge.plantuml.cute; + +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; + +import net.sourceforge.plantuml.geom.LineSegmentDouble; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class CrossingSegment { + + private final Balloon balloon; + private final LineSegmentDouble segment; + + public CrossingSegment(Balloon balloon, LineSegmentDouble segment) { + this.balloon = balloon; + this.segment = segment; + } + + public List intersection() { + final List result = new ArrayList(); + + final UTranslate tr = new UTranslate(balloon.getCenter()); + final UTranslate trInverse = tr.reverse(); + + final CrossingSimple simple = new CrossingSimple(balloon.getRadius(), + new InfiniteLine(segment).translate(trInverse)); + for (Point2D pt : simple.intersection()) { + pt = tr.getTranslated(pt); + if (segment.isPointOnSegment(pt)) { + result.add(pt); + } + } + + return result; + } + +} diff --git a/src/net/sourceforge/plantuml/cute/InfiniteLine.java b/src/net/sourceforge/plantuml/cute/InfiniteLine.java index 26d39b399..2eff0c7f5 100644 --- a/src/net/sourceforge/plantuml/cute/InfiniteLine.java +++ b/src/net/sourceforge/plantuml/cute/InfiniteLine.java @@ -35,6 +35,7 @@ package net.sourceforge.plantuml.cute; import java.awt.geom.Point2D; +import net.sourceforge.plantuml.geom.AbstractLineSegment; import net.sourceforge.plantuml.ugraphic.UTranslate; public class InfiniteLine { @@ -47,6 +48,10 @@ public class InfiniteLine { this.b = b; } + public InfiniteLine(AbstractLineSegment segment) { + this(segment.getP1(), segment.getP2()); + } + @Override public String toString() { return "{" + a + ";" + b + "}"; diff --git a/src/net/sourceforge/plantuml/geom/AbstractLineSegment.java b/src/net/sourceforge/plantuml/geom/AbstractLineSegment.java index 91be518d8..9bad35b3d 100644 --- a/src/net/sourceforge/plantuml/geom/AbstractLineSegment.java +++ b/src/net/sourceforge/plantuml/geom/AbstractLineSegment.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18930 $ * */ package net.sourceforge.plantuml.geom; @@ -76,7 +76,7 @@ public abstract class AbstractLineSegment extends Line2D { } else if (other.isHorizontal()) { u = getIntersectionHorizontal(other.getP1().getY()); } else { - throw new UnsupportedOperationException(); + return getDichoIntersection(other); } if (java.lang.Double.isNaN(u) || u < 0 || u > 1) { return null; @@ -88,6 +88,28 @@ public abstract class AbstractLineSegment extends Line2D { return null; } + private Point2D getDichoIntersection(AbstractLineSegment other) { + if (doesIntersect(other) == false) { + return null; + } + if (other.getLength() < 0.01) { + return other.getMiddle(); + } + final LineSegmentDouble p1 = new LineSegmentDouble(other.getP1(), other.getMiddle()); + final LineSegmentDouble p2 = new LineSegmentDouble(other.getMiddle(), other.getP2()); + if (doesIntersect(p1)) { + return getDichoIntersection(p1); + } + if (doesIntersect(p2)) { + return getDichoIntersection(p2); + } + throw new IllegalStateException(); + } + + private Point2D.Double getMiddle() { + return getPoint2D(0.5); + } + private static boolean isBetween(double value, double v1, double v2) { if (v1 < v2) { return value >= v1 && value <= v2; @@ -164,6 +186,10 @@ public abstract class AbstractLineSegment extends Line2D { return Math.abs(a1 - a2) < 0.0001; } + public boolean isPointOnSegment(Point2D pt) { + return equals(pt.distance(getP1()) + pt.distance(getP2()), getLength()); + } + private double getDistanceInternal(AbstractLineSegment other) { double result = this.getDistance(other.getP1()); result += this.getDistance(other.getP2()); @@ -237,8 +263,7 @@ public abstract class AbstractLineSegment extends Line2D { public double determinant(AbstractLineSegment other) { return determinant(this.getP1().getX() - this.getP2().getX(), this.getP1().getY() - this.getP2().getY(), other - .getP1().getX() - - other.getP2().getX(), other.getP1().getY() - other.getP2().getY()); + .getP1().getX() - other.getP2().getX(), other.getP1().getY() - other.getP2().getY()); } private static double determinant(double x1, double y1, double x2, double y2) { diff --git a/src/net/sourceforge/plantuml/geom/LineSegmentDouble.java b/src/net/sourceforge/plantuml/geom/LineSegmentDouble.java index 8991e367f..346511435 100644 --- a/src/net/sourceforge/plantuml/geom/LineSegmentDouble.java +++ b/src/net/sourceforge/plantuml/geom/LineSegmentDouble.java @@ -28,11 +28,12 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18930 $ * */ package net.sourceforge.plantuml.geom; +import java.awt.geom.CubicCurve2D; import java.awt.geom.Point2D; import java.util.Locale; @@ -47,8 +48,8 @@ public class LineSegmentDouble extends AbstractLineSegment { @Override public String toString() { - return String.format(Locale.US, "( %.2f,%.2f - %.2f,%.2f )", getP1().getX(), getP1().getY(), getP2().getX(), getP2() - .getY()); + return String.format(Locale.US, "( %.2f,%.2f - %.2f,%.2f )", getP1().getX(), getP1().getY(), getP2().getX(), + getP2().getY()); } public LineSegmentDouble(double x1, double y1, double x2, double y2) { @@ -66,6 +67,14 @@ public class LineSegmentDouble extends AbstractLineSegment { assert this.getDistance(this) == 0; } + public LineSegmentDouble(CubicCurve2D.Double curve) { + this(curve.getP1(), curve.getP2()); + } + + public LineSegmentDouble translate(UTranslate translate) { + return new LineSegmentDouble(translate.getTranslated(getP1()), translate.getTranslated(getP2())); + } + @Override public Point2D getP1() { return p1; @@ -103,7 +112,8 @@ public class LineSegmentDouble extends AbstractLineSegment { final double y2 = p2.getY(); ug = ug.apply(new UTranslate(x1, y1)); ug.draw(new ULine(x2 - x1, y2 - y1)); - + } + } diff --git a/src/net/sourceforge/plantuml/posimo/DotPath.java b/src/net/sourceforge/plantuml/posimo/DotPath.java index c4484e0f1..3ed8c5329 100644 --- a/src/net/sourceforge/plantuml/posimo/DotPath.java +++ b/src/net/sourceforge/plantuml/posimo/DotPath.java @@ -41,7 +41,6 @@ import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -52,6 +51,7 @@ import net.sourceforge.plantuml.EnsureVisible; import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.asciiart.BasicCharArea; import net.sourceforge.plantuml.eps.EpsGraphics; +import net.sourceforge.plantuml.geom.LineSegmentDouble; import net.sourceforge.plantuml.svek.Cluster; import net.sourceforge.plantuml.svek.ClusterPosition; import net.sourceforge.plantuml.svek.MinFinder; @@ -621,4 +621,24 @@ public class DotPath implements UShape, Moveable { return curve.getP1().distance(curve.getP2()); } + public boolean isLine() { + for (CubicCurve2D.Double curve : beziers) { + if (curve.getFlatnessSq() > 0.001) { + return false; + } + } + return true; + } + + public List getLineSegments() { + final List result = new ArrayList(); + for (CubicCurve2D.Double curve : beziers) { + if (curve.getFlatnessSq() <= 0.001) { + result.add(new LineSegmentDouble(curve)); + + } + } + return Collections.unmodifiableList(result); + } + } diff --git a/src/net/sourceforge/plantuml/preproc/PreprocessorInclude.java b/src/net/sourceforge/plantuml/preproc/PreprocessorInclude.java index 3818e21b0..50b84cba1 100644 --- a/src/net/sourceforge/plantuml/preproc/PreprocessorInclude.java +++ b/src/net/sourceforge/plantuml/preproc/PreprocessorInclude.java @@ -29,7 +29,7 @@ * Original Author: Arnaud Roques * Modified by: Nicolas Jouanin * - * Revision $Revision: 18280 $ + * Revision $Revision: 18896 $ * */ package net.sourceforge.plantuml.preproc; @@ -176,7 +176,8 @@ class PreprocessorInclude implements ReadLine { if (f.exists() == false) { return CharSequence2Impl.errorPreprocessor("Cannot include " + f.getAbsolutePath(), lineLocation); } else if (filesUsedCurrent.contains(f2)) { - return CharSequence2Impl.errorPreprocessor("File already included " + f.getAbsolutePath(), lineLocation); + // return CharSequence2Impl.errorPreprocessor("File already included " + f.getAbsolutePath(), lineLocation); + return this.readLine(); } else { filesUsedCurrent.add(f2); filesUsedGlobal.add(f2); diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java index 17835dec3..27dcbdcfb 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18917 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; @@ -598,7 +598,8 @@ class DrawableSetInitializer { drawableSet.getSkinParam(), participantDisplay); final Component delayLine = drawableSet.getSkin().createComponent(ComponentType.DELAY_LINE, null, drawableSet.getSkinParam(), participantDisplay); - final ParticipantBox box = new ParticipantBox(head, line, tail, delayLine, this.freeX); + final ParticipantBox box = new ParticipantBox(head, line, tail, delayLine, this.freeX, + skinParam.maxAsciiMessageLength() > 0 ? 1 : 5); final Component comp = drawableSet.getSkin().createComponent(ComponentType.ALIVE_BOX_CLOSE_CLOSE, null, drawableSet.getSkinParam(), null); diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java index 347e91d3a..65973bd47 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18917 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; @@ -51,7 +51,7 @@ public class ParticipantBox implements Pushable { private static int CPT = 0; - private final int outMargin = 5; + private final int outMargin; private double startingX; @@ -62,7 +62,8 @@ public class ParticipantBox implements Pushable { private int cpt = CPT++; - public ParticipantBox(Component head, Component line, Component tail, Component delayLine, double startingX) { + public ParticipantBox(Component head, Component line, Component tail, Component delayLine, double startingX, int outMargin) { + this.outMargin = outMargin; this.startingX = startingX; this.head = head; this.line = line; diff --git a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java index 99f76a6e3..eaba11f4f 100644 --- a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java +++ b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java @@ -56,6 +56,7 @@ import net.sourceforge.plantuml.EmptyImageBuilder; import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileUtils; +import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.anim.AffineTransformation; @@ -71,6 +72,7 @@ import net.sourceforge.plantuml.graphic.HtmlColorTransparent; 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; import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps; import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d; import net.sourceforge.plantuml.ugraphic.hand.UGraphicHandwritten; @@ -142,8 +144,9 @@ public class ImageBuilder { } final UGraphic2 ug = createUGraphic(fileFormatOption, dim, affineTransforms, dx, dy); - udrawable.drawU(handwritten(ug.apply(new UTranslate(margin1, margin1)))); - ug.flushUg(); + final UGraphic ugDecored = handwritten(ug.apply(new UTranslate(margin1, margin1))); + udrawable.drawU(ugDecored); + ugDecored.flushUg(); ug.writeImageTOBEMOVED(os, metadata, 96); os.flush(); @@ -162,7 +165,11 @@ public class ImageBuilder { if (useHandwritten) { return new UGraphicHandwritten(ug); } - return ug; + if (OptionFlags.OMEGA_CROSSING) { + return new UGraphicCrossing(ug); + } else { + return ug; + } } private ImageData writeImageMjpeg(OutputStream os) throws IOException { @@ -234,8 +241,8 @@ public class ImageBuilder { return im; } - private UGraphic2 createUGraphic(FileFormatOption fileFormatOption, final Dimension2D dim, Animation affineTransforms, - double dx, double dy) { + private UGraphic2 createUGraphic(FileFormatOption fileFormatOption, final Dimension2D dim, + Animation affineTransforms, double dx, double dy) { final FileFormat fileFormat = fileFormatOption.getFileFormat(); switch (fileFormat) { case PNG: @@ -257,7 +264,8 @@ public class ImageBuilder { } } - private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, HtmlColor mybackcolor, String svgLinkTarget) { + private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, HtmlColor mybackcolor, + String svgLinkTarget) { Color backColor = Color.WHITE; if (mybackcolor instanceof HtmlColorSimple) { backColor = colorMapper.getMappedColor(mybackcolor); diff --git a/src/net/sourceforge/plantuml/ugraphic/crossing/UGraphicCrossing.java b/src/net/sourceforge/plantuml/ugraphic/crossing/UGraphicCrossing.java new file mode 100644 index 000000000..a7d85e86a --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/crossing/UGraphicCrossing.java @@ -0,0 +1,191 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Adrian Vogt + * + */ +package net.sourceforge.plantuml.ugraphic.crossing; + +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; + +import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.cute.Balloon; +import net.sourceforge.plantuml.cute.CrossingSegment; +import net.sourceforge.plantuml.geom.LineSegmentDouble; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.HtmlColorUtils; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.posimo.DotPath; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UChange; +import net.sourceforge.plantuml.ugraphic.UChangeBackColor; +import net.sourceforge.plantuml.ugraphic.UChangeColor; +import net.sourceforge.plantuml.ugraphic.UEllipse; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UParam; +import net.sourceforge.plantuml.ugraphic.UShape; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class UGraphicCrossing implements UGraphic { + + private final UGraphic ug; + private final List lines; + private final UTranslate translate; + + static class Pending { + final UGraphic ug; + final LineSegmentDouble segment; + final UTranslate translate; + + Pending(UGraphic ug, UTranslate translate, LineSegmentDouble segment) { + this.ug = ug; + this.segment = segment; + this.translate = translate; + } + + void drawNow(HtmlColor color) { + if (color == null) { + segment.draw(ug); + } else { + segment.draw(ug.apply(new UChangeColor(color))); + } + } + + List getCollisionsWith(List others) { + final List result = new ArrayList(); + for (Pending other : others) { + if (isClose(segment.getP1(), other.segment.getP1()) || isClose(segment.getP1(), other.segment.getP2()) + || isClose(segment.getP2(), other.segment.getP1()) + || isClose(segment.getP2(), other.segment.getP2())) { + continue; + } + final Point2D inter = segment.getSegIntersection(other.segment); + if (inter != null) { + result.add(inter); + } + } + return result; + } + } + + public UGraphicCrossing(UGraphic ug) { + this(ug, new UTranslate(), new ArrayList()); + } + + private static boolean isClose(Point2D p1, Point2D p2) { + return p1.distance(p2) < 0.1; + } + + private UGraphicCrossing(UGraphic ug, UTranslate translate, List lines) { + this.ug = ug; + this.translate = translate; + this.lines = lines; + } + + public StringBounder getStringBounder() { + return ug.getStringBounder(); + } + + public UParam getParam() { + return ug.getParam(); + } + + public void draw(UShape shape) { + if (shape instanceof DotPath) { + drawDotPath((DotPath) shape); + } else { + ug.draw(shape); + } + } + + private void drawDotPath(DotPath dotPath) { + if (dotPath.isLine()) { + for (LineSegmentDouble seg : dotPath.getLineSegments()) { + lines.add(new Pending(ug.apply(translate.reverse()), translate, seg.translate(translate))); + } + } else { + ug.draw(dotPath); + } + } + + public UGraphic apply(UChange change) { + if (change instanceof UTranslate) { + return new UGraphicCrossing(ug.apply(change), translate.compose((UTranslate) change), lines); + } else { + return new UGraphicCrossing(ug.apply(change), translate, lines); + } + } + + public ColorMapper getColorMapper() { + return ug.getColorMapper(); + } + + public void startUrl(Url url) { + ug.startUrl(url); + } + + public void closeAction() { + ug.closeAction(); + } + + public void flushUg() { + final List pendings = new ArrayList(); + final List balloons = new ArrayList(); + for (Pending p : lines) { + final List tmp = p.getCollisionsWith(lines); + for (Point2D pt : tmp) { + balloons.add(new Balloon(pt, 5)); + } + // if (tmp.size() == 0) { + // p.drawNow(null); + // } else { + // pendings.add(p); + // } + } + for (Balloon b : balloons) { + b.drawU(ug.apply(new UChangeBackColor(HtmlColorUtils.GREEN)).apply(new UChangeColor(HtmlColorUtils.GREEN))); + } + for (Pending p : lines) { + for (Balloon b : balloons) { + List pts = new CrossingSegment(b, p.segment).intersection(); + for (Point2D pt : pts) { + final Balloon s2 = new Balloon(pt, 2); + s2.drawU(ug.apply(new UChangeBackColor(HtmlColorUtils.BLUE)).apply(new UChangeColor(HtmlColorUtils.BLUE))); + } + } + } + ug.flushUg(); + } + + public boolean isSpecialTxt() { + return false; + } + +} diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index dddd4800f..e0cecccd9 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18828 $ + * Revision $Revision: 18947 $ * */ package net.sourceforge.plantuml.version; @@ -39,7 +39,7 @@ import java.util.Date; public class Version { public static int version() { - return 8035; + return 8036; } public static String versionString() { @@ -63,7 +63,7 @@ public class Version { } private static long compileTime() { - return 1454151644150L; + return 1454874605178L; } public static String compileTimeString() {