1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-05-28 14:10:48 +00:00

Add interactive functionality for Usecase diagrams exported to SVG

This commit is contained in:
Arnaud Roques 2021-03-04 19:11:16 +01:00
parent 74ff89f4ba
commit 66520f0a35
106 changed files with 1561 additions and 1090 deletions

View File

@ -76,6 +76,12 @@
<include name="**/*.skin" /> <include name="**/*.skin" />
</fileset> </fileset>
</copy> </copy>
<copy todir="build/svg">
<fileset dir="svg">
<include name="**/*.js" />
<include name="**/*.css" />
</fileset>
</copy>
</target> </target>
<target name="dist" depends="compile"> <target name="dist" depends="compile">

View File

@ -30,12 +30,13 @@
Script Author: Julien Eluard Script Author: Julien Eluard
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>net.sourceforge.plantuml</groupId> <groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId> <artifactId>plantuml</artifactId>
<version>1.2021.2-SNAPSHOT</version> <version>1.2021.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>PlantUML</name> <name>PlantUML</name>
@ -114,6 +115,8 @@
<includes> <includes>
<include>stdlib/**/*.repx</include> <include>stdlib/**/*.repx</include>
<include>skin/**/*.skin</include> <include>skin/**/*.skin</include>
<include>svg/**/*.css</include>
<include>svg/**/*.js</include>
</includes> </includes>
</resource> </resource>
</resources> </resources>

View File

@ -278,3 +278,40 @@ ganttDiagram {
Shadowing 0.0 Shadowing 0.0
} }
} }
usecase {
HorizontalAlignment center
}
yamlDiagram {
arrow {
LineThickness 1
LineStyle 3;3
}
node {
LineThickness 1.5
RoundCorner 10
separator {
LineThickness 1
LineColor #A80036
}
}
}
jsonDiagram {
arrow {
LineThickness 1
LineStyle 3;3
}
node {
LineThickness 1.5
RoundCorner 10
separator {
LineThickness 1
LineColor #A80036
}
}
}

View File

@ -160,6 +160,11 @@ public class FileUtils {
return readSvg(br, false, false); return readSvg(br, false, false);
} }
static public String readText(InputStream is) throws IOException {
final BufferedReader br = new BufferedReader(new InputStreamReader(is));
return readSvg(br, true, true);
}
static public String readFile(SFile svgFile) throws IOException { static public String readFile(SFile svgFile) throws IOException {
final BufferedReader br = svgFile.openBufferedReader(); final BufferedReader br = svgFile.openBufferedReader();
if (br == null) { if (br == null) {

View File

@ -71,18 +71,18 @@ public class ComponentTextActor extends AbstractComponentText {
final int xman = width / 2 - 1; final int xman = width / 2 - 1;
if (type == ComponentType.ACTOR_HEAD) { if (type == ComponentType.ACTOR_HEAD) {
if (fileFormat == FileFormat.UTXT) { if (fileFormat == FileFormat.UTXT) {
charArea.drawStringsLRUnicode(stringsToDisplay.as(), 1, getHeight()); charArea.drawStringsLRUnicode(stringsToDisplay.asList(), 1, getHeight());
charArea.drawShape(AsciiShape.STICKMAN_UNICODE, xman, 0); charArea.drawShape(AsciiShape.STICKMAN_UNICODE, xman, 0);
} else { } else {
charArea.drawStringsLRSimple(stringsToDisplay.as(), 1, getHeight()); charArea.drawStringsLRSimple(stringsToDisplay.asList(), 1, getHeight());
charArea.drawShape(AsciiShape.STICKMAN, xman, 0); charArea.drawShape(AsciiShape.STICKMAN, xman, 0);
} }
} else if (type == ComponentType.ACTOR_TAIL) { } else if (type == ComponentType.ACTOR_TAIL) {
if (fileFormat == FileFormat.UTXT) { if (fileFormat == FileFormat.UTXT) {
charArea.drawStringsLRUnicode(stringsToDisplay.as(), 1, 0); charArea.drawStringsLRUnicode(stringsToDisplay.asList(), 1, 0);
charArea.drawShape(AsciiShape.STICKMAN_UNICODE, xman, 1); charArea.drawShape(AsciiShape.STICKMAN_UNICODE, xman, 1);
} else { } else {
charArea.drawStringsLRSimple(stringsToDisplay.as(), 1, 0); charArea.drawStringsLRSimple(stringsToDisplay.asList(), 1, 0);
charArea.drawShape(AsciiShape.STICKMAN, xman, 1); charArea.drawShape(AsciiShape.STICKMAN, xman, 1);
} }
} else { } else {

View File

@ -135,9 +135,9 @@ public class ComponentTextArrow extends AbstractComponentText implements ArrowCo
// final int position = Math.max(0, (width - textWidth) / 2); // final int position = Math.max(0, (width - textWidth) / 2);
if (fileFormat == FileFormat.UTXT) { if (fileFormat == FileFormat.UTXT) {
charArea.drawStringsLRUnicode(stringsToDisplay.as(), (width - textWidth) / 2, 0); charArea.drawStringsLRUnicode(stringsToDisplay.asList(), (width - textWidth) / 2, 0);
} else { } else {
charArea.drawStringsLRSimple(stringsToDisplay.as(), (width - textWidth) / 2, 0); charArea.drawStringsLRSimple(stringsToDisplay.asList(), (width - textWidth) / 2, 0);
} }
} }
@ -169,4 +169,8 @@ public class ComponentTextArrow extends AbstractComponentText implements ArrowCo
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public double getPosArrow(StringBounder stringBounder) {
throw new UnsupportedOperationException();
}
} }

View File

@ -79,9 +79,9 @@ public class ComponentTextNote extends AbstractComponentText {
} }
} }
if (fileFormat == FileFormat.UTXT) { if (fileFormat == FileFormat.UTXT) {
charArea.drawStringsLRUnicode(stringsToDisplay.as(), 3, 1); charArea.drawStringsLRUnicode(stringsToDisplay.asList(), 3, 1);
} else { } else {
charArea.drawStringsLRSimple(stringsToDisplay.as(), 3, 1); charArea.drawStringsLRSimple(stringsToDisplay.asList(), 3, 1);
} }
} }

View File

@ -83,9 +83,9 @@ public class ComponentTextParticipant extends AbstractComponentText {
} }
} }
if (fileFormat == FileFormat.UTXT) { if (fileFormat == FileFormat.UTXT) {
charArea.drawStringsLRUnicode(stringsToDisplay.as(), 1, 1); charArea.drawStringsLRUnicode(stringsToDisplay.asList(), 1, 1);
} else { } else {
charArea.drawStringsLRSimple(stringsToDisplay.as(), 1, 1); charArea.drawStringsLRSimple(stringsToDisplay.asList(), 1, 1);
} }
} }

View File

@ -97,9 +97,9 @@ public class ComponentTextSelfArrow extends AbstractComponentText implements Arr
} }
if (fileFormat == FileFormat.UTXT) { if (fileFormat == FileFormat.UTXT) {
charArea.drawStringsLRUnicode(stringsToDisplay.as(), 6, 1); charArea.drawStringsLRUnicode(stringsToDisplay.asList(), 6, 1);
} else { } else {
charArea.drawStringsLRSimple(stringsToDisplay.as(), 6, 1); charArea.drawStringsLRSimple(stringsToDisplay.asList(), 6, 1);
} }
} }
@ -126,5 +126,10 @@ public class ComponentTextSelfArrow extends AbstractComponentText implements Arr
public double getYPoint(StringBounder stringBounder) { public double getYPoint(StringBounder stringBounder) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public double getPosArrow(StringBounder stringBounder) {
throw new UnsupportedOperationException();
}
} }

View File

@ -67,10 +67,10 @@ public class ComponentTextShape extends AbstractComponentText {
final int xman = width / 2 - shape.getWidth() / 2 + 1; final int xman = width / 2 - shape.getWidth() / 2 + 1;
if (type.name().endsWith("_HEAD")) { if (type.name().endsWith("_HEAD")) {
charArea.drawStringsLRSimple(stringsToDisplay.as(), 1, getHeight()); charArea.drawStringsLRSimple(stringsToDisplay.asList(), 1, getHeight());
charArea.drawShape(shape, xman, 0); charArea.drawShape(shape, xman, 0);
} else { } else {
charArea.drawStringsLRSimple(stringsToDisplay.as(), 1, 0); charArea.drawStringsLRSimple(stringsToDisplay.asList(), 1, 0);
charArea.drawShape(shape, xman, 1); charArea.drawShape(shape, xman, 1);
} }
} }

View File

@ -47,6 +47,7 @@ import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class CommandAddMethod extends SingleLineCommand2<ClassDiagram> { public class CommandAddMethod extends SingleLineCommand2<ClassDiagram> {
@ -65,7 +66,7 @@ public class CommandAddMethod extends SingleLineCommand2<ClassDiagram> {
} }
@Override @Override
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException {
final String idShort = arg.get("NAME", 0); final String idShort = arg.get("NAME", 0);
final Ident ident = diagram.buildLeafIdent(idShort); final Ident ident = diagram.buildLeafIdent(idShort);
final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort); final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort);

View File

@ -92,7 +92,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
private static IRegex getRegexConcat() { private static IRegex getRegexConcat() {
return RegexConcat.build(CommandCreateClassMultilines.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandCreateClassMultilines.class.getName(), RegexLeaf.start(), //
new RegexLeaf("VISIBILITY", "(" + VisibilityModifier.regexForVisibilityCharacterInClassName() + ")?"), // new RegexLeaf("VISIBILITY", "(" + VisibilityModifier.regexForVisibilityCharacterInClassName() + ")?"), //
new RegexLeaf("TYPE", "(interface|enum|abstract[%s]+class|abstract|class|entity)"), // new RegexLeaf("TYPE", "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity)"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexOr(// new RegexOr(//
new RegexConcat(// new RegexConcat(//

View File

@ -79,13 +79,20 @@ public class BlocLines implements Iterable<StringLocated> {
return loadInternal(br, location); return loadInternal(br, location);
} }
public static BlocLines from(List<StringLocated> lines) {
return new BlocLines(lines);
}
private static BlocLines loadInternal(final BufferedReader br, LineLocation location) throws IOException { private static BlocLines loadInternal(final BufferedReader br, LineLocation location) throws IOException {
final List<StringLocated> result = new ArrayList<StringLocated>(); final List<StringLocated> result = new ArrayList<StringLocated>();
String s; String s;
while ((s = br.readLine()) != null) { try {
result.add(new StringLocated(s, location)); while ((s = br.readLine()) != null) {
result.add(new StringLocated(s, location));
}
} finally {
br.close();
} }
br.close();
return new BlocLines(result); return new BlocLines(result);
} }

View File

@ -80,7 +80,7 @@ public class AtomTextUtils {
final Display display = Display.getWithNewlines(url.getLabel()); final Display display = Display.getWithNewlines(url.getLabel());
if (display.size() > 1) { if (display.size() > 1) {
final List<Atom> all = new ArrayList<Atom>(); final List<Atom> all = new ArrayList<Atom>();
for (CharSequence s : display.as()) { for (CharSequence s : display.asList()) {
all.add(createAtomText(s.toString(), url, fontConfiguration, skinSimple)); all.add(createAtomText(s.toString(), url, fontConfiguration, skinSimple));
} }
return new AtomVerticalTexts(all); return new AtomVerticalTexts(all);

View File

@ -41,6 +41,7 @@ import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public interface Bodier { public interface Bodier {
@ -50,7 +51,7 @@ public interface Bodier {
public Display getMethodsToDisplay(); public Display getMethodsToDisplay();
public void addFieldOrMethod(String s); public void addFieldOrMethod(String s) throws NoSuchColorException;
public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields, public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields,
Stereotype stereotype, Style style); Stereotype stereotype, Style style);

View File

@ -211,7 +211,8 @@ public class BodierLikeClassOrObject implements Bodier {
if (type.isLikeClass() && isBodyEnhanced()) { if (type.isLikeClass() && isBodyEnhanced()) {
if (showMethods || showFields) { if (showMethods || showFields) {
return BodyFactory.create1(rawBodyWithoutHidden(), fontParam, skinParam, stereotype, leaf, style); return BodyFactory.create1(skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
rawBodyWithoutHidden(), fontParam, skinParam, stereotype, leaf, style);
} }
return null; return null;
} }
@ -222,7 +223,8 @@ public class BodierLikeClassOrObject implements Bodier {
if (showFields == false) { if (showFields == false) {
return new TextBlockLineBefore(TextBlockUtils.empty(0, 0)); return new TextBlockLineBefore(TextBlockUtils.empty(0, 0));
} }
return BodyFactory.create1(rawBodyWithoutHidden(), fontParam, skinParam, stereotype, leaf, style); return BodyFactory.create1(skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
rawBodyWithoutHidden(), fontParam, skinParam, stereotype, leaf, style);
} }
assert type.isLikeClass(); assert type.isLikeClass();

View File

@ -41,8 +41,10 @@ import java.util.List;
import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class BodierSimple implements Bodier { public class BodierSimple implements Bodier {
@ -63,8 +65,9 @@ public class BodierSimple implements Bodier {
this.leaf = leaf; this.leaf = leaf;
} }
public void addFieldOrMethod(String s) { public void addFieldOrMethod(String s) throws NoSuchColorException {
rawBody.add(s); final Display display = Display.getWithNewlines2(s);
rawBody.addAll(display.asList());
} }
public Display getMethodsToDisplay() { public Display getMethodsToDisplay() {
@ -85,7 +88,8 @@ public class BodierSimple implements Bodier {
public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields, public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields,
Stereotype stereotype, Style style) { Stereotype stereotype, Style style) {
return BodyFactory.create1(rawBody, fontParam, skinParam, stereotype, leaf, style); return BodyFactory.create1(skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), rawBody, fontParam,
skinParam, stereotype, leaf, style);
} }
} }

View File

@ -74,10 +74,9 @@ public class BodyEnhanced1 extends BodyEnhancedAbstract implements TextBlock, Wi
private final boolean inEllipse; private final boolean inEllipse;
private final Style style; private final Style style;
BodyEnhanced1(List<CharSequence> rawBody, FontParam fontParam, ISkinParam skinParam, Stereotype stereotype, BodyEnhanced1(HorizontalAlignment align, List<CharSequence> rawBody, FontParam fontParam, ISkinParam skinParam,
ILeaf entity, Style style) { Stereotype stereotype, ILeaf entity, Style style) {
super(skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), super(align, new FontConfiguration(skinParam, fontParam, stereotype));
new FontConfiguration(skinParam, fontParam, stereotype));
this.style = style; this.style = style;
this.rawBody2 = Display.create(rawBody); this.rawBody2 = Display.create(rawBody);
this.stereotype = stereotype; this.stereotype = stereotype;
@ -90,11 +89,10 @@ public class BodyEnhanced1 extends BodyEnhancedAbstract implements TextBlock, Wi
this.inEllipse = false; this.inEllipse = false;
} }
BodyEnhanced1(Display display, FontParam fontParam, ISkinParam skinParam, HorizontalAlignment align, BodyEnhanced1(HorizontalAlignment align, Display display, FontParam fontParam, ISkinParam skinParam,
Stereotype stereotype, ILeaf entity, Style style) { Stereotype stereotype, ILeaf entity, Style style) {
super(skinParam.getDefaultTextAlignment(align), super(align, style == null ? new FontConfiguration(skinParam, fontParam, stereotype)
style == null ? new FontConfiguration(skinParam, fontParam, stereotype) : style.getFontConfiguration(skinParam.getIHtmlColorSet()));
: style.getFontConfiguration(skinParam.getIHtmlColorSet()));
this.style = style; this.style = style;
this.entity = entity; this.entity = entity;

View File

@ -63,14 +63,14 @@ public class BodyFactory {
return new BodierSimple(); return new BodierSimple();
} }
public static TextBlock create1(List<CharSequence> rawBody, FontParam fontParam, ISkinParam skinParam, public static TextBlock create1(HorizontalAlignment align, List<CharSequence> rawBody, FontParam fontParam,
Stereotype stereotype, ILeaf entity, Style style) { ISkinParam skinParam, Stereotype stereotype, ILeaf entity, Style style) {
return new BodyEnhanced1(rawBody, fontParam, skinParam, stereotype, entity, style); return new BodyEnhanced1(align, rawBody, fontParam, skinParam, stereotype, entity, style);
} }
public static TextBlock create2(Display display, FontParam fontParam, ISkinParam skinParam, public static TextBlock create2(HorizontalAlignment align, Display display, FontParam fontParam,
HorizontalAlignment align, Stereotype stereotype, ILeaf entity, Style style) { ISkinParam skinParam, Stereotype stereotype, ILeaf entity, Style style) {
return new BodyEnhanced1(display, fontParam, skinParam, align, stereotype, entity, style); return new BodyEnhanced1(align, display, fontParam, skinParam, stereotype, entity, style);
} }
public static TextBlock create3(Display rawBody, FontParam fontParam, ISkinSimple skinParam, public static TextBlock create3(Display rawBody, FontParam fontParam, ISkinSimple skinParam,

View File

@ -418,7 +418,7 @@ public class Display implements Iterable<CharSequence> {
this.defaultCreoleMode); this.defaultCreoleMode);
} }
public List<? extends CharSequence> as() { public List<? extends CharSequence> asList() {
return Collections.unmodifiableList(displayData); return Collections.unmodifiableList(displayData);
} }

View File

@ -62,6 +62,7 @@ import net.sourceforge.plantuml.ugraphic.PlacementStrategy;
import net.sourceforge.plantuml.ugraphic.PlacementStrategyVisibility; import net.sourceforge.plantuml.ugraphic.PlacementStrategyVisibility;
import net.sourceforge.plantuml.ugraphic.PlacementStrategyY1Y2Center; import net.sourceforge.plantuml.ugraphic.PlacementStrategyY1Y2Center;
import net.sourceforge.plantuml.ugraphic.PlacementStrategyY1Y2Left; import net.sourceforge.plantuml.ugraphic.PlacementStrategyY1Y2Left;
import net.sourceforge.plantuml.ugraphic.PlacementStrategyY1Y2Right;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULayoutGroup; import net.sourceforge.plantuml.ugraphic.ULayoutGroup;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
@ -284,7 +285,7 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlock,
} else if (align == HorizontalAlignment.CENTER) { } else if (align == HorizontalAlignment.CENTER) {
placementStrategy = new PlacementStrategyY1Y2Center(stringBounder); placementStrategy = new PlacementStrategyY1Y2Center(stringBounder);
} else { } else {
placementStrategy = new PlacementStrategyY1Y2Left(stringBounder); placementStrategy = new PlacementStrategyY1Y2Right(stringBounder);
} }
group = new ULayoutGroup(placementStrategy); group = new ULayoutGroup(placementStrategy);
for (CharSequence cs : members) { for (CharSequence cs : members) {

View File

@ -131,7 +131,7 @@ public final class CucaDiagramTxtMaker {
final int w = getWidth(ent); final int w = getWidth(ent);
final int h = getHeight(ent); final int h = getHeight(ent);
ug.getCharArea().drawBoxSimple(0, 0, w, h); ug.getCharArea().drawBoxSimple(0, 0, w, h);
ug.getCharArea().drawStringsLRSimple(ent.getDisplay().as(), 1, 1); ug.getCharArea().drawStringsLRSimple(ent.getDisplay().asList(), 1, 1);
if (showMember(ent)) { if (showMember(ent)) {
int y = 2; int y = 2;
ug.getCharArea().drawHLine('-', y, 1, w - 1); ug.getCharArea().drawHLine('-', y, 1, w - 1);

View File

@ -77,8 +77,8 @@ public class EntityImageRequirement extends AbstractEntityImage {
super(entity, skinParam); super(entity, skinParam);
final Stereotype stereotype = entity.getStereotype(); final Stereotype stereotype = entity.getStereotype();
final TextBlock tmp = BodyFactory.create2(entity.getDisplay(), FontParam.REQUIREMENT, skinParam, final TextBlock tmp = BodyFactory.create2(skinParam.getDefaultTextAlignment(HorizontalAlignment.CENTER),
HorizontalAlignment.CENTER, stereotype, entity, null); entity.getDisplay(), FontParam.REQUIREMENT, skinParam, stereotype, entity, null);
if (stereotype == null || stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR) == null) { if (stereotype == null || stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR) == null) {
this.desc = tmp; this.desc = tmp;

View File

@ -77,29 +77,28 @@ public class PSystemDonors extends AbstractPSystem {
private static final int COLS = 6; private static final int COLS = 6;
private static final int FREE_LINES = 6; private static final int FREE_LINES = 6;
public static final String DONORS = public static final String DONORS = "6neD0AmFkBap0wp4H6CjU-RENbb-8cPf4i7oFA4uiOZJNK3y0UwT7lSRwI-YAxltJJEYrckJSaPHV13q"
"6-KC0AmFkBap0wp4H6CjU-RENbb-8cPf4i7oFA4uiOZJNK3y0UwT7lSRwI-YAxltJJEYrckJSWPHVH3q"+ + "W7UtXVQXzBy-27EYV0Z-tGWU80D4ITH6ZIpt9Djjcof3Il3lEr_v9UWTth51ehbAgiMHwq-_8GFlEsFp"
"W7UtXVQXzBy-27EYV0Z-tGWU80D4ITH6ZIpt9Djjcof3Il3lEr_v9UWTth51ehbAgiMHwq-_8GFlEsFp"+ + "x3GsNZsQe2y2FmRsrPzVStLjuA5OdYSeWP8k4zg9ecxlNzf8nq_W_vEaQXTjwOuqQQIX0ZigyDXNVjMr"
"x3GsNZsQe2y2FmRsrV-REbkNLuKmItShC0AZeX4owzXZ_1_Lei8fs7Seq6EhCPrAK1qELLHYiytVvB1A"+ + "yr6ZoQeOCKMAhnNIyEcD2GqvwNs2RD2Wy4Fz4Dvihh2KSIOGHniYT7szjcFRYE4NIdpOvGwnm93074Wv"
"6l12LJil5PfCYb5JfFXQ8GsVtfXGavF6HyX67vn_g1_2cyqLbZBE1E9eGnrTN_-tPTk8zkTAl0XoXrXG"+ + "qXTHzDnGK70BOAYRnMniIUN8anHGP4CBUVE7UbBnI3bpEbmKF1u0WSypg42aDMhGXBFvmu2A8zcYmn9N"
"M60Ef1m9YoX-Rdhmmos0eMeMWx45XJLFOY6H0YtapH_gIS4ZvSpfSF73um4G-3o32YIjg4OJpfPN0ygF"+ + "dHatbkPnM9xIHjBmD6BXOK4he8OW_uCkyBHOuwEfirqDZgIU9hbtMudwiztRkJOh-aRN9WdhQ-kbMMnS"
"P8iMIrnrSTnOwiTXUIfz90sF9nOU5jG2QWZoF-Y2JeirFfewszNWIEffadkzfQXV1M_csape6roQ9Aot"+ + "KSeIgQvjV8xscaS0xfPQEUBBw2EK0pJxpQkAh7wqGFm8T5zDs98_otwma0bXRSC-KDUv-l2OHJWcGwQ9"
"jPTczhYYb2LIJTlu7EqrZm3SBRLon9VHH2W7QFQRLw6iVhH0VWIwgYPioPzbNrd8XAYsOHzwrxdyy1X4"+ + "TVnkjhsclT35TZOWOGLOfFVahpDDS50BNOay0ZoXLSnbdGyKqjBg_QB7mzfzmZN54lU6HEzzXANqtw_w"
"s2T3fecr_swslPR-GjUCOLF22h1epvYlYqrmi8MkJ1u1dj3AvxBE1v2qj7g_wF6mTfzmJRx4lI7HUXzX"+ + "C3CK1-X0cLdGJHCidT6qQY-s889wX8uEk2aaLyAvkox7xkCYVUGd0DvKUa0E6pkD4CylKsaw2g4QqdLD"
"AVttgpxC3CK1sbDc5dJZ1KjdDAsQYos8O8_GqG4tXUHAE7VNvTXzNAIF_0J0cqiFkiD6e1RY-MOgJKSX"+ + "cXN0v6cbBGfUInYKQnDqCwe4GsMrskDqTQOl6nFtIHyyRpKO8t5CPwelB7UlYhGmB5QDPcspTe3c55pX"
"KaFghaWp0PWzhTJ53wyb38gr2ReQLOBfPRNQutGrfYyRC_T96rpN6enH7DEPwWlBtQiYBGppLQCvVRDs"+ + "upYlUizShWAqjl0UyS4z_yY0dkcLWKYH8VTj6_wHfLc5nIpMN3UhqbtL3suUkld0NIoQnOmoUSXKQ1nA"
"WEOKF9MN_RpgNQLS1RYqy1xmmJt_o82VwPM1I97fxjis_2DBimgBMQovRbQbkweV73nq_O4xMZI96MNo"+ + "H4lzIkId9SFV76HLVwqkzWusf-kC46567DnUcbnJasCARjDPZeCDGcIenIjESSBv1NjOLf8jR0gLPwmU"
"aAL1SIWHDVKhaP-M37zBa4tpUpdQQrYThZD2X1bfS7jfSavDZldXDftbEDWWHA9QlEAK99nViDjb9Td2"+ + "XOJyZlaa8bNwGcd0hk6km3EIHq4UpdjWrR9wRIh91LIHpGH1QS6gbYgEzBL01iQQzCoqHcn_Mc31MDfZ"
"faXvnkfUICXldqyYKYKib1hiQky2FADv5EJXl6jMBQlN9amke99i9WXA2rQr53hIrm8P6AlNCz4QiVrf"+ + "T2mx5BrYegtA3JAcm4mJwXS6aIWrr4lfPKuI4VYVFtUf9yrraECxO_Xa74Jsa4I0AkJkZ1DLJztjw3QC"
"WGLZQOzHCt4elcAYjSeD15DWfeJpXK4aaaAzb5xc9161__bpbthQK0SxlZE6JyP1ieSa0geWzHadgeRQ"+ + "zH9_lrxApKVmvrzxjCcfqUxvQOBGEeWAG0ylu5Bk5thmDF3Ns30JS8WLLFGYuSfLIuy32GisuvrTrBbb"
"wz5j6Eib_dwzb9kFuC-_zcYJKwtTyrE2Q1t41Q275t0fzmizU1huQsoO13Z42YvwaN3begMdWOG5w_7E"+ + "HkCc9ikDoKMlo0zL_5lS2XVJ8JRek0YcE5eigTBBpMfGSRPlVjVX8eUEVuagGoAvhDKo6GaUXLcScsDV"
"8khIEADn4vFbXkIYLUI7ol_zkHOkvaDio77n73fQBAdIoyrgK6csht_NuIY7Zh-BAdqYkVmtFPEHq4aO"+ + "RHYQjd834bH7RG9hT_rsckMkCUSha9g6oq2-tP1JgHQXXMfgMjuN0gl5sD_Rj9zoMlmd0_quhRNZgXuQ"
"nBauzjM6eQbA2bXG7RK9hDtrsscMkyQSTo3L3oT0ljoGKwaMeOKrDItk2u7bOYplRTfFEIt-au5-ajRf"+ + "3d9qVRk9XczRsDiPFOdX8cP3XFwLEISSUFZ6Zxoe5ah3qhOPTgvWXVm6NiOB2OViu0EJMbwbh793Zhw5"
"nruzr1navxfs4mtVjX3Q4Js9uI9nGuJ-bI4d6dZune-yg1PAmzAw6NQkO8NyUbx62mcxxE03arfUfQno"+ + "x1tLA3y1H3N1WGmiLkYQn48fnmCfae8vPyjeXfI3Fk2idW2Sec1_Vsz1E2tH_8ncxUqPXMGksznDPX3n"
"Guw-XUmjrS2F0A9AQ203YoMwUh5Gol50YgHWpi4odY7beBKukIS0foZOt-zh42uzqNo7Pktj6OLaBjlS"+ + "S7u6YPfCsUgH0_jYvhBDAt8xQf4EE_Rj-8xpxO-ecmSHo84e9i5hTQ4FD_QQfM5JVAxJu3ukS_DcyWku"
"J0OGwN1-MebD-cpLo85zDNFPwXMvBRL8X-txTdp7-Vf7rDM324WWgadm6btarOszPcdO9CERMHp7PMOU"+ + "5EqyPM1hc6n1bh8Pg7WIWDX1faBvrVwh-OWjvnJvztvZAWmquNdYDBhnN0is8rjjH4eQq7AHXT_wViTD"
"J7uEkwATfGniDPCjo5ms0mLF0X0x42eaT-5NyH5ppZdox_r6NnXemlF0QNJZkH9iGBRSY9GqeEOeYppt"+ + "JWvCd1BPydFDONPw64xHwHK0";
"lNsJ4m00";
/* /*
* Special thanks to our sponsors and donors: * Special thanks to our sponsors and donors:

View File

@ -5,12 +5,12 @@
* (C) Copyright 2009-2020, Arnaud Roques * (C) Copyright 2009-2020, Arnaud Roques
* *
* Project Info: http://plantuml.com * Project Info: http://plantuml.com
* *
* If you like this project or if you find it useful, you can support us at: * 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/patreon (only 1$ per month!)
* http://plantuml.com/paypal * http://plantuml.com/paypal
* *
* This file is part of PlantUML. * This file is part of PlantUML.
* *
* PlantUML is free software; you can redistribute it and/or modify it * PlantUML is free software; you can redistribute it and/or modify it
@ -30,7 +30,7 @@
* *
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* *
*/ */
package net.sourceforge.plantuml.eggs; package net.sourceforge.plantuml.eggs;
@ -73,8 +73,9 @@ public class PSystemWelcome extends AbstractPSystem {
strings.add(" "); strings.add(" ");
strings.add("You will find more information about PlantUML syntax on <u>https://plantuml.com</u>"); strings.add("You will find more information about PlantUML syntax on <u>https://plantuml.com</u>");
strings.add(" "); strings.add(" ");
strings.add("If you use this software, you accept its license."); strings.add("(If you use this software, you accept its license.)");
strings.add("(details by typing \"\"license\"\" keyword)"); strings.add("(details by typing \"\"license\"\" keyword)");
strings.add(" ");
if (position == GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT) { if (position == GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT) {
strings.add(" "); strings.add(" ");
strings.add(" "); strings.add(" ");

View File

@ -77,15 +77,15 @@ public enum HorizontalAlignment {
return toString().substring(0, 1).toLowerCase(); return toString().substring(0, 1).toLowerCase();
} }
public void draw(UGraphic ug, TextBlock tb, double padding, Dimension2D dimTotal) { public void draw(UGraphic ug, TextBlock tb, double padding, double width) {
if (this == HorizontalAlignment.LEFT) { if (this == HorizontalAlignment.LEFT) {
tb.drawU(ug.apply(new UTranslate(padding, padding))); tb.drawU(ug.apply(new UTranslate(padding, padding)));
} else if (this == HorizontalAlignment.RIGHT) { } else if (this == HorizontalAlignment.RIGHT) {
final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder());
tb.drawU(ug.apply(new UTranslate(dimTotal.getWidth() - dimTb.getWidth() - padding, padding))); tb.drawU(ug.apply(new UTranslate(width - dimTb.getWidth() - padding, padding)));
} else if (this == HorizontalAlignment.CENTER) { } else if (this == HorizontalAlignment.CENTER) {
final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder());
tb.drawU(ug.apply(new UTranslate((dimTotal.getWidth() - dimTb.getWidth()) / 2, padding))); tb.drawU(ug.apply(new UTranslate((width - dimTb.getWidth()) / 2, padding)));
} }
} }

View File

@ -135,6 +135,11 @@ public class TextBlockUtils {
public Dimension2D calculateDimension(StringBounder stringBounder) { public Dimension2D calculateDimension(StringBounder stringBounder) {
return new Dimension2DDouble(width, height); return new Dimension2DDouble(width, height);
} }
public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) {
return null;
}
}; };
} }
@ -227,6 +232,8 @@ public class TextBlockUtils {
} }
return null; return null;
} }
}; };
} }

