1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 10:59:01 +00:00

chore: Version 1.2023.8

This commit is contained in:
Arnaud Roques 2023-05-21 10:54:21 +02:00
parent 18a7f99b55
commit 63a09e24c5
9 changed files with 191 additions and 68 deletions

View File

@ -1,4 +1,4 @@
# Warning, "version" should be the same in gradle.properties and Version.java # Warning, "version" should be the same in gradle.properties and Version.java
# Any idea anyone how to magically synchronize those :-) ? # Any idea anyone how to magically synchronize those :-) ?
version = 1.2023.8beta2 version = 1.2023.8
org.gradle.workers.max = 3 org.gradle.workers.max = 3

View File

@ -141,9 +141,6 @@ public class Snake implements UShape {
if (textBlock != null && textBlock != TextBlockUtils.EMPTY_TEXT_BLOCK) if (textBlock != null && textBlock != TextBlockUtils.EMPTY_TEXT_BLOCK)
this.texts.add(new Text(textBlock, verticalAlignment, null)); this.texts.add(new Text(textBlock, verticalAlignment, null));
if (verticalAlignment != VerticalAlignment.CENTER)
throw new UnsupportedOperationException();
return this; return this;
} }
@ -264,8 +261,8 @@ public class Snake implements UShape {
final boolean zigzag = worm.getDirectionsCode().startsWith("DLD") || worm.getDirectionsCode().startsWith("DRD"); final boolean zigzag = worm.getDirectionsCode().startsWith("DLD") || worm.getDirectionsCode().startsWith("DRD");
double y = (pt1.getY() + pt2.getY()) / 2 - dim.getHeight() / 2; double y = (pt1.getY() + pt2.getY()) / 2 - dim.getHeight() / 2;
if (text.verticalAlignment == VerticalAlignment.BOTTOM) { if (text.verticalAlignment == VerticalAlignment.BOTTOM) {
x = worm.getLast().getX(); x = worm.getMinX();
throw new AssertionError(); y = worm.getMaxY();
} else if (text.verticalAlignment == VerticalAlignment.CENTER) { } else if (text.verticalAlignment == VerticalAlignment.CENTER) {
x = worm.getMinX(); x = worm.getMinX();
y = (worm.getFirst().getY() + worm.getLast().getY() - 10) / 2 - dim.getHeight() / 2; y = (worm.getFirst().getY() + worm.getLast().getY() - 10) / 2 - dim.getHeight() / 2;

View File

@ -333,6 +333,13 @@ public class Worm implements Iterable<XPoint2D> {
return result; return result;
} }
public double getMaxY() {
double result = points.get(0).getY();
for (XPoint2D pt : points)
result = Math.max(result, pt.getY());
return result;
}
public Worm merge(Worm other, MergeStrategy merge) { public Worm merge(Worm other, MergeStrategy merge) {
if (Snake.same(this.getLast(), other.getFirst()) == false) if (Snake.same(this.getLast(), other.getFirst()) == false)
throw new IllegalArgumentException(); throw new IllegalArgumentException();

View File

@ -67,6 +67,7 @@ import net.sourceforge.plantuml.klimt.drawing.UGraphic;
import net.sourceforge.plantuml.klimt.font.FontConfiguration; import net.sourceforge.plantuml.klimt.font.FontConfiguration;
import net.sourceforge.plantuml.klimt.font.StringBounder; import net.sourceforge.plantuml.klimt.font.StringBounder;
import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment; import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment;
import net.sourceforge.plantuml.klimt.geom.VerticalAlignment;
import net.sourceforge.plantuml.klimt.geom.XDimension2D; import net.sourceforge.plantuml.klimt.geom.XDimension2D;
import net.sourceforge.plantuml.klimt.geom.XPoint2D; import net.sourceforge.plantuml.klimt.geom.XPoint2D;
import net.sourceforge.plantuml.klimt.shape.TextBlock; import net.sourceforge.plantuml.klimt.shape.TextBlock;
@ -81,6 +82,7 @@ class FtileWhile extends AbstractFtile {
private final Ftile diamond1; private final Ftile diamond1;
private final Ftile specialOut; private final Ftile specialOut;
private final Ftile backward; private final Ftile backward;
private TextBlock back1;
@Override @Override
public Collection<Ftile> getMyChildren() { public Collection<Ftile> getMyChildren() {
@ -141,8 +143,7 @@ class FtileWhile extends AbstractFtile {
final FtileWhile result = new FtileWhile(whileBlock, diamond1, special, backward); final FtileWhile result = new FtileWhile(whileBlock, diamond1, special, backward);
final XDimension2D dim = whileBlock.calculateDimension(ftileFactory.getStringBounder()); final XDimension2D dim = whileBlock.calculateDimension(ftileFactory.getStringBounder());
final TextBlock back1 = incoming1.getDisplay().create(fontArrow, HorizontalAlignment.LEFT, result.back1 = incoming1.getDisplay().create(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam());
ftileFactory.skinParam());
final List<Connection> conns = new ArrayList<>(); final List<Connection> conns = new ArrayList<>();
if (dim.getWidth() == 0 || dim.getHeight() == 0) { if (dim.getWidth() == 0 || dim.getHeight() == 0) {
@ -150,11 +151,11 @@ class FtileWhile extends AbstractFtile {
} else { } else {
conns.add(result.new ConnectionIn(whileBlock.getInLinkRendering().getRainbow(arrowColor))); conns.add(result.new ConnectionIn(whileBlock.getInLinkRendering().getRainbow(arrowColor)));
if (backward == null) { if (backward == null) {
conns.add(result.new ConnectionBackSimple(incoming1.getRainbow(), back1)); conns.add(result.new ConnectionBackSimple(incoming1.getRainbow(), result.back1));
} else { } else {
final TextBlock back2 = incoming2.getDisplay().create(fontArrow, HorizontalAlignment.LEFT, final TextBlock back2 = incoming2.getDisplay().create(fontArrow, HorizontalAlignment.LEFT,
ftileFactory.skinParam()); ftileFactory.skinParam());
conns.add(result.new ConnectionBackBackward1(incoming1.getRainbow(), back1)); conns.add(result.new ConnectionBackBackward1(incoming1.getRainbow(), result.back1));
conns.add(result.new ConnectionBackBackward2(incoming2.getRainbow(), back2)); conns.add(result.new ConnectionBackBackward2(incoming2.getRainbow(), back2));
} }
} }
@ -257,7 +258,7 @@ class FtileWhile extends AbstractFtile {
final double y2 = p2.getY() + dimDiamond1.getInY() + half; final double y2 = p2.getY() + dimDiamond1.getInY() + half;
final Snake snake = Snake.create(skinParam(), endInlinkColor, skinParam().arrows().asToLeft()) final Snake snake = Snake.create(skinParam(), endInlinkColor, skinParam().arrows().asToLeft())
.emphasizeDirection(Direction.UP).withLabel(back, arrowHorizontalAlignment()); .emphasizeDirection(Direction.UP).withLabel(back, VerticalAlignment.BOTTOM);
snake.addPoint(x1, y1); snake.addPoint(x1, y1);
final double y1bis = Math.max(y1, getBottom(stringBounder)) + Hexagon.hexagonHalfSize; final double y1bis = Math.max(y1, getBottom(stringBounder)) + Hexagon.hexagonHalfSize;
snake.addPoint(x1, y1bis); snake.addPoint(x1, y1bis);
@ -350,7 +351,7 @@ class FtileWhile extends AbstractFtile {
final double y2 = p2.getY(); final double y2 = p2.getY();
final Snake snake = Snake.create(skinParam(), endInlinkColor, skinParam().arrows().asToUp()).withLabel(back, final Snake snake = Snake.create(skinParam(), endInlinkColor, skinParam().arrows().asToUp()).withLabel(back,
arrowHorizontalAlignment()); VerticalAlignment.BOTTOM);
snake.addPoint(x1, y1); snake.addPoint(x1, y1);
final double y1bis = Math.max(y1, getBottom(stringBounder)) + Hexagon.hexagonHalfSize; final double y1bis = Math.max(y1, getBottom(stringBounder)) + Hexagon.hexagonHalfSize;
snake.addPoint(x1, y1bis); snake.addPoint(x1, y1bis);
@ -580,7 +581,7 @@ class FtileWhile extends AbstractFtile {
assert false; assert false;
} }
final FtileGeometry geo = geoDiamond1.appendBottom(geoWhile); final FtileGeometry geo = geoDiamond1.appendBottom(geoWhile);
final double height = geo.getHeight() + 4 * Hexagon.hexagonHalfSize; final double height = geo.getHeight() + 4 * Hexagon.hexagonHalfSize + getSuppHeightForLabel(stringBounder);
final double dx = 2 * Hexagon.hexagonHalfSize; final double dx = 2 * Hexagon.hexagonHalfSize;
double backwardWidth = 0; double backwardWidth = 0;
if (backward != null) if (backward != null)
@ -592,6 +593,12 @@ class FtileWhile extends AbstractFtile {
} }
private double getSuppHeightForLabel(StringBounder stringBounder) {
if (back1 != null)
return back1.calculateDimension(stringBounder).getHeight();
return 0;
}
private double xDeltaBecauseSpecial(StringBounder stringBounder) { private double xDeltaBecauseSpecial(StringBounder stringBounder) {
if (specialOut == null) if (specialOut == null)
return 0; return 0;
@ -616,8 +623,8 @@ class FtileWhile extends AbstractFtile {
final FtileGeometry dimTotal = calculateDimension(stringBounder); final FtileGeometry dimTotal = calculateDimension(stringBounder);
final FtileGeometry dimWhile = whileBlock.calculateDimension(stringBounder); final FtileGeometry dimWhile = whileBlock.calculateDimension(stringBounder);
final double y = dimDiamond1.getHeight() final double y = dimDiamond1.getHeight() + (dimTotal.getHeight() - dimDiamond1.getHeight()
+ (dimTotal.getHeight() - dimDiamond1.getHeight() - dimWhile.getHeight()) / 2; - dimWhile.getHeight() - getSuppHeightForLabel(stringBounder)) / 2;
final double x = dimTotal.getLeft() - dimWhile.getLeft(); final double x = dimTotal.getLeft() - dimWhile.getLeft();
return new UTranslate(x, y); return new UTranslate(x, y);

View File

@ -48,16 +48,12 @@ class GraphvizLinux extends AbstractGraphviz {
@Override @Override
protected File specificDotExe() { protected File specificDotExe() {
final File usrLocalBinDot = new File("/usr/local/bin/dot"); final File all[] = new File[] { new File("/usr/local/bin/dot"), new File("/usr/bin/dot"),
if (usrLocalBinDot.exists()) { new File("/opt/homebrew/bin/dot") };
return usrLocalBinDot; for (File f : all)
} if (f.exists())
final File usrBinDot = new File("/usr/bin/dot"); return f;
if (usrBinDot.exists()) { return new File("/opt/local/bin/dot");
return usrBinDot;
}
final File optLocalBinDot = new File("/opt/local/bin/dot");
return optLocalBinDot;
} }
@Override @Override

View File

@ -147,6 +147,8 @@ public class PSystemRegex extends TitledDiagram {
} }
public CommandExecutionResult addBlocLines(BlocLines from) { public CommandExecutionResult addBlocLines(BlocLines from) {
try {
final CharInspector it = from.inspector(); final CharInspector it = from.inspector();
final List<ReToken> parsed1 = RegexExpression.parse(it); final List<ReToken> parsed1 = RegexExpression.parse(it);
// System.err.println("parsed1=" + parsed1); // System.err.println("parsed1=" + parsed1);
@ -179,7 +181,10 @@ public class PSystemRegex extends TitledDiagram {
else if (token.getType() == ReTokenType.QUANTIFIER && token.getData().startsWith("{")) else if (token.getType() == ReTokenType.QUANTIFIER && token.getData().startsWith("{"))
repetitionOneOrMore(token.getData()); repetitionOneOrMore(token.getData());
else else
throw new UnsupportedOperationException(token.toString()); throw new RegexParsingException(token.toString());
} catch (RegexParsingException ex) {
return CommandExecutionResult.error("Error parsing: " + ex.getMessage());
}
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }

View File

@ -43,7 +43,7 @@ import net.sourceforge.plantuml.utils.CharInspector;
public class RegexExpression { public class RegexExpression {
// ::remove folder when __HAXE__ // ::remove folder when __HAXE__
public static List<ReToken> parse(CharInspector it) { public static List<ReToken> parse(CharInspector it) throws RegexParsingException {
final List<ReToken> result = new ArrayList<>(); final List<ReToken> result = new ArrayList<>();
while (true) { while (true) {
final char current = it.peek(0); final char current = it.peek(0);
@ -72,6 +72,15 @@ public class RegexExpression {
} else if (isStartQuantifier(it)) { } else if (isStartQuantifier(it)) {
final String s = readQuantifier(it); final String s = readQuantifier(it);
result.add(new ReToken(ReTokenType.QUANTIFIER, s)); result.add(new ReToken(ReTokenType.QUANTIFIER, s));
} else if (isStartOctalEscape(it)) {
final String s = readUnicodeOrOctalEscape(it, 4);
result.add(new ReToken(ReTokenType.CLASS, s));
} else if (isStartUnicodeEscape(it)) {
final String s = readUnicodeOrOctalEscape(it, 5);
result.add(new ReToken(ReTokenType.CLASS, s));
} else if (isStartUnicodeClass(it)) {
final String s = readUnicodeClass(it);
result.add(new ReToken(ReTokenType.CLASS, s));
} else if (isStartClass(it)) { } else if (isStartClass(it)) {
final String s = readClass(it); final String s = readClass(it);
result.add(new ReToken(ReTokenType.CLASS, s)); result.add(new ReToken(ReTokenType.CLASS, s));
@ -119,24 +128,28 @@ public class RegexExpression {
return false; return false;
} }
private static String readQuantifier(CharInspector it) { private static String readQuantifier(CharInspector it) throws RegexParsingException {
final char current0 = it.peek(0); final char current0 = it.peek(0);
it.jump(); it.jump();
final StringBuilder result = new StringBuilder(); final StringBuilder tmp = new StringBuilder();
result.append(current0); tmp.append(current0);
if (current0 == '{') if (current0 == '{')
while (it.peek(0) != 0) { while (it.peek(0) != 0) {
final char ch = it.peek(0); final char ch = it.peek(0);
result.append(ch); tmp.append(ch);
it.jump(); it.jump();
if (ch == '}') if (ch == '}')
break; break;
} }
if (it.peek(0) == '?') { if (it.peek(0) == '?') {
result.append('?'); tmp.append('?');
it.jump(); it.jump();
} }
return result.toString(); // System.err.println("RESULT=" + tmp);
final String result = tmp.toString();
if (result.startsWith("{") && result.matches("^\\{[0-9,]+\\}$") == false)
throw new RegexParsingException("Bad quantifier " + result);
return result;
} }
private static boolean isEscapedChar(CharInspector it) { private static boolean isEscapedChar(CharInspector it) {
@ -173,6 +186,40 @@ public class RegexExpression {
return result.toString(); return result.toString();
} }
private static String readUnicodeClass(CharInspector it) throws RegexParsingException {
final char current0 = it.peek(0);
if (current0 != '\\')
throw new IllegalStateException();
it.jump();
final StringBuilder result = new StringBuilder();
result.append(current0);
while (it.peek(0) != 0) {
final char ch = it.peek(0);
it.jump();
result.append(ch);
if (ch == '}')
return result.toString();
}
throw new RegexParsingException("Unexpected end of data");
}
private static String readUnicodeOrOctalEscape(CharInspector it, int nb) throws RegexParsingException {
final char current0 = it.peek(0);
if (current0 != '\\')
throw new IllegalStateException();
it.jump();
final StringBuilder result = new StringBuilder();
result.append(current0);
for (int i = 0; i < nb; i++) {
final char ch = it.peek(0);
if (ch == 0)
throw new RegexParsingException("Unexpected end of data");
result.append(ch);
it.jump();
}
return result.toString();
}
private static String readClass(CharInspector it) { private static String readClass(CharInspector it) {
final char current0 = it.peek(0); final char current0 = it.peek(0);
if (current0 == '.') { if (current0 == '.') {
@ -197,6 +244,26 @@ public class RegexExpression {
return false; return false;
} }
private static boolean isStartUnicodeClass(CharInspector it) {
if (it.peek(0) == '\\' && it.peek(1) == 'p' && it.peek(2) == '{')
return true;
if (it.peek(0) == '\\' && it.peek(1) == 'x' && it.peek(2) == '{')
return true;
return false;
}
private static boolean isStartUnicodeEscape(CharInspector it) {
if (it.peek(0) == '\\' && it.peek(1) == 'u')
return true;
return false;
}
private static boolean isStartOctalEscape(CharInspector it) {
if (it.peek(0) == '\\' && it.peek(1) == '0')
return true;
return false;
}
private static boolean isSimpleLetter(char ch) { private static boolean isSimpleLetter(char ch) {
if (ch == '\\' || ch == '.') if (ch == '\\' || ch == '.')
return false; return false;

View File

@ -0,0 +1,44 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2024, Arnaud Roques
*
* Project Info: https://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* https://plantuml.com/patreon (only 1$ per month!)
* https://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.regexdiagram;
public class RegexParsingException extends Exception {
public RegexParsingException(String msg) {
super(msg);
}
}

View File

@ -46,7 +46,7 @@ public class Version {
// Warning, "version" should be the same in gradle.properties and Version.java // Warning, "version" should be the same in gradle.properties and Version.java
// Any idea anyone how to magically synchronize those :-) ? // Any idea anyone how to magically synchronize those :-) ?
private static final String version = "1.2023.8beta2"; private static final String version = "1.2023.8";
public static String versionString() { public static String versionString() {
return version; return version;
@ -80,7 +80,7 @@ public class Version {
} }
public static long compileTime() { public static long compileTime() {
return 1683912222767L; return 1684658280620L;
} }
public static String compileTimeString() { public static String compileTimeString() {