1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-21 20:45:10 +00:00
Arnaud Roques 2023-06-21 20:50:30 +02:00
parent 21461b83fc
commit 968a958b9d
15 changed files with 120 additions and 34 deletions

View File

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

View File

@ -65,6 +65,14 @@ document {
}
}
package {
title {
FontStyle bold
}
}
stereotype {
FontStyle italic
}

View File

@ -111,7 +111,8 @@ public class CommandPackage extends SingleLineCommand2<AbstractEntityDiagram> {
if (name.length() == 0) {
idShort = "##" + diagram.getUniqueSequence();
display = null;
throw new IllegalStateException("AS");
return CommandExecutionResult.error("Error in name");
// throw new IllegalStateException("AS");
} else {
idShort = name;
display = idShort;

View File

@ -77,8 +77,8 @@ public class BodyFactory {
}
public static TextBlock create3(Display rawBody, ISkinSimple skinParam, HorizontalAlignment align,
FontConfiguration titleConfig, LineBreakStrategy lineBreakStrategy, Style style) {
return new BodyEnhanced2(rawBody, skinParam, align, titleConfig, lineBreakStrategy, style);
FontConfiguration fc, LineBreakStrategy lineBreakStrategy, Style style) {
return new BodyEnhanced2(rawBody, skinParam, align, fc, lineBreakStrategy, style);
}
}

View File

@ -283,14 +283,16 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker {
final UmlDiagramType umlDiagramType = diagram.getUmlDiagramType();
final Style style = Cluster.getDefaultStyleDefinition(umlDiagramType.getStyleName(), group.getUSymbol())
final Style style = Cluster
.getDefaultStyleDefinition(umlDiagramType.getStyleName(), group.getUSymbol(), group.getGroupType())
.getMergedStyle(skinParam.getCurrentStyleBuilder());
final double shadowing = style.value(PName.Shadowing).asDouble();
final UStroke stroke = Cluster.getStrokeInternal(group, style);
HColor backColor = getBackColor(umlDiagramType);
backColor = Cluster.getBackColor(backColor, group.getStereotype(), umlDiagramType.getStyleName(),
group.getUSymbol(), skinParam.getCurrentStyleBuilder(), skinParam.getIHtmlColorSet());
group.getUSymbol(), skinParam.getCurrentStyleBuilder(), skinParam.getIHtmlColorSet(),
group.getGroupType());
final double roundCorner = style.value(PName.RoundCorner).asDouble();
// final double roundCorner = group.getUSymbol() == null ? 0

View File

@ -43,7 +43,7 @@ import net.sourceforge.plantuml.klimt.UShape;
import net.sourceforge.plantuml.utils.SignatureUtils;
public class UImageSvg implements UShape {
// ::remove file when __HAXE__
// ::remove file when __HAXE__
private final String svg;
private final double scale;
@ -77,8 +77,12 @@ public class UImageSvg implements UShape {
final String style = extractSvgStyle();
if (style != null) {
final String background = extractBackground(style);
if (background != null)
result = result.replaceFirst("<g>", "<g><rect fill=\"" + background + "\" style=\"" + style + "\" /> ");
if (background != null) {
final int width = getData("width");
final int height = getData("height");
result = result.replaceFirst("<g>", "<g><rect fill=\"" + background + "\" style=\"" + style
+ "\" width=\"" + width + "\" height=\"" + height + "\"/> ");
}
}
if (result.startsWith("<svg>") == false)

View File

@ -52,6 +52,7 @@ import java.util.Set;
import net.sourceforge.plantuml.abel.CucaNote;
import net.sourceforge.plantuml.abel.Entity;
import net.sourceforge.plantuml.abel.EntityPosition;
import net.sourceforge.plantuml.abel.GroupType;
import net.sourceforge.plantuml.abel.Together;
import net.sourceforge.plantuml.cucadiagram.ICucaDiagram;
import net.sourceforge.plantuml.decoration.symbol.USymbol;
@ -75,7 +76,6 @@ import net.sourceforge.plantuml.klimt.shape.TextBlock;
import net.sourceforge.plantuml.klimt.shape.UComment;
import net.sourceforge.plantuml.klimt.shape.ULine;
import net.sourceforge.plantuml.skin.AlignmentParam;
import net.sourceforge.plantuml.skin.ComponentStyle;
import net.sourceforge.plantuml.skin.UmlDiagramType;
import net.sourceforge.plantuml.stereo.Stereotype;
import net.sourceforge.plantuml.style.ISkinParam;
@ -274,12 +274,16 @@ public class Cluster implements Moveable {
this.xyNoteBottom = pos;
}
static public StyleSignatureBasic getDefaultStyleDefinition(SName diagramStyleName, USymbol symbol) {
static public StyleSignatureBasic getDefaultStyleDefinition(SName diagramStyleName, USymbol symbol,
GroupType groupType) {
if (diagramStyleName == SName.stateDiagram)
return StyleSignatureBasic.of(SName.root, SName.element, SName.stateDiagram, SName.state, SName.group);
if (symbol == null)
return StyleSignatureBasic.of(SName.root, SName.element, diagramStyleName, SName.group);
return StyleSignatureBasic.of(SName.root, SName.element, diagramStyleName, SName.group, symbol.getSName());
if (symbol != null)
return StyleSignatureBasic.of(SName.root, SName.element, diagramStyleName, SName.group, symbol.getSName());
if (groupType == GroupType.PACKAGE)
return StyleSignatureBasic.of(SName.root, SName.element, diagramStyleName, SName.package_, SName.group);
return StyleSignatureBasic.of(SName.root, SName.element, diagramStyleName, SName.group);
}
public void drawU(UGraphic ug, UmlDiagramType umlDiagramType) {
@ -298,7 +302,7 @@ public class Cluster implements Moveable {
ug.draw(new UComment("cluster " + fullName));
final USymbol uSymbol = group.getUSymbol() == null ? USymbols.PACKAGE : group.getUSymbol();
Style style = getDefaultStyleDefinition(umlDiagramType.getStyleName(), uSymbol)
Style style = getDefaultStyleDefinition(umlDiagramType.getStyleName(), uSymbol, group.getGroupType())
.withTOBECHANGED(group.getStereotype()).getMergedStyle(skinParam.getCurrentStyleBuilder());
final double shadowing = style.value(PName.Shadowing).asDouble();
HColor borderColor;
@ -341,7 +345,8 @@ public class Cluster implements Moveable {
HColor backColor = getBackColor(umlDiagramType, style);
backColor = getBackColor(backColor, group.getStereotype(), umlDiagramType.getStyleName(),
group.getUSymbol(), skinParam.getCurrentStyleBuilder(), skinParam.getIHtmlColorSet());
group.getUSymbol(), skinParam.getCurrentStyleBuilder(), skinParam.getIHtmlColorSet(),
group.getGroupType());
final ClusterDecoration decoration = new ClusterDecoration(packageStyle, group.getUSymbol(),
clusterHeader.getTitle(), clusterHeader.getStereo(), rectangleArea, stroke);
@ -638,9 +643,9 @@ public class Cluster implements Moveable {
}
public static HColor getBackColor(HColor backColor, Stereotype stereotype, SName styleName, USymbol symbol,
StyleBuilder styleBuilder, HColorSet colorSet) {
StyleBuilder styleBuilder, HColorSet colorSet, GroupType groupType) {
final Style style = getDefaultStyleDefinition(styleName, symbol).getMergedStyle(styleBuilder);
final Style style = getDefaultStyleDefinition(styleName, symbol, groupType).getMergedStyle(styleBuilder);
if (backColor == null)
backColor = style.value(PName.BackGroundColor).asColor(colorSet);

View File

@ -118,6 +118,8 @@ public final class ClusterHeader {
else if (uSymbol != null)
signature = StyleSignatureBasic.of(SName.root, SName.element, sname, uSymbol.getSName(), SName.composite,
SName.title);
else if (g.getGroupType() == GroupType.PACKAGE)
signature = StyleSignatureBasic.of(SName.root, SName.element, sname, SName.package_, SName.title);
else
signature = StyleSignatureBasic.of(SName.root, SName.element, sname, SName.composite, SName.title);
@ -163,7 +165,7 @@ public final class ClusterHeader {
return TextBlockUtils.empty(0, 0);
final Style style = Cluster
.getDefaultStyleDefinition(skinParam.getUmlDiagramType().getStyleName(), g.getUSymbol())
.getDefaultStyleDefinition(skinParam.getUmlDiagramType().getStyleName(), g.getUSymbol(), g.getGroupType())
.forStereotypeItself(g.getStereotype()).getMergedStyle(skinParam.getCurrentStyleBuilder());
final FontConfiguration fontConfiguration = style.getFontConfiguration(skinParam.getIHtmlColorSet());

View File

@ -70,7 +70,7 @@ class PointListIteratorImpl implements PointListIterator {
}
public List<XPoint2D> next() {
if (pos == -1) {
if (pos < 0) {
pos = -2;
return Collections.emptyList();
}
@ -83,7 +83,7 @@ class PointListIteratorImpl implements PointListIterator {
pos = svg.indexOf(SvgResult.POINTS_EQUALS, pos) + SvgResult.POINTS_EQUALS.length() + 1;
return result;
} catch (StringIndexOutOfBoundsException e) {
Log.error("Error " + e);
Log.error("ErrorString " + e);
return Collections.emptyList();
}
}

View File

@ -145,8 +145,9 @@ public class EntityImageDescription extends AbstractEntityImage {
final Style styleStereo = tmp.forStereotypeItself(stereotype)
.getMergedStyle(getSkinParam().getCurrentStyleBuilder());
final Style style = StyleSignatureBasic.of(SName.root, SName.element, styleName, symbol.getSName())
.withTOBECHANGED(stereotype).getMergedStyle(getSkinParam().getCurrentStyleBuilder())
final StyleSignatureBasic tmp2 = StyleSignatureBasic.of(SName.root, SName.element, styleName,
symbol.getSName());
final Style style = tmp2.withTOBECHANGED(stereotype).getMergedStyle(getSkinParam().getCurrentStyleBuilder())
.eventuallyOverride(colors);
final HColor forecolor = styleTitle.value(PName.LineColor).asColor(getSkinParam().getIHtmlColorSet());
@ -160,6 +161,7 @@ public class EntityImageDescription extends AbstractEntityImage {
final double deltaShadow = styleTitle.value(PName.Shadowing).asDouble();
final UStroke stroke = styleTitle.getStroke(colors);
final FontConfiguration fcTitle = styleTitle.getFontConfiguration(getSkinParam().getIHtmlColorSet());
final FontConfiguration fc = style.getFontConfiguration(getSkinParam().getIHtmlColorSet());
final FontConfiguration fcStereo = styleStereo.getFontConfiguration(getSkinParam().getIHtmlColorSet());
final HorizontalAlignment defaultAlign = styleTitle.getHorizontalAlignment();
@ -172,9 +174,11 @@ public class EntityImageDescription extends AbstractEntityImage {
if ((entity.getDisplay().equalsLike(codeDisplay) && symbol.getSName() == SName.package_)
|| entity.getDisplay().isWhite())
desc = TextBlockUtils.empty(style.value(PName.MinimumWidth).asDouble(), 0);
else
else if (entity.getDisplay().equalsLike(codeDisplay))
desc = BodyFactory.create3(entity.getDisplay(), getSkinParam(), defaultAlign, fcTitle, style.wrapWidth(),
styleTitle);
else
desc = BodyFactory.create3(entity.getDisplay(), getSkinParam(), defaultAlign, fc, style.wrapWidth(), style);
stereo = TextBlockUtils.empty(0, 0);

View File

@ -105,10 +105,12 @@ public class PlayerAnalog extends Player {
return max;
}
@Override
public double getFullHeight(StringBounder stringBounder) {
return getHeightForConstraints(stringBounder) + suggestedHeight;
}
@Override
public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) {
final double x = ruler.getPosInPixel(tick);
final double value = getValueAt(stringBounder, tick);
@ -139,14 +141,17 @@ public class PlayerAnalog extends Player {
return last.getValue();
}
@Override
public void addNote(TimeTick now, Display note, Position position) {
throw new UnsupportedOperationException();
}
@Override
public void defineState(String stateCode, String label) {
throw new UnsupportedOperationException();
}
@Override
public void setState(TimeTick now, String comment, Colors color, String... valueString) {
final double value = getState(valueString[0]);
if (now == null)
@ -256,6 +261,7 @@ public class PlayerAnalog extends Player {
}
@Override
public UDrawable getPart2() {
return new UDrawable() {
public void drawU(UGraphic ug) {

View File

@ -58,6 +58,7 @@ import net.sourceforge.plantuml.skin.ArrowConfiguration;
import net.sourceforge.plantuml.stereo.Stereotype;
import net.sourceforge.plantuml.style.ISkinParam;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.style.StyleSignatureBasic;
import net.sourceforge.plantuml.timingdiagram.graphic.IntricatedPoint;
@ -72,6 +73,8 @@ public class PlayerBinary extends Player {
private final SortedMap<TimeTick, ChangeState> values = new TreeMap<>();
private ChangeState initialState;
private final List<TimingNote> notes = new ArrayList<>();
public PlayerBinary(String code, ISkinParam skinParam, TimingRuler ruler, boolean compact, Stereotype stereotype) {
super(code, skinParam, ruler, compact, stereotype);
this.suggestedHeight = 30;
@ -81,8 +84,10 @@ public class PlayerBinary extends Player {
return TimeConstraint.getHeightForConstraints(stringBounder, constraints);
}
@Override
public double getFullHeight(StringBounder stringBounder) {
return getHeightForConstraints(stringBounder) + suggestedHeight;
return getHeightForConstraints(stringBounder) + getHeightForNotes(stringBounder, Position.TOP) + suggestedHeight
+ getHeightForNotes(stringBounder, Position.BOTTOM);
}
@Override
@ -91,20 +96,28 @@ public class PlayerBinary extends Player {
.withTOBECHANGED(stereotype);
}
@Override
public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) {
final double x = ruler.getPosInPixel(tick);
return new IntricatedPoint(new XPoint2D(x, getYpos(stringBounder, HIGH_STRING)),
new XPoint2D(x, getYpos(stringBounder, HIGH_STRING)));
}
@Override
public void addNote(TimeTick now, Display note, Position position) {
throw new UnsupportedOperationException();
final StyleSignatureBasic signature = StyleSignatureBasic.of(SName.root, SName.element, SName.timingDiagram,
SName.note);
final Style style = signature.getMergedStyle(skinParam.getCurrentStyleBuilder());
this.notes.add(new TimingNote(now, this, note, position, skinParam, style));
}
@Override
public void defineState(String stateCode, String label) {
throw new UnsupportedOperationException();
}
@Override
public void setState(TimeTick now, String comment, Colors color, String... states) {
final ChangeState cs = new ChangeState(now, comment, color, convert(states));
if (now == null)
@ -139,14 +152,16 @@ public class PlayerBinary extends Player {
return getYhigh(stringBounder);
}
private double getYlow(StringBounder stringBounder) {
return getFullHeight(stringBounder) - ymargin;
}
private double getYhigh(StringBounder stringBounder) {
return ymargin + getHeightForConstraints(stringBounder);
return ymargin + getHeightForConstraints(stringBounder) + getHeightForNotes(stringBounder, Position.TOP);
}
private double getYlow(StringBounder stringBounder) {
return getHeightForConstraints(stringBounder) + getHeightForNotes(stringBounder, Position.TOP) + suggestedHeight
- ymargin;
}
@Override
public TextBlock getPart1(double fullAvailableWidth, double specialVSpace) {
return new AbstractTextBlock() {
@ -165,6 +180,7 @@ public class PlayerBinary extends Player {
};
}
@Override
public UDrawable getPart2() {
return new UDrawable() {
public void drawU(UGraphic ug) {
@ -204,6 +220,12 @@ public class PlayerBinary extends Player {
drawConstraints(ug.apply(UTranslate.dy(getHeightForConstraints(ug.getStringBounder()))));
drawNotes(ug.apply(UTranslate.dy(ymargin)), Position.TOP);
drawNotes(
ug.apply(UTranslate.dy(getHeightForConstraints(stringBounder)
+ getHeightForNotes(stringBounder, Position.TOP) + suggestedHeight - ymargin / 2)),
Position.BOTTOM);
}
};
}
@ -219,9 +241,26 @@ public class PlayerBinary extends Player {
}
private void drawConstraints(final UGraphic ug) {
for (TimeConstraint constraint : constraints) {
for (TimeConstraint constraint : constraints)
constraint.drawU(ug, ruler);
}
}
private void drawNotes(UGraphic ug, final Position position) {
for (TimingNote note : notes)
if (note.getPosition() == position) {
final TimeTick when = note.getWhen();
final double x = when == null ? 0 : ruler.getPosInPixel(when);
note.drawU(ug.apply(UTranslate.dx(x)));
}
}
private double getHeightForNotes(StringBounder stringBounder, Position position) {
double height = 0;
for (TimingNote note : notes)
if (note.getPosition() == position)
height = Math.max(height, note.getHeight(stringBounder));
return height;
}
}

View File

@ -73,6 +73,7 @@ public class PlayerClock extends Player {
this.suggestedHeight = 30;
}
@Override
public double getFullHeight(StringBounder stringBounder) {
return suggestedHeight + getTitleHeight(stringBounder);
}
@ -87,22 +88,27 @@ public class PlayerClock extends Player {
return 0;
}
@Override
protected StyleSignatureBasic getStyleSignature() {
return StyleSignatureBasic.of(SName.root, SName.element, SName.timingDiagram, SName.clock);
}
@Override
public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) {
throw new UnsupportedOperationException();
}
@Override
public void addNote(TimeTick now, Display note, Position position) {
throw new UnsupportedOperationException();
}
@Override
public void defineState(String stateCode, String label) {
throw new UnsupportedOperationException();
}
@Override
public void setState(TimeTick now, String comment, Colors color, String... states) {
throw new UnsupportedOperationException();
}
@ -116,6 +122,7 @@ public class PlayerClock extends Player {
return period;
}
@Override
public TextBlock getPart1(double fullAvailableWidth, double specialVSpace) {
if (displayTitle)
return new AbstractTextBlock() {
@ -131,6 +138,7 @@ public class PlayerClock extends Player {
return TextBlockUtils.empty(0, 0);
}
@Override
public UDrawable getPart2() {
return new UDrawable() {

View File

@ -115,6 +115,7 @@ public final class PlayerRobustConcise extends Player {
throw new IllegalStateException();
}
@Override
public final TextBlock getPart1(final double fullAvailableWidth, final double specialVSpace) {
return new AbstractTextBlock() {
@ -132,6 +133,7 @@ public final class PlayerRobustConcise extends Player {
};
}
@Override
public UDrawable getPart2() {
return new UDrawable() {
public void drawU(UGraphic ug) {
@ -145,6 +147,7 @@ public final class PlayerRobustConcise extends Player {
return UTranslate.dy(getTitleHeight(stringBounder));
}
@Override
public final double getFullHeight(StringBounder stringBounder) {
return getTitleHeight(stringBounder) + getZoneHeight(stringBounder);
}
@ -179,6 +182,7 @@ public final class PlayerRobustConcise extends Player {
return getTimeDrawing().getFullHeight(stringBounder);
}
@Override
public final void setState(TimeTick now, String comment, Colors color, String... states) {
for (int i = 0; i < states.length; i++)
states[i] = decodeState(states[i]);
@ -200,6 +204,7 @@ public final class PlayerRobustConcise extends Player {
return label;
}
@Override
public final IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) {
if (tick == null)
return null;
@ -211,6 +216,7 @@ public final class PlayerRobustConcise extends Player {
return point.translated(translation);
}
@Override
public final void addNote(TimeTick now, Display note, Position position) {
final StyleSignatureBasic signature = StyleSignatureBasic.of(SName.root, SName.element, SName.timingDiagram,
@ -220,6 +226,7 @@ public final class PlayerRobustConcise extends Player {
this.notes.add(new TimingNote(now, this, note, position, skinParam, style));
}
@Override
public final void defineState(String stateCode, String label) {
statesLabel.put(stateCode, label);
}

View File

@ -46,7 +46,7 @@ public class Version {
// Warning, "version" should be the same in gradle.properties and Version.java
// Any idea anyone how to magically synchronize those :-) ?
private static final String version = "1.2023.9";
private static final String version = "1.2023.10beta1";
public static String versionString() {
return version;