View File

@ -25,7 +25,7 @@ import java.io.IOException;
@SuppressWarnings("serial") // use default serial UID @SuppressWarnings("serial") // use default serial UID
class JsonString extends JsonValue { public class JsonString extends JsonValue {
private final String string; private final String string;

View File

@ -45,7 +45,7 @@ import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.Scale; import net.sourceforge.plantuml.Scale;
import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.TitledDiagram;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.UseStyle;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
@ -69,7 +69,7 @@ import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity; import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
public class JsonDiagram extends UmlDiagram { public class JsonDiagram extends TitledDiagram {
private final JsonValue root; private final JsonValue root;
private final List<String> highlighted; private final List<String> highlighted;
@ -93,7 +93,7 @@ public class JsonDiagram extends UmlDiagram {
} }
@Override @Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
throws IOException { throws IOException {
final Scale scale = getScale(); final Scale scale = getScale();

View File

@ -40,7 +40,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.BackSlash; import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.command.PSystemAbstractFactory; import net.sourceforge.plantuml.command.PSystemAbstractFactory;
import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.Diagram;
@ -58,13 +57,15 @@ public class JsonDiagramFactory extends PSystemAbstractFactory {
public Diagram createSystem(UmlSource source) { public Diagram createSystem(UmlSource source) {
final List<String> highlighted = new ArrayList<String>(); final List<String> highlighted = new ArrayList<String>();
StyleExtractor styleExtractor = null;
JsonValue json; JsonValue json;
try { try {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
final Iterator<StringLocated> it = source.iterator2(); styleExtractor = new StyleExtractor(source.iterator2());
final Iterator<String> it = styleExtractor.getIterator();
it.next(); it.next();
while (true) { while (true) {
final String line = it.next().getString(); final String line = it.next();
if (it.hasNext() == false) { if (it.hasNext() == false) {
break; break;
} }
@ -83,6 +84,9 @@ public class JsonDiagramFactory extends PSystemAbstractFactory {
json = null; json = null;
} }
final JsonDiagram result = new JsonDiagram(UmlDiagramType.JSON, json, highlighted); final JsonDiagram result = new JsonDiagram(UmlDiagramType.JSON, json, highlighted);
if (styleExtractor != null) {
styleExtractor.applyStyles(result.getSkinParam());
}
result.setSource(source); result.setSource(source);
return result; return result;
} }

View File

@ -53,6 +53,7 @@ import h.ST_Agnodeinfo_t;
import h.ST_Agraph_s; import h.ST_Agraph_s;
import h.ST_GVC_s; import h.ST_GVC_s;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.json.JsonValue;
import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.PName;
@ -60,7 +61,6 @@ import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
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;
import smetana.core.CString; import smetana.core.CString;
@ -106,16 +106,21 @@ public class SmetanaForJson {
public SmetanaForJson(UGraphic ug, ISkinParam skinParam) { public SmetanaForJson(UGraphic ug, ISkinParam skinParam) {
this.stringBounder = ug.getStringBounder(); this.stringBounder = ug.getStringBounder();
this.skinParam = skinParam; this.skinParam = skinParam;
this.ug = getStyle().applyStrokeAndLineColor(ug, skinParam.getIHtmlColorSet()); this.ug = ug;
} }
private Style getStyle() { private UGraphic getUgFor(SName name) {
return StyleSignature.of(SName.root, SName.element, SName.jsonDiagram) return getStyle(name).applyStrokeAndLineColor(ug, skinParam.getIHtmlColorSet());
}
private Style getStyle(SName name) {
return StyleSignature.of(SName.root, SName.element,
skinParam.getUmlDiagramType() == UmlDiagramType.YAML ? SName.yamlDiagram : SName.jsonDiagram, name)
.getMergedStyle(skinParam.getCurrentStyleBuilder()); .getMergedStyle(skinParam.getCurrentStyleBuilder());
} }
private ST_Agnode_s manageOneNode(JsonValue current, List<String> highlighted) { private ST_Agnode_s manageOneNode(JsonValue current, List<String> highlighted) {
final TextBlockJson block = new TextBlockJson(skinParam, current, highlighted); final TextBlockJson block = new TextBlockJson(skinParam, current, highlighted, getStyle(SName.node));
final ST_Agnode_s node1 = createNode(block.calculateDimension(stringBounder), block.size(), current.isArray(), final ST_Agnode_s node1 = createNode(block.calculateDimension(stringBounder), block.size(), current.isArray(),
(int) block.getWidthColA(stringBounder), (int) block.getWidthColB(stringBounder)); (int) block.getWidthColA(stringBounder), (int) block.getWidthColB(stringBounder));
nodes.add(new InternalNode(block, node1)); nodes.add(new InternalNode(block, node1));
@ -157,14 +162,15 @@ public class SmetanaForJson {
xMirror = new Mirror(max); xMirror = new Mirror(max);
for (InternalNode node : nodes) { for (InternalNode node : nodes) {
node.block.drawU(ug.apply(getPosition(node.node))); node.block.drawU(getUgFor(SName.node).apply(getPosition(node.node)));
} }
final HColor color = getStyle().value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); final HColor color = getStyle(SName.arrow).value(PName.LineColor).asColor(skinParam.getIHtmlColorSet());
for (ST_Agedge_s edge : edges) { for (ST_Agedge_s edge : edges) {
final JsonCurve curve = getCurve(edge, 13); final JsonCurve curve = getCurve(edge, 13);
curve.drawCurve(color, ug.apply(new UStroke(3, 3, 1))); // curve.drawCurve(color, getUgFor(SName.arrow).apply(new UStroke(3, 3, 1)));
curve.drawSpot(ug.apply(color.bg())); curve.drawCurve(color, getUgFor(SName.arrow));
curve.drawSpot(getUgFor(SName.arrow).apply(color.bg()));
} }
} }
@ -235,7 +241,8 @@ public class SmetanaForJson {
agsafeset(node, new CString("height"), new CString("" + width), new CString("")); agsafeset(node, new CString("height"), new CString("" + width), new CString(""));
agsafeset(node, new CString("width"), new CString("" + height), new CString("")); agsafeset(node, new CString("width"), new CString("" + height), new CString(""));
final String dotLabel = getDotLabel(size, isArray, colAwidth - 8, colBwidth - 8); final int lineHeight = 0;
final String dotLabel = getDotLabel(size, isArray, colAwidth - 8, colBwidth - 8, lineHeight);
if (size > 0) { if (size > 0) {
agsafeset(node, new CString("label"), new CString(dotLabel), new CString("")); agsafeset(node, new CString("label"), new CString(dotLabel), new CString(""));
} }
@ -250,14 +257,15 @@ public class SmetanaForJson {
return node; return node;
} }
private String getDotLabel(int size, boolean isArray, int widthA, int widthB) { private String getDotLabel(int size, boolean isArray, int widthA, int widthB, int height) {
final StringBuilder sb = new StringBuilder(""); final StringBuilder sb = new StringBuilder("");
if (isArray == false) { if (isArray == false) {
sb.append("{_dim_0_" + widthA + "_|{"); // "+height+"
sb.append("{_dim_" + height + "_" + widthA + "_|{");
} }
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
sb.append("<P" + i + ">"); sb.append("<P" + i + ">");
sb.append("_dim_0_" + widthB + "_"); sb.append("_dim_" + height + "_" + widthB + "_");
if (i < size - 1) if (i < size - 1)
sb.append("|"); sb.append("|");
} }

View File

@ -0,0 +1,85 @@
/* ========================================================================
* 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.jsondiagram;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.command.BlocLines;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleBuilder;
import net.sourceforge.plantuml.style.StyleLoader;
public class StyleExtractor {
private final List<String> list = new ArrayList<String>();
private final List<StringLocated> style = new ArrayList<StringLocated>();
public StyleExtractor(Iterator<StringLocated> data) {
while (data.hasNext()) {
StringLocated line = data.next();
if (line.getString().trim().equals("<style>")) {
while (data.hasNext()) {
style.add(line);
if (line.getString().trim().equals("</style>")) {
break;
}
line = data.next();
}
} else {
list.add(line.getString());
}
}
}
public void applyStyles(ISkinParam skinParam) {
if (style.size() > 0) {
final StyleBuilder styleBuilder = skinParam.getCurrentStyleBuilder();
final BlocLines blocLines = BlocLines.from(style);
for (Style modifiedStyle : StyleLoader.getDeclaredStyles(blocLines.subExtract(1, 1), styleBuilder)) {
skinParam.muteStyle(modifiedStyle);
}
}
}
public Iterator<String> getIterator() {
return list.iterator();
}
}

View File

@ -42,6 +42,7 @@ import java.util.List;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.AbstractTextBlock;
@ -54,14 +55,13 @@ import net.sourceforge.plantuml.json.JsonArray;
import net.sourceforge.plantuml.json.JsonObject; import net.sourceforge.plantuml.json.JsonObject;
import net.sourceforge.plantuml.json.JsonObject.Member; import net.sourceforge.plantuml.json.JsonObject.Member;
import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.json.JsonValue;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
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.URectangle; import net.sourceforge.plantuml.ugraphic.URectangle;
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;
@ -70,6 +70,7 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol
private final List<Line> lines = new ArrayList<Line>(); private final List<Line> lines = new ArrayList<Line>();
private final Style style;
private final ISkinParam skinParam; private final ISkinParam skinParam;
private double totalWidth; private double totalWidth;
private final JsonValue root; private final JsonValue root;
@ -99,8 +100,9 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol
} }
public TextBlockJson(ISkinParam skinParam, JsonValue root, List<String> highlighted) { public TextBlockJson(ISkinParam skinParam, JsonValue root, List<String> highlighted, Style style) {
this.skinParam = skinParam; this.skinParam = skinParam;
this.style = style;
this.root = root; this.root = root;
if (root instanceof JsonObject) if (root instanceof JsonObject)
for (Member member : (JsonObject) root) { for (Member member : (JsonObject) root) {
@ -230,17 +232,37 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol
return width; return width;
} }
public void drawU(UGraphic ug) { public void drawU(final UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder(); final StringBounder stringBounder = ug.getStringBounder();
final Dimension2D fullDim = calculateDimension(stringBounder); final Dimension2D fullDim = calculateDimension(stringBounder);
double trueWidth = Math.max(fullDim.getWidth(), totalWidth); double trueWidth = Math.max(fullDim.getWidth(), totalWidth);
final double widthColA = getWidthColA(stringBounder); final double widthColA = getWidthColA(stringBounder);
final double widthColB = getWidthColB(stringBounder);
double y = 0; double y = 0;
ug = getStyle().applyStrokeAndLineColor(ug, skinParam.getIHtmlColorSet()); final UGraphic ugNode = style.applyStrokeAndLineColor(ug, skinParam.getIHtmlColorSet());
for (Line line : lines) { for (Line line : lines) {
final UGraphic ugline = ug.apply(UTranslate.dy(y)); final double heightOfRow = line.getHeightOfRow(stringBounder);
y += heightOfRow;
}
if (y == 0)
y = 15;
if (trueWidth == 0)
trueWidth = 30;
final double round = style.value(PName.RoundCorner).asDouble();
final URectangle fullNodeRectangle = new URectangle(trueWidth, y).rounded(round);
final HColor backColor = style.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet());
ugNode.apply(backColor.bg()).apply(backColor).draw(fullNodeRectangle);
final Style styleSeparator = style.getSignature().add(SName.separator)
.getMergedStyle(skinParam.getCurrentStyleBuilder());
final UGraphic ugSeparator = styleSeparator.applyStrokeAndLineColor(ug, skinParam.getIHtmlColorSet());
y = 0;
for (Line line : lines) {
final UGraphic ugline = ugSeparator.apply(UTranslate.dy(y));
final double heightOfRow = line.getHeightOfRow(stringBounder); final double heightOfRow = line.getHeightOfRow(stringBounder);
if (line.highlighted) { if (line.highlighted) {
final URectangle back = new URectangle(trueWidth - 2, heightOfRow).rounded(4); final URectangle back = new URectangle(trueWidth - 2, heightOfRow).rounded(4);
@ -251,24 +273,19 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol
if (y > 0) if (y > 0)
ugline.draw(ULine.hline(trueWidth)); ugline.draw(ULine.hline(trueWidth));
final double posColA = (widthColA - line.b1.calculateDimension(stringBounder).getWidth()) / 2; final HorizontalAlignment horizontalAlignment = style.getHorizontalAlignment();
line.b1.drawU(ugline.apply(UTranslate.dx(posColA))); horizontalAlignment.draw(ugline, line.b1, 0, widthColA);
if (line.b2 != null) { if (line.b2 != null) {
line.b2.drawU(ugline.apply(UTranslate.dx(widthColA))); final UGraphic uglineColB = ugline.apply(UTranslate.dx(widthColA));
ugline.apply(UTranslate.dx(widthColA)).draw(ULine.vline(heightOfRow)); horizontalAlignment.draw(uglineColB, line.b2, 0, widthColB);
uglineColB.draw(ULine.vline(heightOfRow));
} }
y += heightOfRow; y += heightOfRow;
} }
ugNode.draw(fullNodeRectangle);
if (y == 0)
y = 15;
if (trueWidth == 0)
trueWidth = 30;
final URectangle full = new URectangle(trueWidth, y).rounded(10);
ug.apply(new UStroke(1.5)).draw(full);
} }
private double getTotalHeight(StringBounder stringBounder) { private double getTotalHeight(StringBounder stringBounder) {
@ -281,18 +298,15 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol
private TextBlock getTextBlock(String key) { private TextBlock getTextBlock(String key) {
final Display display = Display.getWithNewlines(key); final Display display = Display.getWithNewlines(key);
final FontConfiguration fontConfiguration = getStyle().getFontConfiguration(skinParam.getIHtmlColorSet()); final FontConfiguration fontConfiguration = style.getFontConfiguration(skinParam.getIHtmlColorSet());
TextBlock result = display.create7(fontConfiguration, HorizontalAlignment.LEFT, skinParam, final LineBreakStrategy wrap = style.wrapWidth();
CreoleMode.NO_CREOLE); final HorizontalAlignment horizontalAlignment = style.getHorizontalAlignment();
TextBlock result = display.create0(fontConfiguration, horizontalAlignment, skinParam, wrap,
CreoleMode.NO_CREOLE, null, null);
result = TextBlockUtils.withMargin(result, 5, 2); result = TextBlockUtils.withMargin(result, 5, 2);
return result; return result;
} }
private Style getStyle() {
return StyleSignature.of(SName.root, SName.element, SName.jsonDiagram)
.getMergedStyle(skinParam.getCurrentStyleBuilder());
}
public void setTotalWidth(double totalWidth) { public void setTotalWidth(double totalWidth) {
this.totalWidth = totalWidth; this.totalWidth = totalWidth;
} }

View File

@ -45,6 +45,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram; import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class CommandAddData extends SingleLineCommand2<AbstractClassOrObjectDiagram> { public class CommandAddData extends SingleLineCommand2<AbstractClassOrObjectDiagram> {
@ -63,7 +64,7 @@ public class CommandAddData extends SingleLineCommand2<AbstractClassOrObjectDiag
@Override @Override
protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, LineLocation location, protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, LineLocation location,
RegexResult arg) { RegexResult arg) throws NoSuchColorException {
final String name = arg.get("NAME", 0); final String name = arg.get("NAME", 0);
final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(name), final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(name),
diagram.buildCode(name), null, null); diagram.buildCode(name), null, null);

View File

@ -36,6 +36,9 @@
*/ */
package net.sourceforge.plantuml.picoweb; package net.sourceforge.plantuml.picoweb;
import static java.nio.charset.StandardCharsets.UTF_8;
import static net.sourceforge.plantuml.ErrorUmlType.SYNTAX_ERROR;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -67,9 +70,6 @@ import net.sourceforge.plantuml.error.PSystemErrorUtils;
import net.sourceforge.plantuml.graphic.QuoteUtils; import net.sourceforge.plantuml.graphic.QuoteUtils;
import net.sourceforge.plantuml.version.Version; import net.sourceforge.plantuml.version.Version;
import static java.nio.charset.StandardCharsets.UTF_8;
import static net.sourceforge.plantuml.ErrorUmlType.SYNTAX_ERROR;
public class PicoWebServer implements Runnable { public class PicoWebServer implements Runnable {
private final Socket connect; private final Socket connect;
@ -127,8 +127,7 @@ public class PicoWebServer implements Runnable {
} catch (Throwable e) { } catch (Throwable e) {
try { try {
sendError(e, out); sendError(e, out);
} } catch (Throwable e1) {
catch (Throwable e1) {
e.printStackTrace(); e.printStackTrace();
} }
} finally { } finally {
@ -142,7 +141,8 @@ public class PicoWebServer implements Runnable {
} }
} }
private boolean handleGET(ReceivedHTTPRequest request, BufferedOutputStream out, final FileFormat format) throws IOException { private boolean handleGET(ReceivedHTTPRequest request, BufferedOutputStream out, final FileFormat format)
throws IOException {
final int x = request.getPath().lastIndexOf('/'); final int x = request.getPath().lastIndexOf('/');
final String compressed = request.getPath().substring(x + 1); final String compressed = request.getPath().substring(x + 1);
final Transcoder transcoder = TranscoderUtil.getDefaultTranscoderProtected(); final Transcoder transcoder = TranscoderUtil.getDefaultTranscoderProtected();
@ -156,7 +156,8 @@ public class PicoWebServer implements Runnable {
final ByteArrayOutputStream os = new ByteArrayOutputStream(); final ByteArrayOutputStream os = new ByteArrayOutputStream();
final ImageData imageData = system.exportDiagram(os, 0, fileFormatOption); final ImageData imageData = system.exportDiagram(os, 0, fileFormatOption);
os.close(); os.close();
sendDiagram(out, system, fileFormatOption, httpReturnCode(imageData.getStatus()), imageData, os.toByteArray()); sendDiagram(out, system, fileFormatOption, httpReturnCode(imageData.getStatus()), imageData,
os.toByteArray());
return true; return true;
} }
return false; return false;
@ -176,8 +177,7 @@ public class PicoWebServer implements Runnable {
final Option option = new Option(renderRequest.getOptions()); final Option option = new Option(renderRequest.getOptions());
final String source = renderRequest.getSource().startsWith("@start") final String source = renderRequest.getSource().startsWith("@start") ? renderRequest.getSource()
? renderRequest.getSource()
: "@startuml\n" + renderRequest.getSource() + "\n@enduml"; : "@startuml\n" + renderRequest.getSource() + "\n@enduml";
final SourceStringReader ssr = new SourceStringReader(option.getDefaultDefines(), source, option.getConfig()); final SourceStringReader ssr = new SourceStringReader(option.getDefaultDefines(), source, option.getConfig());
@ -186,13 +186,10 @@ public class PicoWebServer implements Runnable {
final ImageData imageData; final ImageData imageData;
if (ssr.getBlocks().size() == 0) { if (ssr.getBlocks().size() == 0) {
system = PSystemErrorUtils.buildV2( system = PSystemErrorUtils.buildV2(null,
null, new ErrorUml(SYNTAX_ERROR, "No @startuml/@enduml found", 0, new LineLocationImpl("", null)), null,
new ErrorUml(SYNTAX_ERROR, "No @startuml/@enduml found", 0, new LineLocationImpl("", null)), Collections.<StringLocated>emptyList());
null, imageData = ssr.noStartumlFound(os, option.getFileFormatOption(), 42);
Collections.<StringLocated>emptyList()
);
imageData = ssr.noStartumlFound(os, option.getFileFormatOption(),42);
} else { } else {
system = ssr.getBlocks().get(0).getDiagram(); system = ssr.getBlocks().get(0).getDiagram();
imageData = system.exportDiagram(os, 0, option.getFileFormatOption()); imageData = system.exportDiagram(os, 0, option.getFileFormatOption());
@ -201,9 +198,9 @@ public class PicoWebServer implements Runnable {
sendDiagram(out, system, option.getFileFormatOption(), "200", imageData, os.toByteArray()); sendDiagram(out, system, option.getFileFormatOption(), "200", imageData, os.toByteArray());
} }
private void sendDiagram(final BufferedOutputStream out, final Diagram system, final FileFormatOption fileFormatOption, private void sendDiagram(final BufferedOutputStream out, final Diagram system,
final String returnCode, final ImageData imageData, final byte[] fileData) final FileFormatOption fileFormatOption, final String returnCode, final ImageData imageData,
throws IOException { final byte[] fileData) throws IOException {
write(out, "HTTP/1.1 " + returnCode); write(out, "HTTP/1.1 " + returnCode);
write(out, "Cache-Control: no-cache"); write(out, "Cache-Control: no-cache");

View File

@ -248,11 +248,16 @@ public class PicoWebServerTest {
} }
private static String httpRaw(String request) throws Exception { private static String httpRaw(String request) throws Exception {
try (Socket socket = socketConnection()) { Socket socket = null;
try {
socket = socketConnection();
socket.getOutputStream().write(request.getBytes(UTF_8)); socket.getOutputStream().write(request.getBytes(UTF_8));
socket.shutdownOutput(); socket.shutdownOutput();
return readStreamAsString(socket.getInputStream()) return readStreamAsString(socket.getInputStream()).replaceAll("\r\n", "\n");
.replaceAll("\r\n", "\n"); } finally {
if (socket != null) {
socket.close();
}
} }
} }

View File

@ -102,7 +102,6 @@ public class Sub {
result.add(s); result.add(s);
} }
} }
reader.close();
return result; return result;
} }

View File

@ -82,11 +82,10 @@ public class LinkAnchor {
public void drawAnchor(UGraphic ug, YPositionedTile tile1, YPositionedTile tile2, ISkinParam param) { public void drawAnchor(UGraphic ug, YPositionedTile tile1, YPositionedTile tile2, ISkinParam param) {
final StringBounder stringBounder = ug.getStringBounder(); final double y1 = tile1.getY();
final double y1 = tile1.getY(stringBounder); final double y2 = tile2.getY();
final double y2 = tile2.getY(stringBounder); final double xx1 = tile1.getMiddleX();
final double xx1 = tile1.getMiddleX(stringBounder); final double xx2 = tile2.getMiddleX();
final double xx2 = tile2.getMiddleX(stringBounder);
final double x = (xx1 + xx2) / 2; final double x = (xx1 + xx2) / 2;
final double ymin = Math.min(y1, y2); final double ymin = Math.min(y1, y2);
final double ymax = Math.max(y1, y2); final double ymax = Math.max(y1, y2);

View File

@ -35,6 +35,9 @@
*/ */
package net.sourceforge.plantuml.sequencediagram; package net.sourceforge.plantuml.sequencediagram;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.skin.ArrowConfiguration;
import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.style.StyleBuilder;
@ -79,4 +82,14 @@ public final class Message extends AbstractMessage {
return p1 == p2; return p1 == p2;
} }
private List<Participant> multicast = Collections.emptyList();
public void setMulticast(List<Participant> multicast) {
this.multicast = multicast;
}
public List<Participant> getMulticast() {
return multicast;
}
} }

View File

@ -35,6 +35,9 @@
*/ */
package net.sourceforge.plantuml.sequencediagram.command; package net.sourceforge.plantuml.sequencediagram.command;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.LineLocation;
@ -48,6 +51,7 @@ import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
@ -106,9 +110,10 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
new RegexLeaf("PART2LONG", "[%g]([^%g]+)[%g]"), // new RegexLeaf("PART2LONG", "[%g]([^%g]+)[%g]"), //
new RegexLeaf("PART2LONGCODE", "[%g]([^%g]+)[%g][%s]*as[%s]+([\\p{L}0-9_.@]+)"), // new RegexLeaf("PART2LONGCODE", "[%g]([^%g]+)[%g][%s]*as[%s]+([\\p{L}0-9_.@]+)"), //
new RegexLeaf("PART2CODELONG", "([\\p{L}0-9_.@]+)[%s]+as[%s]*[%g]([^%g]+)[%g]")), // new RegexLeaf("PART2CODELONG", "([\\p{L}0-9_.@]+)[%s]+as[%s]*[%g]([^%g]+)[%g]")), //
new RegexLeaf("MULTICAST", "((?:\\s&\\s[\\p{L}0-9_.@]+)*)"), //
new RegexLeaf("PART2ANCHOR", ANCHOR), // new RegexLeaf("PART2ANCHOR", ANCHOR), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("ACTIVATION", "(?:([+*!-]+)?)"), // new RegexLeaf("ACTIVATION", "(?:(\\+\\+|\\*\\*|!!|--|--\\+\\+|\\+\\+--)?)"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("LIFECOLOR", "(?:(#\\w+)?)"), // new RegexLeaf("LIFECOLOR", "(?:(#\\w+)?)"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -118,6 +123,25 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
RegexLeaf.end()); RegexLeaf.end());
} }
private List<Participant> getMulticasts(SequenceDiagram system, RegexResult arg2) {
final String multicast = arg2.get("MULTICAST", 0);
if (multicast != null) {
final List<Participant> result = new ArrayList<Participant>();
for (String s : multicast.split("&")) {
s = s.trim();
if (s.length() == 0) {
continue;
}
final Participant participant = system.getOrCreateParticipant(s);
if (participant != null) {
result.add(participant);
}
}
return Collections.unmodifiableList(result);
}
return Collections.emptyList();
}
private Participant getOrCreateParticipant(SequenceDiagram system, RegexResult arg2, String n) { private Participant getOrCreateParticipant(SequenceDiagram system, RegexResult arg2, String n) {
final String code; final String code;
final Display display; final Display display;
@ -157,7 +181,8 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
} }
@Override @Override
protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException {
Participant p1; Participant p1;
Participant p2; Participant p2;
@ -251,6 +276,7 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
final String messageNumber = diagram.getNextMessageNumber(); final String messageNumber = diagram.getNextMessageNumber();
final Message msg = new Message(diagram.getSkinParam().getCurrentStyleBuilder(), p1, p2, final Message msg = new Message(diagram.getSkinParam().getCurrentStyleBuilder(), p1, p2,
diagram.manageVariable(labels), config, messageNumber); diagram.manageVariable(labels), config, messageNumber);
msg.setMulticast(getMulticasts(diagram, arg));
final String url = arg.get("URL", 0); final String url = arg.get("URL", 0);
if (url != null) { if (url != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT); final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
@ -272,31 +298,44 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
} }
final String s = arg.get("LIFECOLOR", 0); final String s = arg.get("LIFECOLOR", 0);
final HColor activationColor = s == null ? null final HColor activationColor = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s);
: diagram.getSkinParam().getIHtmlColorSet().getColor(s);
if (activationSpec != null) { if (activationSpec != null) {
switch (activationSpec.charAt(0)) { return manageActivations(activationSpec, diagram, p1, p2, activationColor);
}
if (diagram.isAutoactivate() && (config.getHead() == ArrowHead.NORMAL || config.getHead() == ArrowHead.ASYNC)) {
if (config.isDotted()) {
diagram.activate(p1, LifeEventType.DEACTIVATE, null);
} else {
diagram.activate(p2, LifeEventType.ACTIVATE, activationColor);
}
}
return CommandExecutionResult.ok();
}
private CommandExecutionResult manageActivations(String spec, SequenceDiagram diagram, Participant p1,
Participant p2, HColor activationColor) {
switch (spec.charAt(0)) {
case '+':
diagram.activate(p2, LifeEventType.ACTIVATE, activationColor);
break;
case '-':
diagram.activate(p1, LifeEventType.DEACTIVATE, null);
break;
case '!':
diagram.activate(p2, LifeEventType.DESTROY, null);
break;
}
if (spec.length() == 4) {
switch (spec.charAt(2)) {
case '+': case '+':
diagram.activate(p2, LifeEventType.ACTIVATE, activationColor); diagram.activate(p2, LifeEventType.ACTIVATE, activationColor);
break; break;
case '-': case '-':
diagram.activate(p1, LifeEventType.DEACTIVATE, null); diagram.activate(p1, LifeEventType.DEACTIVATE, null);
break; break;
case '!':
diagram.activate(p2, LifeEventType.DESTROY, null);
break;
default:
break;
} }
} else if (diagram.isAutoactivate()
&& (config.getHead() == ArrowHead.NORMAL || config.getHead() == ArrowHead.ASYNC)) {
if (config.isDotted()) {
diagram.activate(p1, LifeEventType.DEACTIVATE, null);
} else {
diagram.activate(p2, LifeEventType.ACTIVATE, activationColor);
}
} }
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }
@ -313,7 +352,8 @@ public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
return sa.length() + sb.length(); return sa.length() + sb.length();
} }
public static ArrowConfiguration applyStyle(String arrowStyle, ArrowConfiguration config) throws NoSuchColorException { public static ArrowConfiguration applyStyle(String arrowStyle, ArrowConfiguration config)
throws NoSuchColorException {
if (arrowStyle == null) { if (arrowStyle == null) {
return config; return config;
} }

View File

@ -113,13 +113,13 @@ public class SequenceDiagramTxtMaker implements FileMaker {
if (title.isWhite()) { if (title.isWhite()) {
ug2 = ug; ug2 = ug;
} else { } else {
ug2 = (UGraphicTxt) ug.apply(UTranslate.dy(title.as().size() + 1)); ug2 = (UGraphicTxt) ug.apply(UTranslate.dy(title.asList().size() + 1));
} }
drawableSet.drawU22(ug2, 0, fullDimension.getWidth(), page, diagram.isShowFootbox()); drawableSet.drawU22(ug2, 0, fullDimension.getWidth(), page, diagram.isShowFootbox());
if (title.isWhite() == false) { if (title.isWhite() == false) {
final int widthTitle = StringUtils.getWcWidth(title); final int widthTitle = StringUtils.getWcWidth(title);
final UmlCharArea charArea = ug.getCharArea(); final UmlCharArea charArea = ug.getCharArea();
charArea.drawStringsLRSimple(title.as(), (int) ((fullDimension.getWidth() - widthTitle) / 2), 0); charArea.drawStringsLRSimple(title.asList(), (int) ((fullDimension.getWidth() - widthTitle) / 2), 0);
} }
} }

View File

@ -39,18 +39,22 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.sequencediagram.AbstractMessage; import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.sequencediagram.Event;
public abstract class AbstractTile implements Tile { public abstract class AbstractTile extends CommonTile implements Tile {
public double getYPoint(StringBounder stringBounder) { public AbstractTile(StringBounder stringBounder) {
throw new UnsupportedOperationException(getClass().toString()); super(stringBounder);
} }
final public double getZ(StringBounder stringBounder) { public double getContactPointRelative() {
final double result = getPreferredHeight(stringBounder) - getYPoint(stringBounder); return -1;
}
final public double getZZZ() {
final double result = getPreferredHeight() - getContactPointRelative();
assert result >= 0; assert result >= 0;
return result; return result;
} }
public boolean matchAnchorV1(String anchor) { public boolean matchAnchorV1(String anchor) {
final Event event = this.getEvent(); final Event event = this.getEvent();
if (event instanceof AbstractMessage) { if (event instanceof AbstractMessage) {
@ -62,5 +66,4 @@ public abstract class AbstractTile implements Tile {
return false; return false;
} }
} }

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.sequencediagram.teoz; package net.sourceforge.plantuml.sequencediagram.teoz;
public interface Bordered { public interface Bordered {
public double getBorder1(); public double getBorder1();

View File

@ -37,10 +37,23 @@ package net.sourceforge.plantuml.sequencediagram.teoz;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
public interface TileWithUpdateStairs extends Tile { public abstract class CommonTile implements Tile {
public void updateStairs(StringBounder stringBounder, double y); private final StringBounder stringBounder;
public double getYPoint(StringBounder stringBounder); public CommonTile(StringBounder stringBounder) {
this.stringBounder = stringBounder;
}
final public void callbackY(double y) {
callbackY_internal(y);
}
public void callbackY_internal(double y) {
}
protected final StringBounder getStringBounder() {
return stringBounder;
}
} }

View File

@ -54,7 +54,7 @@ import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
public class CommunicationExoTile extends AbstractTile implements TileWithUpdateStairs { public class CommunicationExoTile extends AbstractTile {
private final LivingSpace livingSpace; private final LivingSpace livingSpace;
private final MessageExo message; private final MessageExo message;
@ -68,6 +68,7 @@ public class CommunicationExoTile extends AbstractTile implements TileWithUpdate
public CommunicationExoTile(LivingSpace livingSpace, MessageExo message, Rose skin, ISkinParam skinParam, public CommunicationExoTile(LivingSpace livingSpace, MessageExo message, Rose skin, ISkinParam skinParam,
TileArguments tileArguments) { TileArguments tileArguments) {
super(tileArguments.getStringBounder());
this.tileArguments = tileArguments; this.tileArguments = tileArguments;
this.livingSpace = livingSpace; this.livingSpace = livingSpace;
this.message = message; this.message = message;
@ -76,8 +77,8 @@ public class CommunicationExoTile extends AbstractTile implements TileWithUpdate
} }
@Override @Override
public double getYPoint(StringBounder stringBounder) { public double getContactPointRelative() {
return getComponent(stringBounder).getYPoint(stringBounder); return getComponent(getStringBounder()).getYPoint(getStringBounder());
} }
private ArrowComponent getComponent(StringBounder stringBounder) { private ArrowComponent getComponent(StringBounder stringBounder) {
@ -129,9 +130,9 @@ public class CommunicationExoTile extends AbstractTile implements TileWithUpdate
return message.isShortArrow(); return message.isShortArrow();
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
return dim.getHeight(); return dim.getHeight();
} }
@ -141,15 +142,15 @@ public class CommunicationExoTile extends AbstractTile implements TileWithUpdate
return dim.getWidth(); return dim.getWidth();
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
final double width = dim.getWidth(); final double width = dim.getWidth();
if (message.getType().isRightBorder()) { if (message.getType().isRightBorder()) {
} else { } else {
livingSpace.getPosC(stringBounder).ensureBiggerThan(tileArguments.getOrigin().addFixed(width)); livingSpace.getPosC(getStringBounder()).ensureBiggerThan(tileArguments.getOrigin().addFixed(width));
} }
// final Real point1 = getPoint1(stringBounder); // final Real point1 = getPoint1(stringBounder);
@ -165,10 +166,11 @@ public class CommunicationExoTile extends AbstractTile implements TileWithUpdate
// } // }
} }
public void updateStairs(StringBounder stringBounder, double y) { @Override
final ArrowComponent comp = getComponent(stringBounder); public void callbackY_internal(double y) {
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final ArrowComponent comp = getComponent(getStringBounder());
final double arrowY = comp.getStartPoint(stringBounder, dim).getY(); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
final double arrowY = comp.getStartPoint(getStringBounder(), dim).getY();
livingSpace.addStepForLivebox(getEvent(), y + arrowY); livingSpace.addStepForLivebox(getEvent(), y + arrowY);
@ -201,15 +203,15 @@ public class CommunicationExoTile extends AbstractTile implements TileWithUpdate
return livingSpace.getPosC(stringBounder).getCurrentValue(); return livingSpace.getPosC(stringBounder).getCurrentValue();
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
return getPoint1(stringBounder); return getPoint1(getStringBounder());
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
final double width = dim.getWidth(); final double width = dim.getWidth();
return getPoint1(stringBounder).addFixed(width); return getPoint1(getStringBounder()).addFixed(width);
} }
} }

View File

@ -39,12 +39,14 @@ import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.cucadiagram.Display;
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.VerticalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.real.Real;
import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.sequencediagram.Message; import net.sourceforge.plantuml.sequencediagram.Message;
import net.sourceforge.plantuml.sequencediagram.Participant;
import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.Area;
import net.sourceforge.plantuml.skin.ArrowComponent; import net.sourceforge.plantuml.skin.ArrowComponent;
import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.skin.ArrowConfiguration;
@ -56,10 +58,11 @@ import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
public class CommunicationTile extends AbstractTile implements TileWithUpdateStairs, TileWithCallbackY { public class CommunicationTile extends AbstractTile {
private final LivingSpace livingSpace1; private final LivingSpace livingSpace1;
private final LivingSpace livingSpace2; private final LivingSpace livingSpace2;
private final LivingSpaces livingSpaces;
private final Message message; private final Message message;
private final Rose skin; private final Rose skin;
private final ISkinParam skinParam; private final ISkinParam skinParam;
@ -73,13 +76,12 @@ public class CommunicationTile extends AbstractTile implements TileWithUpdateSta
return super.toString() + " " + message; return super.toString() + " " + message;
} }
public CommunicationTile(LivingSpace livingSpace1, LivingSpace livingSpace2, Message message, Rose skin, public CommunicationTile(StringBounder stringBounder, LivingSpaces livingSpaces, Message message, Rose skin,
ISkinParam skinParam) { ISkinParam skinParam) {
if (livingSpace1 == livingSpace2) { super(stringBounder);
throw new IllegalArgumentException(); this.livingSpace1 = livingSpaces.get(message.getParticipant1());
} this.livingSpace2 = livingSpaces.get(message.getParticipant2());
this.livingSpace1 = livingSpace1; this.livingSpaces = livingSpaces;
this.livingSpace2 = livingSpace2;
this.message = message; this.message = message;
this.skin = skin; this.skin = skin;
this.skinParam = skinParam; this.skinParam = skinParam;
@ -87,11 +89,6 @@ public class CommunicationTile extends AbstractTile implements TileWithUpdateSta
if (message.isCreate()) { if (message.isCreate()) {
livingSpace2.goCreate(); livingSpace2.goCreate();
} }
// for (LifeEvent lifeEvent : message.getLiveEvents()) {
// System.err.println("lifeEvent = " + lifeEvent);
// // livingSpace1.addLifeEvent(this, lifeEvent);
// // livingSpace2.addLifeEvent(this, lifeEvent);
// }
} }
public boolean isReverse(StringBounder stringBounder) { public boolean isReverse(StringBounder stringBounder) {
@ -117,37 +114,45 @@ public class CommunicationTile extends AbstractTile implements TileWithUpdateSta
private ArrowComponent getComponent(StringBounder stringBounder) { private ArrowComponent getComponent(StringBounder stringBounder) {
ArrowConfiguration arrowConfiguration = message.getArrowConfiguration(); ArrowConfiguration arrowConfiguration = message.getArrowConfiguration();
/*
* if (isSelf()) { arrowConfiguration = arrowConfiguration.self(); } else
*/
if (isReverse(stringBounder)) { if (isReverse(stringBounder)) {
arrowConfiguration = arrowConfiguration.reverse(); arrowConfiguration = arrowConfiguration.reverse();
} }
arrowConfiguration = arrowConfiguration.withThickness(getArrowThickness()); arrowConfiguration = arrowConfiguration.withThickness(getArrowThickness());
final ArrowComponent comp = skin.createComponentArrow(message.getUsedStyles(), arrowConfiguration, skinParam, return skin.createComponentArrow(message.getUsedStyles(), arrowConfiguration, skinParam,
message.getLabelNumbered()); message.getLabelNumbered());
return comp; }
private ArrowComponent getComponentMulticast(StringBounder stringBounder, boolean reverse) {
ArrowConfiguration arrowConfiguration = message.getArrowConfiguration();
if (reverse) {
arrowConfiguration = arrowConfiguration.reverse();
}
arrowConfiguration = arrowConfiguration.withThickness(getArrowThickness());
return skin.createComponentArrow(message.getUsedStyles(), arrowConfiguration, skinParam, Display.NULL);
} }
@Override @Override
public double getYPoint(StringBounder stringBounder) { public double getContactPointRelative() {
return getComponent(stringBounder).getYPoint(stringBounder); return getComponent(getStringBounder()).getYPoint(getStringBounder());
} }
public static final double LIVE_DELTA_SIZE = 5; public static final double LIVE_DELTA_SIZE = 5;
public void updateStairs(StringBounder stringBounder, double y) { @Override
final AbstractComponentRoseArrow comp = (AbstractComponentRoseArrow) getComponent(stringBounder); public void callbackY_internal(double y) {
final Dimension2D dim = comp.getPreferredDimension(stringBounder); if (message.isCreate()) {
// final Point2D p2 = comp.getEndPoint(stringBounder, dim); livingSpace2.goCreate(y);
// System.err.println("CommunicationTile::updateStairs y=" + y + " p1=" + p1 + " p2=" + p2 + " dim=" + dim); }
final double arrowY = comp.getStartPoint(stringBounder, dim).getY();
final AbstractComponentRoseArrow comp = (AbstractComponentRoseArrow) getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
final double arrowY = comp.getStartPoint(getStringBounder(), dim).getY();
livingSpace1.addStepForLivebox(getEvent(), y + arrowY); livingSpace1.addStepForLivebox(getEvent(), y + arrowY);
livingSpace2.addStepForLivebox(getEvent(), y + arrowY); livingSpace2.addStepForLivebox(getEvent(), y + arrowY);
// System.err.println("CommunicationTile::updateStairs msg=" + message + " y=" + y + " arrowY=" + arrowY);
} }
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
@ -161,6 +166,7 @@ public class CommunicationTile extends AbstractTile implements TileWithUpdateSta
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(stringBounder);
double x1 = getPoint1(stringBounder).getCurrentValue(); double x1 = getPoint1(stringBounder).getCurrentValue();
double x2 = getPoint2(stringBounder).getCurrentValue(); double x2 = getPoint2(stringBounder).getCurrentValue();
drawMulticast(ug.apply(UTranslate.dy(comp.getPosArrow(stringBounder))));
final Area area; final Area area;
if (isReverse(stringBounder)) { if (isReverse(stringBounder)) {
@ -193,24 +199,45 @@ public class CommunicationTile extends AbstractTile implements TileWithUpdateSta
comp.drawU(ug, area, (Context2D) ug); comp.drawU(ug, area, (Context2D) ug);
} }
public double getPreferredHeight(StringBounder stringBounder) { private void drawMulticast(final UGraphic ug) {
final Component comp = getComponent(stringBounder); if (message.getMulticast().size() == 0) {
final Dimension2D dim = comp.getPreferredDimension(stringBounder); return;
}
final StringBounder stringBounder = ug.getStringBounder();
final double x1 = getPoint1(stringBounder).getCurrentValue();
double dy = 2;
for (Participant participant : message.getMulticast()) {
final double x2 = livingSpaces.get(participant).getPosC(stringBounder).getCurrentValue();
final boolean reverse = x2 < x1;
final ArrowComponent comp = getComponentMulticast(stringBounder, reverse);
final Dimension2D dim = comp.getPreferredDimension(stringBounder);
final Area area = new Area(Math.abs(x2 - x1), dim.getHeight());
final UGraphic ug2 = ug.apply(UTranslate.dx(Math.min(x1, x2))).apply(UTranslate.dy(dy));
dy += 2;
comp.drawU(ug2, area, (Context2D) ug2);
}
}
public double getPreferredHeight() {
final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
double height = dim.getHeight(); double height = dim.getHeight();
if (isCreate()) { if (isCreate()) {
height = Math.max(height, livingSpace2.getHeadPreferredDimension(stringBounder).getHeight()); height = Math.max(height, livingSpace2.getHeadPreferredDimension(getStringBounder()).getHeight());
} }
return height; return height;
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
final double width = dim.getWidth(); final double width = dim.getWidth();
Real point1 = getPoint1(stringBounder); Real point1 = getPoint1(getStringBounder());
Real point2 = getPoint2(stringBounder); Real point2 = getPoint2(getStringBounder());
if (isReverse(stringBounder)) { if (isReverse(getStringBounder())) {
final int level1 = livingSpace1.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE); final int level1 = livingSpace1.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE);
final int level2 = livingSpace2.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE); final int level2 = livingSpace2.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE);
if (level1 > 0) { if (level1 > 0) {
@ -241,24 +268,18 @@ public class CommunicationTile extends AbstractTile implements TileWithUpdateSta
return livingSpace2.getPosC(stringBounder); return livingSpace2.getPosC(stringBounder);
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
if (isReverse(stringBounder)) { if (isReverse(getStringBounder())) {
return getPoint2(stringBounder); return getPoint2(getStringBounder());
} }
return getPoint1(stringBounder); return getPoint1(getStringBounder());
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
if (isReverse(stringBounder)) { if (isReverse(getStringBounder())) {
return getPoint1(stringBounder); return getPoint1(getStringBounder());
}
return getPoint2(stringBounder);
}
public void callbackY(double y) {
if (message.isCreate()) {
livingSpace2.goCreate(y);
} }
return getPoint2(getStringBounder());
} }
} }

View File

@ -55,9 +55,9 @@ 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;
public class CommunicationTileNoteBottom extends AbstractTile implements TileWithUpdateStairs, TileWithCallbackY { public class CommunicationTileNoteBottom extends AbstractTile {
private final TileWithUpdateStairs tile; private final Tile tile;
private final AbstractMessage message; private final AbstractMessage message;
private final Rose skin; private final Rose skin;
private final ISkinParam skinParam; private final ISkinParam skinParam;
@ -68,12 +68,13 @@ public class CommunicationTileNoteBottom extends AbstractTile implements TileWit
} }
@Override @Override
public double getYPoint(StringBounder stringBounder) { public double getContactPointRelative() {
return tile.getYPoint(stringBounder); return tile.getContactPointRelative();
} }
public CommunicationTileNoteBottom(TileWithUpdateStairs tile, AbstractMessage message, Rose skin, public CommunicationTileNoteBottom(Tile tile, AbstractMessage message, Rose skin, ISkinParam skinParam,
ISkinParam skinParam, Note noteOnMessage) { Note noteOnMessage) {
super(((AbstractTile) tile).getStringBounder());
this.tile = tile; this.tile = tile;
this.message = message; this.message = message;
this.skin = skin; this.skin = skin;
@ -81,8 +82,9 @@ public class CommunicationTileNoteBottom extends AbstractTile implements TileWit
this.noteOnMessage = noteOnMessage; this.noteOnMessage = noteOnMessage;
} }
public void updateStairs(StringBounder stringBounder, double y) { @Override
tile.updateStairs(stringBounder, y); public void callbackY_internal(double y) {
tile.callbackY(y);
} }
private Component getComponent(StringBounder stringBounder) { private Component getComponent(StringBounder stringBounder) {
@ -92,7 +94,7 @@ public class CommunicationTileNoteBottom extends AbstractTile implements TileWit
} }
private Real getNotePosition(StringBounder stringBounder) { private Real getNotePosition(StringBounder stringBounder) {
final Real minX = tile.getMinX(stringBounder); final Real minX = tile.getMinX();
return minX; return minX;
} }
@ -103,15 +105,15 @@ public class CommunicationTileNoteBottom extends AbstractTile implements TileWit
final Area area = new Area(dim.getWidth(), dim.getHeight()); final Area area = new Area(dim.getWidth(), dim.getHeight());
tile.drawU(ug); tile.drawU(ug);
final double middleMsg = (tile.getMinX(stringBounder).getCurrentValue() + tile.getMaxX(stringBounder).getCurrentValue()) / 2; final double middleMsg = (tile.getMinX().getCurrentValue() + tile.getMaxX().getCurrentValue()) / 2;
final double xNote = getNotePosition(stringBounder).getCurrentValue(); final double xNote = getNotePosition(stringBounder).getCurrentValue();
final double yNote = tile.getPreferredHeight(stringBounder); final double yNote = tile.getPreferredHeight();
comp.drawU(ug.apply(new UTranslate(xNote, yNote + spacey)), area, (Context2D) ug); comp.drawU(ug.apply(new UTranslate(xNote, yNote + spacey)), area, (Context2D) ug);
drawLine(ug, middleMsg, tile.getYPoint(stringBounder), xNote + dim.getWidth() / 2, yNote + spacey drawLine(ug, middleMsg, tile.getContactPointRelative(), xNote + dim.getWidth() / 2,
+ Rose.paddingY); yNote + spacey + Rose.paddingY);
} }
@ -123,33 +125,26 @@ public class CommunicationTileNoteBottom extends AbstractTile implements TileWit
final double dx = x2 - x1; final double dx = x2 - x1;
final double dy = y2 - y1; final double dy = y2 - y1;
ug.apply(new UTranslate(x1, y1)).apply(color).apply(new UStroke(2, 2, 1)) ug.apply(new UTranslate(x1, y1)).apply(color).apply(new UStroke(2, 2, 1)).draw(new ULine(dx, dy));
.draw(new ULine(dx, dy));
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
return tile.getPreferredHeight(stringBounder) + dim.getHeight() + spacey; return tile.getPreferredHeight() + dim.getHeight() + spacey;
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
tile.addConstraints(stringBounder); tile.addConstraints();
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
return tile.getMinX(stringBounder); return tile.getMinX();
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
return tile.getMaxX(stringBounder); return tile.getMaxX();
}
public void callbackY(double y) {
if (tile instanceof TileWithCallbackY) {
((TileWithCallbackY) tile).callbackY(y);
}
} }
} }

