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

Fix background color for MinMapDiagram

This commit is contained in:
Arnaud Roques 2021-03-09 19:02:38 +01:00
parent 89c170d3ae
commit bedbe1036b
8 changed files with 58 additions and 36 deletions

View File

@ -171,7 +171,15 @@ public class Run {
dir = f; dir = f;
} }
} }
new MainWindow2(option, dir); try {
new MainWindow2(option, dir);
} catch (java.awt.HeadlessException e) {
System.err.println("There is an issue with your server. You will find some tips here:");
System.err.println("https://forum.plantuml.net/3399/problem-with-x11-and-headless-exception");
System.err.println("https://plantuml.com/en/faq#239d64f675c3e515");
throw e;
}
} else if (option.isPipe() || option.isPipeMap() || option.isSyntax()) { } else if (option.isPipe() || option.isPipeMap() || option.isSyntax()) {
managePipe(option, error); managePipe(option, error);
forceQuit = true; forceQuit = true;

View File

@ -35,9 +35,9 @@
*/ */
package net.sourceforge.plantuml.command; package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.TitledDiagram;
public class CommandAffineTransformMultiline extends CommandMultilines<UmlDiagram> { public class CommandAffineTransformMultiline extends CommandMultilines<TitledDiagram> {
public CommandAffineTransformMultiline() { public CommandAffineTransformMultiline() {
super("(?i)^!transformation[%s]+\\{[%s]*$"); super("(?i)^!transformation[%s]+\\{[%s]*$");
@ -48,7 +48,7 @@ public class CommandAffineTransformMultiline extends CommandMultilines<UmlDiagra
return "(?i)^[%s]*!\\}[%s]*$"; return "(?i)^[%s]*!\\}[%s]*$";
} }
public CommandExecutionResult execute(final UmlDiagram diagram, BlocLines lines) { public CommandExecutionResult execute(final TitledDiagram diagram, BlocLines lines) {
// lines = lines.subExtract(1, 1); // lines = lines.subExtract(1, 1);
// diagram.setAnimation(lines); // diagram.setAnimation(lines);
return CommandExecutionResult.error("Not yet implemented"); return CommandExecutionResult.error("Not yet implemented");

View File

@ -123,6 +123,7 @@ public final class EntityFactory {
final USymbol symbol = g.getUSymbol(); final USymbol symbol = g.getUSymbol();
folder.setUSymbol(symbol); folder.setUSymbol(symbol);
folder.setStereotype(g.getStereotype()); folder.setStereotype(g.getStereotype());
folder.setColors(g.getColors(skinParam));
if (g.getUrl99() != null) { if (g.getUrl99() != null) {
folder.addUrl(g.getUrl99()); folder.addUrl(g.getUrl99());
} }

View File

@ -98,7 +98,9 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
color().getRegex(), // color().getRegex(), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), new RegexLeaf("LABEL_LINK", "(?::[%s]*(.+))?"), RegexLeaf.end()); RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("LABEL_LINK", "(?::[%s]*(.+))?"), //
RegexLeaf.end());
} }
private static ColorParser color() { private static ColorParser color() {

View File

@ -56,10 +56,7 @@ import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.style.NoStyleAvailableException; import net.sourceforge.plantuml.style.NoStyleAvailableException;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.style.StyleBuilder;
import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter; import net.sourceforge.plantuml.ugraphic.ImageParameter;
@ -93,18 +90,11 @@ public class MindMapDiagram extends UmlDiagram {
final Scale scale = getScale(); final Scale scale = getScale();
final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100); final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100);
final ISkinParam skinParam = getSkinParam(); final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption, null, dpiFactor, "");
final Style style = StyleSignature.of(SName.root, SName.document, SName.mindmapDiagram)
.getMergedStyle(skinParam.getCurrentStyleBuilder());
final ImageParameter imageParameter = new ImageParameter(this,
fileFormatOption, null, dpiFactor, "");
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
TextBlock result = getTextBlock(); TextBlock result = getTextBlock();
result = new AnnotatedWorker(this, getSkinParam(), fileFormatOption.getDefaultStringBounder(getSkinParam()))
result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder(getSkinParam()))
.addAdd(result); .addAdd(result);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);

View File

@ -147,7 +147,7 @@ public class Line implements Moveable, Hideable, GuideLine {
private HColor arrowLollipopColor; private HColor arrowLollipopColor;
private final ISkinParam skinParam; private final ISkinParam skinParam;
// private final UmlDiagramType umlType; private final double labelShield;
@Override @Override
public String toString() { public String toString() {
@ -304,6 +304,12 @@ public class Line implements Moveable, Hideable, GuideLine {
skinParam); skinParam);
} }
if (link.getType().getMiddleDecor() == LinkMiddleDecor.NONE) {
this.labelShield = 0;
} else {
this.labelShield = 7;
}
} }
private TextBlock addVisibilityModifier(TextBlock block, Link link, ISkinParam skinParam) { private TextBlock addVisibilityModifier(TextBlock block, Link link, ISkinParam skinParam) {
@ -376,8 +382,9 @@ public class Line implements Moveable, Hideable, GuideLine {
} else { } else {
sb.append("label=<"); sb.append("label=<");
} }
final Dimension2D dimNote = hasNoteLabelText() ? labelText.calculateDimension(stringBounder) Dimension2D dimNote = hasNoteLabelText() ? labelText.calculateDimension(stringBounder) : CONSTRAINT_SPOT;
: CONSTRAINT_SPOT; dimNote = Dimension2DDouble.delta(dimNote, 2 * labelShield);
appendTable(sb, eventuallyDivideByTwo(dimNote), noteLabelColor, graphvizVersion); appendTable(sb, eventuallyDivideByTwo(dimNote), noteLabelColor, graphvizVersion);
sb.append(">"); sb.append(">");
} }
@ -711,8 +718,8 @@ public class Line implements Moveable, Hideable, GuideLine {
if (hasNoteLabelText() && this.labelXY != null if (hasNoteLabelText() && this.labelXY != null
&& link.getNoteLinkStrategy() != NoteLinkStrategy.HALF_NOT_PRINTED) { && link.getNoteLinkStrategy() != NoteLinkStrategy.HALF_NOT_PRINTED) {
this.labelText.drawU(ug.apply( this.labelText.drawU(ug.apply(new UTranslate(x + this.labelXY.getPosition().getX() + labelShield,
new UTranslate(x + this.labelXY.getPosition().getX(), y + this.labelXY.getPosition().getY()))); y + this.labelXY.getPosition().getY() + labelShield)));
} }
if (this.startTailText != null && this.startTailLabelXY != null if (this.startTailText != null && this.startTailLabelXY != null
&& this.startTailLabelXY.getPosition() != null) { && this.startTailLabelXY.getPosition() != null) {

View File

@ -53,6 +53,7 @@ import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.svg.LengthAdjust; import net.sourceforge.plantuml.svg.LengthAdjust;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper; import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class ImageParameter { public class ImageParameter {
@ -93,20 +94,32 @@ public class ImageParameter {
this.fileFormatOption = null; this.fileFormatOption = null;
} }
public ImageParameter(TitledDiagram diagram, FileFormatOption fileFormatOption, Animation animation, double dpiFactor, String warningOrError) { public ImageParameter(TitledDiagram diagram, FileFormatOption fileFormatOption, Animation animation,
this( double dpiFactor, String warningOrError) {
diagram, this(diagram, fileFormatOption, animation, dpiFactor,
fileFormatOption, fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, warningOrError,
animation, getBackgroundColor(diagram));
dpiFactor,
fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null,
warningOrError,
diagram.getSkinParam().getBackgroundColor(false)
);
} }
public ImageParameter(TitledDiagram diagram, FileFormatOption fileFormatOption, Animation animation, double dpiFactor, String metadata, private static HColor getBackgroundColor(TitledDiagram diagram) {
String warningOrError, HColor backcolor) { if (UseStyle.useBetaStyle()) {
final Style style = StyleSignature
.of(SName.root, SName.document, diagram.getUmlDiagramType().getStyleName())
.getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder());
HColor backgroundColor = style.value(PName.BackGroundColor)
.asColor(diagram.getSkinParam().getIHtmlColorSet());
if (backgroundColor == null) {
backgroundColor = HColorUtils.transparent();
}
return backgroundColor;
}
return diagram.getSkinParam().getBackgroundColor(false);
}
public ImageParameter(TitledDiagram diagram, FileFormatOption fileFormatOption, Animation animation,
double dpiFactor, String metadata, String warningOrError, HColor backcolor) {
final ISkinParam skinParam = diagram.getSkinParam(); final ISkinParam skinParam = diagram.getSkinParam();
this.fileFormatOption = fileFormatOption; this.fileFormatOption = fileFormatOption;
this.colorMapper = skinParam.getColorMapper(); this.colorMapper = skinParam.getColorMapper();
@ -196,7 +209,8 @@ public class ImageParameter {
private static ClockwiseTopRightBottomLeft calculateDiagramMargin(TitledDiagram diagram) { private static ClockwiseTopRightBottomLeft calculateDiagramMargin(TitledDiagram diagram) {
if (UseStyle.useBetaStyle()) { if (UseStyle.useBetaStyle()) {
final Style style = StyleSignature.of(SName.root, SName.document).getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); final Style style = StyleSignature.of(SName.root, SName.document)
.getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder());
if (style.hasValue(PName.Margin)) { if (style.hasValue(PName.Margin)) {
return style.getMargin(); return style.getMargin();
} }

View File

@ -80,7 +80,7 @@ public class Version {
} }
public static int beta() { public static int beta() {
final int beta = 0; final int beta = 2;
return beta; return beta;
} }