1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 02:49:06 +00:00

version 8036

This commit is contained in:
Arnaud Roques 2016-02-07 22:13:01 +01:00
parent 94542f7760
commit 274a1fa43e
33 changed files with 671 additions and 56 deletions

View File

@ -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);

View File

@ -127,5 +127,7 @@ public interface ISkinParam extends ISkinSimple {
public String getSvgLinkTarget();
public int getTabSize();
public int maxAsciiMessageLength();
}

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -233,4 +233,8 @@ public class SkinParamDelegator implements ISkinParam {
return shadowingForNote(stereotype);
}
public int maxAsciiMessageLength() {
return skinParam.maxAsciiMessageLength();
}
}

View File

@ -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;

View File

@ -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<Ftile> all = new ArrayList<Ftile>(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();

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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<? extends CharSequence> 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++;

View File

@ -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<ClassDiagram> {

View File

@ -64,7 +64,8 @@ import net.sourceforge.plantuml.skin.VisibilityModifier;
public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagram> {
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 {

View File

@ -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<AbstractClassOrOb
return "(" + getSeparator() + "?[\\p{L}0-9_$]+(?:" + getSeparator() + "[\\p{L}0-9_$]+)*|[%g][^%g]+[%g])";
}
private static String getSeparator() {
return "(?:\\.|::)";
public static String getSeparator() {
return "(?:\\.|::|\\\\|\\\\\\\\)";
}
private static String optionalKeywords(UmlDiagramType type) {

View File

@ -36,6 +36,7 @@ package net.sourceforge.plantuml.classdiagram.command;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -52,7 +53,6 @@ import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.utils.UniqueSequence;
final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassOrObjectDiagram> {

View File

@ -54,7 +54,7 @@ public class CommandNamespace extends SingleLineCommand2<ClassDiagram> {
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]*"), //

View File

@ -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<UmlDiagram> {
public CommandScaleMaxHeight() {
super("(?i)^scale[%s]+max[%s]+([0-9.]+)[%s]+height$");
}
@Override
protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
final double height = Double.parseDouble(arg.get(0));
diagram.setScale(new ScaleMaxHeight(height));
return CommandExecutionResult.ok();
}
}

View File

@ -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<UmlDiagram> {
public CommandScaleMaxWidth() {
super("(?i)^scale[%s]+max[%s]+([0-9.]+)[%s]+width$");
}
@Override
protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
final double width = Double.parseDouble(arg.get(0));
diagram.setScale(new ScaleMaxWidth(width));
return CommandExecutionResult.ok();
}
}

View File

@ -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());

View File

@ -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());
}

View File

@ -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)) {

View File

@ -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<Point2D> intersection() {
final List<Point2D> result = new ArrayList<Point2D>();
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;
}
}

View File

@ -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 + "}";

View File

@ -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) {

View File

@ -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));
}
}

View File

@ -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<LineSegmentDouble> getLineSegments() {
final List<LineSegmentDouble> result = new ArrayList<LineSegmentDouble>();
for (CubicCurve2D.Double curve : beziers) {
if (curve.getFlatnessSq() <= 0.001) {
result.add(new LineSegmentDouble(curve));
}
}
return Collections.unmodifiableList(result);
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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<Pending> 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<Point2D> getCollisionsWith(List<Pending> others) {
final List<Point2D> result = new ArrayList<Point2D>();
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<Pending>());
}
private static boolean isClose(Point2D p1, Point2D p2) {
return p1.distance(p2) < 0.1;
}
private UGraphicCrossing(UGraphic ug, UTranslate translate, List<Pending> 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<Pending> pendings = new ArrayList<Pending>();
final List<Balloon> balloons = new ArrayList<Balloon>();
for (Pending p : lines) {
final List<Point2D> 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<Point2D> 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;
}
}

View File

@ -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() {