View File

@ -51,9 +51,9 @@ import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
public class CommunicationTileNoteLeft extends AbstractTile implements TileWithUpdateStairs, TileWithCallbackY { public class CommunicationTileNoteLeft extends AbstractTile {
private final TileWithUpdateStairs tile; private final Tile tile;
private final AbstractMessage message; private final AbstractMessage message;
private final Rose skin; private final Rose skin;
private final ISkinParam skinParam; private final ISkinParam skinParam;
@ -65,12 +65,13 @@ public class CommunicationTileNoteLeft extends AbstractTile implements TileWithU
} }
@Override @Override
public double getYPoint(StringBounder stringBounder) { public double getContactPointRelative() {
return tile.getYPoint(stringBounder); return tile.getContactPointRelative();
} }
public CommunicationTileNoteLeft(TileWithUpdateStairs tile, AbstractMessage message, Rose skin, public CommunicationTileNoteLeft(Tile tile, AbstractMessage message, Rose skin, ISkinParam skinParam,
ISkinParam skinParam, LivingSpace livingSpace, Note noteOnMessage) { LivingSpace livingSpace, Note noteOnMessage) {
super(((AbstractTile) tile).getStringBounder());
this.tile = tile; this.tile = tile;
this.message = message; this.message = message;
this.skin = skin; this.skin = skin;
@ -79,8 +80,9 @@ public class CommunicationTileNoteLeft extends AbstractTile implements TileWithU
this.livingSpace = livingSpace; this.livingSpace = livingSpace;
} }
public void updateStairs(StringBounder stringBounder, double y) { @Override
tile.updateStairs(stringBounder, y); public void callbackY_internal(double y) {
tile.callbackY(y);
} }
private Component getComponent(StringBounder stringBounder) { private Component getComponent(StringBounder stringBounder) {
@ -106,28 +108,22 @@ public class CommunicationTileNoteLeft extends AbstractTile implements TileWithU
comp.drawU(ug.apply(UTranslate.dx(p.getCurrentValue())), area, (Context2D) ug); comp.drawU(ug.apply(UTranslate.dx(p.getCurrentValue())), area, (Context2D) ug);
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
return Math.max(tile.getPreferredHeight(stringBounder), dim.getHeight()); return Math.max(tile.getPreferredHeight(), dim.getHeight());
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
tile.addConstraints(stringBounder); tile.addConstraints();
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
return getNotePosition(stringBounder); return getNotePosition(getStringBounder());
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
return tile.getMaxX(stringBounder); return tile.getMaxX();
}
public void callbackY(double y) {
if (tile instanceof TileWithCallbackY) {
((TileWithCallbackY) tile).callbackY(y);
}
} }
} }

View File

@ -51,9 +51,9 @@ import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
public class CommunicationTileNoteRight extends AbstractTile implements TileWithUpdateStairs, TileWithCallbackY { public class CommunicationTileNoteRight extends AbstractTile {
private final TileWithUpdateStairs tile; private final Tile tile;
private final AbstractMessage message; private final AbstractMessage message;
private final Rose skin; private final Rose skin;
private final ISkinParam skinParam; private final ISkinParam skinParam;
@ -69,12 +69,13 @@ public class CommunicationTileNoteRight extends AbstractTile implements TileWith
} }
@Override @Override
public double getYPoint(StringBounder stringBounder) { public double getContactPointRelative() {
return tile.getYPoint(stringBounder); return tile.getContactPointRelative();
} }
public CommunicationTileNoteRight(TileWithUpdateStairs tile, AbstractMessage message, Rose skin, public CommunicationTileNoteRight(Tile tile, AbstractMessage message, Rose skin, ISkinParam skinParam,
ISkinParam skinParam, LivingSpace livingSpace, Note noteOnMessage) { LivingSpace livingSpace, Note noteOnMessage) {
super(((AbstractTile) tile).getStringBounder());
this.tile = tile; this.tile = tile;
this.message = message; this.message = message;
this.skin = skin; this.skin = skin;
@ -83,8 +84,9 @@ public class CommunicationTileNoteRight extends AbstractTile implements TileWith
this.livingSpace = livingSpace; this.livingSpace = livingSpace;
} }
public void updateStairs(StringBounder stringBounder, double y) { @Override
tile.updateStairs(stringBounder, y); public void callbackY_internal(double y) {
tile.callbackY(y);
} }
private Component getComponent(StringBounder stringBounder) { private Component getComponent(StringBounder stringBounder) {
@ -114,30 +116,24 @@ public class CommunicationTileNoteRight extends AbstractTile implements TileWith
comp.drawU(ug.apply(UTranslate.dx(p.getCurrentValue())), area, (Context2D) ug); comp.drawU(ug.apply(UTranslate.dx(p.getCurrentValue())), area, (Context2D) ug);
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
return Math.max(tile.getPreferredHeight(stringBounder), dim.getHeight()); return Math.max(tile.getPreferredHeight(), dim.getHeight());
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
tile.addConstraints(stringBounder); tile.addConstraints();
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
return tile.getMinX(stringBounder); return tile.getMinX();
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
return getNotePosition(stringBounder).addFixed(dim.getWidth()); return getNotePosition(getStringBounder()).addFixed(dim.getWidth());
}
public void callbackY(double y) {
if (tile instanceof TileWithCallbackY) {
((TileWithCallbackY) tile).callbackY(y);
}
} }
} }

View File

@ -55,9 +55,9 @@ 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;
public class CommunicationTileNoteTop extends AbstractTile implements TileWithUpdateStairs, TileWithCallbackY { public class CommunicationTileNoteTop extends AbstractTile {
private final TileWithUpdateStairs tile; private final Tile tile;
private final AbstractMessage message; private final AbstractMessage message;
private final Rose skin; private final Rose skin;
private final ISkinParam skinParam; private final ISkinParam skinParam;
@ -68,12 +68,13 @@ public class CommunicationTileNoteTop extends AbstractTile implements TileWithUp
} }
@Override @Override
public double getYPoint(StringBounder stringBounder) { public double getContactPointRelative() {
return tile.getYPoint(stringBounder); return tile.getContactPointRelative();
} }
public CommunicationTileNoteTop(TileWithUpdateStairs tile, AbstractMessage message, Rose skin, public CommunicationTileNoteTop(Tile tile, AbstractMessage message, Rose skin, ISkinParam skinParam,
ISkinParam skinParam, Note noteOnMessage) { Note noteOnMessage) {
super(((AbstractTile) tile).getStringBounder());
this.tile = tile; this.tile = tile;
this.message = message; this.message = message;
this.skin = skin; this.skin = skin;
@ -81,8 +82,9 @@ public class CommunicationTileNoteTop extends AbstractTile implements TileWithUp
this.noteOnMessage = noteOnMessage; this.noteOnMessage = noteOnMessage;
} }
public void updateStairs(StringBounder stringBounder, double y) { @Override
tile.updateStairs(stringBounder, y); public void callbackY_internal(double y) {
tile.callbackY(y);
} }
private Component getComponent(StringBounder stringBounder) { private Component getComponent(StringBounder stringBounder) {
@ -92,7 +94,7 @@ public class CommunicationTileNoteTop extends AbstractTile implements TileWithUp
} }
private Real getNotePosition(StringBounder stringBounder) { private Real getNotePosition(StringBounder stringBounder) {
final Real minX = tile.getMinX(stringBounder); final Real minX = tile.getMinX();
return minX; return minX;
} }
@ -104,14 +106,13 @@ public class CommunicationTileNoteTop extends AbstractTile implements TileWithUp
tile.drawU(ug.apply(UTranslate.dy(dim.getHeight() + spacey))); tile.drawU(ug.apply(UTranslate.dy(dim.getHeight() + spacey)));
final double middleMsg = (tile.getMinX(stringBounder).getCurrentValue() + tile.getMaxX(stringBounder) final double middleMsg = (tile.getMinX().getCurrentValue() + tile.getMaxX().getCurrentValue()) / 2;
.getCurrentValue()) / 2;
final double xNote = getNotePosition(stringBounder).getCurrentValue(); final double xNote = getNotePosition(stringBounder).getCurrentValue();
comp.drawU(ug.apply(UTranslate.dx(xNote)), area, (Context2D) ug); comp.drawU(ug.apply(UTranslate.dx(xNote)), area, (Context2D) ug);
drawLine(ug, middleMsg, tile.getYPoint(stringBounder) + dim.getHeight() + spacey, xNote + dim.getWidth() / 2, drawLine(ug, middleMsg, tile.getContactPointRelative() + dim.getHeight() + spacey, xNote + dim.getWidth() / 2,
dim.getHeight() - 2 * Rose.paddingY); dim.getHeight() - 2 * Rose.paddingY);
} }
@ -124,33 +125,26 @@ public class CommunicationTileNoteTop extends AbstractTile implements TileWithUp
final double dx = x2 - x1; final double dx = x2 - x1;
final double dy = y2 - y1; final double dy = y2 - y1;
ug.apply(new UTranslate(x1, y1)).apply(color).apply(new UStroke(2, 2, 1)) ug.apply(new UTranslate(x1, y1)).apply(color).apply(new UStroke(2, 2, 1)).draw(new ULine(dx, dy));
.draw(new ULine(dx, dy));
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
return tile.getPreferredHeight(stringBounder) + dim.getHeight() + spacey; return tile.getPreferredHeight() + dim.getHeight() + spacey;
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
tile.addConstraints(stringBounder); tile.addConstraints();
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
return tile.getMinX(stringBounder); return tile.getMinX();
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
return tile.getMaxX(stringBounder); return tile.getMaxX();
}
public void callbackY(double y) {
if (tile instanceof TileWithCallbackY) {
((TileWithCallbackY) tile).callbackY(y);
}
} }
} }

View File

@ -54,7 +54,7 @@ import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
public class CommunicationTileSelf extends AbstractTile implements TileWithUpdateStairs { public class CommunicationTileSelf extends AbstractTile {
private final LivingSpace livingSpace1; private final LivingSpace livingSpace1;
private final Message message; private final Message message;
@ -67,12 +67,13 @@ public class CommunicationTileSelf extends AbstractTile implements TileWithUpdat
} }
@Override @Override
public double getYPoint(StringBounder stringBounder) { public double getContactPointRelative() {
return getComponent(stringBounder).getYPoint(stringBounder); return getComponent(getStringBounder()).getYPoint(getStringBounder());
} }
public CommunicationTileSelf(LivingSpace livingSpace1, Message message, Rose skin, ISkinParam skinParam, public CommunicationTileSelf(StringBounder stringBounder, LivingSpace livingSpace1, Message message, Rose skin,
LivingSpaces livingSpaces) { ISkinParam skinParam, LivingSpaces livingSpaces) {
super(stringBounder);
this.livingSpace1 = livingSpace1; this.livingSpace1 = livingSpace1;
this.livingSpaces = livingSpaces; this.livingSpaces = livingSpaces;
this.message = message; this.message = message;
@ -98,11 +99,12 @@ public class CommunicationTileSelf extends AbstractTile implements TileWithUpdat
return comp; return comp;
} }
public void updateStairs(StringBounder stringBounder, double y) { @Override
final ArrowComponent comp = getComponent(stringBounder); public void callbackY_internal(double y) {
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final ArrowComponent comp = getComponent(getStringBounder());
final Point2D p1 = comp.getStartPoint(stringBounder, dim); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
final Point2D p2 = comp.getEndPoint(stringBounder, dim); final Point2D p1 = comp.getStartPoint(getStringBounder(), dim);
final Point2D p2 = comp.getEndPoint(getStringBounder(), dim);
if (message.isActivate()) { if (message.isActivate()) {
livingSpace1.addStepForLivebox(getEvent(), y + p2.getY()); livingSpace1.addStepForLivebox(getEvent(), y + p2.getY());
@ -139,20 +141,20 @@ public class CommunicationTileSelf extends AbstractTile implements TileWithUpdat
comp.drawU(ug, area, (Context2D) ug); comp.drawU(ug, area, (Context2D) ug);
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
return dim.getHeight(); return dim.getHeight();
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
// final Component comp = getComponent(stringBounder); // final Component comp = getComponent(stringBounder);
// final Dimension2D dim = comp.getPreferredDimension(stringBounder); // final Dimension2D dim = comp.getPreferredDimension(stringBounder);
// final double width = dim.getWidth(); // final double width = dim.getWidth();
final LivingSpace next = getNext(); final LivingSpace next = getNext();
if (next != null) { if (next != null) {
next.getPosC(stringBounder).ensureBiggerThan(getMaxX(stringBounder)); next.getPosC(getStringBounder()).ensureBiggerThan(getMaxX());
} }
} }
@ -174,15 +176,15 @@ public class CommunicationTileSelf extends AbstractTile implements TileWithUpdat
return livingSpace1.getPosC(stringBounder); return livingSpace1.getPosC(stringBounder);
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
return getPoint1(stringBounder); return getPoint1(getStringBounder());
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
final double width = dim.getWidth(); final double width = dim.getWidth();
return livingSpace1.getPosC2(stringBounder).addFixed(width); return livingSpace1.getPosC2(getStringBounder()).addFixed(width);
} }
} }

View File

@ -51,7 +51,7 @@ import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
public class CommunicationTileSelfNoteRight extends AbstractTile implements TileWithUpdateStairs { public class CommunicationTileSelfNoteRight extends AbstractTile {
private final CommunicationTileSelf tile; private final CommunicationTileSelf tile;
private final Message message; private final Message message;
@ -62,14 +62,15 @@ public class CommunicationTileSelfNoteRight extends AbstractTile implements Tile
public Event getEvent() { public Event getEvent() {
return message; return message;
} }
@Override @Override
public double getYPoint(StringBounder stringBounder) { public double getContactPointRelative() {
return tile.getYPoint(stringBounder); return tile.getContactPointRelative();
} }
public CommunicationTileSelfNoteRight(CommunicationTileSelf tile, Message message, Rose skin, ISkinParam skinParam, public CommunicationTileSelfNoteRight(CommunicationTileSelf tile, Message message, Rose skin, ISkinParam skinParam,
Note noteOnMessage) { Note noteOnMessage) {
super(((AbstractTile) tile).getStringBounder());
this.tile = tile; this.tile = tile;
this.message = message; this.message = message;
this.skin = skin; this.skin = skin;
@ -77,18 +78,19 @@ public class CommunicationTileSelfNoteRight extends AbstractTile implements Tile
this.noteOnMessage = noteOnMessage; this.noteOnMessage = noteOnMessage;
} }
public void updateStairs(StringBounder stringBounder, double y) { @Override
tile.updateStairs(stringBounder, y); public void callbackY_internal(double y) {
tile.callbackY(y);
} }
private Component getComponent(StringBounder stringBounder) { private Component getComponent(StringBounder stringBounder) {
final Component comp = skin.createComponent(null, ComponentType.NOTE, final Component comp = skin.createComponent(null, ComponentType.NOTE, null,
null, noteOnMessage.getSkinParamBackcolored(skinParam), noteOnMessage.getStrings()); noteOnMessage.getSkinParamBackcolored(skinParam), noteOnMessage.getStrings());
return comp; return comp;
} }
private Real getNotePosition(StringBounder stringBounder) { private Real getNotePosition(StringBounder stringBounder) {
return tile.getMaxX(stringBounder); return tile.getMaxX();
} }
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
@ -102,24 +104,24 @@ public class CommunicationTileSelfNoteRight extends AbstractTile implements Tile
comp.drawU(ug.apply(UTranslate.dx(p.getCurrentValue())), area, (Context2D) ug); comp.drawU(ug.apply(UTranslate.dx(p.getCurrentValue())), area, (Context2D) ug);
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
return Math.max(tile.getPreferredHeight(stringBounder), dim.getHeight()); return Math.max(tile.getPreferredHeight(), dim.getHeight());
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
tile.addConstraints(stringBounder); tile.addConstraints();
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
return tile.getMinX(stringBounder); return tile.getMinX();
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
return getNotePosition(stringBounder).addFixed(dim.getWidth()); return getNotePosition(getStringBounder()).addFixed(dim.getWidth());
} }
} }

View File

@ -49,7 +49,7 @@ import net.sourceforge.plantuml.skin.Context2D;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
public class DelayTile extends AbstractTile implements Tile, TileWithCallbackY { public class DelayTile extends AbstractTile implements Tile {
private final Delay delay; private final Delay delay;
private final TileArguments tileArguments; private final TileArguments tileArguments;
@ -62,11 +62,13 @@ public class DelayTile extends AbstractTile implements Tile, TileWithCallbackY {
return delay; return delay;
} }
public void callbackY(double y) { @Override
public void callbackY_internal(double y) {
this.y = y; this.y = y;
} }
public DelayTile(Delay delay, TileArguments tileArguments) { public DelayTile(Delay delay, TileArguments tileArguments) {
super(tileArguments.getStringBounder());
this.delay = delay; this.delay = delay;
this.tileArguments = tileArguments; this.tileArguments = tileArguments;
} }
@ -102,27 +104,27 @@ public class DelayTile extends AbstractTile implements Tile, TileWithCallbackY {
final Area area = new Area(getPreferredWidth(stringBounder), dim.getHeight()); final Area area = new Area(getPreferredWidth(stringBounder), dim.getHeight());
tileArguments.getLivingSpaces().delayOn(y, dim.getHeight()); tileArguments.getLivingSpaces().delayOn(y, dim.getHeight());
ug = ug.apply(UTranslate.dx(getMinX(stringBounder).getCurrentValue())); ug = ug.apply(UTranslate.dx(getMinX().getCurrentValue()));
comp.drawU(ug, area, (Context2D) ug); comp.drawU(ug, area, (Context2D) ug);
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
return dim.getHeight(); return dim.getHeight();
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
init(stringBounder); init(getStringBounder());
return this.middle.addFixed(-getPreferredWidth(stringBounder) / 2); return this.middle.addFixed(-getPreferredWidth(getStringBounder()) / 2);
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
init(stringBounder); init(getStringBounder());
return this.middle.addFixed(getPreferredWidth(stringBounder) / 2); return this.middle.addFixed(getPreferredWidth(getStringBounder()) / 2);
} }
// private double startingY; // private double startingY;

View File

@ -63,6 +63,7 @@ public class DividerTile extends AbstractTile implements Tile {
} }
public DividerTile(Divider divider, TileArguments tileArguments) { public DividerTile(Divider divider, TileArguments tileArguments) {
super(tileArguments.getStringBounder());
this.tileArguments = tileArguments; this.tileArguments = tileArguments;
this.divider = divider; this.divider = divider;
this.skin = tileArguments.getSkin(); this.skin = tileArguments.getSkin();
@ -87,25 +88,25 @@ public class DividerTile extends AbstractTile implements Tile {
comp.drawU(ug, area, (Context2D) ug); comp.drawU(ug, area, (Context2D) ug);
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
return dim.getHeight(); return dim.getHeight();
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
// final Component comp = getComponent(stringBounder); // final Component comp = getComponent(stringBounder);
// final Dimension2D dim = comp.getPreferredDimension(stringBounder); // final Dimension2D dim = comp.getPreferredDimension(stringBounder);
// final double width = dim.getWidth(); // final double width = dim.getWidth();
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
return origin; return origin;
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
return origin.addFixed(dim.getWidth()); return origin.addFixed(dim.getWidth());
} }

View File

@ -49,7 +49,7 @@ import net.sourceforge.plantuml.skin.ComponentType;
import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
public class ElseTile extends AbstractTile implements TileWithCallbackY { public class ElseTile extends AbstractTile {
private final Rose skin; private final Rose skin;
private final ISkinParam skinParam; private final ISkinParam skinParam;
@ -61,11 +61,12 @@ public class ElseTile extends AbstractTile implements TileWithCallbackY {
} }
@Override @Override
public double getYPoint(StringBounder stringBounder) { public double getContactPointRelative() {
return 0; return 0;
} }
public ElseTile(GroupingLeaf anElse, Rose skin, ISkinParam skinParam, Tile parent) { public ElseTile(GroupingLeaf anElse, Rose skin, ISkinParam skinParam, Tile parent) {
super(((AbstractTile) parent).getStringBounder());
this.anElse = anElse; this.anElse = anElse;
this.skin = skin; this.skin = skin;
this.skinParam = skinParam; this.skinParam = skinParam;
@ -96,14 +97,15 @@ public class ElseTile extends AbstractTile implements TileWithCallbackY {
// // final double totalParentHeight = parent.getPreferredHeight(stringBounder); // // final double totalParentHeight = parent.getPreferredHeight(stringBounder);
// // height = totalParentHeight - (startingY - y); // // height = totalParentHeight - (startingY - y);
// // } // // }
// final Area area = new Area(max.getCurrentValue() - min.getCurrentValue(), height); // final Area area = new Area(max.getCurrentValue() - min.getCurrentValue(),
// height);
// ug = ug.apply(new UTranslate(min.getCurrentValue(), 0)); // ug = ug.apply(new UTranslate(min.getCurrentValue(), 0));
// comp.drawU(ug, area, context); // comp.drawU(ug, area, context);
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
double height = dim.getHeight(); double height = dim.getHeight();
if (anElse.getComment() != null) { if (anElse.getComment() != null) {
@ -112,25 +114,26 @@ public class ElseTile extends AbstractTile implements TileWithCallbackY {
return height; return height;
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
// final Component comp = getComponent(stringBounder); // final Component comp = getComponent(stringBounder);
// final Dimension2D dim = comp.getPreferredDimension(stringBounder); // final Dimension2D dim = comp.getPreferredDimension(stringBounder);
// final double width = dim.getWidth(); // final double width = dim.getWidth();
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
return parent.getMinX(stringBounder); return parent.getMinX();
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
return getMinX(stringBounder).addFixed(dim.getWidth()); return getMinX().addFixed(dim.getWidth());
} }
private double y; private double y;
public void callbackY(double y) { @Override
public void callbackY_internal(double y) {
this.y = y; this.y = y;
} }

View File

@ -36,7 +36,6 @@
package net.sourceforge.plantuml.sequencediagram.teoz; package net.sourceforge.plantuml.sequencediagram.teoz;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.real.Real;
import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.Participant;
@ -48,6 +47,7 @@ public class EmptyTile extends AbstractTile implements Tile {
private final Tile position; private final Tile position;
public EmptyTile(double height, Tile position) { public EmptyTile(double height, Tile position) {
super(((AbstractTile) position).getStringBounder());
this.height = height; this.height = height;
this.position = position; this.position = position;
} }
@ -55,19 +55,19 @@ public class EmptyTile extends AbstractTile implements Tile {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
return height; return height;
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
return position.getMinX(stringBounder); return position.getMinX();
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
return position.getMaxX(stringBounder); return position.getMaxX();
} }
public Event getEvent() { public Event getEvent() {

View File

@ -64,8 +64,8 @@ public class Englobers {
pending.add(p); pending.add(p);
continue; continue;
} }
pending = Englober.createTeoz(englober, p, tileArguments, tileArguments.getSkinParam() pending = Englober.createTeoz(englober, p, tileArguments,
.getCurrentStyleBuilder()); tileArguments.getSkinParam().getCurrentStyleBuilder());
englobers.add(pending); englobers.add(pending);
} }
} }

View File

@ -69,7 +69,8 @@ public class EventsHistory {
public int getLevelAt(Event event, EventsHistoryMode mode) { public int getLevelAt(Event event, EventsHistoryMode mode) {
final int result = getLevelAtInternal(event, mode); final int result = getLevelAtInternal(event, mode);
// System.err.println("EventsHistory::getLevelAt " + mode + " " + result + " " + event); // System.err.println("EventsHistory::getLevelAt " + mode + " " + result + " " +
// event);
return result; return result;
} }
@ -181,7 +182,8 @@ public class EventsHistory {
int value = 0; int value = 0;
for (Event event : events) { for (Event event : events) {
final Double position = ys3.get(event); final Double position = ys3.get(event);
// System.err.println("EventsHistory::getStairs event=" + event + " position=" + position); // System.err.println("EventsHistory::getStairs event=" + event + " position=" +
// position);
if (position != null) { if (position != null) {
assert position <= totalHeight : "position=" + position + " totalHeight=" + totalHeight; assert position <= totalHeight : "position=" + position + " totalHeight=" + totalHeight;
value = getLevelAt(event, EventsHistoryMode.CONSIDERE_FUTURE_DEACTIVATE); value = getLevelAt(event, EventsHistoryMode.CONSIDERE_FUTURE_DEACTIVATE);
@ -190,7 +192,8 @@ public class EventsHistory {
activateColor); activateColor);
} }
} }
// System.err.println("EventsHistory::getStairs finishing totalHeight=" + totalHeight); // System.err.println("EventsHistory::getStairs finishing totalHeight=" +
// totalHeight);
result.addStep(new StairsPosition(totalHeight, false), value, null); result.addStep(new StairsPosition(totalHeight, false), value, null);
// System.err.println("EventsHistory::getStairs " + p + " result=" + result); // System.err.println("EventsHistory::getStairs " + p + " result=" + result);
return result; return result;

View File

@ -59,12 +59,13 @@ import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
public class GroupingTile extends AbstractTile implements TileWithCallbackY { public class GroupingTile extends AbstractTile {
private static final int EXTERNAL_MARGINX1 = 3; private static final int EXTERNAL_MARGINX1 = 3;
private static final int EXTERNAL_MARGINX2 = 9; private static final int EXTERNAL_MARGINX2 = 9;
private static final int MARGINX = 16; private static final int MARGINX = 16;
private static final int MARGINY = 10; // private static final int MARGINY = 10;
private static final int MARGINY_MAGIC = 20;
private List<Tile> tiles = new ArrayList<Tile>(); private List<Tile> tiles = new ArrayList<Tile>();
private final Real min; private final Real min;
private final Real max; private final Real max;
@ -83,24 +84,27 @@ public class GroupingTile extends AbstractTile implements TileWithCallbackY {
} }
@Override @Override
public double getYPoint(StringBounder stringBounder) { public double getContactPointRelative() {
return 0; return 0;
} }
public GroupingTile(Iterator<Event> it, GroupingStart start, TileArguments tileArgumentsBachColorChanged, public GroupingTile(Iterator<Event> it, GroupingStart start, TileArguments tileArgumentsBackColorChanged,
TileArguments tileArgumentsOriginal) { TileArguments tileArgumentsOriginal) {
super(tileArgumentsBackColorChanged.getStringBounder());
final StringBounder stringBounder = tileArgumentsOriginal.getStringBounder(); final StringBounder stringBounder = tileArgumentsOriginal.getStringBounder();
this.start = start; this.start = start;
this.display = start.getTitle().equals("group") ? Display.create(start.getComment()) this.display = start.getTitle().equals("group") ? Display.create(start.getComment())
: Display.create(start.getTitle(), start.getComment()); : Display.create(start.getTitle(), start.getComment());
this.skin = tileArgumentsOriginal.getSkin(); this.skin = tileArgumentsOriginal.getSkin();
// this.skinParam = tileArgumentsOriginal.getSkinParam(); // this.skinParam = tileArgumentsOriginal.getSkinParam();
this.skinParam = tileArgumentsBachColorChanged.getSkinParam(); this.skinParam = tileArgumentsBackColorChanged.getSkinParam();
final List<Real> min2 = new ArrayList<Real>(); final List<Real> min2 = new ArrayList<Real>();
final List<Real> max2 = new ArrayList<Real>(); final List<Real> max2 = new ArrayList<Real>();
final List<Tile> allElses = new ArrayList<Tile>(); final List<Tile> allElses = new ArrayList<Tile>();
final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder);
while (it.hasNext()) { while (it.hasNext()) {
final Event ev = it.next(); final Event ev = it.next();
if (ev instanceof GroupingLeaf && ((Grouping) ev).getType() == GroupingType.END) { if (ev instanceof GroupingLeaf && ((Grouping) ev).getType() == GroupingType.END) {
@ -110,31 +114,31 @@ public class GroupingTile extends AbstractTile implements TileWithCallbackY {
tiles.add(tile); tiles.add(tile);
} }
} }
tiles = mergeParallel(tiles);
tiles = mergeParallel(getStringBounder(), tiles);
for (Tile tile : tiles) { for (Tile tile : tiles) {
bodyHeight += tile.getPreferredHeight(stringBounder); bodyHeight += tile.getPreferredHeight();
final Event ev = tile.getEvent(); final Event ev = tile.getEvent();
if (ev instanceof GroupingLeaf && ((Grouping) ev).getType() == GroupingType.ELSE) { if (ev instanceof GroupingLeaf && ((Grouping) ev).getType() == GroupingType.ELSE) {
allElses.add(tile); allElses.add(tile);
continue; continue;
} }
min2.add(tile.getMinX(stringBounder).addFixed(-MARGINX)); min2.add(tile.getMinX().addFixed(-MARGINX));
final Real m = tile.getMaxX(stringBounder); final Real m = tile.getMaxX();
// max2.add(m == tileArgumentsOriginal.getOmega() ? m : m.addFixed(MARGINX)); // max2.add(m == tileArgumentsOriginal.getOmega() ? m : m.addFixed(MARGINX));
max2.add(m.addFixed(MARGINX)); max2.add(m.addFixed(MARGINX));
} }
final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder);
final double width = dim1.getWidth(); final double width = dim1.getWidth();
if (min2.size() == 0) { if (min2.size() == 0) {
min2.add(tileArgumentsOriginal.getOrigin()); min2.add(tileArgumentsOriginal.getOrigin());
} }
this.min = RealUtils.min(min2); this.min = RealUtils.min(min2);
for (Tile anElse : allElses) { for (Tile anElse : allElses) {
max2.add(anElse.getMaxX(stringBounder)); max2.add(anElse.getMaxX());
} }
max2.add(this.min.addFixed(width + 16)); max2.add(this.min.addFixed(width + 16));
this.max = RealUtils.max(max2); this.max = RealUtils.max(max2);
} }
private Component getComponent(StringBounder stringBounder) { private Component getComponent(StringBounder stringBounder) {
@ -154,36 +158,31 @@ public class GroupingTile extends AbstractTile implements TileWithCallbackY {
final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder); final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder);
final Area area = new Area(max.getCurrentValue() - min.getCurrentValue(), getTotalHeight(stringBounder)); final Area area = new Area(max.getCurrentValue() - min.getCurrentValue(), getTotalHeight(stringBounder));
if (ug instanceof LiveBoxFinder == false) { comp.drawU(ug.apply(UTranslate.dx(min.getCurrentValue())), area, (Context2D) ug);
comp.drawU(ug.apply(UTranslate.dx(min.getCurrentValue())), area, (Context2D) ug); drawAllElses(ug);
drawAllElses(ug);
}
// ug.apply(UChangeBackColor.nnn(HtmlColorUtils.LIGHT_GRAY)).draw(new
// URectangle(area.getDimensionToUse()));
double h = dim1.getHeight() + MARGINY / 2; double h = dim1.getHeight() + MARGINY_MAGIC / 2;
for (Tile tile : tiles) { for (Tile tile : tiles) {
ug.apply(UTranslate.dy(h)).draw(tile); tile.drawU(ug.apply(UTranslate.dy(h)));
final double preferredHeight = tile.getPreferredHeight(stringBounder); final double preferredHeight = tile.getPreferredHeight();
h += preferredHeight; h += preferredHeight;
} }
} }
private double getTotalHeight(StringBounder stringBounder) { private double getTotalHeight(StringBounder stringBounder) {
final Dimension2D dimIfEmpty = getPreferredDimensionIfEmpty(stringBounder); final Dimension2D dimIfEmpty = getPreferredDimensionIfEmpty(stringBounder);
return bodyHeight + dimIfEmpty.getHeight() + MARGINY / 2; return bodyHeight + dimIfEmpty.getHeight() + MARGINY_MAGIC / 2;
} }
private void drawAllElses(UGraphic ug) { private void drawAllElses(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder(); final StringBounder stringBounder = ug.getStringBounder();
final double totalHeight = getTotalHeight(stringBounder); final double totalHeight = getTotalHeight(stringBounder);
// final double suppHeight =
// getPreferredDimensionIfEmpty(stringBounder).getHeight() + MARGINY / 2;
final List<Double> ys = new ArrayList<Double>(); final List<Double> ys = new ArrayList<Double>();
for (Tile tile : tiles) { for (Tile tile : tiles) {
if (tile instanceof ElseTile) { if (tile instanceof ElseTile) {
final ElseTile elseTile = (ElseTile) tile; final ElseTile elseTile = (ElseTile) tile;
ys.add(elseTile.getCallbackY() - y + MARGINY / 2/* suppHeight */); ys.add(elseTile.getCallbackY() - y + MARGINY_MAGIC / 2);
} }
} }
ys.add(totalHeight); ys.add(totalHeight);
@ -199,34 +198,35 @@ public class GroupingTile extends AbstractTile implements TileWithCallbackY {
} }
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder); final Dimension2D dim1 = getPreferredDimensionIfEmpty(getStringBounder());
return dim1.getHeight() + bodyHeight + MARGINY; return dim1.getHeight() + bodyHeight + MARGINY_MAGIC;
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
for (Tile tile : tiles) { for (Tile tile : tiles) {
tile.addConstraints(stringBounder); tile.addConstraints();
} }
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
return min.addFixed(-EXTERNAL_MARGINX1); return min.addFixed(-EXTERNAL_MARGINX1);
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
return max.addFixed(EXTERNAL_MARGINX2); return max.addFixed(EXTERNAL_MARGINX2);
} }
private double y; private double y;
public void callbackY(double y) { @Override
public void callbackY_internal(double y) {
this.y = y; this.y = y;
} }
public static double fillPositionelTiles(StringBounder stringBounder, double y, List<Tile> tiles, public static double fillPositionelTiles(StringBounder stringBounder, double y, List<Tile> tiles,
final List<YPositionedTile> local, List<YPositionedTile> full) { final List<YPositionedTile> local, List<YPositionedTile> full) {
for (Tile tile : mergeParallel(tiles)) { for (Tile tile : mergeParallel(stringBounder, tiles)) {
final YPositionedTile ytile = new YPositionedTile(tile, y); final YPositionedTile ytile = new YPositionedTile(tile, y);
local.add(ytile); local.add(ytile);
full.add(ytile); full.add(ytile);
@ -236,7 +236,7 @@ public class GroupingTile extends AbstractTile implements TileWithCallbackY {
final ArrayList<YPositionedTile> local2 = new ArrayList<YPositionedTile>(); final ArrayList<YPositionedTile> local2 = new ArrayList<YPositionedTile>();
fillPositionelTiles(stringBounder, y + headerHeight, groupingTile.tiles, local2, full); fillPositionelTiles(stringBounder, y + headerHeight, groupingTile.tiles, local2, full);
} }
y += tile.getPreferredHeight(stringBounder); y += tile.getPreferredHeight();
} }
return y; return y;
@ -246,14 +246,14 @@ public class GroupingTile extends AbstractTile implements TileWithCallbackY {
return getPreferredDimensionIfEmpty(stringBounder).getHeight() + 10; return getPreferredDimensionIfEmpty(stringBounder).getHeight() + 10;
} }
private static List<Tile> mergeParallel(List<Tile> tiles) { private static List<Tile> mergeParallel(StringBounder stringBounder, List<Tile> tiles) {
TileParallel pending = null; TileParallel pending = null;
tiles = removeEmptyCloseToParallel(tiles); tiles = removeEmptyCloseToParallel(tiles);
final List<Tile> result = new ArrayList<Tile>(); final List<Tile> result = new ArrayList<Tile>();
for (Tile tile : tiles) { for (Tile tile : tiles) {
if (isParallel(tile)) { if (isParallel(tile)) {
if (pending == null) { if (pending == null) {
pending = new TileParallel(); pending = new TileParallel(stringBounder);
final Tile tmp = result.get(result.size() - 1); final Tile tmp = result.get(result.size() - 1);
if (tmp instanceof LifeEventTile) { if (tmp instanceof LifeEventTile) {
pending.add(result.get(result.size() - 2)); pending.add(result.get(result.size() - 2));
@ -293,7 +293,7 @@ public class GroupingTile extends AbstractTile implements TileWithCallbackY {
} }
} }
private static boolean isParallel(Tile tile) { public static boolean isParallel(Tile tile) {
return tile instanceof TileParallel == false && tile.getEvent().isParallel(); return tile instanceof TileParallel == false && tile.getEvent().isParallel();
} }

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.sequencediagram.teoz; package net.sourceforge.plantuml.sequencediagram.teoz;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.real.Real;
import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.sequencediagram.HSpace; import net.sourceforge.plantuml.sequencediagram.HSpace;
@ -51,6 +50,7 @@ public class HSpaceTile extends AbstractTile implements Tile {
} }
public HSpaceTile(HSpace hspace, TileArguments tileArguments) { public HSpaceTile(HSpace hspace, TileArguments tileArguments) {
super(tileArguments.getStringBounder());
this.hspace = hspace; this.hspace = hspace;
this.origin = tileArguments.getOrigin(); this.origin = tileArguments.getOrigin();
} }
@ -58,18 +58,18 @@ public class HSpaceTile extends AbstractTile implements Tile {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
return hspace.getPixel(); return hspace.getPixel();
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
return origin; return origin;
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
return origin.addFixed(10); return origin.addFixed(10);
} }

View File

@ -38,7 +38,6 @@ package net.sourceforge.plantuml.sequencediagram.teoz;
import java.awt.geom.Dimension2D; import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.real.Real;
import net.sourceforge.plantuml.real.RealUtils; import net.sourceforge.plantuml.real.RealUtils;
import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.sequencediagram.Event;
@ -51,7 +50,7 @@ import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
public class LifeEventTile extends AbstractTile implements TileWithUpdateStairs { public class LifeEventTile extends AbstractTile {
private final LifeEvent lifeEvent; private final LifeEvent lifeEvent;
private final TileArguments tileArguments; private final TileArguments tileArguments;
@ -59,22 +58,25 @@ public class LifeEventTile extends AbstractTile implements TileWithUpdateStairs
private final Rose skin; private final Rose skin;
private final ISkinParam skinParam; private final ISkinParam skinParam;
public void updateStairs(StringBounder stringBounder, double y) { @Override
// System.err.println("LifeEventTile::updateStairs " + lifeEvent + " " + livingSpace.getParticipant() + " y=" + y); public void callbackY_internal(double y) {
// System.err.println("LifeEventTile::updateStairs " + lifeEvent + " " +
// livingSpace.getParticipant() + " y=" + y);
livingSpace.addStepForLivebox(getEvent(), y); livingSpace.addStepForLivebox(getEvent(), y);
} }
public Event getEvent() { public Event getEvent() {
return lifeEvent; return lifeEvent;
} }
@Override @Override
public double getYPoint(StringBounder stringBounder) { public double getContactPointRelative() {
return 0; return 0;
} }
public LifeEventTile(LifeEvent lifeEvent, TileArguments tileArguments, LivingSpace livingSpace, Rose skin, public LifeEventTile(LifeEvent lifeEvent, TileArguments tileArguments, LivingSpace livingSpace, Rose skin,
ISkinParam skinParam) { ISkinParam skinParam) {
super(tileArguments.getStringBounder());
this.lifeEvent = lifeEvent; this.lifeEvent = lifeEvent;
this.tileArguments = tileArguments; this.tileArguments = tileArguments;
this.livingSpace = livingSpace; this.livingSpace = livingSpace;
@ -95,29 +97,30 @@ public class LifeEventTile extends AbstractTile implements TileWithUpdateStairs
return lifeEvent.getMessage() == null && lifeEvent.getType() == LifeEventType.DESTROY; return lifeEvent.getMessage() == null && lifeEvent.getType() == LifeEventType.DESTROY;
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
// if (lifeEvent.isActivate()) { // if (lifeEvent.isActivate()) {
// return 20; // return 20;
// } // }
if (isDestroyWithoutMessage()) { if (isDestroyWithoutMessage()) {
final Component cross = skin.createComponent(null, ComponentType.DESTROY, null, skinParam, null); final Component cross = skin.createComponent(null, ComponentType.DESTROY, null, skinParam, null);
final Dimension2D dimCross = cross.getPreferredDimension(stringBounder); final Dimension2D dimCross = cross.getPreferredDimension(getStringBounder());
return dimCross.getHeight(); return dimCross.getHeight();
} }
return 0; return 0;
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
// return tileArguments.getLivingSpace(lifeEvent.getParticipant()).getPosB(); // return tileArguments.getLivingSpace(lifeEvent.getParticipant()).getPosB();
return livingSpace.getPosB(); return livingSpace.getPosB();
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
// final LivingSpace livingSpace2 = tileArguments.getLivingSpace(lifeEvent.getParticipant()); // final LivingSpace livingSpace2 =
return RealUtils.max(livingSpace.getPosD(stringBounder), livingSpace.getPosC2(stringBounder)); // tileArguments.getLivingSpace(lifeEvent.getParticipant());
return RealUtils.max(livingSpace.getPosD(getStringBounder()), livingSpace.getPosC2(getStringBounder()));
} }
} }

View File

@ -1,127 +0,0 @@
/* ========================================================================
* 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.sequencediagram.teoz;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.UBackground;
import net.sourceforge.plantuml.ugraphic.UChange;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UGraphicNo;
import net.sourceforge.plantuml.ugraphic.UParam;
import net.sourceforge.plantuml.ugraphic.UParamNull;
import net.sourceforge.plantuml.ugraphic.UShape;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class LiveBoxFinder extends UGraphicNo implements UGraphic {
public boolean matchesProperty(String propertyName) {
return false;
}
public double dpiFactor() {
return 1;
}
public UGraphic apply(UChange change) {
if (change instanceof UTranslate) {
return new LiveBoxFinder(stringBounder, translate.compose((UTranslate) change));
} else if (change instanceof UStroke) {
return new LiveBoxFinder(this);
} else if (change instanceof UBackground) {
return new LiveBoxFinder(this);
} else if (change instanceof HColor) {
return new LiveBoxFinder(this);
}
throw new UnsupportedOperationException();
}
private final StringBounder stringBounder;
private final UTranslate translate;
public LiveBoxFinder(StringBounder stringBounder) {
this(stringBounder, new UTranslate());
}
private LiveBoxFinder(StringBounder stringBounder, UTranslate translate) {
this.stringBounder = stringBounder;
this.translate = translate;
}
private LiveBoxFinder(LiveBoxFinder other) {
this(other.stringBounder, other.translate);
}
public StringBounder getStringBounder() {
return stringBounder;
}
public UParam getParam() {
return new UParamNull();
}
public void draw(UShape shape) {
final double x = translate.getDx();
final double y = translate.getDy();
if (shape instanceof GroupingTile) {
((GroupingTile) shape).drawU(this);
} else if (shape instanceof TileWithUpdateStairs) {
((TileWithUpdateStairs) shape).updateStairs(stringBounder, y);
// } else if (shape instanceof EmptyTile) {
// // Nothing ?
// } else if (shape instanceof TileParallel) {
// // Nothing ?
// } else if (shape instanceof NotesTile) {
// // Nothing ?
// } else if (shape instanceof Tile) {
// Log.info("OtherTile " + shape);
} else {
// Nothing ?
// throw new UnsupportedOperationException(shape.getClass().getName());
}
}
public ColorMapper getColorMapper() {
return new ColorMapperIdentity();
}
public void flushUg() {
}
}

View File

@ -68,10 +68,13 @@ public class LiveBoxesDrawer {
private final Collection<Segment> delays; private final Collection<Segment> delays;
public LiveBoxesDrawer(Context2D context, Rose skin, ISkinParam skinParam, Map<Double, Double> delays) { public LiveBoxesDrawer(Context2D context, Rose skin, ISkinParam skinParam, Map<Double, Double> delays) {
this.cross = skin.createComponent(new Style[] { ComponentType.DESTROY.getDefaultStyleDefinition() this.cross = skin.createComponent(
.getMergedStyle(skinParam.getCurrentStyleBuilder()) }, ComponentType.DESTROY, null, skinParam, null); new Style[] { ComponentType.DESTROY.getDefaultStyleDefinition()
this.compForWidth = skin.createComponent(new Style[] { ComponentType.ALIVE_BOX_CLOSE_CLOSE .getMergedStyle(skinParam.getCurrentStyleBuilder()) },
.getDefaultStyleDefinition().getMergedStyle(skinParam.getCurrentStyleBuilder()) }, ComponentType.DESTROY, null, skinParam, null);
this.compForWidth = skin.createComponent(
new Style[] { ComponentType.ALIVE_BOX_CLOSE_CLOSE.getDefaultStyleDefinition()
.getMergedStyle(skinParam.getCurrentStyleBuilder()) },
ComponentType.ALIVE_BOX_CLOSE_CLOSE, null, skinParam, null); ComponentType.ALIVE_BOX_CLOSE_CLOSE, null, skinParam, null);
this.context = context; this.context = context;
this.skin = skin; this.skin = skin;
@ -121,8 +124,8 @@ public class LiveBoxesDrawer {
private void drawInternal(UGraphic ug, StairsPosition yposition, double ya, double yb, ComponentType type) { private void drawInternal(UGraphic ug, StairsPosition yposition, 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, symbolContext == null ? null ISkinParam skinParam2 = new SkinParamBackcolored(skinParam,
: 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) {
style = style.eventuallyOverride(symbolContext); style = style.eventuallyOverride(symbolContext);

View File

@ -35,23 +35,23 @@
*/ */
package net.sourceforge.plantuml.sequencediagram.teoz; package net.sourceforge.plantuml.sequencediagram.teoz;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.real.Real;
import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.sequencediagram.Newpage; import net.sourceforge.plantuml.sequencediagram.Newpage;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
public class NewpageTile extends AbstractTile implements TileWithCallbackY { public class NewpageTile extends AbstractTile {
private final Newpage newpage; private final Newpage newpage;
private final TileArguments tileArguments; private final TileArguments tileArguments;
@Override @Override
public double getYPoint(StringBounder stringBounder) { public double getContactPointRelative() {
return 0; return 0;
} }
public NewpageTile(Newpage newpage, TileArguments tileArguments) { public NewpageTile(Newpage newpage, TileArguments tileArguments) {
super(tileArguments.getStringBounder());
this.newpage = newpage; this.newpage = newpage;
this.tileArguments = tileArguments; this.tileArguments = tileArguments;
} }
@ -59,24 +59,25 @@ public class NewpageTile extends AbstractTile implements TileWithCallbackY {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
return 0; return 0;
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
return tileArguments.getOrigin(); return tileArguments.getOrigin();
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
return tileArguments.getOrigin(); return tileArguments.getOrigin();
} }
private double y; private double y;
public void callbackY(double y) { @Override
public void callbackY_internal(double y) {
this.y = y; this.y = y;
} }

View File

@ -66,11 +66,13 @@ public class NoteTile extends AbstractTile implements Tile {
} }
@Override @Override
public double getYPoint(StringBounder stringBounder) { public double getContactPointRelative() {
return getComponent(stringBounder).getPreferredHeight(stringBounder) / 2; return getComponent(getStringBounder()).getPreferredHeight(getStringBounder()) / 2;
} }
public NoteTile(LivingSpace livingSpace1, LivingSpace livingSpace2, Note note, Rose skin, ISkinParam skinParam) { public NoteTile(StringBounder stringBounder, LivingSpace livingSpace1, LivingSpace livingSpace2, Note note,
Rose skin, ISkinParam skinParam) {
super(stringBounder);
this.livingSpace1 = livingSpace1; this.livingSpace1 = livingSpace1;
this.livingSpace2 = livingSpace2; this.livingSpace2 = livingSpace2;
this.note = note; this.note = note;
@ -140,20 +142,20 @@ public class NoteTile extends AbstractTile implements Tile {
} }
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
return dim.getHeight(); return dim.getHeight();
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
// final Component comp = getComponent(stringBounder); // final Component comp = getComponent(stringBounder);
// final Dimension2D dim = comp.getPreferredDimension(stringBounder); // final Dimension2D dim = comp.getPreferredDimension(stringBounder);
// final double width = dim.getWidth(); // final double width = dim.getWidth();
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
final Real result = getX(stringBounder); final Real result = getX(getStringBounder());
if (note.getPosition() == NotePosition.OVER_SEVERAL) { if (note.getPosition() == NotePosition.OVER_SEVERAL) {
final Real x1 = livingSpace1.getPosB(); final Real x1 = livingSpace1.getPosB();
return RealUtils.min(result, x1); return RealUtils.min(result, x1);
@ -161,10 +163,10 @@ public class NoteTile extends AbstractTile implements Tile {
return result; return result;
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
final Real result = getX(stringBounder).addFixed(getUsedWidth(stringBounder)); final Real result = getX(getStringBounder()).addFixed(getUsedWidth(getStringBounder()));
if (note.getPosition() == NotePosition.OVER_SEVERAL) { if (note.getPosition() == NotePosition.OVER_SEVERAL) {
final Real x2 = livingSpace2.getPosD(stringBounder); final Real x2 = livingSpace2.getPosD(getStringBounder());
return RealUtils.max(result, x2); return RealUtils.max(result, x2);
} }
return result; return result;

View File

@ -67,7 +67,9 @@ public class NotesTile extends AbstractTile implements Tile {
return notes; return notes;
} }
public NotesTile(LivingSpaces livingSpaces, Notes notes, Rose skin, ISkinParam skinParam) { public NotesTile(StringBounder stringBounder, LivingSpaces livingSpaces, Notes notes, Rose skin,
ISkinParam skinParam) {
super(stringBounder);
this.livingSpaces = livingSpaces; this.livingSpaces = livingSpaces;
this.notes = notes; this.notes = notes;
this.skin = skin; this.skin = skin;
@ -138,39 +140,39 @@ public class NotesTile extends AbstractTile implements Tile {
} }
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
double result = 0; double result = 0;
for (Note note : notes) { for (Note note : notes) {
final Component comp = getComponent(stringBounder, note); final Component comp = getComponent(getStringBounder(), note);
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
result = Math.max(result, dim.getHeight()); result = Math.max(result, dim.getHeight());
} }
return result; return result;
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
final List<Note> all = notes.asList(); final List<Note> all = notes.asList();
for (int i = 0; i < all.size() - 1; i++) { for (int i = 0; i < all.size() - 1; i++) {
for (int j = i + 1; j < all.size(); j++) { for (int j = i + 1; j < all.size(); j++) {
final double center1 = getXcenter(stringBounder, all.get(i)).getCurrentValue(); final double center1 = getXcenter(getStringBounder(), all.get(i)).getCurrentValue();
final double center2 = getXcenter(stringBounder, all.get(j)).getCurrentValue(); final double center2 = getXcenter(getStringBounder(), all.get(j)).getCurrentValue();
if (center2 > center1) { if (center2 > center1) {
final Real point1b = getX2(stringBounder, all.get(i)); final Real point1b = getX2(getStringBounder(), all.get(i));
final Real point2 = getX(stringBounder, all.get(j)); final Real point2 = getX(getStringBounder(), all.get(j));
point2.ensureBiggerThan(point1b); point2.ensureBiggerThan(point1b);
} else { } else {
final Real point1 = getX(stringBounder, all.get(i)); final Real point1 = getX(getStringBounder(), all.get(i));
final Real point2b = getX2(stringBounder, all.get(j)); final Real point2b = getX2(getStringBounder(), all.get(j));
point1.ensureBiggerThan(point2b); point1.ensureBiggerThan(point2b);
} }
} }
} }
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
final List<Real> reals = new ArrayList<Real>(); final List<Real> reals = new ArrayList<Real>();
for (Note note : notes) { for (Note note : notes) {
reals.add(getX(stringBounder, note)); reals.add(getX(getStringBounder(), note));
} }
return RealUtils.min(reals); return RealUtils.min(reals);
} }
@ -179,10 +181,10 @@ public class NotesTile extends AbstractTile implements Tile {
return getX(stringBounder, note).addFixed(getUsedWidth(stringBounder, note)); return getX(stringBounder, note).addFixed(getUsedWidth(stringBounder, note));
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
final List<Real> reals = new ArrayList<Real>(); final List<Real> reals = new ArrayList<Real>();
for (Note note : notes) { for (Note note : notes) {
reals.add(getX2(stringBounder, note)); reals.add(getX2(getStringBounder(), note));
} }
return RealUtils.max(reals); return RealUtils.max(reals);
} }

View File

@ -79,8 +79,8 @@ public class PlayingSpace implements Bordered {
tiles.addAll(TileBuilder.buildSeveral(diagram.events().iterator(), tileArguments, null)); tiles.addAll(TileBuilder.buildSeveral(diagram.events().iterator(), tileArguments, null));
for (Tile tile : tiles) { for (Tile tile : tiles) {
min2.add(tile.getMinX(tileArguments.getStringBounder())); min2.add(tile.getMinX());
max2.add(tile.getMaxX(tileArguments.getStringBounder())); max2.add(tile.getMaxX());
} }
for (LivingSpace livingSpace : livingSpaces.values()) { for (LivingSpace livingSpace : livingSpaces.values()) {
@ -95,10 +95,6 @@ public class PlayingSpace implements Bordered {
} }
public void drawBackground(UGraphic ug) { public void drawBackground(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final LiveBoxFinder liveBoxFinder = new LiveBoxFinder(stringBounder);
drawUInternal(liveBoxFinder, false);
final UGraphicInterceptorTile interceptor = new UGraphicInterceptorTile(ug, true); final UGraphicInterceptorTile interceptor = new UGraphicInterceptorTile(ug, true);
drawUInternal(interceptor, false); drawUInternal(interceptor, false);
} }
@ -146,9 +142,9 @@ public class PlayingSpace implements Bordered {
return result; return result;
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
for (Tile tile : tiles) { for (Tile tile : tiles) {
tile.addConstraints(stringBounder); tile.addConstraints();
} }
} }

View File

@ -72,8 +72,8 @@ public class PlayingSpaceWithParticipants extends AbstractTextBlock implements T
- playingSpace.getMinX(stringBounder).getCurrentValue(); - playingSpace.getMinX(stringBounder).getCurrentValue();
final int factor = playingSpace.isShowFootbox() ? 2 : 1; final int factor = playingSpace.isShowFootbox() ? 2 : 1;
final double height = playingSpace.getPreferredHeight(stringBounder) + factor final double height = playingSpace.getPreferredHeight(stringBounder)
* playingSpace.getLivingSpaces().getHeadHeight(stringBounder); + factor * playingSpace.getLivingSpaces().getHeadHeight(stringBounder);
cacheDimension = new Dimension2DDouble(width, height); cacheDimension = new Dimension2DDouble(width, height);
} }
@ -106,7 +106,8 @@ public class PlayingSpaceWithParticipants extends AbstractTextBlock implements T
playingSpace.drawForeground(ug.apply(UTranslate.dy(headHeight))); playingSpace.drawForeground(ug.apply(UTranslate.dy(headHeight)));
} else { } else {
final UClip clip = new UClip(-1000, ymin, Double.MAX_VALUE, ymax - ymin + 1); final UClip clip = new UClip(-1000, ymin, Double.MAX_VALUE, ymax - ymin + 1);
// playingSpace.drawForeground(new UGraphicNewpages(ug.apply(UTranslate.dy(headHeight)), ymin, ymax)); // playingSpace.drawForeground(new
// UGraphicNewpages(ug.apply(UTranslate.dy(headHeight)), ymin, ymax));
playingSpace.drawForeground(ug.apply(UTranslate.dy(headHeight)).apply(clip)); playingSpace.drawForeground(ug.apply(UTranslate.dy(headHeight)).apply(clip));
} }
// drawNewPages(ug.apply(UTranslate.dy(headHeight))); // drawNewPages(ug.apply(UTranslate.dy(headHeight)));

View File

@ -62,6 +62,7 @@ public class ReferenceTile extends AbstractTile implements Tile {
} }
public ReferenceTile(Reference reference, TileArguments tileArguments) { public ReferenceTile(Reference reference, TileArguments tileArguments) {
super(tileArguments.getStringBounder());
this.reference = reference; this.reference = reference;
this.tileArguments = tileArguments; this.tileArguments = tileArguments;
} }
@ -94,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, final Component comp = tileArguments.getSkin().createComponent(null, ComponentType.REFERENCE, null,
null, tileArguments.getSkinParam(), strings); tileArguments.getSkinParam(), strings);
return comp; return comp;
} }
@ -110,22 +111,22 @@ public class ReferenceTile extends AbstractTile implements Tile {
comp.drawU(ug, area, (Context2D) ug); comp.drawU(ug, area, (Context2D) ug);
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
final Component comp = getComponent(stringBounder); final Component comp = getComponent(getStringBounder());
final Dimension2D dim = comp.getPreferredDimension(stringBounder); final Dimension2D dim = comp.getPreferredDimension(getStringBounder());
return dim.getHeight(); return dim.getHeight();
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
init(stringBounder); init(getStringBounder());
return this.first; return this.first;
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
init(stringBounder); init(getStringBounder());
return this.last; return this.last;
} }

