mirror of https://github.com/octoleo/plantuml.git
Import version 1.2021.10
This commit is contained in:
parent
550ff078a8
commit
9238bacd65
12
pom.xml
12
pom.xml
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
<groupId>net.sourceforge.plantuml</groupId>
|
<groupId>net.sourceforge.plantuml</groupId>
|
||||||
<artifactId>plantuml</artifactId>
|
<artifactId>plantuml</artifactId>
|
||||||
<version>1.2021.9-SNAPSHOT</version>
|
<version>1.2021.11-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>PlantUML</name>
|
<name>PlantUML</name>
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit</groupId>
|
<groupId>org.junit</groupId>
|
||||||
<artifactId>junit-bom</artifactId>
|
<artifactId>junit-bom</artifactId>
|
||||||
<version>5.7.2</version>
|
<version>5.7.1</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -74,13 +74,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.ant</groupId>
|
<groupId>org.apache.ant</groupId>
|
||||||
<artifactId>ant</artifactId>
|
<artifactId>ant</artifactId>
|
||||||
<version>1.10.11</version>
|
<version>1.10.9</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.assertj</groupId>
|
<groupId>org.assertj</groupId>
|
||||||
<artifactId>assertj-core</artifactId>
|
<artifactId>assertj-core</artifactId>
|
||||||
<version>3.20.2</version>
|
<version>3.19.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -163,7 +163,7 @@
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.1.2</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
@ -179,7 +179,7 @@
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.2.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>attach-javadocs</id>
|
<id>attach-javadocs</id>
|
||||||
|
|
|
@ -348,3 +348,12 @@ jsonDiagram {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
timingDiagram {
|
||||||
|
arrow {
|
||||||
|
LineThickness 1.5
|
||||||
|
}
|
||||||
|
constraintArrow {
|
||||||
|
LineThickness 1.5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.core.Diagram;
|
import net.sourceforge.plantuml.core.Diagram;
|
||||||
|
@ -119,7 +120,7 @@ public class EmbeddedDiagram implements CharSequence {
|
||||||
private final ISkinSimple skinParam;
|
private final ISkinSimple skinParam;
|
||||||
|
|
||||||
public List<Atom> splitInTwo(StringBounder stringBounder, double width) {
|
public List<Atom> splitInTwo(StringBounder stringBounder, double width) {
|
||||||
throw new UnsupportedOperationException(getClass().toString());
|
return Arrays.asList((Atom) this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Draw(ISkinSimple skinParam) {
|
private Draw(ISkinSimple skinParam) {
|
||||||
|
|
|
@ -81,6 +81,9 @@ public enum UmlDiagramType {
|
||||||
if (this == JSON) {
|
if (this == JSON) {
|
||||||
return SName.jsonDiagram;
|
return SName.jsonDiagram;
|
||||||
}
|
}
|
||||||
|
if (this == TIMING) {
|
||||||
|
return SName.timingDiagram;
|
||||||
|
}
|
||||||
return SName.activityDiagram;
|
return SName.activityDiagram;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ import java.awt.geom.Point2D;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.Direction;
|
||||||
import net.sourceforge.plantuml.activitydiagram3.Branch;
|
import net.sourceforge.plantuml.activitydiagram3.Branch;
|
||||||
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
|
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
|
||||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
|
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
|
||||||
|
@ -135,15 +136,19 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds {
|
||||||
final Point2D ptD = getTranslateDiamond2(stringBounder).getTranslated(dimDiamond2.getPointD());
|
final Point2D ptD = getTranslateDiamond2(stringBounder).getTranslated(dimDiamond2.getPointD());
|
||||||
final Point2D p2;
|
final Point2D p2;
|
||||||
final UPolygon arrow;
|
final UPolygon arrow;
|
||||||
|
final Direction direction;
|
||||||
if (x1 < ptD.getX()) {
|
if (x1 < ptD.getX()) {
|
||||||
p2 = ptD;
|
p2 = ptD;
|
||||||
arrow = Arrows.asToRight();
|
arrow = Arrows.asToRight();
|
||||||
|
direction = Direction.RIGHT;
|
||||||
} else if (x1 > ptB.getX()) {
|
} else if (x1 > ptB.getX()) {
|
||||||
p2 = ptB;
|
p2 = ptB;
|
||||||
arrow = Arrows.asToLeft();
|
arrow = Arrows.asToLeft();
|
||||||
|
direction = Direction.LEFT;
|
||||||
} else {
|
} else {
|
||||||
p2 = ptA;
|
p2 = ptA;
|
||||||
arrow = Arrows.asToDown();
|
arrow = Arrows.asToDown();
|
||||||
|
direction = Direction.DOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
final double x2 = p2.getX();
|
final double x2 = p2.getX();
|
||||||
|
@ -151,9 +156,14 @@ public class FtileSwitchWithManyLinks extends FtileSwitchWithDiamonds {
|
||||||
|
|
||||||
final Snake snake = Snake.create(arrowColor, arrow);
|
final Snake snake = Snake.create(arrowColor, arrow);
|
||||||
snake.addPoint(x1, y1);
|
snake.addPoint(x1, y1);
|
||||||
snake.addPoint(x1, y2);
|
if (direction == Direction.LEFT && x2 > x1 - 10) {
|
||||||
|
snake.addPoint(x1, y2 - 8);
|
||||||
|
snake.addPoint(x1 + 12, y2 - 8);
|
||||||
|
snake.addPoint(x1 + 12, y2);
|
||||||
|
} else {
|
||||||
|
snake.addPoint(x1, y2);
|
||||||
|
}
|
||||||
snake.addPoint(x2, y2);
|
snake.addPoint(x2, y2);
|
||||||
|
|
||||||
ug.draw(snake);
|
ug.draw(snake);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,12 @@ public abstract class RegexComposed implements IRegex {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean match(StringLocated s) {
|
public boolean match(StringLocated s) {
|
||||||
return getPattern2().matcher(s.getString()).find();
|
final String tmp = s.getString();
|
||||||
|
final Matcher2 matcher = getPattern2().matcher(tmp);
|
||||||
|
if (matcher == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return matcher.find();
|
||||||
}
|
}
|
||||||
|
|
||||||
final public String getPattern() {
|
final public String getPattern() {
|
||||||
|
|
|
@ -46,6 +46,7 @@ public final class RegexConcat extends RegexComposed implements IRegex {
|
||||||
|
|
||||||
private static final ConcurrentMap<Object, RegexConcat> cache = new ConcurrentHashMap<Object, RegexConcat>();
|
private static final ConcurrentMap<Object, RegexConcat> cache = new ConcurrentHashMap<Object, RegexConcat>();
|
||||||
private final AtomicLong foxRegex = new AtomicLong(-1L);
|
private final AtomicLong foxRegex = new AtomicLong(-1L);
|
||||||
|
private int limitSize;
|
||||||
|
|
||||||
// private static final Set<String> PRINTED2 = new HashSet<>();
|
// private static final Set<String> PRINTED2 = new HashSet<>();
|
||||||
|
|
||||||
|
@ -93,7 +94,8 @@ public final class RegexConcat extends RegexComposed implements IRegex {
|
||||||
// } else {
|
// } else {
|
||||||
// synchronized (PRINTED2) {
|
// synchronized (PRINTED2) {
|
||||||
// if (PRINTED2.contains(key) == false) {
|
// if (PRINTED2.contains(key) == false) {
|
||||||
// System.err.println("if (key.equals(\"" + key + "\")) return buildInternal(partials);");
|
// System.err.println("if (key.equals(\"" + key + "\")) return
|
||||||
|
// buildInternal(partials);");
|
||||||
// }
|
// }
|
||||||
// PRINTED2.add(key);
|
// PRINTED2.add(key);
|
||||||
}
|
}
|
||||||
|
@ -113,11 +115,15 @@ public final class RegexConcat extends RegexComposed implements IRegex {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(StringLocated s) {
|
public boolean match(StringLocated s) {
|
||||||
|
if (limitSize != 0 && s.getString().length() > limitSize) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
final long foxRegex = foxRegex();
|
final long foxRegex = foxRegex();
|
||||||
if (foxRegex != 0L) {
|
if (foxRegex != 0L) {
|
||||||
final long foxLine = s.getFoxSignature();
|
final long foxLine = s.getFoxSignature();
|
||||||
final long check = foxRegex & foxLine;
|
final long check = foxRegex & foxLine;
|
||||||
// System.err.println("r=" + getFullSlow() + " s=" + s + " line=" + foxLine + " regex" + foxRegex + " "
|
// System.err.println("r=" + getFullSlow() + " s=" + s + " line=" + foxLine + "
|
||||||
|
// regex" + foxRegex + " "
|
||||||
// + check + " <" + FoxSignature.backToString(check) + ">");
|
// + check + " <" + FoxSignature.backToString(check) + ">");
|
||||||
if (check != foxRegex) {
|
if (check != foxRegex) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -136,4 +142,9 @@ public final class RegexConcat extends RegexComposed implements IRegex {
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RegexConcat protectSize(int size) {
|
||||||
|
limitSize = size;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,7 @@ public class BodierLikeClassOrObject implements Bodier {
|
||||||
if (fieldsToDisplay == null) {
|
if (fieldsToDisplay == null) {
|
||||||
fieldsToDisplay = new ArrayList<>();
|
fieldsToDisplay = new ArrayList<>();
|
||||||
for (CharSequence s : rawBody) {
|
for (CharSequence s : rawBody) {
|
||||||
if (isMethod(s) == true) {
|
if (type != LeafType.OBJECT && isMethod(s) == true) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (s.length() == 0 && fieldsToDisplay.size() == 0) {
|
if (s.length() == 0 && fieldsToDisplay.size() == 0) {
|
||||||
|
|
|
@ -276,10 +276,14 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlock,
|
||||||
group = new ULayoutGroup(
|
group = new ULayoutGroup(
|
||||||
new PlacementStrategyVisibility(stringBounder, skinParam.getCircledCharacterRadius() + 3));
|
new PlacementStrategyVisibility(stringBounder, skinParam.getCircledCharacterRadius() + 3));
|
||||||
for (CharSequence cs : members) {
|
for (CharSequence cs : members) {
|
||||||
final Member att = (Member) cs;
|
final TextBlock bloc = createTextBlock(cs);
|
||||||
final TextBlock bloc = createTextBlock(att);
|
if (cs instanceof EmbeddedDiagram) {
|
||||||
final VisibilityModifier modifier = att.getVisibilityModifier();
|
group.add(getUBlock(null, null));
|
||||||
group.add(getUBlock(modifier, att.getUrl()));
|
} else {
|
||||||
|
final Member att = (Member) cs;
|
||||||
|
final VisibilityModifier modifier = att.getVisibilityModifier();
|
||||||
|
group.add(getUBlock(modifier, att.getUrl()));
|
||||||
|
}
|
||||||
group.add(bloc);
|
group.add(bloc);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -43,6 +43,7 @@ import java.util.StringTokenizer;
|
||||||
import net.sourceforge.plantuml.ThemeStyle;
|
import net.sourceforge.plantuml.ThemeStyle;
|
||||||
import net.sourceforge.plantuml.graphic.color.ColorType;
|
import net.sourceforge.plantuml.graphic.color.ColorType;
|
||||||
import net.sourceforge.plantuml.graphic.color.Colors;
|
import net.sourceforge.plantuml.graphic.color.Colors;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||||
import net.sourceforge.plantuml.ugraphic.color.HColorSet;
|
import net.sourceforge.plantuml.ugraphic.color.HColorSet;
|
||||||
|
|
||||||
|
@ -158,4 +159,8 @@ public abstract class WithLinkType {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UStroke getUStroke() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,8 @@ final public class EntityImpl implements ILeaf, IGroup {
|
||||||
|
|
||||||
EntityImpl(Ident ident, Code code, EntityFactory entityFactory, Bodier bodier, IGroup parentContainer,
|
EntityImpl(Ident ident, Code code, EntityFactory entityFactory, Bodier bodier, IGroup parentContainer,
|
||||||
LeafType leafType, String namespaceSeparator, int rawLayout) {
|
LeafType leafType, String namespaceSeparator, int rawLayout) {
|
||||||
this(Objects.requireNonNull(ident), entityFactory, code, bodier, parentContainer, namespaceSeparator, rawLayout);
|
this(Objects.requireNonNull(ident), entityFactory, code, bodier, parentContainer, namespaceSeparator,
|
||||||
|
rawLayout);
|
||||||
// System.err.println("ID for leaf=" + code + " " + ident);
|
// System.err.println("ID for leaf=" + code + " " + ident);
|
||||||
// ident.checkSameAs(code, namespaceSeparator);
|
// ident.checkSameAs(code, namespaceSeparator);
|
||||||
this.leafType = leafType;
|
this.leafType = leafType;
|
||||||
|
@ -163,7 +164,8 @@ final public class EntityImpl implements ILeaf, IGroup {
|
||||||
|
|
||||||
EntityImpl(Ident ident, Code code, EntityFactory entityFactory, Bodier bodier, IGroup parentContainer,
|
EntityImpl(Ident ident, Code code, EntityFactory entityFactory, Bodier bodier, IGroup parentContainer,
|
||||||
GroupType groupType, Code namespace, String namespaceSeparator, int rawLayout) {
|
GroupType groupType, Code namespace, String namespaceSeparator, int rawLayout) {
|
||||||
this(Objects.requireNonNull(ident), entityFactory, code, bodier, parentContainer, namespaceSeparator, rawLayout);
|
this(Objects.requireNonNull(ident), entityFactory, code, bodier, parentContainer, namespaceSeparator,
|
||||||
|
rawLayout);
|
||||||
// System.err.println("ID for group=" + code + " " + ident);
|
// System.err.println("ID for group=" + code + " " + ident);
|
||||||
ident.checkSameAs(code, namespaceSeparator, entityFactory.namespaceSeparator);
|
ident.checkSameAs(code, namespaceSeparator, entityFactory.namespaceSeparator);
|
||||||
this.groupType = groupType;
|
this.groupType = groupType;
|
||||||
|
@ -630,7 +632,7 @@ final public class EntityImpl implements ILeaf, IGroup {
|
||||||
if (entityFactory.isRemoved(this)) {
|
if (entityFactory.isRemoved(this)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (getLeafsDirect().size() == 0) {
|
if (getLeafsDirect().size() == 0 && getChildren().size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (ILeaf leaf : getLeafsDirect()) {
|
for (ILeaf leaf : getLeafsDirect()) {
|
||||||
|
|
|
@ -298,7 +298,14 @@ public class QuoteUtils {
|
||||||
"Jnxr zr hc orsber lbh tb-tb",
|
"Jnxr zr hc orsber lbh tb-tb",
|
||||||
"Fbzrguvat vf ebggra va gur fgngr bs Qraznex! Naq, Unzyrg vf gnxvat bhg gur genfu!",
|
"Fbzrguvat vf ebggra va gur fgngr bs Qraznex! Naq, Unzyrg vf gnxvat bhg gur genfu!",
|
||||||
"Bu bhv, cneybaf-ra qrf pbcnvaf, cbhe sbhger yn zreqr vyf fbag punzcvbaf", "Gjb qnlf gb ergverzrag!",
|
"Bu bhv, cneybaf-ra qrf pbcnvaf, cbhe sbhger yn zreqr vyf fbag punzcvbaf", "Gjb qnlf gb ergverzrag!",
|
||||||
"Gh nf qrf qbvtgf ? Pebvfrf-ra ha znk g'nf vagrerg !");
|
"Gh nf qrf qbvtgf ? Pebvfrf-ra ha znk g'nf vagrerg !",
|
||||||
|
"Ba rfg syhrag ra Senatynvf dhnaq ba pbzceraq cyhf gebc pr dh'ba enpbagr.",
|
||||||
|
"N jvmneq vf arire yngr, abe vf ur rneyl, ur neevirf cerpvfryl jura ur zrnaf gb.",
|
||||||
|
"Lbh jnag gb tb ubzr naq erguvax lbhe yvsr", "V'z trggva gbb byq sbe guvf fuvg",
|
||||||
|
"Vg'f n jryy xabja snpg gung n tybony pbafcvenpl jbhyq or ng gur bevtva bs znal snxr pbafcvenpl gurbevrf",
|
||||||
|
"Gh nhenvf ienvzrag qh pubvfve ha nhger zrgvre.",
|
||||||
|
"...rg qrf srfgvaf qr ebv fhe yr mvap q'ha ohssrg qr tner",
|
||||||
|
"Obevf, V guvax lbh'er tbaan arrq n ovttre ohf");
|
||||||
|
|
||||||
private QuoteUtils() {
|
private QuoteUtils() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ import h.ST_splines;
|
||||||
import net.sourceforge.plantuml.ugraphic.UEllipse;
|
import net.sourceforge.plantuml.ugraphic.UEllipse;
|
||||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
import net.sourceforge.plantuml.ugraphic.UPath;
|
import net.sourceforge.plantuml.ugraphic.UPath;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ public class JsonCurve {
|
||||||
public void drawSpot(UGraphic ug) {
|
public void drawSpot(UGraphic ug) {
|
||||||
final double size = 3;
|
final double size = 3;
|
||||||
ug = ug.apply(new UTranslate(getVeryFirst()).compose(new UTranslate(-size, -size)));
|
ug = ug.apply(new UTranslate(getVeryFirst()).compose(new UTranslate(-size, -size)));
|
||||||
ug.draw(new UEllipse(2 * size, 2 * size));
|
ug.apply(new UStroke()).draw(new UEllipse(2 * size, 2 * size));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Point2D getVeryFirst() {
|
private Point2D getVeryFirst() {
|
||||||
|
|
|
@ -43,7 +43,6 @@ import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -64,10 +63,12 @@ import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||||
import net.sourceforge.plantuml.nwdiag.legacy.GridTextBlockDecorated;
|
import net.sourceforge.plantuml.nwdiag.core.NServer;
|
||||||
import net.sourceforge.plantuml.nwdiag.legacy.NServerLegacy;
|
import net.sourceforge.plantuml.nwdiag.core.Network;
|
||||||
import net.sourceforge.plantuml.nwdiag.legacy.NetworkLegacy;
|
import net.sourceforge.plantuml.nwdiag.core.NwGroup;
|
||||||
import net.sourceforge.plantuml.nwdiag.legacy.NwGroupLegacy;
|
import net.sourceforge.plantuml.nwdiag.next.GridTextBlockDecoratedNext;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.next.LinkedElementNext;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.next.NBar;
|
||||||
import net.sourceforge.plantuml.nwdiag.next.NPlayField;
|
import net.sourceforge.plantuml.nwdiag.next.NPlayField;
|
||||||
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
|
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
|
||||||
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
|
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
|
||||||
|
@ -82,10 +83,10 @@ import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
||||||
public class NwDiagram extends UmlDiagram {
|
public class NwDiagram extends UmlDiagram {
|
||||||
|
|
||||||
private boolean initDone;
|
private boolean initDone;
|
||||||
private final Map<String, NServerLegacy> servers = new LinkedHashMap<String, NServerLegacy>();
|
private final Map<String, NServer> servers = new LinkedHashMap<>();
|
||||||
private final List<NetworkLegacy> networks = new ArrayList<>();
|
private final List<Network> networks = new ArrayList<>();
|
||||||
private final List<NwGroupLegacy> groups = new ArrayList<>();
|
private final List<NwGroup> groups = new ArrayList<>();
|
||||||
private NwGroupLegacy currentGroup = null;
|
private NwGroup currentGroup = null;
|
||||||
|
|
||||||
private final NPlayField playField = new NPlayField();
|
private final NPlayField playField = new NPlayField();
|
||||||
|
|
||||||
|
@ -101,7 +102,7 @@ public class NwDiagram extends UmlDiagram {
|
||||||
initDone = true;
|
initDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private NetworkLegacy currentNetwork() {
|
private Network currentNetwork() {
|
||||||
if (networks.size() == 0) {
|
if (networks.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +113,7 @@ public class NwDiagram extends UmlDiagram {
|
||||||
if (initDone == false) {
|
if (initDone == false) {
|
||||||
return errorNoInit();
|
return errorNoInit();
|
||||||
}
|
}
|
||||||
currentGroup = new NwGroupLegacy(name, currentNetwork());
|
currentGroup = new NwGroup(name, currentNetwork());
|
||||||
groups.add(currentGroup);
|
groups.add(currentGroup);
|
||||||
return CommandExecutionResult.ok();
|
return CommandExecutionResult.ok();
|
||||||
}
|
}
|
||||||
|
@ -125,8 +126,8 @@ public class NwDiagram extends UmlDiagram {
|
||||||
return CommandExecutionResult.ok();
|
return CommandExecutionResult.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
private NetworkLegacy createNetwork(String name) {
|
private Network createNetwork(String name) {
|
||||||
final NetworkLegacy network = new NetworkLegacy(playField.createNewStage(), name, networks.size());
|
final Network network = new Network(playField.getLast(), playField.createNewStage(), name, networks.size());
|
||||||
networks.add(network);
|
networks.add(network);
|
||||||
return network;
|
return network;
|
||||||
}
|
}
|
||||||
|
@ -135,29 +136,26 @@ public class NwDiagram extends UmlDiagram {
|
||||||
if (initDone == false) {
|
if (initDone == false) {
|
||||||
return errorNoInit();
|
return errorNoInit();
|
||||||
}
|
}
|
||||||
final NServerLegacy element;
|
final NServer element;
|
||||||
if (currentNetwork() == null) {
|
if (currentNetwork() == null) {
|
||||||
createNetwork(name1);
|
createNetwork(name1);
|
||||||
element = new NServerLegacy(name2, currentNetwork(), this.getSkinParam());
|
element = new NServer(name2, currentNetwork(), this.getSkinParam());
|
||||||
} else {
|
} else {
|
||||||
final NServerLegacy already = servers.get(name1);
|
final NServer already = servers.get(name1);
|
||||||
final NetworkLegacy network1 = createNetwork("");
|
final Network network1 = createNetwork("");
|
||||||
network1.goInvisible();
|
network1.goInvisible();
|
||||||
if (already != null) {
|
if (already != null) {
|
||||||
currentNetwork().addServer(already, toSet(null));
|
connect(already, toSet(null));
|
||||||
already.connect(currentNetwork(), toSet(null));
|
|
||||||
}
|
}
|
||||||
element = new NServerLegacy(name2, currentNetwork(), this.getSkinParam());
|
element = new NServer(name2, currentNetwork(), this.getSkinParam());
|
||||||
element.sameColThan(already);
|
|
||||||
}
|
}
|
||||||
servers.put(name2, element);
|
servers.put(name2, element);
|
||||||
addInternal(element, toSet(null));
|
addInternal(element, toSet(null));
|
||||||
return CommandExecutionResult.ok();
|
return CommandExecutionResult.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addInternal(NServerLegacy server, Map<String, String> props) {
|
private void addInternal(NServer server, Map<String, String> props) {
|
||||||
currentNetwork().addServer(Objects.requireNonNull(server), props);
|
connect(server, props);
|
||||||
server.connect(currentNetwork(), props);
|
|
||||||
final String description = props.get("description");
|
final String description = props.get("description");
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
server.setDescription(description);
|
server.setDescription(description);
|
||||||
|
@ -166,6 +164,11 @@ public class NwDiagram extends UmlDiagram {
|
||||||
if (shape != null) {
|
if (shape != null) {
|
||||||
server.setShape(shape);
|
server.setShape(shape);
|
||||||
}
|
}
|
||||||
|
playField.addInPlayfield(server.getBar());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void connect(NServer server, final Map<String, String> props) {
|
||||||
|
server.connect(currentNetwork(), props);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult addElement(String name, String definition) {
|
public CommandExecutionResult addElement(String name, String definition) {
|
||||||
|
@ -175,21 +178,21 @@ public class NwDiagram extends UmlDiagram {
|
||||||
if (currentGroup != null) {
|
if (currentGroup != null) {
|
||||||
currentGroup.addName(name);
|
currentGroup.addName(name);
|
||||||
}
|
}
|
||||||
NServerLegacy server = null;
|
NServer server = null;
|
||||||
if (currentNetwork() == null) {
|
if (currentNetwork() == null) {
|
||||||
if (currentGroup != null) {
|
if (currentGroup != null) {
|
||||||
return CommandExecutionResult.ok();
|
return CommandExecutionResult.ok();
|
||||||
}
|
}
|
||||||
assert currentGroup == null;
|
assert currentGroup == null;
|
||||||
final NetworkLegacy network1 = createNetwork("");
|
final Network network1 = createNetwork("");
|
||||||
network1.goInvisible();
|
network1.goInvisible();
|
||||||
server = new NServerLegacy(name, currentNetwork(), this.getSkinParam());
|
server = new NServer(name, currentNetwork(), this.getSkinParam());
|
||||||
servers.put(name, server);
|
servers.put(name, server);
|
||||||
server.doNotHaveItsOwnColumn();
|
server.doNotHaveItsOwnColumn();
|
||||||
} else {
|
} else {
|
||||||
server = servers.get(name);
|
server = servers.get(name);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
server = new NServerLegacy(name, currentNetwork(), this.getSkinParam());
|
server = new NServer(name, currentNetwork(), this.getSkinParam());
|
||||||
servers.put(name, server);
|
servers.put(name, server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,25 +287,27 @@ public class NwDiagram extends UmlDiagram {
|
||||||
ug = ug.apply(new UTranslate(margin, margin));
|
ug = ug.apply(new UTranslate(margin, margin));
|
||||||
|
|
||||||
final StringBounder stringBounder = ug.getStringBounder();
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
final GridTextBlockDecorated grid = buildGrid();
|
|
||||||
|
|
||||||
double deltaX = 0;
|
double deltaX = 0;
|
||||||
double deltaY = 0;
|
double deltaY = 0;
|
||||||
|
|
||||||
|
final GridTextBlockDecoratedNext grid = buildGrid(stringBounder);
|
||||||
|
|
||||||
for (int i = 0; i < networks.size(); i++) {
|
for (int i = 0; i < networks.size(); i++) {
|
||||||
final NetworkLegacy current = networks.get(i);
|
final Network current = networks.get(i);
|
||||||
final String address = current.getOwnAdress();
|
final String address = current.getOwnAdress();
|
||||||
final TextBlock desc = toTextBlock(current.getName(), address);
|
final TextBlock desc = toTextBlock(current.getDisplayName(), address);
|
||||||
final Dimension2D dim = desc.calculateDimension(stringBounder);
|
final Dimension2D dim = desc.calculateDimension(stringBounder);
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
deltaY = (dim.getHeight() - GridTextBlockDecorated.NETWORK_THIN) / 2;
|
deltaY = (dim.getHeight() - GridTextBlockDecoratedNext.NETWORK_THIN) / 2;
|
||||||
}
|
}
|
||||||
deltaX = Math.max(deltaX, dim.getWidth());
|
deltaX = Math.max(deltaX, dim.getWidth());
|
||||||
}
|
}
|
||||||
double y = 0;
|
double y = 0;
|
||||||
for (int i = 0; i < networks.size(); i++) {
|
for (int i = 0; i < networks.size(); i++) {
|
||||||
final NetworkLegacy current = networks.get(i);
|
final Network current = networks.get(i);
|
||||||
final String address = current.getOwnAdress();
|
final String address = current.getOwnAdress();
|
||||||
final TextBlock desc = toTextBlock(current.getName(), address);
|
final TextBlock desc = toTextBlock(current.getDisplayName(), address);
|
||||||
final Dimension2D dim = desc.calculateDimension(stringBounder);
|
final Dimension2D dim = desc.calculateDimension(stringBounder);
|
||||||
desc.drawU(ug.apply(new UTranslate(deltaX - dim.getWidth(), y)));
|
desc.drawU(ug.apply(new UTranslate(deltaX - dim.getWidth(), y)));
|
||||||
|
|
||||||
|
@ -319,10 +324,10 @@ public class NwDiagram extends UmlDiagram {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<NetworkLegacy, String> getLinks(NServerLegacy element) {
|
private Map<Network, String> getLinks(NServer element) {
|
||||||
final Map<NetworkLegacy, String> result = new LinkedHashMap<NetworkLegacy, String>();
|
final Map<Network, String> result = new LinkedHashMap<>();
|
||||||
for (NetworkLegacy network : networks) {
|
for (Network network : networks) {
|
||||||
final String s = network.getAdress(element);
|
final String s = element.getAdress(network);
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
result.put(network, s);
|
result.put(network, s);
|
||||||
}
|
}
|
||||||
|
@ -330,36 +335,42 @@ public class NwDiagram extends UmlDiagram {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GridTextBlockDecorated buildGrid() {
|
private GridTextBlockDecoratedNext buildGrid(StringBounder stringBounder) {
|
||||||
final GridTextBlockDecorated grid = new GridTextBlockDecorated(networks.size(), servers.size(), groups,
|
|
||||||
|
playField.fixGroups(groups, servers.values());
|
||||||
|
|
||||||
|
final GridTextBlockDecoratedNext grid = new GridTextBlockDecoratedNext(networks.size(), servers.size(), groups,
|
||||||
networks, getSkinParam());
|
networks, getSkinParam());
|
||||||
|
|
||||||
|
final Map<NBar, Integer> layout = playField.doLayout();
|
||||||
for (int i = 0; i < networks.size(); i++) {
|
for (int i = 0; i < networks.size(); i++) {
|
||||||
final NetworkLegacy current = networks.get(i);
|
final Network current = networks.get(i);
|
||||||
int j = 0;
|
for (Map.Entry<String, NServer> ent : servers.entrySet()) {
|
||||||
for (Map.Entry<String, NServerLegacy> ent : servers.entrySet()) {
|
final NServer server = ent.getValue();
|
||||||
final NServerLegacy square = ent.getValue();
|
if (server.getMainNetworkNext() == current) {
|
||||||
if (square.getMainNetwork() == current) {
|
final Map<Network, String> conns = getLinks(server);
|
||||||
final Map<NetworkLegacy, String> conns = getLinks(square);
|
final int col = layout.get(server.getBar());
|
||||||
final NServerLegacy sameCol = square.getSameCol();
|
double topMargin = LinkedElementNext.MAGIC;
|
||||||
if (sameCol != null) {
|
NwGroup group = getGroupOf(server);
|
||||||
square.setNumCol(sameCol.getNumCol());
|
if (group != null)
|
||||||
} else {
|
topMargin += group.getTopHeaderHeight(stringBounder, getSkinParam());
|
||||||
square.setNumCol(j);
|
grid.add(i, col, server.asTextBlockNext(topMargin, conns, networks, getSkinParam()));
|
||||||
}
|
|
||||||
grid.add(i, square.getNumCol(), square.asTextBlock(conns, networks));
|
|
||||||
}
|
|
||||||
if (square.hasItsOwnColumn()) {
|
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
grid.checkGroups();
|
|
||||||
|
|
||||||
return grid;
|
return grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private NwGroup getGroupOf(NServer server) {
|
||||||
|
for (NwGroup group : groups) {
|
||||||
|
if (group.containsNext(server)) {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public CommandExecutionResult setProperty(String property, String value) {
|
public CommandExecutionResult setProperty(String property, String value) {
|
||||||
if (initDone == false) {
|
if (initDone == false) {
|
||||||
return errorNoInit();
|
return errorNoInit();
|
||||||
|
@ -372,7 +383,7 @@ public class NwDiagram extends UmlDiagram {
|
||||||
}
|
}
|
||||||
if ("color".equalsIgnoreCase(property)) {
|
if ("color".equalsIgnoreCase(property)) {
|
||||||
final HColor color = value == null ? null
|
final HColor color = value == null ? null
|
||||||
: NwGroupLegacy.colors.getColorOrWhite(getSkinParam().getThemeStyle(), value);
|
: NwGroup.colors.getColorOrWhite(getSkinParam().getThemeStyle(), value);
|
||||||
if (currentGroup != null) {
|
if (currentGroup != null) {
|
||||||
currentGroup.setColor(color);
|
currentGroup.setColor(color);
|
||||||
} else if (currentNetwork() != null) {
|
} else if (currentNetwork() != null) {
|
||||||
|
@ -380,7 +391,9 @@ public class NwDiagram extends UmlDiagram {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ("description".equalsIgnoreCase(property)) {
|
if ("description".equalsIgnoreCase(property)) {
|
||||||
if (currentGroup != null) {
|
if (currentGroup == null) {
|
||||||
|
currentNetwork().setDescription(value);
|
||||||
|
} else {
|
||||||
currentGroup.setDescription(value);
|
currentGroup.setDescription(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,403 @@
|
||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2020, Arnaud Roques
|
||||||
|
*
|
||||||
|
* Project Info: http://plantuml.com
|
||||||
|
*
|
||||||
|
* If you like this project or if you find it useful, you can support us at:
|
||||||
|
*
|
||||||
|
* http://plantuml.com/patreon (only 1$ per month!)
|
||||||
|
* http://plantuml.com/paypal
|
||||||
|
*
|
||||||
|
* This file is part of PlantUML.
|
||||||
|
*
|
||||||
|
* PlantUML is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* PlantUML distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Original Author: Arnaud Roques
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.nwdiag;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.awt.geom.Rectangle2D;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ColorParam;
|
||||||
|
import net.sourceforge.plantuml.FileFormatOption;
|
||||||
|
import net.sourceforge.plantuml.SpriteContainerEmpty;
|
||||||
|
import net.sourceforge.plantuml.UmlDiagram;
|
||||||
|
import net.sourceforge.plantuml.UmlDiagramType;
|
||||||
|
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||||
|
import net.sourceforge.plantuml.core.DiagramDescription;
|
||||||
|
import net.sourceforge.plantuml.core.ImageData;
|
||||||
|
import net.sourceforge.plantuml.core.UmlSource;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||||
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||||
|
import net.sourceforge.plantuml.graphic.InnerStrategy;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||||
|
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.core.NServer;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.core.Network;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.core.NwGroup;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.legacy.GridTextBlockDecorated;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.legacy.NServerLegacy;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.legacy.NetworkLegacy;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.legacy.NwGroupLegacy;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.next.NPlayField;
|
||||||
|
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
|
||||||
|
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UEmpty;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
||||||
|
|
||||||
|
public class NwDiagramLegacy extends UmlDiagram {
|
||||||
|
|
||||||
|
private boolean initDone;
|
||||||
|
private final Map<String, NServer> servers = new LinkedHashMap<>();
|
||||||
|
private final List<Network> networks = new ArrayList<>();
|
||||||
|
private final List<NwGroup> groups = new ArrayList<>();
|
||||||
|
private NwGroup currentGroup = null;
|
||||||
|
|
||||||
|
private final NPlayField playField = new NPlayField();
|
||||||
|
|
||||||
|
public DiagramDescription getDescription() {
|
||||||
|
return new DiagramDescription("(Nwdiag)");
|
||||||
|
}
|
||||||
|
|
||||||
|
public NwDiagramLegacy(UmlSource source) {
|
||||||
|
super(source, UmlDiagramType.NWDIAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
initDone = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Network currentNetwork() {
|
||||||
|
if (networks.size() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return networks.get(networks.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandExecutionResult openGroup(String name) {
|
||||||
|
if (initDone == false) {
|
||||||
|
return errorNoInit();
|
||||||
|
}
|
||||||
|
currentGroup = new NwGroupLegacy(name, currentNetwork());
|
||||||
|
groups.add(currentGroup);
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandExecutionResult openNetwork(String name) {
|
||||||
|
if (initDone == false) {
|
||||||
|
return errorNoInit();
|
||||||
|
}
|
||||||
|
createNetwork(name);
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Network createNetwork(String name) {
|
||||||
|
final Network network = new NetworkLegacy(playField.createNewStage(), name, networks.size());
|
||||||
|
networks.add(network);
|
||||||
|
return network;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandExecutionResult link(String name1, String name2) {
|
||||||
|
if (initDone == false) {
|
||||||
|
return errorNoInit();
|
||||||
|
}
|
||||||
|
final NServer element;
|
||||||
|
if (currentNetwork() == null) {
|
||||||
|
createNetwork(name1);
|
||||||
|
element = new NServerLegacy(name2, currentNetwork(), this.getSkinParam());
|
||||||
|
} else {
|
||||||
|
final NServer already = servers.get(name1);
|
||||||
|
final Network network1 = createNetwork("");
|
||||||
|
network1.goInvisible();
|
||||||
|
if (already != null) {
|
||||||
|
connect(already, toSet(null));
|
||||||
|
}
|
||||||
|
element = new NServerLegacy(name2, currentNetwork(), this.getSkinParam());
|
||||||
|
((NServerLegacy)element).sameColThan(already);
|
||||||
|
}
|
||||||
|
servers.put(name2, element);
|
||||||
|
addInternal(element, toSet(null));
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addInternal(NServer server, Map<String, String> props) {
|
||||||
|
connect(server, props);
|
||||||
|
final String description = props.get("description");
|
||||||
|
if (description != null) {
|
||||||
|
server.setDescription(description);
|
||||||
|
}
|
||||||
|
final String shape = props.get("shape");
|
||||||
|
if (shape != null) {
|
||||||
|
server.setShape(shape);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void connect(NServer server, final Map<String, String> props) {
|
||||||
|
((NetworkLegacy) currentNetwork()).addServer(Objects.requireNonNull((NServerLegacy) server), props);
|
||||||
|
server.connect(currentNetwork(), props);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandExecutionResult addElement(String name, String definition) {
|
||||||
|
if (initDone == false) {
|
||||||
|
return errorNoInit();
|
||||||
|
}
|
||||||
|
if (currentGroup != null) {
|
||||||
|
currentGroup.addName(name);
|
||||||
|
}
|
||||||
|
NServer server = null;
|
||||||
|
if (currentNetwork() == null) {
|
||||||
|
if (currentGroup != null) {
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
assert currentGroup == null;
|
||||||
|
final Network network1 = createNetwork("");
|
||||||
|
network1.goInvisible();
|
||||||
|
server = new NServerLegacy(name, currentNetwork(), this.getSkinParam());
|
||||||
|
servers.put(name, server);
|
||||||
|
((NServerLegacy) server).doNotHaveItsOwnColumn();
|
||||||
|
} else {
|
||||||
|
server = servers.get(name);
|
||||||
|
if (server == null) {
|
||||||
|
server = new NServerLegacy(name, currentNetwork(), this.getSkinParam());
|
||||||
|
servers.put(name, server);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addInternal(server, toSet(definition));
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandExecutionResult endSomething() {
|
||||||
|
if (initDone == false) {
|
||||||
|
return errorNoInit();
|
||||||
|
}
|
||||||
|
this.currentGroup = null;
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandExecutionResult errorNoInit() {
|
||||||
|
return CommandExecutionResult.error("Maybe you forget 'nwdiag {' in your diagram ?");
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, String> toSet(String definition) {
|
||||||
|
final Map<String, String> result = new HashMap<String, String>();
|
||||||
|
if (definition == null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
final Pattern p = Pattern.compile("\\s*(\\w+)\\s*=\\s*(\"([^\"]*)\"|[^\\s,]+)");
|
||||||
|
final Matcher m = p.matcher(definition);
|
||||||
|
while (m.find()) {
|
||||||
|
final String name = m.group(1);
|
||||||
|
final String value = m.group(3) == null ? m.group(2) : m.group(3);
|
||||||
|
result.put(name, value);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
|
throws IOException {
|
||||||
|
|
||||||
|
return createImageBuilder(fileFormatOption).drawable(getTextBlock()).write(os);
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextBlockBackcolored getTextBlock() {
|
||||||
|
return new TextBlockBackcolored() {
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
drawMe(ug);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||||
|
return getTotalDimension(stringBounder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MinMax getMinMax(StringBounder stringBounder) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public HColor getBackcolor() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextBlock toTextBlock(String name, String s) {
|
||||||
|
if (s != null) {
|
||||||
|
name += "\\n" + s;
|
||||||
|
}
|
||||||
|
return Display.getWithNewlines(name).create(getFontConfiguration(), HorizontalAlignment.RIGHT,
|
||||||
|
new SpriteContainerEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
private FontConfiguration getFontConfiguration() {
|
||||||
|
final UFont font = UFont.serif(11);
|
||||||
|
return new FontConfiguration(font, HColorUtils.BLACK, HColorUtils.BLACK, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dimension2D getTotalDimension(StringBounder stringBounder) {
|
||||||
|
return TextBlockUtils.getMinMax(new UDrawable() {
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
drawMe(ug);
|
||||||
|
}
|
||||||
|
}, stringBounder, true).getDimension();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final double margin = 5;
|
||||||
|
|
||||||
|
private void drawMe(UGraphic ug) {
|
||||||
|
ug = ug.apply(new UTranslate(margin, margin));
|
||||||
|
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
final GridTextBlockDecorated grid = buildGrid();
|
||||||
|
|
||||||
|
double deltaX = 0;
|
||||||
|
double deltaY = 0;
|
||||||
|
for (int i = 0; i < networks.size(); i++) {
|
||||||
|
final Network current = networks.get(i);
|
||||||
|
final String address = current.getOwnAdress();
|
||||||
|
final TextBlock desc = toTextBlock(current.getDisplayName(), address);
|
||||||
|
final Dimension2D dim = desc.calculateDimension(stringBounder);
|
||||||
|
if (i == 0) {
|
||||||
|
deltaY = (dim.getHeight() - GridTextBlockDecorated.NETWORK_THIN) / 2;
|
||||||
|
}
|
||||||
|
deltaX = Math.max(deltaX, dim.getWidth());
|
||||||
|
}
|
||||||
|
double y = 0;
|
||||||
|
for (int i = 0; i < networks.size(); i++) {
|
||||||
|
final Network current = networks.get(i);
|
||||||
|
final String address = current.getOwnAdress();
|
||||||
|
final TextBlock desc = toTextBlock(current.getDisplayName(), address);
|
||||||
|
final Dimension2D dim = desc.calculateDimension(stringBounder);
|
||||||
|
desc.drawU(ug.apply(new UTranslate(deltaX - dim.getWidth(), y)));
|
||||||
|
|
||||||
|
y += grid.lineHeight(stringBounder, i);
|
||||||
|
}
|
||||||
|
deltaX += 5;
|
||||||
|
|
||||||
|
grid.drawU(ug.apply(ColorParam.activityBorder.getDefaultValue())
|
||||||
|
.apply(ColorParam.activityBackground.getDefaultValue().bg()).apply(new UTranslate(deltaX, deltaY)));
|
||||||
|
final Dimension2D dimGrid = grid.calculateDimension(stringBounder);
|
||||||
|
|
||||||
|
ug.apply(new UTranslate(dimGrid.getWidth() + deltaX + margin, dimGrid.getHeight() + deltaY + margin))
|
||||||
|
.draw(new UEmpty(1, 1));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<NetworkLegacy, String> getLinks(NServer element) {
|
||||||
|
final Map<NetworkLegacy, String> result = new LinkedHashMap<>();
|
||||||
|
for (Network network1 : networks) {
|
||||||
|
final NetworkLegacy network = (NetworkLegacy) network1;
|
||||||
|
final String s = network.getAdress(element);
|
||||||
|
if (s != null) {
|
||||||
|
result.put(network, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private GridTextBlockDecorated buildGrid() {
|
||||||
|
final GridTextBlockDecorated grid = new GridTextBlockDecorated(networks.size(), servers.size(), groups,
|
||||||
|
networks, getSkinParam());
|
||||||
|
|
||||||
|
for (int i = 0; i < networks.size(); i++) {
|
||||||
|
final NetworkLegacy current = (NetworkLegacy) networks.get(i);
|
||||||
|
int j = 0;
|
||||||
|
for (Map.Entry<String, NServer> ent : servers.entrySet()) {
|
||||||
|
final NServerLegacy square = (NServerLegacy) ent.getValue();
|
||||||
|
if (square.getMainNetwork() == current) {
|
||||||
|
final Map<NetworkLegacy, String> conns = getLinks(square);
|
||||||
|
final NServerLegacy sameCol = square.getSameCol();
|
||||||
|
if (sameCol != null) {
|
||||||
|
square.setNumCol(sameCol.getNumCol());
|
||||||
|
} else {
|
||||||
|
square.setNumCol(j);
|
||||||
|
}
|
||||||
|
grid.add(i, square.getNumCol(), square.asTextBlock(conns, networks));
|
||||||
|
}
|
||||||
|
if (square.hasItsOwnColumn()) {
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
grid.checkGroups();
|
||||||
|
|
||||||
|
return grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandExecutionResult setProperty(String property, String value) {
|
||||||
|
if (initDone == false) {
|
||||||
|
return errorNoInit();
|
||||||
|
}
|
||||||
|
if ("address".equalsIgnoreCase(property) && currentNetwork() != null) {
|
||||||
|
currentNetwork().setOwnAdress(value);
|
||||||
|
}
|
||||||
|
if ("width".equalsIgnoreCase(property) && currentNetwork() != null) {
|
||||||
|
currentNetwork().setFullWidth("full".equalsIgnoreCase(value));
|
||||||
|
}
|
||||||
|
if ("color".equalsIgnoreCase(property)) {
|
||||||
|
final HColor color = value == null ? null
|
||||||
|
: NwGroup.colors.getColorOrWhite(getSkinParam().getThemeStyle(), value);
|
||||||
|
if (currentGroup != null) {
|
||||||
|
currentGroup.setColor(color);
|
||||||
|
} else if (currentNetwork() != null) {
|
||||||
|
currentNetwork().setColor(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ("description".equalsIgnoreCase(property)) {
|
||||||
|
if (currentGroup == null) {
|
||||||
|
currentNetwork().setDescription(value);
|
||||||
|
} else {
|
||||||
|
currentGroup.setDescription(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClockwiseTopRightBottomLeft getDefaultMargins() {
|
||||||
|
return ClockwiseTopRightBottomLeft.none();
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,11 +35,21 @@
|
||||||
package net.sourceforge.plantuml.nwdiag.core;
|
package net.sourceforge.plantuml.nwdiag.core;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ColorParam;
|
||||||
import net.sourceforge.plantuml.ComponentStyle;
|
import net.sourceforge.plantuml.ComponentStyle;
|
||||||
|
import net.sourceforge.plantuml.ISkinSimple;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||||
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||||
|
import net.sourceforge.plantuml.graphic.SymbolContext;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||||
import net.sourceforge.plantuml.graphic.USymbol;
|
import net.sourceforge.plantuml.graphic.USymbol;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.next.LinkedElementNext;
|
||||||
import net.sourceforge.plantuml.nwdiag.next.NBar;
|
import net.sourceforge.plantuml.nwdiag.next.NBar;
|
||||||
import net.sourceforge.plantuml.skin.ActorStyle;
|
import net.sourceforge.plantuml.skin.ActorStyle;
|
||||||
import net.sourceforge.plantuml.svek.PackageStyle;
|
import net.sourceforge.plantuml.svek.PackageStyle;
|
||||||
|
@ -55,6 +65,50 @@ public class NServer {
|
||||||
private String description;
|
private String description;
|
||||||
private final NBar bar = new NBar();
|
private final NBar bar = new NBar();
|
||||||
|
|
||||||
|
// To be renamed in "printFirstLink"
|
||||||
|
private boolean hasItsOwnColumn = true;
|
||||||
|
|
||||||
|
public void doNotHaveItsOwnColumn() {
|
||||||
|
this.hasItsOwnColumn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean hasItsOwnColumn() {
|
||||||
|
return hasItsOwnColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Network getMainNetworkNext() {
|
||||||
|
return connections.keySet().iterator().next();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAdress(Network network) {
|
||||||
|
return connections.get(network);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final TextBlock toTextBlock(String s, ISkinSimple spriteContainer) {
|
||||||
|
if (s == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (s.length() == 0) {
|
||||||
|
return TextBlockUtils.empty(0, 0);
|
||||||
|
}
|
||||||
|
s = s.replace(", ", "\\n");
|
||||||
|
return Display.getWithNewlines(s).create(getFontConfiguration(), HorizontalAlignment.LEFT, spriteContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedElementNext asTextBlockNext(double topMargin, Map<Network, String> conns, List<Network> networks,
|
||||||
|
ISkinSimple spriteContainer) {
|
||||||
|
final Map<Network, TextBlock> conns2 = new LinkedHashMap<Network, TextBlock>();
|
||||||
|
for (Entry<Network, String> ent : conns.entrySet()) {
|
||||||
|
conns2.put(ent.getKey(), toTextBlock(ent.getValue(), spriteContainer));
|
||||||
|
}
|
||||||
|
final SymbolContext symbolContext = new SymbolContext(ColorParam.activityBackground.getDefaultValue(),
|
||||||
|
ColorParam.activityBorder.getDefaultValue()).withShadow(3);
|
||||||
|
final TextBlock desc = toTextBlock(getDescription(), spriteContainer);
|
||||||
|
final TextBlock box = getShape().asSmall(TextBlockUtils.empty(0, 0), desc, TextBlockUtils.empty(0, 0),
|
||||||
|
symbolContext, HorizontalAlignment.CENTER);
|
||||||
|
return new LinkedElementNext(topMargin, this, box, conns2, networks);
|
||||||
|
}
|
||||||
|
|
||||||
public void connect(Network network, Map<String, String> props) {
|
public void connect(Network network, Map<String, String> props) {
|
||||||
String address = props.get("address");
|
String address = props.get("address");
|
||||||
if (address == null) {
|
if (address == null) {
|
||||||
|
@ -64,7 +118,14 @@ public class NServer {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
connections.put(network, address);
|
connections.put(network, address);
|
||||||
bar.addStage(network.getNstage());
|
if (bar.getStart() == null) {
|
||||||
|
bar.addStage(network.getNstage());
|
||||||
|
} else {
|
||||||
|
// Test to be removed
|
||||||
|
if (network.getUp() != null)
|
||||||
|
if (this.getMainNetworkNext() != network)
|
||||||
|
bar.addStage(network.getUp());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,6 +138,11 @@ public class NServer {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NServer(String name, Object... unused) {
|
||||||
|
this.description = name;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
protected final FontConfiguration getFontConfiguration() {
|
protected final FontConfiguration getFontConfiguration() {
|
||||||
final UFont font = UFont.serif(11);
|
final UFont font = UFont.serif(11);
|
||||||
return new FontConfiguration(font, HColorUtils.BLACK, HColorUtils.BLACK, false);
|
return new FontConfiguration(font, HColorUtils.BLACK, HColorUtils.BLACK, false);
|
||||||
|
|
|
@ -40,11 +40,14 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||||
public class Network {
|
public class Network {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
private String description;
|
||||||
private HColor color;
|
private HColor color;
|
||||||
private boolean visible = true;
|
private boolean visible = true;
|
||||||
private String ownAdress;
|
private String ownAdress;
|
||||||
private double y;
|
private double y;
|
||||||
private boolean fullWidth;
|
private boolean fullWidth;
|
||||||
|
private final NStage up;
|
||||||
|
|
||||||
private final NStage nstage;
|
private final NStage nstage;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,7 +55,25 @@ public class Network {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Network(NStage nstage, String name) {
|
private boolean isEven() {
|
||||||
|
return nstage.getNumber() % 2 == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double magicDelta() {
|
||||||
|
if (isVisible() == false)
|
||||||
|
return 0;
|
||||||
|
if (isEven())
|
||||||
|
return 2;
|
||||||
|
else
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NStage getUp() {
|
||||||
|
return up;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Network(NStage up, NStage nstage, String name, Object... unused) {
|
||||||
|
this.up = up;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.nstage = nstage;
|
this.nstage = nstage;
|
||||||
}
|
}
|
||||||
|
@ -65,8 +86,15 @@ public class Network {
|
||||||
this.ownAdress = ownAdress;
|
this.ownAdress = ownAdress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getName() {
|
public final String getDisplayName() {
|
||||||
return name;
|
if (this.description == null) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final HColor getColor() {
|
public final HColor getColor() {
|
||||||
|
@ -105,4 +133,20 @@ public class Network {
|
||||||
return nstage;
|
return nstage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double xmin;
|
||||||
|
private double xmax;
|
||||||
|
|
||||||
|
public void setMinMax(double xmin, double xmax) {
|
||||||
|
this.xmin = xmin;
|
||||||
|
this.xmax = xmax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final double getXmin() {
|
||||||
|
return xmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final double getXmax() {
|
||||||
|
return xmax;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,16 +34,25 @@
|
||||||
*/
|
*/
|
||||||
package net.sourceforge.plantuml.nwdiag.core;
|
package net.sourceforge.plantuml.nwdiag.core;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ISkinParam;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||||
import net.sourceforge.plantuml.nwdiag.legacy.NServerLegacy;
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.next.LinkedElementNext;
|
||||||
import net.sourceforge.plantuml.nwdiag.next.NBox;
|
import net.sourceforge.plantuml.nwdiag.next.NBox;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||||
import net.sourceforge.plantuml.ugraphic.UFont;
|
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||||
import net.sourceforge.plantuml.ugraphic.color.HColorSet;
|
import net.sourceforge.plantuml.ugraphic.color.HColorSet;
|
||||||
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
||||||
|
@ -59,10 +68,17 @@ public class NwGroup {
|
||||||
private String description;
|
private String description;
|
||||||
private NBox nbox;
|
private NBox nbox;
|
||||||
|
|
||||||
public final NBox getNbox(Map<String, NServerLegacy> servers) {
|
public NBox getNboxInternal() {
|
||||||
if (nbox == null) {
|
if (nbox == null) {
|
||||||
nbox = new NBox();
|
nbox = new NBox();
|
||||||
for (Entry<String, NServerLegacy> ent : servers.entrySet()) {
|
}
|
||||||
|
return nbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final NBox getNbox(Map<String, ? extends NServer> servers) {
|
||||||
|
if (nbox == null) {
|
||||||
|
nbox = new NBox();
|
||||||
|
for (Entry<String, ? extends NServer> ent : servers.entrySet()) {
|
||||||
if (names.contains(ent.getKey())) {
|
if (names.contains(ent.getKey())) {
|
||||||
nbox.add(ent.getValue().getBar());
|
nbox.add(ent.getValue().getBar());
|
||||||
}
|
}
|
||||||
|
@ -77,10 +93,10 @@ public class NwGroup {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return "NwGroup:" + name + " " + names + " " + nbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NwGroup(String name) {
|
public NwGroup(String name, Object... unused) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,4 +129,48 @@ public class NwGroup {
|
||||||
return Collections.unmodifiableSet(names);
|
return Collections.unmodifiableSet(names);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean matches(LinkedElementNext tested) {
|
||||||
|
// To be merged with containsNext
|
||||||
|
return names().contains(tested.getElement().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containsNext(NServer server) {
|
||||||
|
return names.contains(server.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getTopHeaderHeight(StringBounder stringBounder, ISkinParam skinParam) {
|
||||||
|
final TextBlock block = buildHeaderName(skinParam);
|
||||||
|
if (block == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
final Dimension2D blockDim = block.calculateDimension(stringBounder);
|
||||||
|
return blockDim.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawGroup(UGraphic ug, MinMax size, ISkinParam skinParam) {
|
||||||
|
final TextBlock block = buildHeaderName(skinParam);
|
||||||
|
if (block != null) {
|
||||||
|
final Dimension2D blockDim = block.calculateDimension(ug.getStringBounder());
|
||||||
|
final double dy = size.getMinY() - blockDim.getHeight();
|
||||||
|
size = size.addPoint(size.getMinX(), dy);
|
||||||
|
}
|
||||||
|
HColor color = getColor();
|
||||||
|
if (color == null) {
|
||||||
|
color = colors.getColorOrWhite(skinParam.getThemeStyle(), "#AAA");
|
||||||
|
}
|
||||||
|
size.draw(ug, color);
|
||||||
|
|
||||||
|
if (block != null) {
|
||||||
|
block.drawU(ug.apply(new UTranslate(size.getMinX() + 5, size.getMinY())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextBlock buildHeaderName(ISkinParam skinParam) {
|
||||||
|
if (getDescription() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Display.getWithNewlines(getDescription()).create(getGroupDescriptionFontConfiguration(),
|
||||||
|
HorizontalAlignment.LEFT, skinParam);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,8 @@ public class GridTextBlockDecorated extends GridTextBlockSimple {
|
||||||
private final List<NwGroupLegacy> groups;
|
private final List<NwGroupLegacy> groups;
|
||||||
private final List<NetworkLegacy> networks;
|
private final List<NetworkLegacy> networks;
|
||||||
|
|
||||||
public GridTextBlockDecorated(int lines, int cols, List<NwGroupLegacy> groups, List<NetworkLegacy> networks,
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
|
public GridTextBlockDecorated(int lines, int cols, List groups, List networks,
|
||||||
ISkinParam skinparam) {
|
ISkinParam skinparam) {
|
||||||
super(lines, cols, skinparam);
|
super(lines, cols, skinparam);
|
||||||
this.groups = groups;
|
this.groups = groups;
|
||||||
|
|
|
@ -41,45 +41,33 @@ import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.ColorParam;
|
import net.sourceforge.plantuml.ColorParam;
|
||||||
import net.sourceforge.plantuml.ISkinSimple;
|
import net.sourceforge.plantuml.ISkinSimple;
|
||||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
|
||||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||||
import net.sourceforge.plantuml.graphic.SymbolContext;
|
import net.sourceforge.plantuml.graphic.SymbolContext;
|
||||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||||
import net.sourceforge.plantuml.nwdiag.core.NServer;
|
import net.sourceforge.plantuml.nwdiag.core.NServer;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.core.Network;
|
||||||
|
|
||||||
public class NServerLegacy extends NServer {
|
public class NServerLegacy extends NServer {
|
||||||
|
|
||||||
private final NetworkLegacy mainNetwork;
|
private final NetworkLegacy mainNetwork;
|
||||||
private final ISkinSimple spriteContainer;
|
private final ISkinSimple spriteContainer;
|
||||||
private boolean hasItsOwnColumn = true;
|
|
||||||
private NServerLegacy sameCol;
|
private NServerLegacy sameCol;
|
||||||
|
|
||||||
public NServerLegacy(String name, NetworkLegacy network, ISkinSimple spriteContainer) {
|
public NServerLegacy(String name, Network network, ISkinSimple spriteContainer) {
|
||||||
super(name);
|
super(name);
|
||||||
this.mainNetwork = network;
|
this.mainNetwork = (NetworkLegacy) network;
|
||||||
this.spriteContainer = spriteContainer;
|
this.spriteContainer = spriteContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextBlock toTextBlock(String s) {
|
public LinkedElement asTextBlock(Map<NetworkLegacy, String> conns, List networks) {
|
||||||
if (s == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (s.length() == 0) {
|
|
||||||
return TextBlockUtils.empty(0, 0);
|
|
||||||
}
|
|
||||||
s = s.replace(", ", "\\n");
|
|
||||||
return Display.getWithNewlines(s).create(getFontConfiguration(), HorizontalAlignment.LEFT, spriteContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LinkedElement asTextBlock(Map<NetworkLegacy, String> conns, List<NetworkLegacy> networks) {
|
|
||||||
final Map<NetworkLegacy, TextBlock> conns2 = new LinkedHashMap<NetworkLegacy, TextBlock>();
|
final Map<NetworkLegacy, TextBlock> conns2 = new LinkedHashMap<NetworkLegacy, TextBlock>();
|
||||||
for (Entry<NetworkLegacy, String> ent : conns.entrySet()) {
|
for (Entry<NetworkLegacy, String> ent : conns.entrySet()) {
|
||||||
conns2.put(ent.getKey(), toTextBlock(ent.getValue()));
|
conns2.put(ent.getKey(), toTextBlock(ent.getValue(), spriteContainer));
|
||||||
}
|
}
|
||||||
final SymbolContext symbolContext = new SymbolContext(ColorParam.activityBackground.getDefaultValue(),
|
final SymbolContext symbolContext = new SymbolContext(ColorParam.activityBackground.getDefaultValue(),
|
||||||
ColorParam.activityBorder.getDefaultValue()).withShadow(3);
|
ColorParam.activityBorder.getDefaultValue()).withShadow(3);
|
||||||
final TextBlock desc = toTextBlock(getDescription());
|
final TextBlock desc = toTextBlock(getDescription(), spriteContainer);
|
||||||
final TextBlock box = getShape().asSmall(TextBlockUtils.empty(0, 0), desc, TextBlockUtils.empty(0, 0),
|
final TextBlock box = getShape().asSmall(TextBlockUtils.empty(0, 0), desc, TextBlockUtils.empty(0, 0),
|
||||||
symbolContext, HorizontalAlignment.CENTER);
|
symbolContext, HorizontalAlignment.CENTER);
|
||||||
return new LinkedElement(this, box, conns2, networks);
|
return new LinkedElement(this, box, conns2, networks);
|
||||||
|
@ -89,16 +77,8 @@ public class NServerLegacy extends NServer {
|
||||||
return mainNetwork;
|
return mainNetwork;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doNotHaveItsOwnColumn() {
|
public void sameColThan(NServer sameCol) {
|
||||||
this.hasItsOwnColumn = false;
|
this.sameCol = (NServerLegacy) sameCol;
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean hasItsOwnColumn() {
|
|
||||||
return hasItsOwnColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sameColThan(NServerLegacy sameCol) {
|
|
||||||
this.sameCol = sameCol;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final NServerLegacy getSameCol() {
|
public final NServerLegacy getSameCol() {
|
||||||
|
|
|
@ -37,6 +37,7 @@ package net.sourceforge.plantuml.nwdiag.legacy;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.nwdiag.core.NServer;
|
||||||
import net.sourceforge.plantuml.nwdiag.core.Network;
|
import net.sourceforge.plantuml.nwdiag.core.Network;
|
||||||
import net.sourceforge.plantuml.nwdiag.next.NStage;
|
import net.sourceforge.plantuml.nwdiag.next.NStage;
|
||||||
|
|
||||||
|
@ -51,11 +52,11 @@ public class NetworkLegacy extends Network {
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkLegacy(NStage nstage, String name, int stage) {
|
public NetworkLegacy(NStage nstage, String name, int stage) {
|
||||||
super(nstage, name);
|
super(null, nstage, name);
|
||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAdress(NServerLegacy server) {
|
public String getAdress(NServer server) {
|
||||||
return localServers.get(server);
|
return localServers.get(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,20 +84,5 @@ public class NetworkLegacy extends Network {
|
||||||
return stage;
|
return stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double xmin;
|
|
||||||
private double xmax;
|
|
||||||
|
|
||||||
public void setMinMax(double xmin, double xmax) {
|
|
||||||
this.xmin = xmin;
|
|
||||||
this.xmax = xmax;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final double getXmin() {
|
|
||||||
return xmin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final double getXmax() {
|
|
||||||
return xmax;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,17 +34,8 @@
|
||||||
*/
|
*/
|
||||||
package net.sourceforge.plantuml.nwdiag.legacy;
|
package net.sourceforge.plantuml.nwdiag.legacy;
|
||||||
|
|
||||||
import java.awt.geom.Dimension2D;
|
import net.sourceforge.plantuml.nwdiag.core.Network;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.ISkinParam;
|
|
||||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
|
||||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
|
||||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
|
||||||
import net.sourceforge.plantuml.nwdiag.core.NwGroup;
|
import net.sourceforge.plantuml.nwdiag.core.NwGroup;
|
||||||
import net.sourceforge.plantuml.ugraphic.MinMax;
|
|
||||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
|
||||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
|
||||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
|
||||||
|
|
||||||
public class NwGroupLegacy extends NwGroup {
|
public class NwGroupLegacy extends NwGroup {
|
||||||
|
|
||||||
|
@ -55,9 +46,9 @@ public class NwGroupLegacy extends NwGroup {
|
||||||
return getName() + " " + network + " " + names();
|
return getName() + " " + network + " " + names();
|
||||||
}
|
}
|
||||||
|
|
||||||
public NwGroupLegacy(String name, NetworkLegacy network) {
|
public NwGroupLegacy(String name, Network network) {
|
||||||
super(name);
|
super(name);
|
||||||
this.network = network;
|
this.network = (NetworkLegacy) network;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
|
@ -71,27 +62,6 @@ public class NwGroupLegacy extends NwGroup {
|
||||||
return names().contains(tested.getElement().getName());
|
return names().contains(tested.getElement().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawGroup(UGraphic ug, MinMax size, ISkinParam skinParam) {
|
|
||||||
TextBlock block = null;
|
|
||||||
Dimension2D blockDim = null;
|
|
||||||
if (getDescription() != null) {
|
|
||||||
block = Display.getWithNewlines(getDescription()).create(getGroupDescriptionFontConfiguration(),
|
|
||||||
HorizontalAlignment.LEFT, skinParam);
|
|
||||||
blockDim = block.calculateDimension(ug.getStringBounder());
|
|
||||||
final double dy = size.getMinY() - blockDim.getHeight();
|
|
||||||
size = size.addPoint(size.getMinX(), dy);
|
|
||||||
}
|
|
||||||
HColor color = getColor();
|
|
||||||
if (color == null) {
|
|
||||||
color = colors.getColorOrWhite(skinParam.getThemeStyle(), "#AAA");
|
|
||||||
}
|
|
||||||
size.draw(ug, color);
|
|
||||||
|
|
||||||
if (block != null) {
|
|
||||||
block.drawU(ug.apply(new UTranslate(size.getMinX() + 5, size.getMinY())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final NetworkLegacy getNetwork() {
|
public final NetworkLegacy getNetwork() {
|
||||||
return network;
|
return network;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,169 @@
|
||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2020, Arnaud Roques
|
||||||
|
*
|
||||||
|
* Project Info: http://plantuml.com
|
||||||
|
*
|
||||||
|
* If you like this project or if you find it useful, you can support us at:
|
||||||
|
*
|
||||||
|
* http://plantuml.com/patreon (only 1$ per month!)
|
||||||
|
* http://plantuml.com/paypal
|
||||||
|
*
|
||||||
|
* This file is part of PlantUML.
|
||||||
|
*
|
||||||
|
* PlantUML is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* PlantUML distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Original Author: Arnaud Roques
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.nwdiag.next;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ISkinParam;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.core.Network;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.core.NwGroup;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.URectangle;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class GridTextBlockDecoratedNext extends GridTextBlockSimpleNext {
|
||||||
|
|
||||||
|
public static final int NETWORK_THIN = 5;
|
||||||
|
|
||||||
|
private final List<NwGroup> groups;
|
||||||
|
private final List<Network> networks;
|
||||||
|
|
||||||
|
public GridTextBlockDecoratedNext(int lines, int cols, List<NwGroup> groups, List<Network> networks,
|
||||||
|
ISkinParam skinparam) {
|
||||||
|
super(lines, cols, skinparam);
|
||||||
|
this.groups = groups;
|
||||||
|
this.networks = networks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawGrid(UGraphic ug) {
|
||||||
|
for (NwGroup group : groups) {
|
||||||
|
drawGroups(ug, group, skinparam);
|
||||||
|
}
|
||||||
|
drawNetworkTube(ug);
|
||||||
|
drawLinks(ug);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawLinks(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
for (int i = 0; i < data.getNbLines(); i++) {
|
||||||
|
final double lineHeight = lineHeight(stringBounder, i);
|
||||||
|
double x = 0;
|
||||||
|
for (int j = 0; j < data.getNbCols(); j++) {
|
||||||
|
final double colWidth = colWidth(stringBounder, j);
|
||||||
|
if (data.get(i, j) != null) {
|
||||||
|
data.get(i, j).drawLinks(ug, x, colWidth, lineHeight);
|
||||||
|
}
|
||||||
|
x += colWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawGroups(UGraphic ug, NwGroup group, ISkinParam skinParam) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
|
||||||
|
MinMax size = null;
|
||||||
|
double y = 0;
|
||||||
|
for (int i = 0; i < data.getNbLines(); i++) {
|
||||||
|
final double lineHeight = lineHeight(stringBounder, i);
|
||||||
|
double x = 0;
|
||||||
|
for (int j = 0; j < data.getNbCols(); j++) {
|
||||||
|
final double colWidth = colWidth(stringBounder, j);
|
||||||
|
final LinkedElementNext element = data.get(i, j);
|
||||||
|
if (element != null && group.matches(element)) {
|
||||||
|
final MinMax minMax = element.getMinMax(stringBounder, colWidth, lineHeight)
|
||||||
|
.translate(new UTranslate(x, y));
|
||||||
|
size = size == null ? minMax : size.addMinMax(minMax);
|
||||||
|
}
|
||||||
|
x += colWidth;
|
||||||
|
}
|
||||||
|
y += lineHeight;
|
||||||
|
}
|
||||||
|
if (size != null) {
|
||||||
|
group.drawGroup(ug, size, skinParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isThereALink(int j, Network network) {
|
||||||
|
for (int i = 0; i < data.getNbLines(); i++) {
|
||||||
|
final LinkedElementNext element = data.get(i, j);
|
||||||
|
if (element != null && element.isLinkedTo(network)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawNetworkTube(final UGraphic ug) {
|
||||||
|
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
double y = 0;
|
||||||
|
for (int i = 0; i < data.getNbLines(); i++) {
|
||||||
|
final Network network = getNetwork(i);
|
||||||
|
computeMixMax(data.getLine(i), stringBounder, network);
|
||||||
|
|
||||||
|
final URectangle rect = new URectangle(network.getXmax() - network.getXmin(), NETWORK_THIN);
|
||||||
|
rect.setDeltaShadow(1.0);
|
||||||
|
UGraphic ug2 = ug.apply(new UTranslate(network.getXmin(), y));
|
||||||
|
if (network != null && network.getColor() != null) {
|
||||||
|
ug2 = ug2.apply(network.getColor().bg());
|
||||||
|
}
|
||||||
|
if (network != null) {
|
||||||
|
network.setY(y);
|
||||||
|
}
|
||||||
|
if (network.isVisible()) {
|
||||||
|
ug2.draw(rect);
|
||||||
|
}
|
||||||
|
y += lineHeight(stringBounder, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void computeMixMax(LinkedElementNext line[], StringBounder stringBounder, Network network) {
|
||||||
|
double x = 0;
|
||||||
|
double xmin = network.isFullWidth() ? 0 : -1;
|
||||||
|
double xmax = 0;
|
||||||
|
for (int j = 0; j < line.length; j++) {
|
||||||
|
final boolean hline = isThereALink(j, network);
|
||||||
|
if (hline && xmin < 0) {
|
||||||
|
xmin = x;
|
||||||
|
}
|
||||||
|
x += colWidth(stringBounder, j);
|
||||||
|
if (hline || network.isFullWidth()) {
|
||||||
|
xmax = x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
network.setMinMax(xmin, xmax);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Network getNetwork(int i) {
|
||||||
|
return networks.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2020, Arnaud Roques
|
||||||
|
*
|
||||||
|
* Project Info: http://plantuml.com
|
||||||
|
*
|
||||||
|
* If you like this project or if you find it useful, you can support us at:
|
||||||
|
*
|
||||||
|
* http://plantuml.com/patreon (only 1$ per month!)
|
||||||
|
* http://plantuml.com/paypal
|
||||||
|
*
|
||||||
|
* This file is part of PlantUML.
|
||||||
|
*
|
||||||
|
* PlantUML is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* PlantUML distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Original Author: Arnaud Roques
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.nwdiag.next;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.awt.geom.Rectangle2D;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||||
|
import net.sourceforge.plantuml.ISkinParam;
|
||||||
|
import net.sourceforge.plantuml.graphic.InnerStrategy;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class GridTextBlockSimpleNext implements TextBlock {
|
||||||
|
|
||||||
|
protected final NwArrayNext data;
|
||||||
|
protected final ISkinParam skinparam;
|
||||||
|
|
||||||
|
public GridTextBlockSimpleNext(int lines, int cols, ISkinParam skinparam) {
|
||||||
|
this.skinparam = skinparam;
|
||||||
|
this.data = new NwArrayNext(lines, cols);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void drawGrid(UGraphic ug) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
drawGrid(ug);
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
double y = 0;
|
||||||
|
for (int i = 0; i < data.getNbLines(); i++) {
|
||||||
|
final double lineHeight = lineHeight(stringBounder, i);
|
||||||
|
double x = 0;
|
||||||
|
for (int j = 0; j < data.getNbCols(); j++) {
|
||||||
|
final double colWidth = colWidth(stringBounder, j);
|
||||||
|
if (data.get(i, j) != null) {
|
||||||
|
data.get(i, j).drawMe(ug.apply(new UTranslate(x, y)), colWidth, lineHeight);
|
||||||
|
}
|
||||||
|
x += colWidth;
|
||||||
|
}
|
||||||
|
y += lineHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected double colWidth(StringBounder stringBounder, final int j) {
|
||||||
|
double width = 0;
|
||||||
|
for (int i = 0; i < data.getNbLines(); i++) {
|
||||||
|
if (data.get(i, j) != null) {
|
||||||
|
width = Math.max(width, data.get(i, j).naturalDimension(stringBounder).getWidth());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double lineHeight(StringBounder stringBounder, final int i) {
|
||||||
|
double height = 50;
|
||||||
|
for (int j = 0; j < data.getNbCols(); j++) {
|
||||||
|
if (data.get(i, j) != null) {
|
||||||
|
height = Math.max(height, data.get(i, j).naturalDimension(stringBounder).getHeight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||||
|
if (data.getNbLines() == 0) {
|
||||||
|
return new Dimension2DDouble(0, 0);
|
||||||
|
}
|
||||||
|
double height = 0;
|
||||||
|
for (int i = 0; i < data.getNbLines(); i++) {
|
||||||
|
height += lineHeight(stringBounder, i);
|
||||||
|
}
|
||||||
|
double width = 0;
|
||||||
|
for (int j = 0; j < data.getNbCols(); j++) {
|
||||||
|
width += colWidth(stringBounder, j);
|
||||||
|
}
|
||||||
|
return new Dimension2DDouble(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) {
|
||||||
|
throw new UnsupportedOperationException("member=" + member + " " + getClass().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public MinMax getMinMax(StringBounder stringBounder) {
|
||||||
|
throw new UnsupportedOperationException(getClass().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(int i, int j, LinkedElementNext value) {
|
||||||
|
data.set(i, j, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,212 @@
|
||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2020, Arnaud Roques
|
||||||
|
*
|
||||||
|
* Project Info: http://plantuml.com
|
||||||
|
*
|
||||||
|
* If you like this project or if you find it useful, you can support us at:
|
||||||
|
*
|
||||||
|
* http://plantuml.com/patreon (only 1$ per month!)
|
||||||
|
* http://plantuml.com/paypal
|
||||||
|
*
|
||||||
|
* This file is part of PlantUML.
|
||||||
|
*
|
||||||
|
* PlantUML is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* PlantUML distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Original Author: Arnaud Roques
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.nwdiag.next;
|
||||||
|
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ColorParam;
|
||||||
|
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.VerticalLine;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.core.NServer;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.core.Network;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||||
|
import net.sourceforge.plantuml.utils.MathUtils;
|
||||||
|
|
||||||
|
public class LinkedElementNext {
|
||||||
|
|
||||||
|
public static final int MAGIC = 15;
|
||||||
|
|
||||||
|
private final TextBlock box;
|
||||||
|
private final Network network;
|
||||||
|
private final NServer server;
|
||||||
|
private final Map<Network, TextBlock> conns;
|
||||||
|
private final List<Network> networks;
|
||||||
|
private final double topMargin;
|
||||||
|
|
||||||
|
public LinkedElementNext(double topMargin, NServer server, TextBlock box, Map<Network, TextBlock> conns,
|
||||||
|
List<Network> networks) {
|
||||||
|
this.topMargin = topMargin;
|
||||||
|
this.networks = networks;
|
||||||
|
this.box = box;
|
||||||
|
this.network = server.getMainNetworkNext();
|
||||||
|
this.server = server;
|
||||||
|
this.conns = conns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLinkedTo(Network some) {
|
||||||
|
return conns.containsKey(some);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final double marginAd = 10;
|
||||||
|
|
||||||
|
private int marginBoxW() {
|
||||||
|
return 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double marginBoxH() {
|
||||||
|
return topMargin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MinMax getMinMax(StringBounder stringBounder, double width, double height) {
|
||||||
|
final double xMiddle = width / 2;
|
||||||
|
final double yMiddle = height / 2;
|
||||||
|
final Dimension2D dimBox = box.calculateDimension(stringBounder);
|
||||||
|
|
||||||
|
final double x1 = xMiddle - dimBox.getWidth() / 2;
|
||||||
|
final double y1 = yMiddle - dimBox.getHeight() / 2;
|
||||||
|
final double x2 = xMiddle + dimBox.getWidth() / 2;
|
||||||
|
final double y2 = yMiddle + dimBox.getHeight() / 2;
|
||||||
|
return MinMax.getEmpty(false).addPoint(x1 - 5, y1 - 5).addPoint(x2 + 5, y2 + 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawMe(UGraphic ug, double width, double height) {
|
||||||
|
final double xMiddle = width / 2;
|
||||||
|
final double yMiddle = height / 2;
|
||||||
|
drawCenter(ug, box, xMiddle, yMiddle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawLinks(UGraphic ug, double xstart, double width, double height) {
|
||||||
|
|
||||||
|
ug = ug.apply(UTranslate.dx(xstart));
|
||||||
|
|
||||||
|
final double ynet1 = network.getY();
|
||||||
|
final double yMiddle = height / 2;
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
final Dimension2D dimBox = box.calculateDimension(stringBounder);
|
||||||
|
|
||||||
|
final double alpha = yMiddle - dimBox.getHeight() / 2;
|
||||||
|
final double posLink1 = (yMiddle - dimBox.getHeight() / 2 - topMargin + MAGIC) / 2;
|
||||||
|
|
||||||
|
final HColor color = ColorParam.activityBorder.getDefaultValue();
|
||||||
|
ug = ug.apply(color);
|
||||||
|
|
||||||
|
final double xMiddle = width / 2;
|
||||||
|
final double xLinkPos = width / 2;
|
||||||
|
|
||||||
|
final TreeSet<Double> skip = new TreeSet<>();
|
||||||
|
|
||||||
|
for (Network n : networks) {
|
||||||
|
if (xstart + xMiddle > n.getXmin() && xstart + xMiddle < n.getXmax())
|
||||||
|
skip.add(n.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (server.hasItsOwnColumn()) {
|
||||||
|
if (network.isVisible()) {
|
||||||
|
new VerticalLine(ynet1 + GridTextBlockDecoratedNext.NETWORK_THIN, ynet1 + alpha, skip)
|
||||||
|
.drawU(ug.apply(UTranslate.dx(xLinkPos + network.magicDelta())));
|
||||||
|
} else {
|
||||||
|
new VerticalLine(ynet1, ynet1 + alpha, Collections.<Double>emptySet())
|
||||||
|
.drawU(ug.apply(UTranslate.dx(xLinkPos + network.magicDelta())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drawCenter(ug, link1(), xMiddle + network.magicDelta(), ynet1 + posLink1);
|
||||||
|
|
||||||
|
final double seven = 9.0;
|
||||||
|
double x = xLinkPos - (conns.size() - 2) * seven / 2;
|
||||||
|
boolean first = true;
|
||||||
|
for (Entry<Network, TextBlock> ent : conns.entrySet()) {
|
||||||
|
if (ent.getKey() == network) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final double ynet2 = ent.getKey().getY();
|
||||||
|
new VerticalLine(ynet1 + yMiddle + dimBox.getHeight() / 2, ynet2, skip)
|
||||||
|
.drawU(ug.apply(UTranslate.dx(x - ent.getKey().magicDelta())));
|
||||||
|
final double xtext;
|
||||||
|
if (first && conns.size() > 2) {
|
||||||
|
xtext = x - ent.getValue().calculateDimension(stringBounder).getWidth() / 2;
|
||||||
|
} else {
|
||||||
|
xtext = x;
|
||||||
|
}
|
||||||
|
drawCenter(ug, ent.getValue(), xtext - ent.getKey().magicDelta(), ynet2 - alpha / 2);
|
||||||
|
x += seven;
|
||||||
|
first = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextBlock link1() {
|
||||||
|
return conns.get(network);
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextBlock link2() {
|
||||||
|
final int i = networks.indexOf(network);
|
||||||
|
if (i == networks.size() - 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return conns.get(networks.get(i + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawCenter(UGraphic ug, TextBlock block, double x, double y) {
|
||||||
|
if (block == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Dimension2D dim = block.calculateDimension(ug.getStringBounder());
|
||||||
|
block.drawU(ug.apply(new UTranslate(x - dim.getWidth() / 2, y - dim.getHeight() / 2)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension2D naturalDimension(StringBounder stringBounder) {
|
||||||
|
final Dimension2D dimLink1 = link1() == null ? new Dimension2DDouble(0, 0)
|
||||||
|
: link1().calculateDimension(stringBounder);
|
||||||
|
final Dimension2D dimBox = box.calculateDimension(stringBounder);
|
||||||
|
final Dimension2D dimLink2 = link2() == null ? new Dimension2DDouble(0, 0)
|
||||||
|
: link2().calculateDimension(stringBounder);
|
||||||
|
final double width = MathUtils.max(dimLink1.getWidth() + 2 * marginAd, dimBox.getWidth() + 2 * marginBoxW(),
|
||||||
|
dimLink2.getWidth() + 2 * marginAd);
|
||||||
|
final double height = dimLink1.getHeight() + 2 * marginAd + 2 * marginBoxH() + dimBox.getHeight()
|
||||||
|
+ dimLink2.getHeight() + 2 * marginAd;
|
||||||
|
return new Dimension2DDouble(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Network getNetwork() {
|
||||||
|
return network;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final NServer getElement() {
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -44,16 +44,13 @@ public class NBox implements Staged {
|
||||||
private final NTetris<NBar> tetris = new NTetris<>();
|
private final NTetris<NBar> tetris = new NTetris<>();
|
||||||
|
|
||||||
public void add(NBar bar) {
|
public void add(NBar bar) {
|
||||||
|
if (this.bars.contains(bar)) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
this.bars.add(bar);
|
this.bars.add(bar);
|
||||||
this.tetris.add(bar);
|
this.tetris.add(bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void addAll(NBox other) {
|
|
||||||
// for (NBar bar : other.bars) {
|
|
||||||
// add(bar);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NStage getStart() {
|
public NStage getStart() {
|
||||||
NStage result = bars.get(0).getStart();
|
NStage result = bars.get(0).getStart();
|
||||||
|
|
|
@ -35,17 +35,20 @@
|
||||||
package net.sourceforge.plantuml.nwdiag.next;
|
package net.sourceforge.plantuml.nwdiag.next;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.nwdiag.core.NServer;
|
||||||
|
import net.sourceforge.plantuml.nwdiag.core.NwGroup;
|
||||||
|
|
||||||
public class NPlayField {
|
public class NPlayField {
|
||||||
|
|
||||||
private final List<NStage> stages = new ArrayList<>();
|
private final List<NStage> stages = new ArrayList<>();
|
||||||
|
|
||||||
private final List<NBar> bars = new ArrayList<>();
|
|
||||||
private final List<NBox> boxes = new ArrayList<>();
|
private final List<NBox> boxes = new ArrayList<>();
|
||||||
|
|
||||||
public NStage getStage(int num) {
|
public NStage getStage(int num) {
|
||||||
|
@ -55,11 +58,18 @@ public class NPlayField {
|
||||||
return stages.get(num);
|
return stages.get(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NStage getLast() {
|
||||||
|
if (stages.size() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return getStage(stages.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
public NStage createNewStage() {
|
public NStage createNewStage() {
|
||||||
return getStage(stages.size());
|
return getStage(stages.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(NBar bar) {
|
public void addInPlayfield(NBar bar) {
|
||||||
if (bar.getParent() == null) {
|
if (bar.getParent() == null) {
|
||||||
final NBox single = new NBox();
|
final NBox single = new NBox();
|
||||||
single.add(bar);
|
single.add(bar);
|
||||||
|
@ -75,21 +85,42 @@ public class NPlayField {
|
||||||
for (NBox box : boxes) {
|
for (NBox box : boxes) {
|
||||||
tetris.add(box);
|
tetris.add(box);
|
||||||
}
|
}
|
||||||
final Map<NBox, Integer> pos = tetris.getPositions();
|
|
||||||
|
|
||||||
final Map<NBar, Integer> result = new HashMap<>();
|
final Map<NBar, Integer> result = new HashMap<>();
|
||||||
|
|
||||||
|
final Map<NBox, Integer> pos = tetris.getPositions();
|
||||||
for (Entry<NBox, Integer> ent : pos.entrySet()) {
|
for (Entry<NBox, Integer> ent : pos.entrySet()) {
|
||||||
final NBox box = ent.getKey();
|
final NBox box = ent.getKey();
|
||||||
final int boxPos = ent.getValue();
|
final int boxPos = ent.getValue();
|
||||||
|
|
||||||
final Map<NBar, Integer> tmp = box.getPositions();
|
final Map<NBar, Integer> bars = box.getPositions();
|
||||||
for (Entry<NBar, Integer> ent2 : tmp.entrySet()) {
|
for (Entry<NBar, Integer> bar : bars.entrySet()) {
|
||||||
result.put(ent2.getKey(), boxPos + ent.getValue());
|
result.put(bar.getKey(), boxPos + bar.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableMap(result);
|
return Collections.unmodifiableMap(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fixGroups(List<NwGroup> groups, Collection<NServer> servers) {
|
||||||
|
for (NwGroup group : groups) {
|
||||||
|
for (NServer server : servers) {
|
||||||
|
if (group.containsNext(server)) {
|
||||||
|
fixServerInGroup(server, group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fixServerInGroup(NServer server, NwGroup group) {
|
||||||
|
final NBox groupBox = group.getNboxInternal();
|
||||||
|
if (server.getBar().getParent() == groupBox)
|
||||||
|
return;
|
||||||
|
boxes.remove(server.getBar().getParent());
|
||||||
|
if (boxes.contains(groupBox) == false)
|
||||||
|
boxes.add(groupBox);
|
||||||
|
server.getBar().setParent(groupBox);
|
||||||
|
groupBox.add(server.getBar());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,6 @@
|
||||||
*/
|
*/
|
||||||
package net.sourceforge.plantuml.nwdiag.next;
|
package net.sourceforge.plantuml.nwdiag.next;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class NStage implements Comparable<NStage> {
|
public class NStage implements Comparable<NStage> {
|
||||||
|
|
||||||
private final int number;
|
private final int number;
|
||||||
|
|
|
@ -43,6 +43,11 @@ public class NTetris<S extends Staged> {
|
||||||
|
|
||||||
private final Map<S, Integer> all = new LinkedHashMap<>();
|
private final Map<S, Integer> all = new LinkedHashMap<>();
|
||||||
private final BooleanGrid grid = new BooleanGrid();
|
private final BooleanGrid grid = new BooleanGrid();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return all.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public void add(S element) {
|
public void add(S element) {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2020, Arnaud Roques
|
||||||
|
*
|
||||||
|
* Project Info: http://plantuml.com
|
||||||
|
*
|
||||||
|
* If you like this project or if you find it useful, you can support us at:
|
||||||
|
*
|
||||||
|
* http://plantuml.com/patreon (only 1$ per month!)
|
||||||
|
* http://plantuml.com/paypal
|
||||||
|
*
|
||||||
|
* This file is part of PlantUML.
|
||||||
|
*
|
||||||
|
* PlantUML is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* PlantUML distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Original Author: Arnaud Roques
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.nwdiag.next;
|
||||||
|
|
||||||
|
public class NwArrayNext {
|
||||||
|
|
||||||
|
private final LinkedElementNext data[][];
|
||||||
|
|
||||||
|
public NwArrayNext(int lines, int cols) {
|
||||||
|
this.data = new LinkedElementNext[lines][cols];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNbLines() {
|
||||||
|
return data.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNbCols() {
|
||||||
|
return data[0].length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedElementNext get(int i, int j) {
|
||||||
|
return data[i][j];
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedElementNext[] getLine(int i) {
|
||||||
|
return data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(int i, int j, LinkedElementNext value) {
|
||||||
|
data[i][j] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public void swapCols(int col1, int col2) {
|
||||||
|
// if (col1 == col2) {
|
||||||
|
// throw new IllegalArgumentException();
|
||||||
|
// }
|
||||||
|
// for (int i = 0; i < getNbLines(); i++) {
|
||||||
|
// final LinkedElement tmp = data[i][col1];
|
||||||
|
// data[i][col1] = data[i][col2];
|
||||||
|
// data[i][col2] = tmp;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public Footprint getFootprint(NwGroupLegacy group) {
|
||||||
|
// int min = Integer.MAX_VALUE;
|
||||||
|
// int max = Integer.MIN_VALUE;
|
||||||
|
// for (int i = 0; i < getNbLines(); i++) {
|
||||||
|
// for (int j = 0; j < getNbCols(); j++) {
|
||||||
|
// if (data[i][j] != null && group.matches(data[i][j])) {
|
||||||
|
// min = Math.min(min, j);
|
||||||
|
// max = Math.max(max, j);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return new Footprint(min, max);
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
|
@ -133,7 +133,7 @@ public class Defines implements Truth {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Defines createWithMap(Map<String, String> init) {
|
private static Defines createWithMap(Map<String, String> init) {
|
||||||
final Defines result = createEmpty();
|
final Defines result = createEmpty();
|
||||||
for (Map.Entry<String, String> ent : init.entrySet()) {
|
for (Map.Entry<String, String> ent : init.entrySet()) {
|
||||||
result.environment.put(ent.getKey(), ent.getValue());
|
result.environment.put(ent.getKey(), ent.getValue());
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class GanttConstraint extends WithLinkType {
|
||||||
}
|
}
|
||||||
|
|
||||||
public UDrawable getUDrawable(TimeScale timeScale, ToTaskDraw toTaskDraw) {
|
public UDrawable getUDrawable(TimeScale timeScale, ToTaskDraw toTaskDraw) {
|
||||||
Style style = styleBuilder.getMergedStyle(getStyleSignature()).eventuallyOverride(PName.LineColor,
|
Style style = getStyleSignature().getMergedStyle(styleBuilder).eventuallyOverride(PName.LineColor,
|
||||||
getSpecificColor());
|
getSpecificColor());
|
||||||
style = style.eventuallyOverride(getType().getStroke3(style.getStroke()));
|
style = style.eventuallyOverride(getType().getStroke3(style.getStroke()));
|
||||||
return new GanttArrow(colorSet, style, timeScale, source, dest, toTaskDraw, styleBuilder);
|
return new GanttArrow(colorSet, style, timeScale, source, dest, toTaskDraw, styleBuilder);
|
||||||
|
|
|
@ -90,10 +90,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLoadAt(Day instant) {
|
public int getLoadAt(Day instant) {
|
||||||
if (pausedDay.contains(instant)) {
|
if (isPaused(instant)) {
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (pausedDayOfWeek(instant)) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +101,16 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable {
|
||||||
return result.getLoadAt(instant);
|
return result.getLoadAt(instant);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isPaused(Day instant) {
|
||||||
|
if (pausedDay.contains(instant)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (pausedDayOfWeek(instant)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean pausedDayOfWeek(Day instant) {
|
private boolean pausedDayOfWeek(Day instant) {
|
||||||
for (DayOfWeek dayOfWeek : pausedDayOfWeek) {
|
for (DayOfWeek dayOfWeek : pausedDayOfWeek) {
|
||||||
if (instant.getDayOfWeek() == dayOfWeek) {
|
if (instant.getDayOfWeek() == dayOfWeek) {
|
||||||
|
@ -116,6 +123,9 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable {
|
||||||
public int loadForResource(Resource res, Day instant) {
|
public int loadForResource(Resource res, Day instant) {
|
||||||
if (resources.keySet().contains(res) && instant.compareTo(getStart()) >= 0
|
if (resources.keySet().contains(res) && instant.compareTo(getStart()) >= 0
|
||||||
&& instant.compareTo(getEnd()) <= 0) {
|
&& instant.compareTo(getEnd()) <= 0) {
|
||||||
|
if (isPaused(instant)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (res.isClosedAt(instant)) {
|
if (res.isClosedAt(instant)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +252,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable {
|
||||||
if (colors.length == 1) {
|
if (colors.length == 1) {
|
||||||
return colors[0];
|
return colors[0];
|
||||||
}
|
}
|
||||||
return colors[0].linearTo(colors[1], completion);
|
return colors[0].unlinearTo(colors[1], completion);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getCompletion() {
|
public final int getCompletion() {
|
||||||
|
|
|
@ -50,17 +50,19 @@ import net.sourceforge.plantuml.project.timescale.TimeScale;
|
||||||
import net.sourceforge.plantuml.real.Real;
|
import net.sourceforge.plantuml.real.Real;
|
||||||
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
|
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
|
||||||
import net.sourceforge.plantuml.style.PName;
|
import net.sourceforge.plantuml.style.PName;
|
||||||
|
import net.sourceforge.plantuml.style.SName;
|
||||||
import net.sourceforge.plantuml.style.Style;
|
import net.sourceforge.plantuml.style.Style;
|
||||||
import net.sourceforge.plantuml.style.StyleBuilder;
|
import net.sourceforge.plantuml.style.StyleBuilder;
|
||||||
import net.sourceforge.plantuml.style.StyleSignature;
|
import net.sourceforge.plantuml.style.StyleSignature;
|
||||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||||
import net.sourceforge.plantuml.ugraphic.color.HColorSet;
|
import net.sourceforge.plantuml.ugraphic.color.HColorSet;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
||||||
|
|
||||||
public abstract class AbstractTaskDraw implements TaskDraw {
|
public abstract class AbstractTaskDraw implements TaskDraw {
|
||||||
|
|
||||||
private CenterBorderColor colors;
|
private CenterBorderColor colors;
|
||||||
|
|
||||||
protected int completion = 100;
|
private int completion = 100;
|
||||||
protected Url url;
|
protected Url url;
|
||||||
protected Display note;
|
protected Display note;
|
||||||
protected final TimeScale timeScale;
|
protected final TimeScale timeScale;
|
||||||
|
@ -98,13 +100,24 @@ public abstract class AbstractTaskDraw implements TaskDraw {
|
||||||
|
|
||||||
abstract StyleSignature getStyleSignature();
|
abstract StyleSignature getStyleSignature();
|
||||||
|
|
||||||
|
private StyleSignature getStyleSignatureUnstarted() {
|
||||||
|
return StyleSignature.of(SName.root, SName.element, SName.ganttDiagram, SName.unstartedTask);
|
||||||
|
}
|
||||||
|
|
||||||
final protected HColor getLineColor() {
|
final protected HColor getLineColor() {
|
||||||
return getStyle().value(PName.LineColor).asColor(getStyleBuilder().getSkinParam().getThemeStyle(), colorSet);
|
final HColor unstarted = getStyleSignatureUnstarted().getMergedStyle(styleBuilder).value(PName.LineColor)
|
||||||
|
.asColor(getStyleBuilder().getSkinParam().getThemeStyle(), colorSet);
|
||||||
|
final HColor regular = getStyle().value(PName.LineColor)
|
||||||
|
.asColor(getStyleBuilder().getSkinParam().getThemeStyle(), colorSet);
|
||||||
|
return HColorUtils.unlinear(unstarted, regular, completion);
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected HColor getBackgroundColor() {
|
final protected HColor getBackgroundColor() {
|
||||||
return getStyle().value(PName.BackGroundColor).asColor(getStyleBuilder().getSkinParam().getThemeStyle(),
|
final HColor unstarted = getStyleSignatureUnstarted().getMergedStyle(styleBuilder).value(PName.BackGroundColor)
|
||||||
colorSet);
|
.asColor(getStyleBuilder().getSkinParam().getThemeStyle(), colorSet);
|
||||||
|
final HColor regular = getStyle().value(PName.BackGroundColor)
|
||||||
|
.asColor(getStyleBuilder().getSkinParam().getThemeStyle(), colorSet);
|
||||||
|
return HColorUtils.unlinear(unstarted, regular, completion);
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected FontConfiguration getFontConfiguration() {
|
final protected FontConfiguration getFontConfiguration() {
|
||||||
|
@ -178,4 +191,8 @@ public abstract class AbstractTaskDraw implements TaskDraw {
|
||||||
return colors;
|
return colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected int getCompletion() {
|
||||||
|
return completion;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,7 +295,7 @@ public class TaskDrawRegular extends AbstractTaskDraw {
|
||||||
.getMergedStyle(getStyleBuilder()).value(PName.BackGroundColor)
|
.getMergedStyle(getStyleBuilder()).value(PName.BackGroundColor)
|
||||||
.asColor(skinParam.getThemeStyle(), getColorSet());
|
.asColor(skinParam.getThemeStyle(), getColorSet());
|
||||||
|
|
||||||
final RectangleTask rectangleTask = new RectangleTask(startPos, endPos, round, completion, off);
|
final RectangleTask rectangleTask = new RectangleTask(startPos, endPos, round, getCompletion(), off);
|
||||||
|
|
||||||
rectangleTask.draw(ug, getShapeHeight(stringBounder), back2, oddStart, oddEnd);
|
rectangleTask.draw(ug, getShapeHeight(stringBounder), back2, oddStart, oddEnd);
|
||||||
|
|
||||||
|
@ -333,10 +333,10 @@ public class TaskDrawRegular extends AbstractTaskDraw {
|
||||||
ug.apply(UTranslate.dx(startPos)).draw(PathUtils.UtoLeft(fullLength, getShapeHeight(stringBounder), round));
|
ug.apply(UTranslate.dx(startPos)).draw(PathUtils.UtoLeft(fullLength, getShapeHeight(stringBounder), round));
|
||||||
} else {
|
} else {
|
||||||
final URectangle full = new URectangle(fullLength, getShapeHeight(stringBounder)).rounded(round);
|
final URectangle full = new URectangle(fullLength, getShapeHeight(stringBounder)).rounded(round);
|
||||||
if (completion == 100) {
|
if (getCompletion() == 100) {
|
||||||
ug.apply(UTranslate.dx(startPos)).draw(full);
|
ug.apply(UTranslate.dx(startPos)).draw(full);
|
||||||
} else {
|
} else {
|
||||||
final double partialLength = fullLength * completion / 100.;
|
final double partialLength = fullLength * getCompletion() / 100.;
|
||||||
ug.apply(UTranslate.dx(startPos)).apply(HColorUtils.WHITE).apply(HColorUtils.WHITE.bg()).draw(full);
|
ug.apply(UTranslate.dx(startPos)).apply(HColorUtils.WHITE).apply(HColorUtils.WHITE.bg()).draw(full);
|
||||||
if (partialLength > 2) {
|
if (partialLength > 2) {
|
||||||
final URectangle partial = new URectangle(partialLength, getShapeHeight(stringBounder))
|
final URectangle partial = new URectangle(partialLength, getShapeHeight(stringBounder))
|
||||||
|
|
|
@ -80,16 +80,9 @@ public class CenterBorderColor {
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CenterBorderColor linearTo(CenterBorderColor other, int completion) {
|
public CenterBorderColor unlinearTo(CenterBorderColor other, int completion) {
|
||||||
if (completion == 0) {
|
final HColor newCenter = HColorUtils.unlinear(this.center, other.center, completion);
|
||||||
return this;
|
final HColor newBorder = HColorUtils.unlinear(this.border, other.border, completion);
|
||||||
}
|
|
||||||
if (completion == 100) {
|
|
||||||
return other;
|
|
||||||
}
|
|
||||||
|
|
||||||
final HColor newCenter = HColorUtils.linear(this.center, other.center, completion);
|
|
||||||
final HColor newBorder = HColorUtils.linear(this.border, other.border, completion);
|
|
||||||
|
|
||||||
return new CenterBorderColor(newCenter, newBorder, style);
|
return new CenterBorderColor(newCenter, newBorder, style);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,17 +55,27 @@ public enum Month {
|
||||||
if (locale == Locale.ENGLISH)
|
if (locale == Locale.ENGLISH)
|
||||||
return longName(locale).substring(0, 3);
|
return longName(locale).substring(0, 3);
|
||||||
|
|
||||||
return StringUtils.capitalize(
|
return StringUtils.capitalize(getJavaTimeMonth().getDisplayName(TextStyle.SHORT_STANDALONE, locale));
|
||||||
java.time.Month.valueOf(this.toString()).getDisplayName(TextStyle.SHORT_STANDALONE, locale));
|
}
|
||||||
|
|
||||||
|
private java.time.Month getJavaTimeMonth() {
|
||||||
|
return java.time.Month.valueOf(this.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String longName(Locale locale) {
|
public String longName(Locale locale) {
|
||||||
if (locale == Locale.ENGLISH)
|
if (locale == Locale.ENGLISH)
|
||||||
return StringUtils.capitalize(name());
|
return StringUtils.capitalize(name());
|
||||||
|
|
||||||
return StringUtils
|
final java.time.Month javaTimeMonth = getJavaTimeMonth();
|
||||||
.capitalize(java.time.Month.valueOf(this.toString()).getDisplayName(TextStyle.FULL_STANDALONE, locale));
|
final String v1 = javaTimeMonth.getDisplayName(TextStyle.FULL_STANDALONE, locale);
|
||||||
|
final String v2 = javaTimeMonth.getDisplayName(TextStyle.FULL, locale);
|
||||||
|
return StringUtils.capitalize(longest(v1, v2));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String longest(String v1, String v2) {
|
||||||
|
if (v1.length() > v2.length())
|
||||||
|
return v1;
|
||||||
|
return v2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public String getRegexString() {
|
static public String getRegexString() {
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
|
||||||
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
|
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
|
||||||
RegexLeaf.spaceZeroOrMore(), //
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
new RegexLeaf("MESSAGE", "(?::[%s]*(.*))?"), //
|
new RegexLeaf("MESSAGE", "(?::[%s]*(.*))?"), //
|
||||||
RegexLeaf.end());
|
RegexLeaf.end()).protectSize(2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Participant> getMulticasts(SequenceDiagram system, RegexResult arg2) {
|
private List<Participant> getMulticasts(SequenceDiagram system, RegexResult arg2) {
|
||||||
|
|
|
@ -41,6 +41,7 @@ import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ColorParam;
|
||||||
import net.sourceforge.plantuml.ISkinParam;
|
import net.sourceforge.plantuml.ISkinParam;
|
||||||
import net.sourceforge.plantuml.SkinParamBackcolored;
|
import net.sourceforge.plantuml.SkinParamBackcolored;
|
||||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
@ -123,10 +124,13 @@ public class LiveBoxesDrawer {
|
||||||
private void drawInternal(UGraphic ug, double ya, double yb, ComponentType type) {
|
private void drawInternal(UGraphic ug, double ya, double yb, ComponentType type) {
|
||||||
final double width = getWidth(ug.getStringBounder());
|
final double width = getWidth(ug.getStringBounder());
|
||||||
final Area area = new Area(width, yb - ya);
|
final Area area = new Area(width, yb - ya);
|
||||||
ISkinParam skinParam2 = new SkinParamBackcolored(skinParam,
|
SkinParamBackcolored skinParam2 = new SkinParamBackcolored(skinParam,
|
||||||
symbolContext == null ? null : symbolContext.getBackColor());
|
symbolContext == null ? null : symbolContext.getBackColor());
|
||||||
Style style = type.getDefaultStyleDefinition().getMergedStyle(skinParam.getCurrentStyleBuilder());
|
Style style = type.getDefaultStyleDefinition().getMergedStyle(skinParam.getCurrentStyleBuilder());
|
||||||
if (style != null) {
|
if (style == null) {
|
||||||
|
if (symbolContext != null)
|
||||||
|
skinParam2.forceColor(ColorParam.sequenceLifeLineBorder, symbolContext.getForeColor());
|
||||||
|
} else {
|
||||||
style = style.eventuallyOverride(symbolContext);
|
style = style.eventuallyOverride(symbolContext);
|
||||||
}
|
}
|
||||||
final Component comp = skin.createComponent(new Style[] { style }, type, null, skinParam2, null);
|
final Component comp = skin.createComponent(new Style[] { style }, type, null, skinParam2, null);
|
||||||
|
|
|
@ -95,8 +95,8 @@ public class ReferenceTile extends AbstractTile implements Tile {
|
||||||
strings = strings.add("ref");
|
strings = strings.add("ref");
|
||||||
strings = strings.addAll(reference.getStrings());
|
strings = strings.addAll(reference.getStrings());
|
||||||
|
|
||||||
final Component comp = tileArguments.getSkin().createComponent(null, ComponentType.REFERENCE, null,
|
final Component comp = tileArguments.getSkin().createComponent(reference.getUsedStyles(),
|
||||||
tileArguments.getSkinParam(), strings);
|
ComponentType.REFERENCE, null, tileArguments.getSkinParam(), strings);
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,9 @@ import net.sourceforge.plantuml.style.PName;
|
||||||
import net.sourceforge.plantuml.style.Style;
|
import net.sourceforge.plantuml.style.Style;
|
||||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UPath;
|
||||||
import net.sourceforge.plantuml.ugraphic.URectangle;
|
import net.sourceforge.plantuml.ugraphic.URectangle;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UShape;
|
||||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||||
|
@ -62,12 +64,15 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent {
|
||||||
|
|
||||||
private final HColor groupBorder;
|
private final HColor groupBorder;
|
||||||
private final HColor backgroundColor;
|
private final HColor backgroundColor;
|
||||||
|
private final double roundCorner;
|
||||||
|
|
||||||
public ComponentRoseGroupingElse(Style style, HColor groupBorder, FontConfiguration smallFont, CharSequence comment,
|
public ComponentRoseGroupingElse(Style style, HColor groupBorder, FontConfiguration smallFont, CharSequence comment,
|
||||||
ISkinSimple spriteContainer, HColor backgroundColor) {
|
ISkinSimple spriteContainer, HColor backgroundColor, double roundCorner) {
|
||||||
super(style, LineBreakStrategy.NONE, comment == null ? null : "[" + comment + "]", smallFont,
|
super(style, LineBreakStrategy.NONE, comment == null ? null : "[" + comment + "]", smallFont,
|
||||||
HorizontalAlignment.LEFT, 5, 5, 1, spriteContainer, null, null);
|
HorizontalAlignment.LEFT, 5, 5, 1, spriteContainer, null, null);
|
||||||
|
|
||||||
if (UseStyle.useBetaStyle()) {
|
if (UseStyle.useBetaStyle()) {
|
||||||
|
this.roundCorner = style.value(PName.RoundCorner).asInt();
|
||||||
if (spriteContainer instanceof SkinParamBackcolored) {
|
if (spriteContainer instanceof SkinParamBackcolored) {
|
||||||
style = style.eventuallyOverride(PName.BackGroundColor,
|
style = style.eventuallyOverride(PName.BackGroundColor,
|
||||||
((SkinParamBackcolored) spriteContainer).getBackgroundColor(false));
|
((SkinParamBackcolored) spriteContainer).getBackgroundColor(false));
|
||||||
|
@ -77,6 +82,7 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent {
|
||||||
this.backgroundColor = style.value(PName.BackGroundColor).asColor(spriteContainer.getThemeStyle(),
|
this.backgroundColor = style.value(PName.BackGroundColor).asColor(spriteContainer.getThemeStyle(),
|
||||||
getIHtmlColorSet());
|
getIHtmlColorSet());
|
||||||
} else {
|
} else {
|
||||||
|
this.roundCorner = roundCorner;
|
||||||
this.groupBorder = groupBorder;
|
this.groupBorder = groupBorder;
|
||||||
this.backgroundColor = backgroundColor;
|
this.backgroundColor = backgroundColor;
|
||||||
}
|
}
|
||||||
|
@ -88,8 +94,27 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Dimension2D dimensionToUse = area.getDimensionToUse();
|
final Dimension2D dimensionToUse = area.getDimensionToUse();
|
||||||
final URectangle rect = new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight());
|
ug = ug.apply(new HColorNone()).apply(backgroundColor.bg());
|
||||||
ug.apply(new HColorNone()).apply(backgroundColor.bg()).draw(rect);
|
final double width = dimensionToUse.getWidth();
|
||||||
|
final double height = dimensionToUse.getHeight();
|
||||||
|
final UShape rect;
|
||||||
|
if (roundCorner == 0) {
|
||||||
|
rect = new URectangle(width, height);
|
||||||
|
} else {
|
||||||
|
final UPath path = new UPath();
|
||||||
|
path.moveTo(0, 0);
|
||||||
|
path.lineTo(width, 0);
|
||||||
|
|
||||||
|
path.lineTo(width, height - roundCorner / 2);
|
||||||
|
path.arcTo(roundCorner / 2, roundCorner / 2, 0, 0, 1, width - roundCorner / 2, height);
|
||||||
|
|
||||||
|
path.lineTo(roundCorner / 2, height);
|
||||||
|
path.arcTo(roundCorner / 2, roundCorner / 2, 0, 0, 1, 0, height - roundCorner / 2);
|
||||||
|
|
||||||
|
path.lineTo(0, 0);
|
||||||
|
rect = path;
|
||||||
|
}
|
||||||
|
ug.draw(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -199,6 +199,9 @@ public class ComponentRoseGroupingHeader extends AbstractTextualComponent {
|
||||||
|
|
||||||
polygon.lineTo(0, height);
|
polygon.lineTo(0, height);
|
||||||
polygon.lineTo(0, roundCorner / 2);
|
polygon.lineTo(0, roundCorner / 2);
|
||||||
|
|
||||||
|
polygon.arcTo(roundCorner / 2, roundCorner / 2, 0, 0, 1, roundCorner / 2, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
return polygon;
|
return polygon;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,10 @@ import net.sourceforge.plantuml.graphic.SymbolContext;
|
||||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
import net.sourceforge.plantuml.skin.AbstractTextualComponent;
|
import net.sourceforge.plantuml.skin.AbstractTextualComponent;
|
||||||
import net.sourceforge.plantuml.skin.Area;
|
import net.sourceforge.plantuml.skin.Area;
|
||||||
|
import net.sourceforge.plantuml.style.PName;
|
||||||
import net.sourceforge.plantuml.style.Style;
|
import net.sourceforge.plantuml.style.Style;
|
||||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
import net.sourceforge.plantuml.ugraphic.UPolygon;
|
import net.sourceforge.plantuml.ugraphic.UPath;
|
||||||
import net.sourceforge.plantuml.ugraphic.URectangle;
|
import net.sourceforge.plantuml.ugraphic.URectangle;
|
||||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
@ -65,6 +66,7 @@ public class ComponentRoseReference extends AbstractTextualComponent {
|
||||||
private final HorizontalAlignment position;
|
private final HorizontalAlignment position;
|
||||||
private final SymbolContext symbolContextHeader;
|
private final SymbolContext symbolContextHeader;
|
||||||
private final SymbolContext symbolContextBody;
|
private final SymbolContext symbolContextBody;
|
||||||
|
private int roundCorner;
|
||||||
|
|
||||||
public ComponentRoseReference(Style style, Style styleHeader, FontConfiguration font, SymbolContext symbolContext,
|
public ComponentRoseReference(Style style, Style styleHeader, FontConfiguration font, SymbolContext symbolContext,
|
||||||
FontConfiguration fcHeader, Display stringsToDisplay, HorizontalAlignment position,
|
FontConfiguration fcHeader, Display stringsToDisplay, HorizontalAlignment position,
|
||||||
|
@ -75,6 +77,7 @@ public class ComponentRoseReference extends AbstractTextualComponent {
|
||||||
this.symbolContextHeader = styleHeader.getSymbolContext(spriteContainer.getThemeStyle(),
|
this.symbolContextHeader = styleHeader.getSymbolContext(spriteContainer.getThemeStyle(),
|
||||||
getIHtmlColorSet());
|
getIHtmlColorSet());
|
||||||
this.symbolContextBody = style.getSymbolContext(spriteContainer.getThemeStyle(), getIHtmlColorSet());
|
this.symbolContextBody = style.getSymbolContext(spriteContainer.getThemeStyle(), getIHtmlColorSet());
|
||||||
|
this.roundCorner = style.value(PName.RoundCorner).asInt();
|
||||||
fcHeader = styleHeader.getFontConfiguration(spriteContainer.getThemeStyle(), getIHtmlColorSet());
|
fcHeader = styleHeader.getFontConfiguration(spriteContainer.getThemeStyle(), getIHtmlColorSet());
|
||||||
this.position = style.getHorizontalAlignment();
|
this.position = style.getHorizontalAlignment();
|
||||||
} else {
|
} else {
|
||||||
|
@ -94,25 +97,40 @@ public class ComponentRoseReference extends AbstractTextualComponent {
|
||||||
final int textHeaderWidth = (int) (getHeaderWidth(stringBounder));
|
final int textHeaderWidth = (int) (getHeaderWidth(stringBounder));
|
||||||
final int textHeaderHeight = (int) (getHeaderHeight(stringBounder));
|
final int textHeaderHeight = (int) (getHeaderHeight(stringBounder));
|
||||||
|
|
||||||
final URectangle rect = new URectangle(
|
URectangle rect = new URectangle(dimensionToUse.getWidth() - xMargin * 2 - symbolContextBody.getDeltaShadow(),
|
||||||
dimensionToUse.getWidth() - xMargin * 2 - symbolContextHeader.getDeltaShadow(),
|
|
||||||
dimensionToUse.getHeight() - heightFooter);
|
dimensionToUse.getHeight() - heightFooter);
|
||||||
rect.setDeltaShadow(symbolContextHeader.getDeltaShadow());
|
if (this.roundCorner != 0) {
|
||||||
|
rect = rect.rounded(this.roundCorner);
|
||||||
|
}
|
||||||
|
rect.setDeltaShadow(symbolContextBody.getDeltaShadow());
|
||||||
ug = symbolContextBody.apply(ug);
|
ug = symbolContextBody.apply(ug);
|
||||||
ug.apply(UTranslate.dx(xMargin)).draw(rect);
|
ug.apply(UTranslate.dx(xMargin)).draw(rect);
|
||||||
|
|
||||||
final UPolygon polygon = new UPolygon();
|
final UPath corner = new UPath();
|
||||||
polygon.addPoint(0, 0);
|
if (this.roundCorner == 0) {
|
||||||
polygon.addPoint(textHeaderWidth, 0);
|
corner.moveTo(0, 0);
|
||||||
|
corner.lineTo(textHeaderWidth, 0);
|
||||||
|
|
||||||
polygon.addPoint(textHeaderWidth, textHeaderHeight - cornersize);
|
corner.lineTo(textHeaderWidth, textHeaderHeight - cornersize);
|
||||||
polygon.addPoint(textHeaderWidth - cornersize, textHeaderHeight);
|
corner.lineTo(textHeaderWidth - cornersize, textHeaderHeight);
|
||||||
|
|
||||||
polygon.addPoint(0, textHeaderHeight);
|
corner.lineTo(0, textHeaderHeight);
|
||||||
polygon.addPoint(0, 0);
|
corner.lineTo(0, 0);
|
||||||
|
} else {
|
||||||
|
corner.moveTo(this.roundCorner / 2, 0);
|
||||||
|
corner.lineTo(textHeaderWidth, 0);
|
||||||
|
|
||||||
|
corner.lineTo(textHeaderWidth, textHeaderHeight - cornersize);
|
||||||
|
corner.lineTo(textHeaderWidth - cornersize, textHeaderHeight);
|
||||||
|
|
||||||
|
corner.lineTo(0, textHeaderHeight);
|
||||||
|
corner.lineTo(0, this.roundCorner / 2);
|
||||||
|
|
||||||
|
corner.arcTo(this.roundCorner / 2, this.roundCorner / 2, 0, 0, 1, this.roundCorner / 2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
ug = symbolContextHeader.apply(ug);
|
ug = symbolContextHeader.apply(ug);
|
||||||
ug.apply(UTranslate.dx(xMargin)).draw(polygon);
|
ug.apply(UTranslate.dx(xMargin)).draw(corner);
|
||||||
|
|
||||||
ug = ug.apply(new UStroke());
|
ug = ug.apply(new UStroke());
|
||||||
|
|
||||||
|
@ -148,7 +166,7 @@ public class ComponentRoseReference extends AbstractTextualComponent {
|
||||||
@Override
|
@Override
|
||||||
public double getPreferredWidth(StringBounder stringBounder) {
|
public double getPreferredWidth(StringBounder stringBounder) {
|
||||||
return Math.max(getTextWidth(stringBounder), getHeaderWidth(stringBounder)) + xMargin * 2
|
return Math.max(getTextWidth(stringBounder), getHeaderWidth(stringBounder)) + xMargin * 2
|
||||||
+ symbolContextHeader.getDeltaShadow();
|
+ symbolContextBody.getDeltaShadow();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,7 +293,7 @@ public class Rose {
|
||||||
return new ComponentRoseGroupingElse(styles == null ? null : styles[0],
|
return new ComponentRoseGroupingElse(styles == null ? null : styles[0],
|
||||||
getHtmlColor(param, stereotype, ColorParam.sequenceGroupBorder),
|
getHtmlColor(param, stereotype, ColorParam.sequenceGroupBorder),
|
||||||
getUFont2(param, FontParam.SEQUENCE_GROUP), stringsToDisplay.get(0), param,
|
getUFont2(param, FontParam.SEQUENCE_GROUP), stringsToDisplay.get(0), param,
|
||||||
param.getBackgroundColor(true));
|
param.getBackgroundColor(true), roundCorner);
|
||||||
}
|
}
|
||||||
if (type == ComponentType.GROUPING_SPACE) {
|
if (type == ComponentType.GROUPING_SPACE) {
|
||||||
return new ComponentRoseGroupingSpace(7);
|
return new ComponentRoseGroupingSpace(7);
|
||||||
|
|
|
@ -59,6 +59,7 @@ public enum SName {
|
||||||
collections, //
|
collections, //
|
||||||
component, //
|
component, //
|
||||||
componentDiagram, //
|
componentDiagram, //
|
||||||
|
constraintArrow, //
|
||||||
control, //
|
control, //
|
||||||
database, //
|
database, //
|
||||||
delay, //
|
delay, //
|
||||||
|
@ -109,7 +110,9 @@ public enum SName {
|
||||||
swimlane, //
|
swimlane, //
|
||||||
task, //
|
task, //
|
||||||
timeline, //
|
timeline, //
|
||||||
|
timingDiagram, //
|
||||||
title, //
|
title, //
|
||||||
|
unstartedTask, //
|
||||||
usecase, //
|
usecase, //
|
||||||
wbsDiagram, //
|
wbsDiagram, //
|
||||||
yamlDiagram; //
|
yamlDiagram; //
|
||||||
|
|
|
@ -68,6 +68,18 @@ public class Style {
|
||||||
this.signature = signature;
|
this.signature = signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Style deltaPriority(int delta) {
|
||||||
|
if (signature.isStarred() == false) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
final EnumMap<PName, Value> copy = new EnumMap<PName, Value>(PName.class);
|
||||||
|
for (Entry<PName, Value> ent : this.map.entrySet()) {
|
||||||
|
copy.put(ent.getKey(), new ValueDeltaPriority(ent.getValue(), delta));
|
||||||
|
}
|
||||||
|
return new Style(this.signature, copy);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void printMe() {
|
public void printMe() {
|
||||||
if (map.size() == 0) {
|
if (map.size() == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -110,11 +122,20 @@ public class Style {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Style(this.signature.mergeWith(other.getSignature()), both);
|
return new Style(this.signature.mergeWith(other.getSignature()), both);
|
||||||
// if (this.name.equals(other.name)) {
|
}
|
||||||
// return new Style(this.kind.add(other.kind), this.name, both);
|
|
||||||
// }
|
private Style mergeIfUnknownWith(Style other) {
|
||||||
// return new Style(this.kind.add(other.kind), this.name + "," + other.name,
|
if (other == null) {
|
||||||
// both);
|
return this;
|
||||||
|
}
|
||||||
|
final EnumMap<PName, Value> both = new EnumMap<PName, Value>(this.map);
|
||||||
|
for (Entry<PName, Value> ent : other.map.entrySet()) {
|
||||||
|
final Value previous = this.map.get(ent.getKey());
|
||||||
|
if (previous == null) {
|
||||||
|
both.put(ent.getKey(), ent.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Style(this.signature.mergeWith(other.getSignature()), both);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style eventuallyOverride(PName param, HColor color) {
|
public Style eventuallyOverride(PName param, HColor color) {
|
||||||
|
|
|
@ -71,11 +71,10 @@ public class StyleBuilder implements AutomaticCounter {
|
||||||
return skinParam;
|
return skinParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public Collection<StyleSignature> getAllStyleSignatures() {
|
|
||||||
// return Collections.unmodifiableCollection(styles.keySet());
|
|
||||||
// }
|
|
||||||
|
|
||||||
public Style createStyle(String name) {
|
public Style createStyle(String name) {
|
||||||
|
if (name.contains("*")) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
name = name.toLowerCase();
|
name = name.toLowerCase();
|
||||||
final StyleSignature signature = new StyleSignature(name);
|
final StyleSignature signature = new StyleSignature(name);
|
||||||
final Style result = styles.get(signature);
|
final Style result = styles.get(signature);
|
||||||
|
@ -101,7 +100,10 @@ public class StyleBuilder implements AutomaticCounter {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void put(StyleSignature styleName, Style newStyle) {
|
public void loadInternal(StyleSignature styleName, Style newStyle) {
|
||||||
|
if (styleName.isStarred()) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
this.styles.put(styleName, newStyle);
|
this.styles.put(styleName, newStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,4 +132,29 @@ public class StyleBuilder implements AutomaticCounter {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Style getMergedStyleSpecial(StyleSignature signature, int deltaPriority) {
|
||||||
|
boolean added = this.printedForLog.add(signature);
|
||||||
|
if (added) {
|
||||||
|
Log.info("Using style " + signature);
|
||||||
|
}
|
||||||
|
Style result = null;
|
||||||
|
for (Entry<StyleSignature, Style> ent : styles.entrySet()) {
|
||||||
|
final StyleSignature key = ent.getKey();
|
||||||
|
if (key.matchAll(signature) == false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Style tmp = ent.getValue();
|
||||||
|
if (key.isStarred()) {
|
||||||
|
tmp = tmp.deltaPriority(deltaPriority);
|
||||||
|
}
|
||||||
|
if (result == null) {
|
||||||
|
result = tmp;
|
||||||
|
} else {
|
||||||
|
result = result.mergeWith(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -101,7 +101,7 @@ public class StyleLoader {
|
||||||
|
|
||||||
private void loadSkinInternal(final BlocLines lines) {
|
private void loadSkinInternal(final BlocLines lines) {
|
||||||
for (Style newStyle : getDeclaredStyles(lines, styleBuilder)) {
|
for (Style newStyle : getDeclaredStyles(lines, styleBuilder)) {
|
||||||
this.styleBuilder.put(newStyle.getSignature(), newStyle);
|
this.styleBuilder.loadInternal(newStyle.getSignature(), newStyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2020, Arnaud Roques
|
||||||
|
*
|
||||||
|
* Project Info: http://plantuml.com
|
||||||
|
*
|
||||||
|
* If you like this project or if you find it useful, you can support us at:
|
||||||
|
*
|
||||||
|
* http://plantuml.com/patreon (only 1$ per month!)
|
||||||
|
* http://plantuml.com/paypal
|
||||||
|
*
|
||||||
|
* This file is part of PlantUML.
|
||||||
|
*
|
||||||
|
* PlantUML is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* PlantUML distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Original Author: Arnaud Roques
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.style;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ThemeStyle;
|
||||||
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.color.HColorSet;
|
||||||
|
|
||||||
|
public class ValueDeltaPriority implements Value {
|
||||||
|
|
||||||
|
private final Value orig;
|
||||||
|
private final int deltaPriority;
|
||||||
|
|
||||||
|
public ValueDeltaPriority(Value orig, int deltaPriority) {
|
||||||
|
this.orig = orig;
|
||||||
|
this.deltaPriority = deltaPriority;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String asString() {
|
||||||
|
return orig.asString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HColor asColor(ThemeStyle themeStyle, HColorSet colorSet) {
|
||||||
|
return orig.asColor(themeStyle, colorSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int asInt() {
|
||||||
|
return orig.asInt();
|
||||||
|
} // TODO Auto-generated method stub
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double asDouble() {
|
||||||
|
return orig.asDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean asBoolean() {
|
||||||
|
return orig.asBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int asFontStyle() {
|
||||||
|
return orig.asFontStyle();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HorizontalAlignment asHorizontalAlignment() {
|
||||||
|
return orig.asHorizontalAlignment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority() {
|
||||||
|
return orig.getPriority() + deltaPriority;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -81,6 +81,7 @@ public class DotStringFactory implements Moveable {
|
||||||
private final UmlDiagramType umlDiagramType;
|
private final UmlDiagramType umlDiagramType;
|
||||||
private final ISkinParam skinParam;
|
private final ISkinParam skinParam;
|
||||||
private final DotMode dotMode;
|
private final DotMode dotMode;
|
||||||
|
private DotSplines dotSplines;
|
||||||
|
|
||||||
private final StringBounder stringBounder;
|
private final StringBounder stringBounder;
|
||||||
|
|
||||||
|
@ -190,12 +191,13 @@ public class DotStringFactory implements Moveable {
|
||||||
// SvekUtils.println(sb);
|
// SvekUtils.println(sb);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
final DotSplines dotSplines = skinParam.getDotSplines();
|
dotSplines = skinParam.getDotSplines();
|
||||||
if (dotSplines == DotSplines.POLYLINE) {
|
if (dotSplines == DotSplines.POLYLINE) {
|
||||||
sb.append("splines=polyline;");
|
sb.append("splines=polyline;");
|
||||||
SvekUtils.println(sb);
|
SvekUtils.println(sb);
|
||||||
} else if (dotSplines == DotSplines.ORTHO) {
|
} else if (dotSplines == DotSplines.ORTHO) {
|
||||||
sb.append("splines=ortho;");
|
sb.append("splines=ortho;");
|
||||||
|
sb.append("forcelabels=true;");
|
||||||
SvekUtils.println(sb);
|
SvekUtils.println(sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,14 +210,14 @@ public class DotStringFactory implements Moveable {
|
||||||
|
|
||||||
root.printCluster1(sb, bibliotekon.allLines(), stringBounder);
|
root.printCluster1(sb, bibliotekon.allLines(), stringBounder);
|
||||||
for (SvekLine line : bibliotekon.lines0()) {
|
for (SvekLine line : bibliotekon.lines0()) {
|
||||||
line.appendLine(getGraphvizVersion(), sb, dotMode);
|
line.appendLine(getGraphvizVersion(), sb, dotMode, dotSplines);
|
||||||
}
|
}
|
||||||
root.fillRankMin(rankMin);
|
root.fillRankMin(rankMin);
|
||||||
root.printCluster2(sb, bibliotekon.allLines(), stringBounder, dotMode, getGraphvizVersion(), umlDiagramType);
|
root.printCluster2(sb, bibliotekon.allLines(), stringBounder, dotMode, getGraphvizVersion(), umlDiagramType);
|
||||||
printMinRanking(sb);
|
printMinRanking(sb);
|
||||||
|
|
||||||
for (SvekLine line : bibliotekon.lines1()) {
|
for (SvekLine line : bibliotekon.lines1()) {
|
||||||
line.appendLine(getGraphvizVersion(), sb, dotMode);
|
line.appendLine(getGraphvizVersion(), sb, dotMode, dotSplines);
|
||||||
}
|
}
|
||||||
SvekUtils.println(sb);
|
SvekUtils.println(sb);
|
||||||
sb.append("}");
|
sb.append("}");
|
||||||
|
|
|
@ -67,6 +67,7 @@ import net.sourceforge.plantuml.cucadiagram.LinkMiddleDecor;
|
||||||
import net.sourceforge.plantuml.cucadiagram.LinkType;
|
import net.sourceforge.plantuml.cucadiagram.LinkType;
|
||||||
import net.sourceforge.plantuml.cucadiagram.NoteLinkStrategy;
|
import net.sourceforge.plantuml.cucadiagram.NoteLinkStrategy;
|
||||||
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.dot.DotSplines;
|
||||||
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
|
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
|
||||||
import net.sourceforge.plantuml.descdiagram.command.StringWithArrow;
|
import net.sourceforge.plantuml.descdiagram.command.StringWithArrow;
|
||||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||||
|
@ -338,7 +339,7 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
|
||||||
return link.getLinkArrow();
|
return link.getLinkArrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void appendLine(GraphvizVersion graphvizVersion, StringBuilder sb, DotMode dotMode) {
|
public void appendLine(GraphvizVersion graphvizVersion, StringBuilder sb, DotMode dotMode, DotSplines dotSplines) {
|
||||||
// Log.println("inverted=" + isInverted());
|
// Log.println("inverted=" + isInverted());
|
||||||
// if (isInverted()) {
|
// if (isInverted()) {
|
||||||
// sb.append(endUid);
|
// sb.append(endUid);
|
||||||
|
@ -375,7 +376,8 @@ public class SvekLine implements Moveable, Hideable, GuideLine {
|
||||||
sb.append("color=\"" + DotStringFactory.sharp000000(lineColor) + "\"");
|
sb.append("color=\"" + DotStringFactory.sharp000000(lineColor) + "\"");
|
||||||
if (hasNoteLabelText() || link.getLinkConstraint() != null) {
|
if (hasNoteLabelText() || link.getLinkConstraint() != null) {
|
||||||
sb.append(",");
|
sb.append(",");
|
||||||
if (graphvizVersion.useXLabelInsteadOfLabel() || dotMode == DotMode.NO_LEFT_RIGHT_AND_XLABEL) {
|
if (graphvizVersion.useXLabelInsteadOfLabel() || dotMode == DotMode.NO_LEFT_RIGHT_AND_XLABEL
|
||||||
|
|| dotSplines == DotSplines.ORTHO) {
|
||||||
sb.append("xlabel=<");
|
sb.append("xlabel=<");
|
||||||
} else {
|
} else {
|
||||||
sb.append("label=<");
|
sb.append("label=<");
|
||||||
|
|
|
@ -35,17 +35,22 @@
|
||||||
*/
|
*/
|
||||||
package net.sourceforge.plantuml.swing;
|
package net.sourceforge.plantuml.swing;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.GeneratedImage;
|
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainPngBuilder;
|
||||||
import net.sourceforge.plantuml.ImageSelection;
|
|
||||||
import net.sourceforge.plantuml.graphic.GraphicStrings;
|
|
||||||
import net.sourceforge.plantuml.security.ImageIO;
|
|
||||||
import net.sourceforge.plantuml.security.SFile;
|
|
||||||
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
|
|
||||||
import net.sourceforge.plantuml.version.PSystemVersion;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.*;
|
import java.awt.Dimension;
|
||||||
import java.awt.event.*;
|
import java.awt.Image;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyAdapter;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseMotionAdapter;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -53,7 +58,24 @@ import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainPngBuilder;
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollBar;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.ListModel;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.WindowConstants;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.GeneratedImage;
|
||||||
|
import net.sourceforge.plantuml.ImageSelection;
|
||||||
|
import net.sourceforge.plantuml.graphic.GraphicStrings;
|
||||||
|
import net.sourceforge.plantuml.security.ImageIO;
|
||||||
|
import net.sourceforge.plantuml.security.SFile;
|
||||||
|
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
|
||||||
|
import net.sourceforge.plantuml.version.PSystemVersion;
|
||||||
|
|
||||||
class ImageWindow extends JFrame {
|
class ImageWindow extends JFrame {
|
||||||
|
|
||||||
|
|
|
@ -35,27 +35,56 @@
|
||||||
*/
|
*/
|
||||||
package net.sourceforge.plantuml.swing;
|
package net.sourceforge.plantuml.swing;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.DirWatcher2;
|
import java.awt.BorderLayout;
|
||||||
import net.sourceforge.plantuml.GeneratedImage;
|
import java.awt.Frame;
|
||||||
import net.sourceforge.plantuml.Log;
|
import java.awt.event.ActionEvent;
|
||||||
import net.sourceforge.plantuml.Option;
|
import java.awt.event.ActionListener;
|
||||||
import net.sourceforge.plantuml.version.PSystemVersion;
|
import java.awt.event.FocusEvent;
|
||||||
|
import java.awt.event.FocusListener;
|
||||||
import javax.swing.Timer;
|
import java.awt.event.KeyAdapter;
|
||||||
import javax.swing.*;
|
import java.awt.event.KeyEvent;
|
||||||
import javax.swing.border.CompoundBorder;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.*;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.*;
|
import java.awt.event.MouseListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.*;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.Vector;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.ListModel;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.Timer;
|
||||||
|
import javax.swing.border.CompoundBorder;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.DirWatcher2;
|
||||||
|
import net.sourceforge.plantuml.GeneratedImage;
|
||||||
|
import net.sourceforge.plantuml.Log;
|
||||||
|
import net.sourceforge.plantuml.Option;
|
||||||
|
import net.sourceforge.plantuml.version.PSystemVersion;
|
||||||
|
|
||||||
public class MainWindow extends JFrame {
|
public class MainWindow extends JFrame {
|
||||||
|
|
||||||
final private static Preferences prefs = Preferences.userNodeForPackage(MainWindow.class);
|
final private static Preferences prefs = Preferences.userNodeForPackage(MainWindow.class);
|
||||||
|
|
|
@ -45,12 +45,19 @@ import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
|
import net.sourceforge.plantuml.style.PName;
|
||||||
|
import net.sourceforge.plantuml.style.SName;
|
||||||
|
import net.sourceforge.plantuml.style.Style;
|
||||||
|
import net.sourceforge.plantuml.style.StyleBuilder;
|
||||||
|
import net.sourceforge.plantuml.style.StyleSignature;
|
||||||
import net.sourceforge.plantuml.timingdiagram.graphic.TimeArrow;
|
import net.sourceforge.plantuml.timingdiagram.graphic.TimeArrow;
|
||||||
import net.sourceforge.plantuml.ugraphic.UFont;
|
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||||
import net.sourceforge.plantuml.ugraphic.UPolygon;
|
import net.sourceforge.plantuml.ugraphic.UPolygon;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||||
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
||||||
|
|
||||||
public class TimeConstraint {
|
public class TimeConstraint {
|
||||||
|
@ -59,12 +66,14 @@ public class TimeConstraint {
|
||||||
private final TimeTick tick2;
|
private final TimeTick tick2;
|
||||||
private final Display label;
|
private final Display label;
|
||||||
private final ISkinParam skinParam;
|
private final ISkinParam skinParam;
|
||||||
|
private final StyleBuilder styleBuilder;
|
||||||
|
|
||||||
public TimeConstraint(TimeTick tick1, TimeTick tick2, String label, ISkinParam skinParam) {
|
public TimeConstraint(TimeTick tick1, TimeTick tick2, String label, ISkinParam skinParam) {
|
||||||
this.tick1 = Objects.requireNonNull(tick1);
|
this.tick1 = Objects.requireNonNull(tick1);
|
||||||
this.tick2 = Objects.requireNonNull(tick2);
|
this.tick2 = Objects.requireNonNull(tick2);
|
||||||
this.label = Display.getWithNewlines(label);
|
this.label = Display.getWithNewlines(label);
|
||||||
this.skinParam = skinParam;
|
this.skinParam = skinParam;
|
||||||
|
this.styleBuilder = skinParam.getCurrentStyleBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final TimeTick getTick1() {
|
public final TimeTick getTick1() {
|
||||||
|
@ -89,11 +98,12 @@ public class TimeConstraint {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawU(UGraphic ug, TimingRuler ruler) {
|
public void drawU(UGraphic ug, TimingRuler ruler) {
|
||||||
ug = ug.apply(HColorUtils.RED).apply(HColorUtils.RED.bg());
|
final HColor arrowColor = getArrowColor();
|
||||||
|
ug = ug.apply(arrowColor).apply(arrowColor.bg());
|
||||||
final double x1 = ruler.getPosInPixel(tick1);
|
final double x1 = ruler.getPosInPixel(tick1);
|
||||||
final double x2 = ruler.getPosInPixel(tick2);
|
final double x2 = ruler.getPosInPixel(tick2);
|
||||||
ug = ug.apply(UTranslate.dx(x1));
|
ug = ug.apply(UTranslate.dx(x1));
|
||||||
ug.draw(ULine.hline(x2 - x1));
|
ug.apply(getUStroke()).draw(ULine.hline(x2 - x1));
|
||||||
|
|
||||||
ug.draw(getPolygon(-Math.PI / 2, new Point2D.Double(0, 0)));
|
ug.draw(getPolygon(-Math.PI / 2, new Point2D.Double(0, 0)));
|
||||||
ug.draw(getPolygon(Math.PI / 2, new Point2D.Double(x2 - x1, 0)));
|
ug.draw(getPolygon(Math.PI / 2, new Point2D.Double(x2 - x1, 0)));
|
||||||
|
@ -104,6 +114,28 @@ public class TimeConstraint {
|
||||||
text.drawU(ug.apply(new UTranslate(x, -getConstraintHeight(ug.getStringBounder()))));
|
text.drawU(ug.apply(new UTranslate(x, -getConstraintHeight(ug.getStringBounder()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private HColor getArrowColor() {
|
||||||
|
if (styleBuilder == null) {
|
||||||
|
return HColorUtils.MY_RED;
|
||||||
|
}
|
||||||
|
return getStyle().value(PName.LineColor).asColor(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Style getStyle() {
|
||||||
|
return getStyleSignature().getMergedStyle(styleBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
private UStroke getUStroke() {
|
||||||
|
if (styleBuilder == null) {
|
||||||
|
return new UStroke(1.5);
|
||||||
|
}
|
||||||
|
return getStyle().getStroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
private StyleSignature getStyleSignature() {
|
||||||
|
return StyleSignature.of(SName.root, SName.element, SName.timingDiagram, SName.constraintArrow);
|
||||||
|
}
|
||||||
|
|
||||||
public double getConstraintHeight(StringBounder stringBounder) {
|
public double getConstraintHeight(StringBounder stringBounder) {
|
||||||
final TextBlock text = getTextBlock(label);
|
final TextBlock text = getTextBlock(label);
|
||||||
final Dimension2D dimText = text.calculateDimension(stringBounder);
|
final Dimension2D dimText = text.calculateDimension(stringBounder);
|
||||||
|
|
|
@ -34,10 +34,18 @@
|
||||||
*/
|
*/
|
||||||
package net.sourceforge.plantuml.timingdiagram;
|
package net.sourceforge.plantuml.timingdiagram;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.ISkinParam;
|
||||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
|
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
|
||||||
import net.sourceforge.plantuml.cucadiagram.LinkType;
|
import net.sourceforge.plantuml.cucadiagram.LinkType;
|
||||||
import net.sourceforge.plantuml.cucadiagram.WithLinkType;
|
import net.sourceforge.plantuml.cucadiagram.WithLinkType;
|
||||||
|
import net.sourceforge.plantuml.style.PName;
|
||||||
|
import net.sourceforge.plantuml.style.SName;
|
||||||
|
import net.sourceforge.plantuml.style.Style;
|
||||||
|
import net.sourceforge.plantuml.style.StyleBuilder;
|
||||||
|
import net.sourceforge.plantuml.style.StyleSignature;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||||
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
||||||
|
|
||||||
public class TimeMessage extends WithLinkType {
|
public class TimeMessage extends WithLinkType {
|
||||||
|
@ -45,15 +53,43 @@ public class TimeMessage extends WithLinkType {
|
||||||
private final TickInPlayer tickInPlayer1;
|
private final TickInPlayer tickInPlayer1;
|
||||||
private final TickInPlayer tickInPlayer2;
|
private final TickInPlayer tickInPlayer2;
|
||||||
private final Display label;
|
private final Display label;
|
||||||
|
private final ISkinParam skinParam;
|
||||||
|
private final StyleBuilder styleBuilder;
|
||||||
|
|
||||||
public TimeMessage(TickInPlayer tickInPlayer1, TickInPlayer tickInPlayer2, String label) {
|
public TimeMessage(TickInPlayer tickInPlayer1, TickInPlayer tickInPlayer2, String label, ISkinParam skinParam) {
|
||||||
|
this.skinParam = skinParam;
|
||||||
|
this.styleBuilder = skinParam.getCurrentStyleBuilder();
|
||||||
this.tickInPlayer1 = tickInPlayer1;
|
this.tickInPlayer1 = tickInPlayer1;
|
||||||
this.tickInPlayer2 = tickInPlayer2;
|
this.tickInPlayer2 = tickInPlayer2;
|
||||||
this.label = Display.getWithNewlines(label);
|
this.label = Display.getWithNewlines(label);
|
||||||
this.setSpecificColor(HColorUtils.BLUE);
|
this.setSpecificColor(getColor());
|
||||||
this.type = new LinkType(LinkDecor.NONE, LinkDecor.NONE);
|
this.type = new LinkType(LinkDecor.NONE, LinkDecor.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UStroke getUStroke() {
|
||||||
|
if (styleBuilder == null) {
|
||||||
|
return new UStroke(1.5);
|
||||||
|
}
|
||||||
|
return getStyle().getStroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
private HColor getColor() {
|
||||||
|
// return HColorUtils.BLUE;
|
||||||
|
if (styleBuilder == null) {
|
||||||
|
return HColorUtils.MY_RED;
|
||||||
|
}
|
||||||
|
return getStyle().value(PName.LineColor).asColor(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Style getStyle() {
|
||||||
|
return getStyleSignature().getMergedStyle(styleBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
private StyleSignature getStyleSignature() {
|
||||||
|
return StyleSignature.of(SName.root, SName.element, SName.timingDiagram, SName.arrow);
|
||||||
|
}
|
||||||
|
|
||||||
public final Player getPlayer1() {
|
public final Player getPlayer1() {
|
||||||
return tickInPlayer1.getPlayer();
|
return tickInPlayer1.getPlayer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,9 +97,7 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
||||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
return createImageBuilder(fileFormatOption)
|
return createImageBuilder(fileFormatOption).drawable(getTextBlock()).write(os);
|
||||||
.drawable(getTextBlock())
|
|
||||||
.write(os);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextBlockBackcolored getTextBlock() {
|
private TextBlockBackcolored getTextBlock() {
|
||||||
|
@ -311,7 +309,7 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
|
||||||
|
|
||||||
public TimeMessage createTimeMessage(Player player1, TimeTick time1, Player player2, TimeTick time2, String label) {
|
public TimeMessage createTimeMessage(Player player1, TimeTick time1, Player player2, TimeTick time2, String label) {
|
||||||
final TimeMessage message = new TimeMessage(new TickInPlayer(player1, time1), new TickInPlayer(player2, time2),
|
final TimeMessage message = new TimeMessage(new TickInPlayer(player1, time1), new TickInPlayer(player2, time2),
|
||||||
label);
|
label, getSkinParam());
|
||||||
messages.add(message);
|
messages.add(message);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@ import net.sourceforge.plantuml.ugraphic.UFont;
|
||||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||||
import net.sourceforge.plantuml.ugraphic.UPolygon;
|
import net.sourceforge.plantuml.ugraphic.UPolygon;
|
||||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
|
||||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
public class TimeArrow implements UDrawable {
|
public class TimeArrow implements UDrawable {
|
||||||
|
@ -59,8 +58,8 @@ public class TimeArrow implements UDrawable {
|
||||||
private final ISkinSimple spriteContainer;
|
private final ISkinSimple spriteContainer;
|
||||||
private final WithLinkType type;
|
private final WithLinkType type;
|
||||||
|
|
||||||
public static TimeArrow create(IntricatedPoint pt1, IntricatedPoint pt2, Display label,
|
public static TimeArrow create(IntricatedPoint pt1, IntricatedPoint pt2, Display label, ISkinSimple spriteContainer,
|
||||||
ISkinSimple spriteContainer, WithLinkType type) {
|
WithLinkType type) {
|
||||||
final TimeArrow arrow1 = new TimeArrow(pt1.getPointA(), pt2.getPointA(), label, spriteContainer, type);
|
final TimeArrow arrow1 = new TimeArrow(pt1.getPointA(), pt2.getPointA(), label, spriteContainer, type);
|
||||||
final TimeArrow arrow2 = new TimeArrow(pt1.getPointA(), pt2.getPointB(), label, spriteContainer, type);
|
final TimeArrow arrow2 = new TimeArrow(pt1.getPointA(), pt2.getPointB(), label, spriteContainer, type);
|
||||||
final TimeArrow arrow3 = new TimeArrow(pt1.getPointB(), pt2.getPointA(), label, spriteContainer, type);
|
final TimeArrow arrow3 = new TimeArrow(pt1.getPointB(), pt2.getPointA(), label, spriteContainer, type);
|
||||||
|
@ -96,7 +95,8 @@ public class TimeArrow implements UDrawable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeArrow translate(UTranslate translate) {
|
public TimeArrow translate(UTranslate translate) {
|
||||||
return new TimeArrow(translate.getTranslated(start), translate.getTranslated(end), label, spriteContainer, type);
|
return new TimeArrow(translate.getTranslated(start), translate.getTranslated(end), label, spriteContainer,
|
||||||
|
type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Point2D onCircle(Point2D pt, double alpha) {
|
public static Point2D onCircle(Point2D pt, double alpha) {
|
||||||
|
@ -114,7 +114,8 @@ public class TimeArrow implements UDrawable {
|
||||||
|
|
||||||
public void drawU(UGraphic ug) {
|
public void drawU(UGraphic ug) {
|
||||||
final double angle = getAngle();
|
final double angle = getAngle();
|
||||||
ug = ug.apply(type.getSpecificColor()).apply(type.getType().getStroke3(new UStroke()));
|
// ug = ug.apply(type.getSpecificColor()).apply(type.getType().getStroke3(new UStroke()));
|
||||||
|
ug = ug.apply(type.getSpecificColor()).apply(type.getUStroke());
|
||||||
final ULine line = new ULine(end.getX() - start.getX(), end.getY() - start.getY());
|
final ULine line = new ULine(end.getX() - start.getX(), end.getY() - start.getY());
|
||||||
ug.apply(new UTranslate(start)).draw(line);
|
ug.apply(new UTranslate(start)).draw(line);
|
||||||
|
|
||||||
|
@ -139,9 +140,6 @@ public class TimeArrow implements UDrawable {
|
||||||
}
|
}
|
||||||
textLabel.drawU(ug.apply(new UTranslate(xText, yText)));
|
textLabel.drawU(ug.apply(new UTranslate(xText, yText)));
|
||||||
|
|
||||||
// final double radius = 4;
|
|
||||||
// final UTranslate forCirle = new UTranslate(end.getX() - radius, end.getY() - radius);
|
|
||||||
// ug.apply(forCirle).draw(new UEllipse(2 * radius, 2 * radius));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,13 +142,15 @@ public class HColorSimple extends HColorAbstract implements HColor {
|
||||||
return monochrome;
|
return monochrome;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HColorSimple linear(HColorSimple color1, HColorSimple color2, int completion) {
|
public static HColorSimple unlinear(HColorSimple color1, HColorSimple color2, int completionInt) {
|
||||||
final HSLColor col1 = new HSLColor(color1.color);
|
final HSLColor col1 = new HSLColor(color1.color);
|
||||||
final HSLColor col2 = new HSLColor(color2.color);
|
final HSLColor col2 = new HSLColor(color2.color);
|
||||||
|
|
||||||
final float[] hsl1 = col1.getHSL();
|
final float[] hsl1 = col1.getHSL();
|
||||||
final float[] hsl2 = col2.getHSL();
|
final float[] hsl2 = col2.getHSL();
|
||||||
|
|
||||||
|
float completion = (float) (completionInt / 100.0);
|
||||||
|
completion = completion * completion * completion;
|
||||||
final float[] hsl = linear(completion, hsl1, hsl2);
|
final float[] hsl = linear(completion, hsl1, hsl2);
|
||||||
|
|
||||||
final HSLColor col = new HSLColor(hsl);
|
final HSLColor col = new HSLColor(hsl);
|
||||||
|
@ -156,15 +158,15 @@ public class HColorSimple extends HColorAbstract implements HColor {
|
||||||
return new HColorSimple(col.getRGB(), color1.monochrome);
|
return new HColorSimple(col.getRGB(), color1.monochrome);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float[] linear(int completion, float[] hsl1, float[] hsl2) {
|
private static float[] linear(float factor, float[] hsl1, float[] hsl2) {
|
||||||
final float h = linear(completion, hsl1[0], hsl2[0]);
|
final float h = linear(factor, hsl1[0], hsl2[0]);
|
||||||
final float s = linear(completion, hsl1[1], hsl2[1]);
|
final float s = linear(factor, hsl1[1], hsl2[1]);
|
||||||
final float l = linear(completion, hsl1[2], hsl2[2]);
|
final float l = linear(factor, hsl1[2], hsl2[2]);
|
||||||
return new float[] { h, s, l };
|
return new float[] { h, s, l };
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float linear(int completion, float x, float y) {
|
private static float linear(float factor, float x, float y) {
|
||||||
return x + (y - x) * completion / 100;
|
return (x + (y - x) * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,9 +152,15 @@ public class HColorUtils {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HColor linear(HColor color1, HColor color2, int completion) {
|
public static HColor unlinear(HColor color1, HColor color2, int completion) {
|
||||||
|
if (completion == 0) {
|
||||||
|
return color1;
|
||||||
|
}
|
||||||
|
if (completion == 100) {
|
||||||
|
return color2;
|
||||||
|
}
|
||||||
if (color1 instanceof HColorSimple && color2 instanceof HColorSimple) {
|
if (color1 instanceof HColorSimple && color2 instanceof HColorSimple) {
|
||||||
return HColorSimple.linear((HColorSimple) color1, (HColorSimple) color2, completion);
|
return HColorSimple.unlinear((HColorSimple) color1, (HColorSimple) color2, completion);
|
||||||
}
|
}
|
||||||
return color1;
|
return color1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class Version {
|
||||||
private static final int MAJOR_SEPARATOR = 1000000;
|
private static final int MAJOR_SEPARATOR = 1000000;
|
||||||
|
|
||||||
public static int version() {
|
public static int version() {
|
||||||
return 1202109;
|
return 1202110;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int versionPatched() {
|
public static int versionPatched() {
|
||||||
|
@ -93,7 +93,7 @@ public class Version {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long compileTime() {
|
public static long compileTime() {
|
||||||
return 1627208036416L;
|
return 1630331028954L;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String compileTimeString() {
|
public static String compileTimeString() {
|
||||||
|
|
|
@ -94,12 +94,16 @@ final class WElement {
|
||||||
return new SkinParamColors(skinParam, Colors.empty().add(ColorType.BACK, backColor));
|
return new SkinParamColors(skinParam, Colors.empty().add(ColorType.BACK, backColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final int STEP_BY_PARENT = 1000_1000;
|
||||||
|
|
||||||
public Style getStyle() {
|
public Style getStyle() {
|
||||||
Style result = getDefaultStyleDefinitionNode(level).getMergedStyle(styleBuilder);
|
int deltaPriority = STEP_BY_PARENT * 1000;
|
||||||
|
Style result = styleBuilder.getMergedStyleSpecial(getDefaultStyleDefinitionNode(level), deltaPriority);
|
||||||
for (WElement up = parent; up != null; up = up.parent) {
|
for (WElement up = parent; up != null; up = up.parent) {
|
||||||
final StyleSignature ss = up.getDefaultStyleDefinitionNode(level).addStar();
|
final StyleSignature ss = up.getDefaultStyleDefinitionNode(level).addStar();
|
||||||
final Style p = ss.getMergedStyle(styleBuilder);
|
deltaPriority -= STEP_BY_PARENT;
|
||||||
result = result.mergeWith(p);
|
final Style styleParent = styleBuilder.getMergedStyleSpecial(ss, deltaPriority);
|
||||||
|
result = result.mergeWith(styleParent);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue