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

fix: fix MaximumWidth style for legend

https://github.com/plantuml/plantuml/issues/1608
This commit is contained in:
Arnaud Roques 2023-11-23 21:04:56 +01:00
parent b48ea95112
commit a98d8ccdd5
7 changed files with 25 additions and 17 deletions

View File

@ -40,6 +40,7 @@ import net.sourceforge.plantuml.abel.DisplayPositioned;
import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
import net.sourceforge.plantuml.cucadiagram.DisplaySection; import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.klimt.Fashion; import net.sourceforge.plantuml.klimt.Fashion;
import net.sourceforge.plantuml.klimt.LineBreakStrategy;
import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.UTranslate;
import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColor;
import net.sourceforge.plantuml.klimt.creole.Display; import net.sourceforge.plantuml.klimt.creole.Display;
@ -167,7 +168,7 @@ public class AnnotatedBuilder {
final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.title) final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.title)
.getMergedStyle(skinParam.getCurrentStyleBuilder()); .getMergedStyle(skinParam.getCurrentStyleBuilder());
final TextBlock block = style.createTextBlockBordered(title.getDisplay(), skinParam.getIHtmlColorSet(), final TextBlock block = style.createTextBlockBordered(title.getDisplay(), skinParam.getIHtmlColorSet(),
skinParam, Style.ID_TITLE); skinParam, Style.ID_TITLE, LineBreakStrategy.NONE);
return block; return block;
} }
@ -179,7 +180,7 @@ public class AnnotatedBuilder {
final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.caption) final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.caption)
.getMergedStyle(skinParam.getCurrentStyleBuilder()); .getMergedStyle(skinParam.getCurrentStyleBuilder());
return style.createTextBlockBordered(caption.getDisplay(), skinParam.getIHtmlColorSet(), skinParam, return style.createTextBlockBordered(caption.getDisplay(), skinParam.getIHtmlColorSet(), skinParam,
Style.ID_CAPTION); Style.ID_CAPTION, LineBreakStrategy.NONE);
} }

View File

@ -49,7 +49,9 @@ public class EntityImageLegend {
final Style style = StyleSignatureBasic final Style style = StyleSignatureBasic
.of(SName.root, SName.root, SName.document, skinParam.getUmlDiagramType().getStyleName(), SName.legend) .of(SName.root, SName.root, SName.document, skinParam.getUmlDiagramType().getStyleName(), SName.legend)
.getMergedStyle(skinParam.getCurrentStyleBuilder()); .getMergedStyle(skinParam.getCurrentStyleBuilder());
return style.createTextBlockBordered(note, skinParam.getIHtmlColorSet(), skinParam, Style.ID_LEGEND);
return style.createTextBlockBordered(note, skinParam.getIHtmlColorSet(), skinParam, Style.ID_LEGEND,
style.wrapWidth());
} }
} }

View File

@ -38,6 +38,7 @@ package net.sourceforge.plantuml.cucadiagram;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.Map; import java.util.Map;
import net.sourceforge.plantuml.klimt.LineBreakStrategy;
import net.sourceforge.plantuml.klimt.creole.Display; import net.sourceforge.plantuml.klimt.creole.Display;
import net.sourceforge.plantuml.klimt.font.FontConfiguration; import net.sourceforge.plantuml.klimt.font.FontConfiguration;
import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment; import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment;
@ -96,7 +97,8 @@ public class DisplaySection {
return null; return null;
if (style != null) if (style != null)
return style.createTextBlockBordered(display, spriteContainer.getIHtmlColorSet(), spriteContainer, null); return style.createTextBlockBordered(display, spriteContainer.getIHtmlColorSet(), spriteContainer, null,
LineBreakStrategy.NONE);
return display.create(fontConfiguration, getHorizontalAlignment(), spriteContainer); return display.create(fontConfiguration, getHorizontalAlignment(), spriteContainer);
} }

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.png; package net.sourceforge.plantuml.png;
import net.sourceforge.plantuml.cucadiagram.DisplaySection; import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.klimt.LineBreakStrategy;
import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.HColorSet;
import net.sourceforge.plantuml.klimt.creole.Display; import net.sourceforge.plantuml.klimt.creole.Display;
import net.sourceforge.plantuml.klimt.font.StringBounder; import net.sourceforge.plantuml.klimt.font.StringBounder;
@ -73,6 +74,6 @@ public class PngTitler {
if (display == null) if (display == null)
return null; return null;
return style.createTextBlockBordered(display, set, spriteContainer, Style.ID_TITLE); return style.createTextBlockBordered(display, set, spriteContainer, Style.ID_TITLE, LineBreakStrategy.NONE);
} }
} }

View File

@ -46,6 +46,7 @@ import net.sourceforge.plantuml.AnnotatedBuilder;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.DisplaySection; import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.klimt.LineBreakStrategy;
import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.UTranslate;
import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColor;
import net.sourceforge.plantuml.klimt.creole.Display; import net.sourceforge.plantuml.klimt.creole.Display;
@ -165,7 +166,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.title) final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.title)
.getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); .getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder());
compTitle = style.createTextBlockBordered(page.getTitle(), diagram.getSkinParam().getIHtmlColorSet(), compTitle = style.createTextBlockBordered(page.getTitle(), diagram.getSkinParam().getIHtmlColorSet(),
diagram.getSkinParam(), Style.ID_TITLE); diagram.getSkinParam(), Style.ID_TITLE, LineBreakStrategy.NONE);
final XDimension2D dimTitle = compTitle.calculateDimension(stringBounder); final XDimension2D dimTitle = compTitle.calculateDimension(stringBounder);
area.setTitleArea(dimTitle.getWidth(), dimTitle.getHeight()); area.setTitleArea(dimTitle.getWidth(), dimTitle.getHeight());
} }
@ -179,7 +180,8 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.legend) final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.legend)
.getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); .getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder());
legendBlock = style.createTextBlockBordered(diagram.getLegend().getDisplay(), legendBlock = style.createTextBlockBordered(diagram.getLegend().getDisplay(),
diagram.getSkinParam().getIHtmlColorSet(), diagram.getSkinParam(), Style.ID_LEGEND); diagram.getSkinParam().getIHtmlColorSet(), diagram.getSkinParam(), Style.ID_LEGEND,
LineBreakStrategy.NONE);
} }
final XDimension2D dimLegend = legendBlock.calculateDimension(stringBounder); final XDimension2D dimLegend = legendBlock.calculateDimension(stringBounder);
area.setLegend(dimLegend, isLegendTop(), diagram.getLegend().getHorizontalAlignment()); area.setLegend(dimLegend, isLegendTop(), diagram.getLegend().getHorizontalAlignment());

View File

@ -43,6 +43,7 @@ import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.DisplaySection; import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.klimt.LineBreakStrategy;
import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.UTranslate;
import net.sourceforge.plantuml.klimt.creole.Display; import net.sourceforge.plantuml.klimt.creole.Display;
import net.sourceforge.plantuml.klimt.drawing.UGraphic; import net.sourceforge.plantuml.klimt.drawing.UGraphic;
@ -213,7 +214,8 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.title) final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.title)
.getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); .getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder());
final TextBlock compTitle = style.createTextBlockBordered(diagram.getTitle().getDisplay(), final TextBlock compTitle = style.createTextBlockBordered(diagram.getTitle().getDisplay(),
diagram.getSkinParam().getIHtmlColorSet(), diagram.getSkinParam(), Style.ID_TITLE); diagram.getSkinParam().getIHtmlColorSet(), diagram.getSkinParam(), Style.ID_TITLE,
LineBreakStrategy.NONE);
return compTitle; return compTitle;
} }

View File

@ -40,7 +40,6 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.klimt.Fashion; import net.sourceforge.plantuml.klimt.Fashion;
import net.sourceforge.plantuml.klimt.LineBreakStrategy; import net.sourceforge.plantuml.klimt.LineBreakStrategy;
import net.sourceforge.plantuml.klimt.UStroke; import net.sourceforge.plantuml.klimt.UStroke;
@ -49,6 +48,7 @@ import net.sourceforge.plantuml.klimt.color.Colors;
import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColor;
import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.HColorSet;
import net.sourceforge.plantuml.klimt.color.HColors; import net.sourceforge.plantuml.klimt.color.HColors;
import net.sourceforge.plantuml.klimt.creole.CreoleMode;
import net.sourceforge.plantuml.klimt.creole.Display; import net.sourceforge.plantuml.klimt.creole.Display;
import net.sourceforge.plantuml.klimt.drawing.UGraphic; import net.sourceforge.plantuml.klimt.drawing.UGraphic;
import net.sourceforge.plantuml.klimt.font.FontConfiguration; import net.sourceforge.plantuml.klimt.font.FontConfiguration;
@ -283,19 +283,17 @@ public class Style {
return value(PName.HorizontalAlignment).asHorizontalAlignment(); return value(PName.HorizontalAlignment).asHorizontalAlignment();
} }
private TextBlock createTextBlockInternal(Display display, HColorSet set, ISkinSimple spriteContainer,
HorizontalAlignment alignment) {
final FontConfiguration fc = getFontConfiguration(set);
return display.create(fc, alignment, spriteContainer);
}
public static final String ID_TITLE = "_title"; public static final String ID_TITLE = "_title";
public static final String ID_CAPTION = "_caption"; public static final String ID_CAPTION = "_caption";
public static final String ID_LEGEND = "_legend"; public static final String ID_LEGEND = "_legend";
public TextBlock createTextBlockBordered(Display note, HColorSet set, ISkinSimple spriteContainer, String id) { public TextBlock createTextBlockBordered(Display note, HColorSet set, ISkinSimple spriteContainer, String id,
LineBreakStrategy lineBreak) {
final HorizontalAlignment alignment = this.getHorizontalAlignment(); final HorizontalAlignment alignment = this.getHorizontalAlignment();
final TextBlock textBlock = this.createTextBlockInternal(note, set, spriteContainer, alignment); final FontConfiguration fc = this.getFontConfiguration(set);
final TextBlock textBlock = note.create0(fc, alignment, spriteContainer, lineBreak, CreoleMode.FULL, null,
null);
final HColor backgroundColor = this.value(PName.BackGroundColor).asColor(set); final HColor backgroundColor = this.value(PName.BackGroundColor).asColor(set);
final HColor lineColor = this.value(PName.LineColor).asColor(set); final HColor lineColor = this.value(PName.LineColor).asColor(set);