View File

@ -227,7 +227,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
this.englobers = new Englobers(tileArguments); this.englobers = new Englobers(tileArguments);
final PlayingSpace mainTile = new PlayingSpace(diagram, englobers, tileArguments); final PlayingSpace mainTile = new PlayingSpace(diagram, englobers, tileArguments);
this.livingSpaces.addConstraints(stringBounder); this.livingSpaces.addConstraints(stringBounder);
mainTile.addConstraints(stringBounder); mainTile.addConstraints();
this.englobers.addConstraints(stringBounder); this.englobers.addConstraints(stringBounder);
origin.compileNow(); origin.compileNow();
tileArguments.setBordered(mainTile); tileArguments.setBordered(mainTile);

View File

@ -58,7 +58,8 @@ public class Stairs2 {
if (value < 0) { if (value < 0) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
// System.err.println("Stairs2::addStep " + position + " " + value + " color=" + color); // System.err.println("Stairs2::addStep " + position + " " + value + " color=" +
// color);
assert ys.size() == values.size(); assert ys.size() == values.size();
if (ys.size() > 0) { if (ys.size() > 0) {
final double lastY = ys.get(ys.size() - 1).getValue(); final double lastY = ys.get(ys.size() - 1).getValue();

View File

@ -35,29 +35,27 @@
*/ */
package net.sourceforge.plantuml.sequencediagram.teoz; package net.sourceforge.plantuml.sequencediagram.teoz;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.real.Real;
import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.ugraphic.UShape;
public interface Tile extends UDrawable, UShape { public interface Tile extends Tile2 {
public double getPreferredHeight(StringBounder stringBounder); public double getPreferredHeight();
public void addConstraints(StringBounder stringBounder); public void callbackY(double y);
public Real getMinX(StringBounder stringBounder); public void addConstraints();
public Real getMaxX(StringBounder stringBounder); public Real getMinX();
public Real getMaxX();
public Event getEvent(); public Event getEvent();
public double getYPoint(StringBounder stringBounder); public double getContactPointRelative();
public double getZZZ();
public double getZ(StringBounder stringBounder);
public boolean matchAnchorV1(String anchor); public boolean matchAnchorV1(String anchor);
} }

View File

@ -35,8 +35,8 @@
*/ */
package net.sourceforge.plantuml.sequencediagram.teoz; package net.sourceforge.plantuml.sequencediagram.teoz;
import net.sourceforge.plantuml.graphic.UDrawable;
public interface TileWithCallbackY extends Tile { public interface Tile2 extends UDrawable {
public void callbackY(double y);
} }

View File

@ -62,8 +62,8 @@ public class TileArguments implements Bordered {
} }
public TileArguments withBackColorGeneral(HColor backColorElement, HColor backColorGeneral) { public TileArguments withBackColorGeneral(HColor backColorElement, HColor backColorGeneral) {
return new TileArguments(stringBounder, livingSpaces, skin, new SkinParamBackcolored(skinParam, return new TileArguments(stringBounder, livingSpaces, skin,
backColorElement, backColorGeneral), origin); new SkinParamBackcolored(skinParam, backColorElement, backColorGeneral), origin);
} }
public TileArguments withBackColor(Reference reference) { public TileArguments withBackColor(Reference reference) {

View File

@ -68,7 +68,7 @@ public class TileBuilder {
final Event ev = it.next(); final Event ev = it.next();
for (Tile tile : TileBuilder.buildOne(it, tileArguments, ev, parent)) { for (Tile tile : TileBuilder.buildOne(it, tileArguments, ev, parent)) {
tiles.add(tile); tiles.add(tile);
final Real tmpMax = tile.getMaxX(tileArguments.getStringBounder()); final Real tmpMax = tile.getMaxX();
} }
} }
return Collections.unmodifiableList(tiles); return Collections.unmodifiableList(tiles);
@ -90,29 +90,27 @@ public class TileBuilder {
boolean reverse = false; boolean reverse = false;
Tile result = null; Tile result = null;
if (msg.isSelfMessage()) { if (msg.isSelfMessage()) {
result = new CommunicationTileSelf(livingSpace1, msg, skin, skinParam, livingSpaces); result = new CommunicationTileSelf(tileArguments.getStringBounder(), livingSpace1, msg, skin, skinParam,
livingSpaces);
} else { } else {
// System.err.println("msg=" + msg); result = new CommunicationTile(tileArguments.getStringBounder(), livingSpaces, msg, skin, skinParam);
result = new CommunicationTile(livingSpace1, livingSpace2, msg, skin, skinParam);
reverse = ((CommunicationTile) result).isReverse(stringBounder); reverse = ((CommunicationTile) result).isReverse(stringBounder);
} }
for (Note noteOnMessage : msg.getNoteOnMessages()) { for (Note noteOnMessage : msg.getNoteOnMessages()) {
final NotePosition notePosition = noteOnMessage.getPosition(); final NotePosition notePosition = noteOnMessage.getPosition();
if (notePosition == NotePosition.LEFT) { if (notePosition == NotePosition.LEFT) {
result = new CommunicationTileNoteLeft((TileWithUpdateStairs) result, msg, skin, skinParam, result = new CommunicationTileNoteLeft(result, msg, skin, skinParam,
reverse ? livingSpace2 : livingSpace1, noteOnMessage); reverse ? livingSpace2 : livingSpace1, noteOnMessage);
} else if (notePosition == NotePosition.RIGHT && msg.isSelfMessage()) { } else if (notePosition == NotePosition.RIGHT && msg.isSelfMessage()) {
result = new CommunicationTileSelfNoteRight((CommunicationTileSelf) result, msg, skin, skinParam, result = new CommunicationTileSelfNoteRight((CommunicationTileSelf) result, msg, skin, skinParam,
noteOnMessage); noteOnMessage);
} else if (notePosition == NotePosition.RIGHT) { } else if (notePosition == NotePosition.RIGHT) {
result = new CommunicationTileNoteRight((TileWithUpdateStairs) result, msg, skin, skinParam, result = new CommunicationTileNoteRight(result, msg, skin, skinParam,
reverse ? livingSpace1 : livingSpace2, noteOnMessage); reverse ? livingSpace1 : livingSpace2, noteOnMessage);
} else if (notePosition == NotePosition.BOTTOM) { } else if (notePosition == NotePosition.BOTTOM) {
result = new CommunicationTileNoteBottom((TileWithUpdateStairs) result, msg, skin, skinParam, result = new CommunicationTileNoteBottom(result, msg, skin, skinParam, noteOnMessage);
noteOnMessage);
} else if (notePosition == NotePosition.TOP) { } else if (notePosition == NotePosition.TOP) {
result = new CommunicationTileNoteTop((TileWithUpdateStairs) result, msg, skin, skinParam, result = new CommunicationTileNoteTop(result, msg, skin, skinParam, noteOnMessage);
noteOnMessage);
} }
} }
tiles.add(result); tiles.add(result);
@ -124,11 +122,9 @@ public class TileBuilder {
for (Note noteOnMessage : exo.getNoteOnMessages()) { for (Note noteOnMessage : exo.getNoteOnMessages()) {
final NotePosition notePosition = exo.getNoteOnMessages().get(0).getPosition(); final NotePosition notePosition = exo.getNoteOnMessages().get(0).getPosition();
if (notePosition == NotePosition.LEFT) { if (notePosition == NotePosition.LEFT) {
result = new CommunicationTileNoteLeft((TileWithUpdateStairs) result, exo, skin, skinParam, result = new CommunicationTileNoteLeft(result, exo, skin, skinParam, livingSpace1, noteOnMessage);
livingSpace1, noteOnMessage);
} else if (notePosition == NotePosition.RIGHT) { } else if (notePosition == NotePosition.RIGHT) {
result = new CommunicationTileNoteRight((TileWithUpdateStairs) result, exo, skin, skinParam, result = new CommunicationTileNoteRight(result, exo, skin, skinParam, livingSpace1, noteOnMessage);
livingSpace1, noteOnMessage);
} }
} }
tiles.add(result); tiles.add(result);
@ -140,17 +136,19 @@ public class TileBuilder {
livingSpace1 = tileArguments.getFirstLivingSpace(); livingSpace1 = tileArguments.getFirstLivingSpace();
livingSpace2 = tileArguments.getLastLivingSpace(); livingSpace2 = tileArguments.getLastLivingSpace();
} }
tiles.add(new NoteTile(livingSpace1, livingSpace2, note, skin, skinParam)); tiles.add(
new NoteTile(tileArguments.getStringBounder(), livingSpace1, livingSpace2, note, skin, skinParam));
} else if (ev instanceof Notes) { } else if (ev instanceof Notes) {
final Notes notes = (Notes) ev; final Notes notes = (Notes) ev;
tiles.add(new NotesTile(livingSpaces, notes, skin, skinParam)); tiles.add(new NotesTile(tileArguments.getStringBounder(), livingSpaces, notes, skin, skinParam));
} else if (ev instanceof Divider) { } else if (ev instanceof Divider) {
final Divider divider = (Divider) ev; final Divider divider = (Divider) ev;
tiles.add(new DividerTile(divider, tileArguments)); tiles.add(new DividerTile(divider, tileArguments));
} else if (ev instanceof GroupingStart) { } else if (ev instanceof GroupingStart) {
final GroupingStart start = (GroupingStart) ev; final GroupingStart start = (GroupingStart) ev;
final GroupingTile groupingTile = new GroupingTile(it, start, tileArguments.withBackColorGeneral( final GroupingTile groupingTile = new GroupingTile(it, start,
start.getBackColorElement(), start.getBackColorGeneral()), tileArguments); tileArguments.withBackColorGeneral(start.getBackColorElement(), start.getBackColorGeneral()),
tileArguments);
tiles.add(new EmptyTile(4, groupingTile)); tiles.add(new EmptyTile(4, groupingTile));
tiles.add(groupingTile); tiles.add(groupingTile);
tiles.add(new EmptyTile(4, groupingTile)); tiles.add(new EmptyTile(4, groupingTile));

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.sequencediagram.teoz; package net.sourceforge.plantuml.sequencediagram.teoz;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.real.Real;
import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
@ -50,6 +49,7 @@ public class TileMarged extends AbstractTile implements Tile {
private final double y2; private final double y2;
public TileMarged(Tile tile, double x1, double x2, double y1, double y2) { public TileMarged(Tile tile, double x1, double x2, double y1, double y2) {
super(((AbstractTile) tile).getStringBounder());
this.tile = tile; this.tile = tile;
this.x1 = x1; this.x1 = x1;
this.x2 = x2; this.x2 = x2;
@ -62,20 +62,20 @@ public class TileMarged extends AbstractTile implements Tile {
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
return tile.getPreferredHeight(stringBounder) + y1 + y2; return tile.getPreferredHeight() + y1 + y2;
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
tile.addConstraints(stringBounder); tile.addConstraints();
} }
public Real getMinX(StringBounder stringBounder) { public Real getMinX() {
return tile.getMinX(stringBounder); return tile.getMinX();
} }
public Real getMaxX(StringBounder stringBounder) { public Real getMaxX() {
return tile.getMaxX(stringBounder).addFixed(x1 + x2); return tile.getMaxX().addFixed(x1 + x2);
} }
public Event getEvent() { public Event getEvent() {

View File

@ -47,23 +47,18 @@ import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
public class TileParallel implements Tile, TileWithUpdateStairs, TileWithCallbackY { public class TileParallel extends CommonTile {
public TileParallel(StringBounder stringBounder) {
super(stringBounder);
}
private final List<Tile> tiles = new ArrayList<Tile>(); private final List<Tile> tiles = new ArrayList<Tile>();
public void callbackY(double y) { @Override
public void callbackY_internal(double y) {
for (Tile tile : tiles) { for (Tile tile : tiles) {
if (tile instanceof TileWithCallbackY) { tile.callbackY(y);
((TileWithCallbackY) tile).callbackY(y);
}
}
}
public void updateStairs(StringBounder stringBounder, double y) {
for (Tile tile : tiles) {
if (tile instanceof TileWithUpdateStairs) {
((TileWithUpdateStairs) tile).updateStairs(stringBounder, y);
}
} }
} }
@ -72,44 +67,40 @@ public class TileParallel implements Tile, TileWithUpdateStairs, TileWithCallbac
} }
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder(); final double yPointAll = getContactPointRelative();
// final double totalHeight = getPreferredHeight(stringBounder);
final double yPointAll = getYPoint(stringBounder);
for (Tile tile : tiles) { for (Tile tile : tiles) {
final double yPoint = tile.getYPoint(stringBounder); final double yPoint = tile.getContactPointRelative();
// tile.drawU(ug.apply(UTranslate.dy(totalHeight -
// tile.getPreferredHeight(stringBounder))));
tile.drawU(ug.apply(UTranslate.dy(yPointAll - yPoint))); tile.drawU(ug.apply(UTranslate.dy(yPointAll - yPoint)));
} }
} }
public double getYPoint(StringBounder stringBounder) { public double getContactPointRelative() {
double result = 0; double result = 0;
for (Tile tile : tiles) { for (Tile tile : tiles) {
result = Math.max(result, tile.getYPoint(stringBounder)); result = Math.max(result, tile.getContactPointRelative());
} }
return result; return result;
} }
public double getZ(StringBounder stringBounder) { public double getZZZ() {
double result = 0; double result = 0;
for (Tile tile : tiles) { for (Tile tile : tiles) {
result = Math.max(result, tile.getZ(stringBounder)); result = Math.max(result, tile.getZZZ());
} }
return result; return result;
} }
public double getPreferredHeight(StringBounder stringBounder) { public double getPreferredHeight() {
return getYPoint(stringBounder) + getZ(stringBounder); return getContactPointRelative() + getZZZ();
} }
public void addConstraints(StringBounder stringBounder) { public void addConstraints() {
for (Tile tile : tiles) { for (Tile tile : tiles) {
tile.addConstraints(stringBounder); tile.addConstraints();
} }
} }
public Real getMinX(final StringBounder stringBounder) { public Real getMinX() {
return RealUtils.min(new AbstractCollection<Real>() { return RealUtils.min(new AbstractCollection<Real>() {
public Iterator<Real> iterator() { public Iterator<Real> iterator() {
return new Iterator<Real>() { return new Iterator<Real>() {
@ -120,7 +111,7 @@ public class TileParallel implements Tile, TileWithUpdateStairs, TileWithCallbac
} }
public Real next() { public Real next() {
return source.next().getMinX(stringBounder); return source.next().getMinX();
} }
public void remove() { public void remove() {
@ -135,7 +126,7 @@ public class TileParallel implements Tile, TileWithUpdateStairs, TileWithCallbac
}); });
} }
public Real getMaxX(final StringBounder stringBounder) { public Real getMaxX() {
return RealUtils.max(new AbstractCollection<Real>() { return RealUtils.max(new AbstractCollection<Real>() {
public Iterator<Real> iterator() { public Iterator<Real> iterator() {
return new Iterator<Real>() { return new Iterator<Real>() {
@ -146,7 +137,7 @@ public class TileParallel implements Tile, TileWithUpdateStairs, TileWithCallbac
} }
public Real next() { public Real next() {
return source.next().getMaxX(stringBounder); return source.next().getMaxX();
} }
public void remove() { public void remove() {

View File

@ -42,7 +42,7 @@ import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UShape; import net.sourceforge.plantuml.ugraphic.UShape;
public class UGraphicInterceptorTile extends UGraphicDelegator implements Context2D { public class UGraphicInterceptorTile extends UGraphicDelegator implements Context2D {
private final boolean isBackground; private final boolean isBackground;
public UGraphicInterceptorTile(UGraphic ug, boolean isBackground) { public UGraphicInterceptorTile(UGraphic ug, boolean isBackground) {

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.sequencediagram.teoz; package net.sourceforge.plantuml.sequencediagram.teoz;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
@ -44,16 +43,10 @@ public class YPositionedTile {
private final Tile tile; private final Tile tile;
private final double y; private final double y;
public boolean inArea(double ymin, double ymax) {
return y >= ymin && y < ymax;
}
public YPositionedTile(Tile tile, double y) { public YPositionedTile(Tile tile, double y) {
this.tile = tile; this.tile = tile;
this.y = y; this.y = y;
if (tile instanceof TileWithCallbackY) { tile.callbackY(y);
((TileWithCallbackY) tile).callbackY(y);
}
} }
@Override @Override
@ -63,7 +56,7 @@ public class YPositionedTile {
public void drawInArea(UGraphic ug) { public void drawInArea(UGraphic ug) {
// System.err.println("YPositionedTile::drawU y=" + y + " " + tile); // System.err.println("YPositionedTile::drawU y=" + y + " " + tile);
ug.apply(UTranslate.dy(y)).draw(tile); tile.drawU(ug.apply(UTranslate.dy(y)));
} }
public boolean matchAnchorV2(String anchor) { public boolean matchAnchorV2(String anchor) {
@ -71,14 +64,13 @@ public class YPositionedTile {
return result; return result;
} }
public final double getY(StringBounder stringBounder) { public final double getY() {
final TileWithUpdateStairs communicationTile = (TileWithUpdateStairs) tile; return y + tile.getContactPointRelative();
return y + communicationTile.getYPoint(stringBounder);
} }
public double getMiddleX(StringBounder stringBounder) { public double getMiddleX() {
final double max = tile.getMaxX(stringBounder).getCurrentValue(); final double max = tile.getMaxX().getCurrentValue();
final double min = tile.getMinX(stringBounder).getCurrentValue(); final double min = tile.getMinX().getCurrentValue();
return (min + max) / 2; return (min + max) / 2;
} }

View File

@ -49,6 +49,8 @@ public interface ArrowComponent extends Component {
double getPaddingY(); double getPaddingY();
public double getYPoint(StringBounder stringBounder); public double getYPoint(StringBounder stringBounder);
public double getPosArrow(StringBounder stringBounder);
} }

View File

@ -103,14 +103,17 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow {
final double pos1 = start + 1; final double pos1 = start + 1;
final double pos2 = len - 1; final double pos2 = len - 1;
if (getArrowConfiguration().getDecoration2() == ArrowDecoration.CIRCLE && dressing2.getHead() == ArrowHead.NONE) { if (getArrowConfiguration().getDecoration2() == ArrowDecoration.CIRCLE
&& dressing2.getHead() == ArrowHead.NONE) {
len -= diamCircle / 2; len -= diamCircle / 2;
} }
if (getArrowConfiguration().getDecoration2() == ArrowDecoration.CIRCLE && dressing2.getHead() != ArrowHead.NONE) { if (getArrowConfiguration().getDecoration2() == ArrowDecoration.CIRCLE
&& dressing2.getHead() != ArrowHead.NONE) {
len -= diamCircle / 2 + thinCircle; len -= diamCircle / 2 + thinCircle;
} }
if (getArrowConfiguration().getDecoration1() == ArrowDecoration.CIRCLE && dressing1.getHead() == ArrowHead.NONE) { if (getArrowConfiguration().getDecoration1() == ArrowDecoration.CIRCLE
&& dressing1.getHead() == ArrowHead.NONE) {
start += diamCircle / 2; start += diamCircle / 2;
len -= diamCircle / 2; len -= diamCircle / 2;
} }
@ -161,12 +164,20 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow {
- (direction2 == ArrowDirection.LEFT_TO_RIGHT_NORMAL ? getArrowDeltaX() : 0); - (direction2 == ArrowDirection.LEFT_TO_RIGHT_NORMAL ? getArrowDeltaX() : 0);
} else { } else {
textPos = getMarginX1() textPos = getMarginX1()
+ (direction2 == ArrowDirection.RIGHT_TO_LEFT_REVERSE + (direction2 == ArrowDirection.RIGHT_TO_LEFT_REVERSE || direction2 == ArrowDirection.BOTH_DIRECTION
|| direction2 == ArrowDirection.BOTH_DIRECTION ? getArrowDeltaX() : 0); ? getArrowDeltaX()
: 0);
} }
getTextBlock().drawU(ug.apply(new UTranslate(textPos, yText))); getTextBlock().drawU(ug.apply(new UTranslate(textPos, yText)));
} }
public double getPosArrow(StringBounder stringBounder) {
if (isBelowForResponse()) {
return 0;
}
return getTextHeight(stringBounder) - 2 * getMarginY();
}
private boolean isBelowForResponse() { private boolean isBelowForResponse() {
return belowForResponse && getDirection2() == ArrowDirection.RIGHT_TO_LEFT_REVERSE; return belowForResponse && getDirection2() == ArrowDirection.RIGHT_TO_LEFT_REVERSE;
} }
@ -192,10 +203,10 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow {
} }
} else if (dressing.getHead() == ArrowHead.CROSSX) { } else if (dressing.getHead() == ArrowHead.CROSSX) {
ug = ug.apply(new UStroke(2)); ug = ug.apply(new UStroke(2));
ug.apply(new UTranslate(spaceCrossX, -getArrowDeltaX() / 2)).draw( ug.apply(new UTranslate(spaceCrossX, -getArrowDeltaX() / 2))
new ULine(getArrowDeltaX(), getArrowDeltaX())); .draw(new ULine(getArrowDeltaX(), getArrowDeltaX()));
ug.apply(new UTranslate(spaceCrossX, getArrowDeltaX() / 2)).draw( ug.apply(new UTranslate(spaceCrossX, getArrowDeltaX() / 2))
new ULine(getArrowDeltaX(), -getArrowDeltaX())); .draw(new ULine(getArrowDeltaX(), -getArrowDeltaX()));
} else if (dressing.getHead() == ArrowHead.NORMAL) { } else if (dressing.getHead() == ArrowHead.NORMAL) {
final UPolygon polygon = getPolygonReverse(dressing.getPart()); final UPolygon polygon = getPolygonReverse(dressing.getPart());
ug.apply(getForegroundColor().bg()).apply(UTranslate.dx(x)).draw(polygon); ug.apply(getForegroundColor().bg()).apply(UTranslate.dx(x)).draw(polygon);
@ -224,10 +235,10 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow {
} }
} else if (dressing.getHead() == ArrowHead.CROSSX) { } else if (dressing.getHead() == ArrowHead.CROSSX) {
ug = ug.apply(new UStroke(2)); ug = ug.apply(new UStroke(2));
ug.apply(new UTranslate(x - spaceCrossX - getArrowDeltaX(), -getArrowDeltaX() / 2)).draw( ug.apply(new UTranslate(x - spaceCrossX - getArrowDeltaX(), -getArrowDeltaX() / 2))
new ULine(getArrowDeltaX(), getArrowDeltaX())); .draw(new ULine(getArrowDeltaX(), getArrowDeltaX()));
ug.apply(new UTranslate(x - spaceCrossX - getArrowDeltaX(), getArrowDeltaX() / 2)).draw( ug.apply(new UTranslate(x - spaceCrossX - getArrowDeltaX(), getArrowDeltaX() / 2))
new ULine(getArrowDeltaX(), -getArrowDeltaX())); .draw(new ULine(getArrowDeltaX(), -getArrowDeltaX()));
ug = ug.apply(new UStroke()); ug = ug.apply(new UStroke());
} else if (dressing.getHead() == ArrowHead.NORMAL) { } else if (dressing.getHead() == ArrowHead.NORMAL) {
final UPolygon polygon = getPolygonNormal(dressing.getPart(), x); final UPolygon polygon = getPolygonNormal(dressing.getPart(), x);

View File

@ -194,5 +194,10 @@ public class ComponentRoseSelfArrow extends AbstractComponentRoseArrow {
public double getPreferredWidth(StringBounder stringBounder) { public double getPreferredWidth(StringBounder stringBounder) {
return Math.max(getTextWidth(stringBounder), arrowWidth); return Math.max(getTextWidth(stringBounder), arrowWidth);
} }
public double getPosArrow(StringBounder stringBounder) {
throw new UnsupportedOperationException();
}
} }

View File

@ -47,6 +47,7 @@ import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.statediagram.StateDiagram; import net.sourceforge.plantuml.statediagram.StateDiagram;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class CommandAddField extends SingleLineCommand2<StateDiagram> { public class CommandAddField extends SingleLineCommand2<StateDiagram> {
@ -66,7 +67,7 @@ public class CommandAddField extends SingleLineCommand2<StateDiagram> {
} }
@Override @Override
protected CommandExecutionResult executeArg(StateDiagram diagram, LineLocation location, RegexResult arg) { protected CommandExecutionResult executeArg(StateDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException {
final String codeString = arg.getLazzy("CODE", 0); final String codeString = arg.getLazzy("CODE", 0);
final String field = arg.get("FIELD", 0); final String field = arg.get("FIELD", 0);

View File

@ -105,7 +105,8 @@ public enum SName {
task, // task, //
title, // title, //
usecase, // usecase, //
wbsDiagram; // wbsDiagram, //
yamlDiagram; //
public static String depth(int level) { public static String depth(int level) {
return "depth(" + level + ")"; return "depth(" + level + ")";

View File

@ -90,6 +90,10 @@ public class StyleSignature {
return new StyleSignature(result); return new StyleSignature(result);
} }
public StyleSignature add(SName name) {
return add(name.name().toLowerCase().replace("_", ""));
}
public StyleSignature addStar() { public StyleSignature addStar() {
final Set<String> result = new HashSet<String>(names); final Set<String> result = new HashSet<String>(names);
result.add("*"); result.add("*");

View File

@ -42,7 +42,7 @@ import net.sourceforge.plantuml.ugraphic.UGraphic;
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;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorNone;
class MiddleCircleCircled extends Extremity { class MiddleCircleCircled extends Extremity {
@ -80,11 +80,11 @@ class MiddleCircleCircled extends Extremity {
final double d = 0; final double d = 0;
if (mode == MiddleCircleCircledMode.MODE1 || mode == MiddleCircleCircledMode.BOTH) { if (mode == MiddleCircleCircledMode.MODE1 || mode == MiddleCircleCircledMode.BOTH) {
final UEllipse arc1 = new UEllipse(2 * radius2, 2 * radius2, angle, 90); final UEllipse arc1 = new UEllipse(2 * radius2, 2 * radius2, angle, 90);
ug.apply(new UTranslate(-radius2 + d, -radius2 + d)).draw(arc1); ug.apply(new HColorNone().bg()).apply(new UTranslate(-radius2 + d, -radius2 + d)).draw(arc1);
} }
if (mode == MiddleCircleCircledMode.MODE2 || mode == MiddleCircleCircledMode.BOTH) { if (mode == MiddleCircleCircledMode.MODE2 || mode == MiddleCircleCircledMode.BOTH) {
final UEllipse arc2 = new UEllipse(2 * radius2, 2 * radius2, angle + 180, 90); final UEllipse arc2 = new UEllipse(2 * radius2, 2 * radius2, angle + 180, 90);
ug.apply(new UTranslate(-radius2 + d, -radius2 + d)).draw(arc2); ug.apply(new HColorNone().bg()).apply(new UTranslate(-radius2 + d, -radius2 + d)).draw(arc2);
} }
ug.apply(new UTranslate(-radius1, -radius1)).draw(circle); ug.apply(new UTranslate(-radius1, -radius1)).draw(circle);
} }

View File

@ -200,8 +200,8 @@ public class EntityImageDescription extends AbstractEntityImage {
HorizontalAlignment.CENTER, getSkinParam()); HorizontalAlignment.CENTER, getSkinParam());
} }
name = BodyFactory.create2(codeDisplay, symbol.getFontParam(), getSkinParam(), HorizontalAlignment.CENTER, name = BodyFactory.create2(skinParam.getDefaultTextAlignment(HorizontalAlignment.CENTER), codeDisplay,
stereotype, entity, style); symbol.getFontParam(), getSkinParam(), stereotype, entity, style);
if (hideText) { if (hideText) {
asSmall = symbol.asSmall(TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), asSmall = symbol.asSmall(TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0),

View File

@ -85,8 +85,9 @@ public class EntityImageLollipopInterfaceEye2 extends AbstractEntityImage {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
this.desc = BodyFactory.create2(entity.getDisplay(), symbol.getFontParam(), skinParam, this.desc = BodyFactory.create2(skinParam.getDefaultTextAlignment(HorizontalAlignment.CENTER),
HorizontalAlignment.CENTER, stereotype, entity, getStyle(symbol.getFontParam())); entity.getDisplay(), symbol.getFontParam(), skinParam, stereotype, entity,
getStyle(symbol.getFontParam()));
this.url = entity.getUrl99(); this.url = entity.getUrl99();

View File

@ -94,8 +94,9 @@ public class EntityImageState2 extends AbstractEntityImage {
this.url = entity.getUrl99(); this.url = entity.getUrl99();
TextBlock stereo = TextBlockUtils.empty(0, 0); TextBlock stereo = TextBlockUtils.empty(0, 0);
final TextBlock desc = BodyFactory.create2(entity.getDisplay(), symbol.getFontParam(), skinParam, final TextBlock desc = BodyFactory.create2(skinParam.getDefaultTextAlignment(HorizontalAlignment.CENTER),
HorizontalAlignment.CENTER, stereotype, entity, getStyle(symbol.getFontParam())); entity.getDisplay(), symbol.getFontParam(), skinParam, stereotype, entity,
getStyle(symbol.getFontParam()));
asSmall = symbol.asSmall(null, desc, stereo, ctx, skinParam.getStereotypeAlignment()); asSmall = symbol.asSmall(null, desc, stereo, ctx, skinParam.getStereotypeAlignment());

View File

@ -5,12 +5,12 @@
* (C) Copyright 2009-2020, Arnaud Roques * (C) Copyright 2009-2020, Arnaud Roques
* *
* Project Info: http://plantuml.com * Project Info: http://plantuml.com
* *
* If you like this project or if you find it useful, you can support us at: * 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/patreon (only 1$ per month!)
* http://plantuml.com/paypal * http://plantuml.com/paypal
* *
* This file is part of PlantUML. * This file is part of PlantUML.
* *
* PlantUML is free software; you can redistribute it and/or modify it * PlantUML is free software; you can redistribute it and/or modify it
@ -30,7 +30,7 @@
* *
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* *
*/ */
package net.sourceforge.plantuml.svek.image; package net.sourceforge.plantuml.svek.image;
@ -87,8 +87,15 @@ public class EntityImageUseCase extends AbstractEntityImage {
super(entity, skinParam); super(entity, skinParam);
final Stereotype stereotype = entity.getStereotype(); final Stereotype stereotype = entity.getStereotype();
final TextBlock tmp = BodyFactory.create2(entity.getDisplay(), FontParam.USECASE, skinParam, final HorizontalAlignment align;
HorizontalAlignment.CENTER, stereotype, entity, getStyle()); if (UseStyle.useBetaStyle()) {
final Style style = getStyle();
align = style.getHorizontalAlignment();
} else {
align = HorizontalAlignment.CENTER;
}
final TextBlock tmp = BodyFactory.create2(skinParam.getDefaultTextAlignment(align), entity.getDisplay(),
FontParam.USECASE, skinParam, stereotype, entity, getStyle());
if (stereotype == null || stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR) == null if (stereotype == null || stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR) == null
|| portionShower.showPortion(EntityPortion.STEREOTYPE, entity) == false) { || portionShower.showPortion(EntityPortion.STEREOTYPE, entity) == false) {

View File

@ -5,12 +5,12 @@
* (C) Copyright 2009-2020, Arnaud Roques * (C) Copyright 2009-2020, Arnaud Roques
* *
* Project Info: http://plantuml.com * Project Info: http://plantuml.com
* *
* If you like this project or if you find it useful, you can support us at: * 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/patreon (only 1$ per month!)
* http://plantuml.com/paypal * http://plantuml.com/paypal
* *
* This file is part of PlantUML. * This file is part of PlantUML.
* *
* PlantUML is free software; you can redistribute it and/or modify it * PlantUML is free software; you can redistribute it and/or modify it
@ -30,7 +30,7 @@
* *
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* *
*/ */
package net.sourceforge.plantuml.svg; package net.sourceforge.plantuml.svg;
@ -40,6 +40,7 @@ import java.awt.geom.PathIterator;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -64,6 +65,7 @@ import org.w3c.dom.Comment;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import net.sourceforge.plantuml.FileUtils;
import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.SignatureUtils; import net.sourceforge.plantuml.SignatureUtils;
import net.sourceforge.plantuml.code.Base64Coder; import net.sourceforge.plantuml.code.Base64Coder;
@ -159,9 +161,15 @@ public class SvgGraphics {
defs.appendChild(getPathHover(hover)); defs.appendChild(getPathHover(hover));
} }
// Add styles and script for interactive SVG final Element styles = getStylesForInteractiveMode();
defs.appendChild(getStylesForInteractiveMode()); if (styles != null) {
defs.appendChild(getScriptForInteractiveMode()); defs.appendChild(styles);
}
final Element script = getScriptForInteractiveMode();
if (script != null) {
defs.appendChild(script);
}
} catch (ParserConfigurationException e) { } catch (ParserConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
throw new IllegalStateException(e); throw new IllegalStateException(e);
@ -170,11 +178,11 @@ public class SvgGraphics {
private Element getStylesForInteractiveMode() { private Element getStylesForInteractiveMode() {
final Element style = simpleElement("style"); final Element style = simpleElement("style");
final CDATASection cdata = document.createCDATASection( final String text = getData("default.css");
".elem {cursor: pointer;} " + "\n" + if (text == null) {
".elem, .link {opacity: 0.3;}" + "\n" + return null;
".elem.selected, .link.selected {opacity: 1;}" }
); final CDATASection cdata = document.createCDATASection(text);
style.setAttribute("type", "text/css"); style.setAttribute("type", "text/css");
style.appendChild(cdata); style.appendChild(cdata);
return style; return style;
@ -182,121 +190,24 @@ public class SvgGraphics {
private Element getScriptForInteractiveMode() { private Element getScriptForInteractiveMode() {
final Element script = document.createElement("script"); final Element script = document.createElement("script");
script.setTextContent( final String text = getData("default.js");
"function addItemToMapOfLists(mapOfLists, name, item) {" + "\n" + if (text == null) {
" // mapOfLists = {" + "\n" + return null;
" // 'key1': [item1, item2, ...]," + "\n" + }
" // 'key2': [item3, item4, ...]," + "\n" + script.setTextContent(text);
" // }" + "\n" +
" if (mapOfLists[name].length > 0) {" + "\n" +
" if (!mapOfLists[name].includes(item)) {" + "\n" +
" mapOfLists[name].push(item);" + "\n" +
" }" + "\n" +
" } else {" + "\n" +
" mapOfLists[name] = [item];" + "\n" +
" }" + "\n" +
"}" + "\n" +
"" + "\n" +
"function main() {" + "\n" +
" let elems = Array.from(document.getElementsByClassName('elem'));" + "\n" +
" let links = Array.from(document.getElementsByClassName('link'));" + "\n" +
"" + "\n" +
" let elemsMap = {};" + "\n" +
" let linkedElems = {};" + "\n" +
" let linkedLinks = {};" + "\n" +
"" + "\n" +
" elems.forEach(elem => {" + "\n" +
" let name = elem.classList[1];" + "\n" +
" elemsMap[name] = elem;" + "\n" +
" linkedElems[name] = [];" + "\n" +
" linkedLinks[name] = [];" + "\n" +
" });" + "\n" +
"" + "\n" +
" links.forEach(link => {" + "\n" +
" if (elemsMap[name1]) {" + "\n" +
" if (elemsMap[name2]) {" + "\n" +
" let name1 = link.classList[1];" + "\n" +
" let name2 = link.classList[2];" + "\n" +
"" + "\n" +
" let elem1 = elemsMap[name1];" + "\n" +
" let elem2 = elemsMap[name2];" + "\n" +
"" + "\n" +
" addItemToMapOfLists(linkedElems, name1, elem2);" + "\n" +
" addItemToMapOfLists(linkedElems, name2, elem1);" + "\n" +
"" + "\n" +
" addItemToMapOfLists(linkedLinks, name1, link);" + "\n" +
" addItemToMapOfLists(linkedLinks, name2, link);" + "\n" +
" }" + "\n" +
" }" + "\n" +
" });" + "\n" +
"" + "\n" +
" let selectedElems = [];" + "\n" +
" let selectedLinks = [];" + "\n" +
" let selectedElemName = null;" + "\n" +
"" + "\n" +
" function clearSelected() {" + "\n" +
" selectedElems.forEach(item => {" + "\n" +
" item.classList.remove('selected');" + "\n" +
" });" + "\n" +
" selectedElems = [];" + "\n" +
"" + "\n" +
" selectedLinks.forEach(item => {" + "\n" +
" item.classList.remove('selected');" + "\n" +
" });" + "\n" +
" selectedLinks = [];" + "\n" +
" }" + "\n" +
"" + "\n" +
" function selectAll() {" + "\n" +
" selectedElemName = null;" + "\n" +
"" + "\n" +
" selectedElems = Array.from(elems);" + "\n" +
" selectedElems.forEach(item => {" + "\n" +
" item.classList.add('selected');" + "\n" +
" });" + "\n" +
"" + "\n" +
" selectedLinks = Array.from(links);" + "\n" +
" selectedLinks.forEach(item => {" + "\n" +
" item.classList.add('selected');" + "\n" +
" });" + "\n" +
" }" + "\n" +
"" + "\n" +
" function selectElem(elemName) {" + "\n" +
" if (elemName === selectedElemName) {" + "\n" +
" selectAll();" + "\n" +
"" + "\n" +
" } else {" + "\n" +
" clearSelected();" + "\n" +
" selectedElemName = elemName;" + "\n" +
"" + "\n" +
" elemsMap[elemName].classList.add('selected');" + "\n" +
" selectedElems.push(elemsMap[elemName]);" + "\n" +
"" + "\n" +
" linkedElems[elemName].forEach(linkedElem => {" + "\n" +
" selectedElems.push(linkedElem);" + "\n" +
" linkedElem.classList.add('selected');" + "\n" +
" });" + "\n" +
"" + "\n" +
" linkedLinks[elemName].forEach(linkedLink => {" + "\n" +
" selectedLinks.push(linkedLink);" + "\n" +
" linkedLink.classList.add('selected');" + "\n" +
" });" + "\n" +
" }" + "\n" +
" }" + "\n" +
"" + "\n" +
" Object.keys(elemsMap).forEach(name => {" + "\n" +
" elemsMap[name].onclick = () => { selectElem(name); };" + "\n" +
" });" + "\n" +
"" + "\n" +
" selectAll();" + "\n" +
"}" + "\n" +
"" + "\n" +
"document.addEventListener('DOMContentLoaded', (event) => {" + "\n" +
" main();" + "\n" +
"});"
);
return script; return script;
} }
private static String getData(final String name) {
try {
final InputStream is = SvgGraphics.class.getResourceAsStream("/svg/" + name);
return FileUtils.readText(is);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
private Element getPathHover(String hover) { private Element getPathHover(String hover) {
final Element style = simpleElement("style"); final Element style = simpleElement("style");
final CDATASection cdata = document.createCDATASection("path:hover { stroke: " + hover + " !important;}"); final CDATASection cdata = document.createCDATASection("path:hover { stroke: " + hover + " !important;}");
@ -1066,6 +977,7 @@ public class SvgGraphics {
} }
public void startGroupWithClass(String groupClasses) { public void startGroupWithClass(String groupClasses) {
pendingAction.add(0, (Element) document.createElement("g")); pendingAction.add(0, (Element) document.createElement("g"));
pendingAction.get(0).setAttribute("class", groupClasses); pendingAction.get(0).setAttribute("class", groupClasses);
} }

View File

@ -50,7 +50,6 @@ import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.StringLocated; import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.json.Json; import net.sourceforge.plantuml.json.Json;
import net.sourceforge.plantuml.json.JsonObject;
import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.json.JsonValue;
import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.preproc.FileWithSuffix; import net.sourceforge.plantuml.preproc.FileWithSuffix;
@ -197,17 +196,6 @@ public class TContext {
} }
} }
private TValue fromJsonOld(TMemory memory, String name) {
final int x = name.indexOf('.');
final TValue data = memory.getVariable(name.substring(0, x));
if (data == null) {
return null;
}
final JsonObject json = (JsonObject) data.toJson();
final JsonValue result = json.get(name.substring(x + 1));
return TValue.fromJson(result);
}
private CodeIterator buildCodeIterator(TMemory memory, List<StringLocated> body) { private CodeIterator buildCodeIterator(TMemory memory, List<StringLocated> body) {
final CodeIterator it10 = new CodeIteratorImpl(body); final CodeIterator it10 = new CodeIteratorImpl(body);
final CodeIterator it20 = new CodeIteratorLongComment(it10, debug); final CodeIterator it20 = new CodeIteratorLongComment(it10, debug);
@ -498,9 +486,13 @@ public class TContext {
if (reader == null) { if (reader == null) {
throw EaterException.located("cannot include " + location); throw EaterException.located("cannot include " + location);
} }
ReadLine readerline = ReadLineReader.create(reader, location, s.getLocation()); try {
readerline = new UncommentReadLine(readerline); ReadLine readerline = ReadLineReader.create(reader, location, s.getLocation());
sub = Sub.fromFile(readerline, blocname, this, memory); readerline = new UncommentReadLine(readerline);
sub = Sub.fromFile(readerline, blocname, this, memory);
} finally {
reader.close();
}
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
@ -526,7 +518,7 @@ public class TContext {
include.analyze(this, memory); include.analyze(this, memory);
final String definitionName = include.getLocation(); final String definitionName = include.getLocation();
final List<String> definition = definitionsContainer.getDefinition(definitionName); final List<String> definition = definitionsContainer.getDefinition(definitionName);
ReadLine reader2 = new ReadLineList(definition, s.getLocation()); final ReadLine reader2 = new ReadLineList(definition, s.getLocation());
try { try {
final List<StringLocated> body = new ArrayList<StringLocated>(); final List<StringLocated> body = new ArrayList<StringLocated>();
@ -541,6 +533,12 @@ public class TContext {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
throw EaterException.located("" + e); throw EaterException.located("" + e);
} finally {
try {
reader2.close();
} catch (IOException e) {
e.printStackTrace();
}
} }
} }
@ -565,9 +563,7 @@ public class TContext {
throw EaterException.located("Cannot open URL"); throw EaterException.located("Cannot open URL");
} }
reader2 = PreprocessorUtils.getReaderIncludeUrl2(url, s, suf, charset); reader2 = PreprocessorUtils.getReaderIncludeUrl2(url, s, suf, charset);
} else if (location.startsWith("<") && location.endsWith(">")) {
}
if (location.startsWith("<") && location.endsWith(">")) {
reader2 = PreprocessorUtils.getReaderStdlibInclude(s, location.substring(1, location.length() - 1)); reader2 = PreprocessorUtils.getReaderStdlibInclude(s, location.substring(1, location.length() - 1));
} else { } else {
final FileWithSuffix f2 = importedFiles.getFile(location, suf); final FileWithSuffix f2 = importedFiles.getFile(location, suf);
@ -614,6 +610,14 @@ public class TContext {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
throw EaterException.located("cannot include " + e); throw EaterException.located("cannot include " + e);
} finally {
if (reader2 != null) {
try {
reader2.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
throw EaterException.located("cannot include " + location); throw EaterException.located("cannot include " + location);

View File

@ -37,6 +37,8 @@ package net.sourceforge.plantuml.timingdiagram;
import java.awt.geom.Dimension2D; import java.awt.geom.Dimension2D;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator;
import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
@ -76,6 +78,9 @@ public class TimingRuler {
if (times.size() == 0) { if (times.size() == 0) {
this.times.add(new TimeTick(BigDecimal.ZERO, TimingFormat.DECIMAL)); this.times.add(new TimeTick(BigDecimal.ZERO, TimingFormat.DECIMAL));
} }
if (getMax().getTime().signum() > 0 && getMin().getTime().signum() < 0) {
this.times.add(new TimeTick(BigDecimal.ZERO, TimingFormat.DECIMAL));
}
} }
public TimingRuler(ISkinParam skinParam) { public TimingRuler(ISkinParam skinParam) {
@ -99,22 +104,39 @@ public class TimingRuler {
private long highestCommonFactor() { private long highestCommonFactor() {
if (highestCommonFactorInternal == -1) { if (highestCommonFactorInternal == -1) {
for (TimeTick time : times) { for (long tick : getAbsolutesTicks()) {
long tick = time.getTime().longValue(); if (highestCommonFactorInternal == -1) {
if (tick > 0) { highestCommonFactorInternal = tick;
if (highestCommonFactorInternal == -1) { } else {
highestCommonFactorInternal = time.getTime().longValue(); final long candidate = computeHighestCommonFactor(highestCommonFactorInternal, tick);
} else { final double size = (getMax().getTime().doubleValue() - getMin().getTime().doubleValue())
highestCommonFactorInternal = computeHighestCommonFactor(highestCommonFactorInternal, / candidate;
Math.abs(time.getTime().longValue())); if (size > 200) {
return highestCommonFactorInternal;
} }
highestCommonFactorInternal = candidate;
} }
} }
} }
return highestCommonFactorInternal; return highestCommonFactorInternal;
} }
private int getNbTick(boolean capped) { private Set<Long> getAbsolutesTicks() {
final Set<Long> result = new TreeSet<Long>(new Comparator<Long>() {
public int compare(Long o1, Long o2) {
return o2.compareTo(o1);
}
});
for (TimeTick time : times) {
final long value = Math.abs(time.getTime().longValue());
if (value > 0) {
result.add(value);
}
}
return result;
}
private int getNbTick() {
if (times.size() == 0) { if (times.size() == 0) {
return 1; return 1;
} }
@ -123,7 +145,9 @@ public class TimingRuler {
} }
public double getWidth() { public double getWidth() {
return getNbTick(false) * tickIntervalInPixels; final double delta = getMax().getTime().doubleValue() - getMin().getTime().doubleValue();
return (delta / tickUnitary() + 1) * tickIntervalInPixels;
} }
public final double getPosInPixel(TimeTick when) { public final double getPosInPixel(TimeTick when) {
@ -160,11 +184,13 @@ public class TimingRuler {
ug = ug.apply(new UStroke(2.0)).apply(HColorUtils.BLACK); ug = ug.apply(new UStroke(2.0)).apply(HColorUtils.BLACK);
final double tickHeight = 5; final double tickHeight = 5;
final ULine line = ULine.vline(tickHeight); final ULine line = ULine.vline(tickHeight);
final int nb = getNbTick(true); final double firstTickPosition = getPosInPixelInternal(getFirstPositiveOrZeroValue().doubleValue());
for (int i = 0; i <= nb; i++) { int nb = 0;
ug.apply(UTranslate.dx(tickIntervalInPixels * i)).draw(line); while (firstTickPosition + nb * tickIntervalInPixels <= getWidth()) {
ug.apply(UTranslate.dx(firstTickPosition + nb * tickIntervalInPixels)).draw(line);
nb++;
} }
ug.draw(ULine.hline(nb * tickIntervalInPixels)); ug.apply(UTranslate.dx(firstTickPosition)).draw(ULine.hline((nb - 1) * tickIntervalInPixels));
for (long round : roundValues()) { for (long round : roundValues()) {
final TextBlock text = getTimeTextBlock(round); final TextBlock text = getTimeTextBlock(round);
@ -173,6 +199,15 @@ public class TimingRuler {
} }
} }
private BigDecimal getFirstPositiveOrZeroValue() {
for (TimeTick time : times) {
if (time.getTime().signum() >= 0) {
return time.getTime();
}
}
throw new IllegalStateException();
}
private Collection<Long> roundValues() { private Collection<Long> roundValues() {
final SortedSet<Long> result = new TreeSet<Long>(); final SortedSet<Long> result = new TreeSet<Long>();
if (tickUnitary == 0) { if (tickUnitary == 0) {
@ -181,7 +216,7 @@ public class TimingRuler {
result.add(round); result.add(round);
} }
} else { } else {
final int nb = getNbTick(true); final int nb = getNbTick();
for (int i = 0; i <= nb; i++) { for (int i = 0; i <= nb; i++) {
final long round = tickToTime(i); final long round = tickToTime(i);
result.add(round); result.add(round);
@ -196,7 +231,7 @@ public class TimingRuler {
public void drawVlines(UGraphic ug, double height) { public void drawVlines(UGraphic ug, double height) {
ug = applyForVLines(ug); ug = applyForVLines(ug);
final ULine line = ULine.vline(height); final ULine line = ULine.vline(height);
final int nb = getNbTick(true); final int nb = getNbTick();
for (int i = 0; i <= nb; i++) { for (int i = 0; i <= nb; i++) {
ug.apply(UTranslate.dx(tickIntervalInPixels * i)).draw(line); ug.apply(UTranslate.dx(tickIntervalInPixels * i)).draw(line);
} }

View File

@ -172,10 +172,11 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
public void startGroup(String groupId) { public void startGroup(String groupId) {
} }
public void startGroupWithClass(String groupClasses) { public void startGroupWithClass(String groupClasses) {
} }
public void closeGroup() { public void closeGroup() {
} }

View File

@ -0,0 +1,66 @@
/* ========================================================================
* 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.ugraphic;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.LinkedHashMap;
import java.util.Map;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
public class PlacementStrategyY1Y2Right extends AbstractPlacementStrategy {
public PlacementStrategyY1Y2Right(StringBounder stringBounder) {
super(stringBounder);
}
public Map<TextBlock, Point2D> getPositions(double width, double height) {
final double usedHeight = getSumHeight();
final double space = (height - usedHeight) / (getDimensions().size() + 1);
final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
double y = space;
for (Map.Entry<TextBlock, Dimension2D> ent : getDimensions().entrySet()) {
final double x = width - ent.getValue().getWidth();
result.put(ent.getKey(), new Point2D.Double(x, y));
y += ent.getValue().getHeight() + space;
}
return result;
}
}

View File

@ -76,7 +76,7 @@ public class DriverEllipseSvg implements UDriver<SvgGraphics> {
gr.getPolicy()); gr.getPolicy());
svg.setFillColor("url(#" + id + ")"); svg.setFillColor("url(#" + id + ")");
} else if (back == null || back instanceof HColorBackground) { } else if (back == null || back instanceof HColorBackground) {
svg.setFillColor("none"); svg.setFillColor("#00000000");
} else { } else {
final String backcolor = mapper.toSvg(back); final String backcolor = mapper.toSvg(back);
svg.setFillColor(backcolor); svg.setFillColor(backcolor);

View File

@ -87,7 +87,8 @@ public class DriverTextSvg implements UDriver<SvgGraphics> {
} else if (fontConfiguration.containsStyle(FontStyle.STRIKE)) { } else if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
textDecoration = "line-through"; textDecoration = "line-through";
} else if (fontConfiguration.containsStyle(FontStyle.WAVE)) { } else if (fontConfiguration.containsStyle(FontStyle.WAVE)) {
// Beware that some current SVG implementations do not render the wave properly (e.g. Chrome just draws a straight line) // Beware that some current SVG implementations do not render the wave properly
// (e.g. Chrome just draws a straight line)
// Works ok on Firefox 85. // Works ok on Firefox 85.
textDecoration = "wavy underline"; textDecoration = "wavy underline";
} }

View File

@ -179,12 +179,13 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
public void startGroup(String groupId) { public void startGroup(String groupId) {
getGraphicObject().startGroup(groupId); getGraphicObject().startGroup(groupId);
} }
@Override @Override
public void startGroupWithClass(String groupClasses) { public void startGroupWithClass(String groupClasses) {
getGraphicObject().startGroupWithClass(groupClasses); getGraphicObject().startGroupWithClass(groupClasses);
} }
@Override @Override
public void closeGroup() { public void closeGroup() {
getGraphicObject().closeGroup(); getGraphicObject().closeGroup();

View File

@ -217,13 +217,16 @@ public class LicenseInfo {
if (br == null) { if (br == null) {
return null; return null;
} }
final String s = br.readLine(); try {
br.close(); final String s = br.readLine();
final LicenseInfo result = retrieveNamed(s); final LicenseInfo result = retrieveNamed(s);
if (result != null) { if (result != null) {
Log.info("Reading license from " + f.getAbsolutePath()); Log.info("Reading license from " + f.getAbsolutePath());
}
return result;
} finally {
br.close();
} }
return result;
} }
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -68,7 +68,7 @@ public class Version {
private static String dotted(int nb) { private static String dotted(int nb) {
final String minor = "" + nb % MAJOR_SEPARATOR; final String minor = "" + nb % MAJOR_SEPARATOR;
final String major = "" + nb / MAJOR_SEPARATOR; final String major = "" + nb / MAJOR_SEPARATOR;
return major + "." + minor.substring(0, 4) + "." + minor.substring(4); return major + "." + minor.substring(0, 4) + "." + Integer.parseInt(minor.substring(4));
} }
public static String versionString(int size) { public static String versionString(int size) {
@ -80,7 +80,7 @@ public class Version {
} }
public static int beta() { public static int beta() {
final int beta = 0; final int beta = 11;
return beta; return beta;
} }

Some files were not shown because too many files have changed in this diff Show More