1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-05 01:50:49 +00:00

Import version 1.2020.23

This commit is contained in:
Arnaud Roques 2020-12-14 19:31:06 +01:00
parent 7e81ef289b
commit 56cd2269dd
88 changed files with 1398 additions and 1015 deletions

View File

@ -35,7 +35,7 @@
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>1.2020.23-SNAPSHOT</version>
<version>1.2020.24-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>

View File

@ -42,13 +42,12 @@ import java.util.List;
public class BackSlash {
private static final char PRIVATE_BLOCK = '\uE000';
public static final String BS_BS_N = "\\n";
public static final String NEWLINE = "\n";
public static final char CHAR_NEWLINE = '\n';
public static char hiddenNewLine() {
return PRIVATE_BLOCK + BackSlash.CHAR_NEWLINE;
return StringUtils.PRIVATE_BLOCK + BackSlash.CHAR_NEWLINE;
}
public static String convertHiddenNewLine(String s) {
@ -126,8 +125,8 @@ public class BackSlash {
final StringBuilder result = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c > PRIVATE_BLOCK && c < '\uE07F') {
c = (char) (c - PRIVATE_BLOCK);
if (c > StringUtils.PRIVATE_BLOCK && c < '\uE07F') {
c = (char) (c - StringUtils.PRIVATE_BLOCK);
}
result.append(c);
}
@ -138,7 +137,7 @@ public class BackSlash {
if (c > 128) {
throw new IllegalArgumentException();
}
return (char) (PRIVATE_BLOCK + c);
return (char) (StringUtils.PRIVATE_BLOCK + c);
}
}

View File

@ -80,6 +80,9 @@ public class EmbeddedDiagram implements CharSequence {
if (s.equals("{{gantt")) {
return "gantt";
}
if (s.equals("{{json")) {
return "json";
}
return null;
}

View File

@ -51,6 +51,59 @@ import net.sourceforge.plantuml.cucadiagram.Display;
// Do not move
public class StringUtils {
public static final char USER_NEWLINE = '\uEE00';
public static final char USER_TAB = '\uEE01';
public static final char HR_SIMPLE = '\uEEFF';
public static final char HR_DOUBLE = '\uEEFE';
public static final char HR_DOTTED = '\uEEFD';
public static final char HR_BOLD = '\uEEFC';
public static final char PRIVATE_FIELD = '\uEEFB';
public static final char PROTECTED_FIELD = '\uEEFA';
public static final char PACKAGE_PRIVATE_FIELD = '\uEEF9';
public static final char PUBLIC_FIELD = '\uEEF8';
public static final char PRIVATE_METHOD = '\uEEF7';
public static final char PROTECTED_METHOD = '\uEEF6';
public static final char PACKAGE_PRIVATE_METHOD = '\uEEF5';
public static final char PUBLIC_METHOD = '\uEEF4';
public static final char IE_MANDATORY = '\uEEF3';
// Used in BackSlash
public static final char PRIVATE_BLOCK = '\uE000';
public static final char INTERNAL_BOLD = '\uE100';
public static String toInternalBoldNumber(String s) {
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
final char c = s.charAt(i);
if (c >= '0' && c <= '9') {
sb.append(Character.toChars('\uE100' + c - '0'));
} else {
sb.append(c);
}
}
return sb.toString();
}
public static void appendInternalToRealBoldNumber(StringBuilder sb, char c) {
if (c >= '\uE100' && c <= ('\uE100' + 9)) {
sb.append(Character.toChars(0x1d7ce + c - '\uE100'));
} else {
sb.append(c);
}
}
public static void appendInternalToPlainNumber(StringBuilder sb, char c) {
if (c >= '\uE100' && c <= ('\uE100' + 9)) {
sb.append(Character.toChars('0' + c - '\uE100'));
} else {
sb.append(c);
}
}
final static public List<String> getSplit(Pattern2 pattern, String line) {
final Matcher2 m = pattern.matcher(line);
if (m.find() == false) {

View File

@ -40,6 +40,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.StringUtils;
public class BasicCharAreaImpl implements BasicCharArea {
private int charSize1 = 160;
@ -141,7 +143,7 @@ public class BasicCharAreaImpl implements BasicCharArea {
for (int x = 0; x < width; x++) {
final char c = chars[x][line];
if (c != '\0') {
sb.append(c);
StringUtils.appendInternalToRealBoldNumber(sb, c);
}
}
return sb.toString();

View File

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

View File

@ -37,6 +37,8 @@ package net.sourceforge.plantuml.asciiart;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.StringUtils;
@ -62,14 +64,14 @@ public class ComponentTextArrow extends AbstractComponentText implements ArrowCo
public ComponentTextArrow(ComponentType type, ArrowConfiguration config, Display stringsToDisplay,
FileFormat fileFormat, int maxAsciiMessageLength) {
this.fileFormat = fileFormat;
this.maxAsciiMessageLength = maxAsciiMessageLength;
this.type = type;
this.config = config;
this.stringsToDisplay = clean(stringsToDisplay);
this.fileFormat = fileFormat;
}
private static Display clean(Display orig) {
private Display clean(Display orig) {
if (orig.size() == 0 || orig.get(0) instanceof MessageNumber == false) {
return orig;
}
@ -86,7 +88,19 @@ public class ComponentTextArrow extends AbstractComponentText implements ArrowCo
return result;
}
private static String removeTag(String s) {
private String removeTag(String s) {
if (fileFormat == FileFormat.UTXT) {
final Pattern pattern = Pattern.compile("\\<b\\>([0-9]+)\\</b\\>");
final Matcher matcher = pattern.matcher(s);
final StringBuffer result = new StringBuffer();
while (matcher.find()) {
final String num = matcher.group(1);
final String replace = StringUtils.toInternalBoldNumber(num);
matcher.appendReplacement(result, Matcher.quoteReplacement(replace));
}
matcher.appendTail(result);
s = result.toString();
}
return s.replaceAll("\\<[^<>]+\\>", "");
}
@ -119,7 +133,12 @@ public class ComponentTextArrow extends AbstractComponentText implements ArrowCo
throw new UnsupportedOperationException();
}
// final int position = Math.max(0, (width - textWidth) / 2);
charArea.drawStringsLR(stringsToDisplay.as(), (width - textWidth) / 2, 0);
if (fileFormat == FileFormat.UTXT) {
charArea.drawStringsLRUnicode(stringsToDisplay.as(), (width - textWidth) / 2, 0);
} else {
charArea.drawStringsLRSimple(stringsToDisplay.as(), (width - textWidth) / 2, 0);
}
}
public double getPreferredHeight(StringBounder stringBounder) {

View File

@ -78,7 +78,11 @@ public class ComponentTextNote extends AbstractComponentText {
charArea.drawBoxSimple(2, 0, width - 2, height);
}
}
charArea.drawStringsLR(stringsToDisplay.as(), 3, 1);
if (fileFormat == FileFormat.UTXT) {
charArea.drawStringsLRUnicode(stringsToDisplay.as(), 3, 1);
} else {
charArea.drawStringsLRSimple(stringsToDisplay.as(), 3, 1);
}
}
public double getPreferredHeight(StringBounder stringBounder) {

View File

@ -53,8 +53,7 @@ public class ComponentTextParticipant extends AbstractComponentText {
private final Display stringsToDisplay;
private final FileFormat fileFormat;
public ComponentTextParticipant(ComponentType type, Display stringsToDisplay,
FileFormat fileFormat) {
public ComponentTextParticipant(ComponentType type, Display stringsToDisplay, FileFormat fileFormat) {
this.type = type;
this.stringsToDisplay = stringsToDisplay;
this.fileFormat = fileFormat;
@ -83,7 +82,11 @@ public class ComponentTextParticipant extends AbstractComponentText {
charArea.drawChar('+', (width - 1) / 2, height - 1);
}
}
charArea.drawStringsLR(stringsToDisplay.as(), 1, 1);
if (fileFormat == FileFormat.UTXT) {
charArea.drawStringsLRUnicode(stringsToDisplay.as(), 1, 1);
} else {
charArea.drawStringsLRSimple(stringsToDisplay.as(), 1, 1);
}
}
public double getPreferredHeight(StringBounder stringBounder) {

View File

@ -57,8 +57,8 @@ public class ComponentTextSelfArrow extends AbstractComponentText implements Arr
private final FileFormat fileFormat;
private final ArrowConfiguration config;
public ComponentTextSelfArrow(ComponentType type, ArrowConfiguration config,
Display stringsToDisplay, FileFormat fileFormat) {
public ComponentTextSelfArrow(ComponentType type, ArrowConfiguration config, Display stringsToDisplay,
FileFormat fileFormat) {
this.type = type;
this.stringsToDisplay = stringsToDisplay;
this.fileFormat = fileFormat;
@ -96,7 +96,11 @@ public class ComponentTextSelfArrow extends AbstractComponentText implements Arr
charArea.drawStringLR("<---'", 0, 2);
}
charArea.drawStringsLR(stringsToDisplay.as(), 6, 1);
if (fileFormat == FileFormat.UTXT) {
charArea.drawStringsLRUnicode(stringsToDisplay.as(), 6, 1);
} else {
charArea.drawStringsLRSimple(stringsToDisplay.as(), 6, 1);
}
}
public double getPreferredHeight(StringBounder stringBounder) {
@ -114,7 +118,7 @@ public class ComponentTextSelfArrow extends AbstractComponentText implements Arr
public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) {
return new Point2D.Double(0, 0);
}
public double getPaddingY() {
throw new UnsupportedOperationException();
}

View File

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

View File

@ -44,7 +44,10 @@ import net.sourceforge.plantuml.ugraphic.UFont;
public class TextStringBounder implements StringBounder {
public Dimension2D calculateDimension(UFont font, String text) {
return new Dimension2DDouble(text.length(), 1);
final int length1 = text.codePointCount(0, text.length());
final int length2 = text.length();
final int length3 = Wcwidth.length(text);
return new Dimension2DDouble(length2, 1);
}
}

View File

@ -116,8 +116,12 @@ public class TranslatedCharArea implements UmlCharArea {
charArea.print(ps);
}
public void drawStringsLR(Collection<? extends CharSequence> strings, int x, int y) {
charArea.drawStringsLR(strings, x + dx, y + dy);
public void drawStringsLRSimple(Collection<? extends CharSequence> strings, int x, int y) {
charArea.drawStringsLRSimple(strings, x + dx, y + dy);
}
public void drawStringsLRUnicode(Collection<? extends CharSequence> strings, int x, int y) {
charArea.drawStringsLRUnicode(strings, x + dx, y + dy);
}
public void fillRect(char c, int x, int y, int width, int height) {

View File

@ -49,6 +49,8 @@ public interface UmlCharArea extends BasicCharArea {
void drawShape(AsciiShape shape, int x, int y);
void drawStringsLR(Collection<? extends CharSequence> strings, int x, int y);
void drawStringsLRSimple(Collection<? extends CharSequence> strings, int x, int y);
void drawStringsLRUnicode(Collection<? extends CharSequence> strings, int x, int y);
}

View File

@ -37,6 +37,9 @@ package net.sourceforge.plantuml.asciiart;
import java.util.Collection;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.sequencediagram.MessageNumber;
public class UmlCharAreaImpl extends BasicCharAreaImpl implements UmlCharArea {
public void drawBoxSimple(int x, int y, int width, int height) {
@ -69,16 +72,32 @@ public class UmlCharAreaImpl extends BasicCharAreaImpl implements UmlCharArea {
shape.draw(this, x, y);
}
public void drawStringsLR(Collection<? extends CharSequence> strings, int x, int y) {
public void drawStringsLRSimple(Collection<? extends CharSequence> strings, int x, int y) {
int i = 0;
if (x < 0) {
x = 0;
}
for (CharSequence s : strings) {
if (s instanceof MessageNumber) {
s = ((MessageNumber) s).getNumberRaw();
}
this.drawStringLR(s.toString(), x, y + i);
i++;
}
}
public void drawStringsLRUnicode(Collection<? extends CharSequence> strings, int x, int y) {
int i = 0;
if (x < 0) {
x = 0;
}
for (CharSequence s : strings) {
if (s instanceof MessageNumber) {
s = StringUtils.toInternalBoldNumber((((MessageNumber) s).getNumberRaw()));
}
this.drawStringLR(s.toString(), x, y + i);
i++;
}
}
public void drawNoteSimple(int x, int y, int width, int height) {

View File

@ -67,6 +67,7 @@ import net.sourceforge.plantuml.ugraphic.UImage;
public class AtomImg extends AbstractAtom implements Atom {
private static final String DATA_IMAGE_PNG_BASE64 = "data:image/png;base64,";
private static final String DATA_IMAGE_SVG_BASE64 = "data:image/svg+xml;base64,";
private final BufferedImage image;
private final double scale;
private final Url url;
@ -102,8 +103,19 @@ public class AtomImg extends AbstractAtom implements Atom {
} catch (Exception e) {
return AtomTextUtils.createLegacy("ERROR " + e.toString(), fc);
}
}
if (src.startsWith(DATA_IMAGE_SVG_BASE64)) {
final String data = src.substring(DATA_IMAGE_SVG_BASE64.length(), src.length());
try {
final byte bytes[] = Base64Coder.decode(data);
final String tmp = new String(bytes);
return new AtomImgSvg(new TileImageSvg(tmp));
} catch (Exception e) {
return AtomTextUtils.createLegacy("ERROR " + e.toString(), fc);
}
}
try {
// Check if valid URL
if (src.startsWith("http:") || src.startsWith("https:")) {

View File

@ -54,13 +54,16 @@ import net.sourceforge.plantuml.creole.atom.AbstractAtom;
import net.sourceforge.plantuml.creole.atom.Atom;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UText;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorAutomatic;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import net.sourceforge.plantuml.utils.CharHidder;
public final class AtomText extends AbstractAtom implements Atom {
@ -75,12 +78,24 @@ public final class AtomText extends AbstractAtom implements Atom {
private final DelayedDouble marginRight;
private final Url url;
private final boolean manageSpecialChars;
private TextBlock visibility;
protected AtomText(String text, FontConfiguration style, Url url, DelayedDouble marginLeft,
DelayedDouble marginRight, boolean manageSpecialChars) {
if (text.contains("" + BackSlash.hiddenNewLine())) {
throw new IllegalArgumentException(text);
}
// if (text.length() > 0) {
// final VisibilityModifier visibilityModifier = VisibilityModifier.getByUnicode(text.charAt(0));
// if (visibilityModifier != null) {
// final HColor back = HColorUtils.GREEN;
// final HColor fore = HColorUtils.RED;
// visibility = visibilityModifier.getUBlock(11, fore, back, url != null);
// text = text.substring(1);
// }
// }
this.marginLeft = marginLeft;
this.marginRight = marginRight;
String s = CharHidder.unhide(text);
@ -109,9 +124,12 @@ public final class AtomText extends AbstractAtom implements Atom {
if (h < 10) {
h = 10;
}
final double width = text.indexOf("\t") == -1 ? rect.getWidth() : getWidth(stringBounder, text);
double width = text.indexOf("\t") == -1 ? rect.getWidth() : getWidth(stringBounder, text);
final double left = marginLeft.getDouble(stringBounder);
final double right = marginRight.getDouble(stringBounder);
if (visibility != null) {
width += visibility.calculateDimension(stringBounder).getWidth();
}
return new Dimension2DDouble(width + left + right, h);
}
@ -123,6 +141,11 @@ public final class AtomText extends AbstractAtom implements Atom {
if (ug.matchesProperty("SPECIALTXT")) {
ug.draw(this);
} else {
if (visibility != null) {
visibility.drawU(ug.apply(UTranslate.dy(2)));
final double width = visibility.calculateDimension(ug.getStringBounder()).getWidth();
ug = ug.apply(UTranslate.dx(width));
}
HColor textColor = fontConfiguration.getColor();
FontConfiguration useFontConfiguration = fontConfiguration;
if (textColor instanceof HColorAutomatic && ug.getParam().getBackcolor() != null) {
@ -261,7 +284,7 @@ public final class AtomText extends AbstractAtom implements Atom {
}
return Collections.singletonList((Atom) this);
}
private boolean isOfWord(char ch) {
return Character.isWhitespace(ch) == false;
}
@ -269,7 +292,7 @@ public final class AtomText extends AbstractAtom implements Atom {
public final String getText() {
return text;
}
public double getStartingAltitude(StringBounder stringBounder) {
return fontConfiguration.getSpace();
}

View File

@ -104,7 +104,7 @@ public class CreoleParser implements SheetBuilder {
.createStripe(context);
}
private static boolean isTableLine(String line) {
public static boolean isTableLine(String line) {
return line.matches("^(\\<#\\w+(,#?\\w+)?\\>)?\\|(\\=)?.*\\|$");
}

View File

@ -46,16 +46,16 @@ public interface Bodier {
public void setLeaf(ILeaf leaf);
public List<Member> getFieldsToDisplay();
public Display getFieldsToDisplay();
public List<Member> getMethodsToDisplay();
public Display getMethodsToDisplay();
public void addFieldOrMethod(String s);
public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields,
Stereotype stereotype, Style style);
public List<String> getRawBody();
public List<CharSequence> getRawBody();
public void muteClassToObject();

View File

@ -43,6 +43,8 @@ import java.util.Set;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.creole.legacy.CreoleParser;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockLineBefore;
@ -50,14 +52,13 @@ import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.style.Style;
public class BodierImpl implements Bodier {
public class BodierLikeClassOrObject implements Bodier {
private final List<String> rawBody = new ArrayList<String>();
private final List<CharSequence> rawBody = new ArrayList<CharSequence>();
private final Set<VisibilityModifier> hides;
private LeafType type;
private List<Member> methodsToDisplay;
private List<Member> fieldsToDisplay;
private final boolean manageModifier;
private ILeaf leaf;
public void muteClassToObject() {
@ -66,13 +67,16 @@ public class BodierImpl implements Bodier {
type = LeafType.OBJECT;
}
public BodierImpl(LeafType type, Set<VisibilityModifier> hides) {
BodierLikeClassOrObject(LeafType type, Set<VisibilityModifier> hides) {
if (type == LeafType.MAP) {
throw new IllegalArgumentException();
}
if (type == null) {
throw new IllegalArgumentException();
}
assert type.isLikeClass() || type == LeafType.OBJECT;
this.hides = hides;
this.type = type;
this.manageModifier = type == null ? false : type.manageModifier();
}
public void setLeaf(ILeaf leaf) {
@ -91,44 +95,47 @@ public class BodierImpl implements Bodier {
}
private boolean isBodyEnhanced() {
for (String s : rawBody) {
if (BodyEnhanced.isBlockSeparator(s)) {
for (CharSequence s : rawBody) {
if (BodyEnhanced1.isBlockSeparator(s) || CreoleParser.isTableLine(s.toString())) {
return true;
}
}
return false;
}
private boolean isMethod(String s) {
if (type == LeafType.ANNOTATION || type == LeafType.ABSTRACT_CLASS || type == LeafType.CLASS
|| type == LeafType.INTERFACE || type == LeafType.ENUM) {
return Member.isMethod(s);
private boolean isMethod(CharSequence s) {
final String purged = s.toString().replaceAll(UrlBuilder.getRegexp(), "");
if (purged.contains("{method}")) {
return true;
}
return false;
if (purged.contains("{field}")) {
return false;
}
return purged.contains("(") || purged.contains(")");
}
public List<Member> getMethodsToDisplay() {
public Display getMethodsToDisplay() {
if (methodsToDisplay == null) {
methodsToDisplay = new ArrayList<Member>();
for (int i = 0; i < rawBody.size(); i++) {
final String s = rawBody.get(i);
final CharSequence s = rawBody.get(i);
if (isMethod(i, rawBody) == false) {
continue;
}
if (s.length() == 0 && methodsToDisplay.size() == 0) {
continue;
}
final Member m = new Member(s, true, manageModifier);
final Member m = Member.method(s);
if (hides == null || hides.contains(m.getVisibilityModifier()) == false) {
methodsToDisplay.add(m);
}
}
removeFinalEmptyMembers(methodsToDisplay);
}
return Collections.unmodifiableList(methodsToDisplay);
return Display.create(methodsToDisplay);
}
private boolean isMethod(int i, List<String> rawBody) {
private boolean isMethod(int i, List<CharSequence> rawBody) {
if (i > 0 && i < rawBody.size() - 1 && rawBody.get(i).length() == 0 && isMethod(rawBody.get(i - 1))
&& isMethod(rawBody.get(i + 1))) {
return true;
@ -136,24 +143,24 @@ public class BodierImpl implements Bodier {
return isMethod(rawBody.get(i));
}
public List<Member> getFieldsToDisplay() {
public Display getFieldsToDisplay() {
if (fieldsToDisplay == null) {
fieldsToDisplay = new ArrayList<Member>();
for (String s : rawBody) {
for (CharSequence s : rawBody) {
if (isMethod(s) == true) {
continue;
}
if (s.length() == 0 && fieldsToDisplay.size() == 0) {
continue;
}
final Member m = new Member(s, false, manageModifier);
final Member m = Member.field(s);
if (hides == null || hides.contains(m.getVisibilityModifier()) == false) {
fieldsToDisplay.add(m);
}
}
removeFinalEmptyMembers(fieldsToDisplay);
}
return Collections.unmodifiableList(fieldsToDisplay);
return Display.create(fieldsToDisplay);
}
private void removeFinalEmptyMembers(List<Member> result) {
@ -163,12 +170,14 @@ public class BodierImpl implements Bodier {
}
public boolean hasUrl() {
for (Member m : getFieldsToDisplay()) {
for (CharSequence cs : getFieldsToDisplay()) {
final Member m = (Member) cs;
if (m.hasUrl()) {
return true;
}
}
for (Member m : getMethodsToDisplay()) {
for (CharSequence cs : getMethodsToDisplay()) {
final Member m = (Member) cs;
if (m.hasUrl()) {
return true;
}
@ -176,15 +185,17 @@ public class BodierImpl implements Bodier {
return false;
}
private List<String> rawBodyWithoutHidden() {
if (hides == null || hides.size() == 0) {
return rawBody;
}
final List<String> result = new ArrayList<String>();
for (String s : rawBody) {
final Member m = new Member(s, isMethod(s), manageModifier);
private List<CharSequence> rawBodyWithoutHidden() {
final List<CharSequence> result = new ArrayList<CharSequence>();
for (CharSequence s : rawBody) {
final Member m;
if (isMethod(s)) {
m = Member.method(s);
} else {
m = Member.field(s);
}
if (hides.contains(m.getVisibilityModifier()) == false) {
result.add(s);
result.add(m);
}
}
@ -193,28 +204,31 @@ public class BodierImpl implements Bodier {
public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields,
Stereotype stereotype, Style style) {
if (BodyFactory.BODY3) {
return new Body3(rawBody, fontParam, skinParam, stereotype, style);
}
if (type.isLikeClass() && isBodyEnhanced()) {
if (showMethods || showFields) {
return new BodyEnhanced(rawBodyWithoutHidden(), fontParam, skinParam, manageModifier, stereotype, leaf,
style);
return BodyFactory.create1(rawBodyWithoutHidden(), fontParam, skinParam, stereotype, leaf, style);
}
return null;
}
if (leaf == null) {
throw new IllegalStateException();
}
final MethodsOrFieldsArea fields = new MethodsOrFieldsArea(getFieldsToDisplay(), fontParam, skinParam,
stereotype, leaf, style);
if (type == LeafType.OBJECT) {
if (showFields == false) {
return new TextBlockLineBefore(TextBlockUtils.empty(0, 0));
}
return new BodyEnhanced(rawBodyWithoutHidden(), fontParam, skinParam, manageModifier, stereotype, leaf,
style);
}
if (type.isLikeClass() == false) {
throw new UnsupportedOperationException();
return BodyFactory.create1(rawBodyWithoutHidden(), fontParam, skinParam, stereotype, leaf, style);
}
assert type.isLikeClass();
final MethodsOrFieldsArea fields = new MethodsOrFieldsArea(getFieldsToDisplay(), fontParam, skinParam,
stereotype, leaf, style);
final MethodsOrFieldsArea methods = new MethodsOrFieldsArea(getMethodsToDisplay(), fontParam, skinParam,
stereotype, leaf, style);
if (showFields && showMethods == false) {
@ -230,7 +244,7 @@ public class BodierImpl implements Bodier {
return TextBlockUtils.mergeTB(bb1, bb2, HorizontalAlignment.LEFT);
}
public List<String> getRawBody() {
public List<CharSequence> getRawBody() {
return Collections.unmodifiableList(rawBody);
}

View File

@ -50,7 +50,7 @@ import net.sourceforge.plantuml.style.Style;
public class BodierMap implements Bodier {
private final List<String> rawBody = new ArrayList<String>();
private final List<CharSequence> rawBody = new ArrayList<CharSequence>();
private final Map<String, String> map = new LinkedHashMap<String, String>();
private ILeaf leaf;
@ -89,11 +89,11 @@ public class BodierMap implements Bodier {
}
}
public List<Member> getMethodsToDisplay() {
public Display getMethodsToDisplay() {
throw new UnsupportedOperationException();
}
public List<Member> getFieldsToDisplay() {
public Display getFieldsToDisplay() {
throw new UnsupportedOperationException();
}
@ -106,7 +106,7 @@ public class BodierMap implements Bodier {
return new TextBlockMap(fontParam, skinParam, map);
}
public List<String> getRawBody() {
public List<CharSequence> getRawBody() {
return Collections.unmodifiableList(rawBody);
}

View File

@ -0,0 +1,91 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.cucadiagram;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.style.Style;
public class BodierSimple implements Bodier {
private final List<CharSequence> rawBody = new ArrayList<CharSequence>();
private ILeaf leaf;
public void muteClassToObject() {
throw new UnsupportedOperationException();
}
BodierSimple() {
}
public void setLeaf(ILeaf leaf) {
if (leaf == null) {
throw new IllegalArgumentException();
}
this.leaf = leaf;
}
public void addFieldOrMethod(String s) {
rawBody.add(s);
}
public Display getMethodsToDisplay() {
throw new UnsupportedOperationException();
}
public Display getFieldsToDisplay() {
throw new UnsupportedOperationException();
}
public boolean hasUrl() {
throw new UnsupportedOperationException();
}
public List<CharSequence> getRawBody() {
return Collections.unmodifiableList(rawBody);
}
public TextBlock getBody(FontParam fontParam, ISkinParam skinParam, boolean showMethods, boolean showFields,
Stereotype stereotype, Style style) {
return BodyFactory.create1(rawBody, fontParam, skinParam, stereotype, leaf, style);
}
}

View File

@ -0,0 +1,101 @@
/* ========================================================================
* 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.cucadiagram;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.svek.Ports;
import net.sourceforge.plantuml.svek.WithPorts;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class Body3 extends AbstractTextBlock implements TextBlock, WithPorts {
private final List<CharSequence> rawBody = new ArrayList<CharSequence>();
private final FontParam fontParam;
private final ISkinParam skinParam;
private final Stereotype stereotype;
private final Style style;
public Body3(List<CharSequence> rawBody_, FontParam fontParam, ISkinParam skinParam, Stereotype stereotype,
Style style) {
for (CharSequence s : rawBody_) {
this.rawBody.add(VisibilityModifier.replaceVisibilityModifierByUnicodeChar(s.toString(), true));
}
this.fontParam = fontParam;
this.skinParam = skinParam;
this.stereotype = stereotype;
this.style = style;
}
public void drawU(UGraphic ug) {
getTextBlock().drawU(ug);
}
private TextBlock getTextBlock() {
Display display = Display.create(rawBody);
FontConfiguration config;
if (style != null) {
config = new FontConfiguration(skinParam, style);
} else {
config = new FontConfiguration(skinParam, fontParam, stereotype);
}
TextBlock foo = display.create(config, HorizontalAlignment.LEFT, skinParam);
return foo;
}
public Ports getPorts(StringBounder stringBounder) {
return new Ports();
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return getTextBlock().calculateDimension(stringBounder);
}
}

View File

@ -1,289 +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.cucadiagram;
import java.awt.geom.Dimension2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
import net.sourceforge.plantuml.EmbeddedDiagram;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockLineBefore;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.TextBlockVertical2;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.svek.Ports;
import net.sourceforge.plantuml.svek.WithPorts;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPorts {
private TextBlock area;
private final FontConfiguration titleConfig;
private final List<CharSequence> rawBody;
private final FontParam fontParam;
private final ISkinParam skinParam;
private final boolean lineFirst;
private final HorizontalAlignment align;
private final boolean manageHorizontalLine;
private final boolean manageModifier;
private final List<Url> urls = new ArrayList<Url>();
private final Stereotype stereotype;
private final ILeaf entity;
private final boolean inEllipse;
private final double minClassWidth;
private final Style style;
public BodyEnhanced(List<String> rawBody, FontParam fontParam, ISkinParam skinParam, boolean manageModifier,
Stereotype stereotype, ILeaf entity, Style style) {
this.style = style;
this.rawBody = new ArrayList<CharSequence>(rawBody);
this.stereotype = stereotype;
this.fontParam = fontParam;
this.skinParam = skinParam;
this.titleConfig = new FontConfiguration(skinParam, fontParam, stereotype);
this.lineFirst = true;
this.align = skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT);
this.manageHorizontalLine = true;
this.manageModifier = manageModifier;
this.entity = entity;
this.inEllipse = false;
this.minClassWidth = 0;
}
public BodyEnhanced(Display display, FontParam fontParam, ISkinParam skinParam, HorizontalAlignment align,
Stereotype stereotype, boolean manageHorizontalLine, boolean manageModifier, ILeaf entity, Style style) {
this(display, fontParam, skinParam, align, stereotype, manageHorizontalLine, manageHorizontalLine, entity, 0,
style);
}
private BodyEnhanced(Display display, FontParam fontParam, ISkinParam skinParam, HorizontalAlignment align,
Stereotype stereotype, boolean manageHorizontalLine, boolean manageModifier, ILeaf entity,
double minClassWidth, Style style) {
this.style = style;
this.minClassWidth = minClassWidth;
this.entity = entity;
this.stereotype = stereotype;
this.rawBody = new ArrayList<CharSequence>();
this.fontParam = fontParam;
this.skinParam = skinParam;
if (style == null) {
this.titleConfig = new FontConfiguration(skinParam, fontParam, stereotype);
} else {
this.titleConfig = style.getFontConfiguration(skinParam.getIHtmlColorSet());
}
this.lineFirst = false;
this.align = skinParam.getDefaultTextAlignment(align);
this.manageHorizontalLine = manageHorizontalLine;
this.manageModifier = manageModifier;
this.inEllipse = fontParam == FontParam.USECASE;
if (manageHorizontalLine && inEllipse && display.size() > 0 && isBlockSeparator(display.get(0).toString())) {
this.rawBody.add("");
}
for (CharSequence s : display) {
this.rawBody.add(s);
}
}
private TextBlock decorate(StringBounder stringBounder, TextBlock b, char separator, TextBlock title) {
if (separator == 0) {
return b;
}
if (title == null) {
return new TextBlockLineBefore(TextBlockUtils.withMargin(b, 6, 4), separator);
}
final Dimension2D dimTitle = title.calculateDimension(stringBounder);
final TextBlock raw = new TextBlockLineBefore(TextBlockUtils.withMargin(b, 6, 6, dimTitle.getHeight() / 2, 4),
separator, title);
return TextBlockUtils.withMargin(raw, 0, 0, dimTitle.getHeight() / 2, 0);
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return getArea(stringBounder).calculateDimension(stringBounder);
}
private TextBlock getArea(StringBounder stringBounder) {
if (area != null) {
return area;
}
urls.clear();
final List<TextBlock> blocks = new ArrayList<TextBlock>();
char separator = lineFirst ? '_' : 0;
TextBlock title = null;
List<Member> members = new ArrayList<Member>();
for (ListIterator<CharSequence> it = rawBody.listIterator(); it.hasNext();) {
final CharSequence s2 = it.next();
if (s2 instanceof EmbeddedDiagram) {
if (members.size() > 0 || separator != 0) {
blocks.add(decorate(stringBounder,
new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype, entity, style),
separator, title));
separator = 0;
title = null;
members = new ArrayList<Member>();
}
blocks.add(((EmbeddedDiagram) s2).asDraw(skinParam));
} else {
final String s = s2.toString();
if (manageHorizontalLine && isBlockSeparator(s)) {
blocks.add(decorate(stringBounder,
new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype, entity, style),
separator, title));
separator = s.charAt(0);
title = getTitle(s, skinParam);
members = new ArrayList<Member>();
} else if (Parser.isTreeStart(s)) {
if (members.size() > 0) {
blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align,
stereotype, entity, style), separator, title));
}
separator = 0;
title = null;
members = new ArrayList<Member>();
final List<CharSequence> allTree = buildAllTree(s, it);
final TextBlock bloc = Display.create(allTree).create7(fontParam.getFontConfiguration(skinParam),
align, skinParam, CreoleMode.FULL);
blocks.add(bloc);
} else {
final Member m = new Member(s, Member.isMethod(s), manageModifier);
members.add(m);
if (m.getUrl() != null) {
urls.add(m.getUrl());
}
}
}
}
if (inEllipse && members.size() == 0) {
members.add(new Member("", false, false));
}
blocks.add(decorate(stringBounder,
new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype, entity, style), separator,
title));
if (blocks.size() == 1) {
this.area = blocks.get(0);
} else {
this.area = new TextBlockVertical2(blocks, align);
}
if (minClassWidth > 0) {
this.area = TextBlockUtils.withMinWidth(this.area, minClassWidth,
skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT));
}
return area;
}
private static List<CharSequence> buildAllTree(String init, ListIterator<CharSequence> it) {
final List<CharSequence> result = new ArrayList<CharSequence>();
result.add(init);
while (it.hasNext()) {
final CharSequence s = it.next();
if (Parser.isTreeStart(StringUtils.trinNoTrace(s))) {
result.add(s);
} else {
it.previous();
return result;
}
}
return result;
}
public static boolean isBlockSeparator(String s) {
if (s.startsWith("--") && s.endsWith("--")) {
return true;
}
if (s.startsWith("==") && s.endsWith("==")) {
return true;
}
if (s.startsWith("..") && s.endsWith("..") && s.equals("...") == false) {
return true;
}
if (s.startsWith("__") && s.endsWith("__")) {
return true;
}
return false;
}
private TextBlock getTitle(String s, ISkinSimple spriteContainer) {
if (s.length() <= 4) {
return null;
}
s = StringUtils.trin(s.substring(2, s.length() - 2));
return Display.getWithNewlines(s).create(titleConfig, HorizontalAlignment.LEFT, spriteContainer);
}
public Ports getPorts(StringBounder stringBounder) {
final TextBlock area = getArea(stringBounder);
if (area instanceof WithPorts) {
return ((WithPorts) area).getPorts(stringBounder);
}
return new Ports();
}
public void drawU(UGraphic ug) {
getArea(ug.getStringBounder()).drawU(ug);
}
public List<Url> getUrls() {
return Collections.unmodifiableList(urls);
}
public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) {
return getArea(stringBounder).getInnerPosition(member, stringBounder, strategy);
}
}

View File

@ -0,0 +1,232 @@
/* ========================================================================
* 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.cucadiagram;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
import net.sourceforge.plantuml.EmbeddedDiagram;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.legacy.CreoleParser;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.TextBlockVertical2;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.svek.Ports;
import net.sourceforge.plantuml.svek.WithPorts;
public class BodyEnhanced1 extends BodyEnhancedAbstract implements TextBlock, WithPorts {
private final Display rawBody2;
private final FontParam fontParam;
private final ISkinParam skinParam;
private final boolean lineFirst;
private final List<Url> urls = new ArrayList<Url>();
private final Stereotype stereotype;
private final ILeaf entity;
private final boolean inEllipse;
private final Style style;
BodyEnhanced1(List<CharSequence> rawBody, FontParam fontParam, ISkinParam skinParam, Stereotype stereotype,
ILeaf entity, Style style) {
super(skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
new FontConfiguration(skinParam, fontParam, stereotype));
this.style = style;
this.rawBody2 = Display.create(rawBody);
this.stereotype = stereotype;
this.fontParam = fontParam;
this.skinParam = skinParam;
this.lineFirst = true;
this.entity = entity;
this.inEllipse = false;
}
BodyEnhanced1(Display display, FontParam fontParam, ISkinParam skinParam, HorizontalAlignment align,
Stereotype stereotype, ILeaf entity, Style style) {
super(skinParam.getDefaultTextAlignment(align),
style == null ? new FontConfiguration(skinParam, fontParam, stereotype)
: style.getFontConfiguration(skinParam.getIHtmlColorSet()));
this.style = style;
this.entity = entity;
this.stereotype = stereotype;
this.fontParam = fontParam;
this.skinParam = skinParam;
this.lineFirst = false;
this.inEllipse = fontParam == FontParam.USECASE;
if (inEllipse && display.size() > 0 && isBlockSeparator(display.get(0).toString())) {
display = display.add("");
}
this.rawBody2 = display;
}
@Override
protected double getMarginX() {
return 6;
}
private static boolean isTreeOrTable(String s) {
return Parser.isTreeStart(s) || CreoleParser.isTableLine(s);
}
@Override
protected TextBlock getArea(StringBounder stringBounder) {
if (area != null) {
return area;
}
urls.clear();
final List<TextBlock> blocks = new ArrayList<TextBlock>();
char separator = lineFirst ? '_' : 0;
TextBlock title = null;
Display display = Display.empty();
for (ListIterator<CharSequence> it = rawBody2.iterator(); it.hasNext();) {
final CharSequence cs = it.next();
if (cs instanceof EmbeddedDiagram) {
if (display.size() > 0 || separator != 0) {
blocks.add(decorate(stringBounder,
new MethodsOrFieldsArea(display, fontParam, skinParam, align, stereotype, entity, style),
separator, title));
separator = 0;
title = null;
display = Display.empty();
}
blocks.add(((EmbeddedDiagram) cs).asDraw(skinParam));
} else {
final String s = cs.toString();
if (isBlockSeparator(s)) {
blocks.add(decorate(stringBounder,
new MethodsOrFieldsArea(display, fontParam, skinParam, align, stereotype, entity, style),
separator, title));
separator = s.charAt(0);
title = getTitle(s, skinParam);
display = Display.empty();
} else if (isTreeOrTable(s)) {
final boolean isTable = CreoleParser.isTableLine(s);
if (display.size() > 0) {
blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(display, fontParam, skinParam, align,
stereotype, entity, style), separator, title));
}
separator = 0;
title = null;
display = Display.empty();
final List<CharSequence> allTree = buildTreeOrTable(s, it);
TextBlock bloc = Display.create(allTree).create7(fontParam.getFontConfiguration(skinParam), align,
skinParam, CreoleMode.FULL);
if (isTable) {
bloc = TextBlockUtils.withMargin(bloc, 10, 10, 0, 5);
}
blocks.add(bloc);
} else {
display = display.add(cs);
if (cs instanceof Member && ((Member) cs).getUrl() != null) {
urls.add(((Member) cs).getUrl());
}
}
}
}
if (inEllipse && display.size() == 0) {
display = display.add("");
}
blocks.add(decorate(stringBounder,
new MethodsOrFieldsArea(display, fontParam, skinParam, align, stereotype, entity, style), separator,
title));
if (blocks.size() == 1) {
this.area = blocks.get(0);
} else {
this.area = new TextBlockVertical2(blocks, align);
}
if (skinParam.minClassWidth() > 0) {
this.area = TextBlockUtils.withMinWidth(this.area, skinParam.minClassWidth(), align);
}
return area;
}
private static List<CharSequence> buildTreeOrTable(String init, ListIterator<CharSequence> it) {
final List<CharSequence> result = new ArrayList<CharSequence>();
result.add(init);
while (it.hasNext()) {
final CharSequence s = it.next();
if (isTreeOrTable(StringUtils.trinNoTrace(s))) {
result.add(s);
} else {
it.previous();
return result;
}
}
return result;
}
public Ports getPorts(StringBounder stringBounder) {
final TextBlock area = getArea(stringBounder);
if (area instanceof WithPorts) {
return ((WithPorts) area).getPorts(stringBounder);
}
return new Ports();
}
public List<Url> getUrls() {
return Collections.unmodifiableList(urls);
}
public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) {
return getArea(stringBounder).getInnerPosition(member, stringBounder, strategy);
}
}

View File

@ -35,7 +35,6 @@
*/
package net.sourceforge.plantuml.cucadiagram;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.List;
@ -43,59 +42,37 @@ import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.Guillemet;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockLineBefore;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.TextBlockVertical2;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class BodyEnhanced2 extends AbstractTextBlock implements TextBlock {
public class BodyEnhanced2 extends BodyEnhancedAbstract {
private TextBlock area;
private final FontConfiguration titleConfig;
private final Display rawBody;
private final ISkinSimple spriteContainer;
private final ISkinSimple skinParam;
private final HorizontalAlignment align;
private final LineBreakStrategy lineBreakStrategy;
private final double minClassWidth;
// private final List<Url> urls = new ArrayList<Url>();
BodyEnhanced2(Display rawBody, FontParam fontParam, ISkinSimple skinParam, HorizontalAlignment align,
FontConfiguration titleConfig, LineBreakStrategy lineBreakStrategy) {
super(align, titleConfig);
public BodyEnhanced2(Display rawBody, FontParam fontParam, ISkinSimple spriteContainer, HorizontalAlignment align,
FontConfiguration titleConfig, LineBreakStrategy lineBreakStrategy, double minClassWidth) {
this.rawBody = rawBody;
this.lineBreakStrategy = lineBreakStrategy;
this.spriteContainer = spriteContainer;
this.minClassWidth = minClassWidth;
this.skinParam = skinParam;
this.titleConfig = titleConfig;
this.align = align;
}
private TextBlock decorate(StringBounder stringBounder, TextBlock b, char separator, TextBlock title) {
if (separator == 0) {
return b;
}
if (title == null) {
return new TextBlockLineBefore(TextBlockUtils.withMargin(b, 0, 4), separator);
}
final Dimension2D dimTitle = title.calculateDimension(stringBounder);
final TextBlock raw = new TextBlockLineBefore(TextBlockUtils.withMargin(b, 0, 6, dimTitle.getHeight() / 2, 4),
separator, title);
return TextBlockUtils.withMargin(raw, 0, 0, dimTitle.getHeight() / 2, 0);
@Override
protected double getMarginX() {
return 0;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return getArea(stringBounder).calculateDimension(stringBounder);
}
private TextBlock getArea(StringBounder stringBounder) {
@Override
protected TextBlock getArea(StringBounder stringBounder) {
if (area != null) {
return area;
}
@ -107,9 +84,9 @@ public class BodyEnhanced2 extends AbstractTextBlock implements TextBlock {
Display display = Display.empty();
for (CharSequence s : rawBody) {
if (isBlockSeparator(s.toString())) {
blocks.add(decorate(stringBounder, getTextBlock(display, stringBounder), separator, title));
blocks.add(decorate(stringBounder, getTextBlock(display), separator, title));
separator = s.charAt(0);
title = getTitle(s.toString(), spriteContainer);
title = getTitle(s.toString(), skinParam);
display = Display.empty();
} else {
if (s instanceof String) {
@ -118,7 +95,7 @@ public class BodyEnhanced2 extends AbstractTextBlock implements TextBlock {
display = display.add(s);
}
}
blocks.add(decorate(stringBounder, getTextBlock(display, stringBounder), separator, title));
blocks.add(decorate(stringBounder, getTextBlock(display), separator, title));
if (blocks.size() == 1) {
this.area = blocks.get(0);
@ -126,44 +103,16 @@ public class BodyEnhanced2 extends AbstractTextBlock implements TextBlock {
this.area = new TextBlockVertical2(blocks, align);
}
if (minClassWidth > 0) {
this.area = TextBlockUtils.withMinWidth(this.area, minClassWidth, align);
if (skinParam.minClassWidth() > 0) {
this.area = TextBlockUtils.withMinWidth(this.area, skinParam.minClassWidth(), align);
}
return area;
}
private TextBlock getTextBlock(Display display, StringBounder stringBounder) {
final TextBlock result = display.create9(titleConfig, align, spriteContainer, lineBreakStrategy);
private TextBlock getTextBlock(Display display) {
final TextBlock result = display.create9(titleConfig, align, skinParam, lineBreakStrategy);
return result;
}
public static boolean isBlockSeparator(String s) {
if (s.startsWith("--") && s.endsWith("--")) {
return true;
}
if (s.startsWith("==") && s.endsWith("==")) {
return true;
}
if (s.startsWith("..") && s.endsWith("..")) {
return true;
}
if (s.startsWith("__") && s.endsWith("__")) {
return true;
}
return false;
}
private TextBlock getTitle(String s, ISkinSimple spriteContainer) {
if (s.length() <= 4) {
return null;
}
s = StringUtils.trin(s.substring(2, s.length() - 2));
return Display.getWithNewlines(s).create(titleConfig, HorizontalAlignment.LEFT, spriteContainer);
}
public void drawU(UGraphic ug) {
getArea(ug.getStringBounder()).drawU(ug);
}
}

View File

@ -0,0 +1,113 @@
/* ========================================================================
* 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.cucadiagram;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockLineBefore;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public abstract class BodyEnhancedAbstract extends AbstractTextBlock implements TextBlock {
protected final HorizontalAlignment align;
protected final FontConfiguration titleConfig;
protected TextBlock area;
BodyEnhancedAbstract(HorizontalAlignment align, FontConfiguration titleConfig) {
this.align = align;
this.titleConfig = titleConfig;
}
public static boolean isBlockSeparator(CharSequence cs) {
final String s = cs.toString();
if (s.startsWith("--") && s.endsWith("--")) {
return true;
}
if (s.startsWith("==") && s.endsWith("==")) {
return true;
}
if (s.startsWith("..") && s.endsWith("..") && s.equals("...") == false) {
return true;
}
if (s.startsWith("__") && s.endsWith("__")) {
return true;
}
return false;
}
public final Dimension2D calculateDimension(StringBounder stringBounder) {
return getArea(stringBounder).calculateDimension(stringBounder);
}
final public void drawU(UGraphic ug) {
getArea(ug.getStringBounder()).drawU(ug);
}
final protected TextBlock getTitle(String s, ISkinSimple spriteContainer) {
if (s.length() <= 4) {
return null;
}
s = StringUtils.trin(s.substring(2, s.length() - 2));
return Display.getWithNewlines(s).create(titleConfig, HorizontalAlignment.LEFT, spriteContainer);
}
abstract protected TextBlock getArea(StringBounder stringBounder);
abstract protected double getMarginX();
final protected TextBlock decorate(StringBounder stringBounder, TextBlock b, char separator, TextBlock title) {
final double marginX = getMarginX();
if (separator == 0) {
return TextBlockUtils.withMargin(b, marginX, 0);
}
if (title == null) {
return new TextBlockLineBefore(TextBlockUtils.withMargin(b, marginX, 4), separator);
}
final Dimension2D dimTitle = title.calculateDimension(stringBounder);
final TextBlock raw = new TextBlockLineBefore(
TextBlockUtils.withMargin(b, marginX, 6, dimTitle.getHeight() / 2, 4), separator, title);
return TextBlockUtils.withMargin(raw, 0, 0, dimTitle.getHeight() / 2, 0);
}
}

View File

@ -0,0 +1,81 @@
/* ========================================================================
* 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.cucadiagram;
import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.style.Style;
public class BodyFactory {
public final static boolean BODY3 = false;
public static Bodier createLeaf(LeafType type, Set<VisibilityModifier> hides) {
if (type.isLikeClass() || type == LeafType.OBJECT) {
return new BodierLikeClassOrObject(type, hides);
}
return new BodierSimple();
}
public static Bodier createGroup(Set<VisibilityModifier> hides) {
return new BodierSimple();
}
public static TextBlock create1(List<CharSequence> rawBody, FontParam fontParam, ISkinParam skinParam,
Stereotype stereotype, ILeaf entity, Style style) {
return new BodyEnhanced1(rawBody, fontParam, skinParam, stereotype, entity, style);
}
public static TextBlock create2(Display display, FontParam fontParam, ISkinParam skinParam,
HorizontalAlignment align, Stereotype stereotype, ILeaf entity, Style style) {
return new BodyEnhanced1(display, fontParam, skinParam, align, stereotype, entity, style);
}
public static TextBlock create3(Display rawBody, FontParam fontParam, ISkinSimple skinParam,
HorizontalAlignment align, FontConfiguration titleConfig, LineBreakStrategy lineBreakStrategy) {
return new BodyEnhanced2(rawBody, fontParam, skinParam, align, titleConfig, lineBreakStrategy);
}
}

View File

@ -225,7 +225,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
private Ident buildLeafIdentSpecialUnused(String id) {
// if (namespaceSeparator != null) {
// if (id.contains(namespaceSeparator)) {
return Ident.empty().add(id, ".");
return Ident.empty().add(id, ".");
// }
// }
// return getLastID().add(id, namespaceSeparator);
@ -597,8 +597,9 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
result.add(s);
}
}
final String aspect = getPragma().getValue("aspect");
String aspect = getPragma().getValue("aspect");
if (aspect != null) {
aspect = aspect.replace(',', '.');
result.add("aspect=" + aspect + ";");
}
final String ratio = getPragma().getValue("ratio");

View File

@ -41,6 +41,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -242,7 +243,7 @@ public class Display implements Iterable<CharSequence> {
final List<CharSequence> other = new ArrayList<CharSequence>();
other.add("@start" + type);
while (it.hasNext()) {
CharSequence s2 = it.next();
final CharSequence s2 = it.next();
if (s2 != null && StringUtils.trin(s2.toString()).equals("}}")) {
break;
}
@ -398,8 +399,8 @@ public class Display implements Iterable<CharSequence> {
return displayData.get(i);
}
public Iterator<CharSequence> iterator() {
return Collections.unmodifiableList(displayData).iterator();
public ListIterator<CharSequence> iterator() {
return Collections.unmodifiableList(displayData).listIterator();
}
public Display subList(int i, int size) {

View File

@ -45,15 +45,15 @@ import java.util.Map;
class Election {
private final Map<String, Member> all = new HashMap<String, Member>();
private final Map<String, CharSequence> all = new HashMap<String, CharSequence>();
public void addCandidate(String display, Member candidate) {
public void addCandidate(String display, CharSequence candidate) {
all.put(display, candidate);
}
private Member getCandidate(String shortName) {
List<Member> list = getAllCandidateContains(shortName);
private CharSequence getCandidate(String shortName) {
List<CharSequence> list = getAllCandidateContains(shortName);
if (list.size() == 1) {
return list.get(0);
}
@ -64,9 +64,9 @@ class Election {
return null;
}
private List<Member> getAllCandidateContains(String shortName) {
final List<Member> result = new ArrayList<Member>();
for (Map.Entry<String, Member> ent : all.entrySet()) {
private List<CharSequence> getAllCandidateContains(String shortName) {
final List<CharSequence> result = new ArrayList<CharSequence>();
for (Map.Entry<String, CharSequence> ent : all.entrySet()) {
if (ent.getKey().contains(shortName)) {
result.add(ent.getValue());
}
@ -74,9 +74,9 @@ class Election {
return result;
}
private List<Member> getAllCandidateContainsStrict(String shortName) {
final List<Member> result = new ArrayList<Member>();
for (Map.Entry<String, Member> ent : all.entrySet()) {
private List<CharSequence> getAllCandidateContainsStrict(String shortName) {
final List<CharSequence> result = new ArrayList<CharSequence>();
for (Map.Entry<String, CharSequence> ent : all.entrySet()) {
final String key = ent.getKey();
if (key.matches(".*\\b" + shortName + "\\b.*")) {
result.add(ent.getValue());
@ -85,10 +85,10 @@ class Election {
return result;
}
public Map<Member, String> getAllElected(Collection<String> shortNames) {
final Map<Member, String> memberWithPort = new HashMap<Member, String>();
public Map<CharSequence, String> getAllElected(Collection<String> shortNames) {
final Map<CharSequence, String> memberWithPort = new HashMap<CharSequence, String>();
for (String shortName : new HashSet<String>(shortNames)) {
final Member m = getCandidate(shortName);
final CharSequence m = getCandidate(shortName);
if (m != null) {
memberWithPort.put(m, shortName);
shortNames.remove(shortName);

View File

@ -42,8 +42,9 @@ public enum LeafType {
EMPTY_PACKAGE,
ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION, LOLLIPOP_FULL, LOLLIPOP_HALF, NOTE, TIPS, OBJECT, MAP, ASSOCIATION, ENUM, CIRCLE,
ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION, LOLLIPOP_FULL, LOLLIPOP_HALF, NOTE, TIPS, OBJECT, MAP, ASSOCIATION,
ENUM, CIRCLE,
USECASE, USECASE_BUSINESS,
DESCRIPTION,
@ -55,9 +56,9 @@ public enum LeafType {
STATE, STATE_CONCURRENT, PSEUDO_STATE, DEEP_HISTORY, STATE_CHOICE, STATE_FORK_JOIN,
BLOCK, ENTITY,
DOMAIN, REQUIREMENT,
PORT, PORTIN, PORTOUT,
STILL_UNKNOWN;
@ -83,11 +84,11 @@ public enum LeafType {
return StringUtils.capitalize(html);
}
public boolean manageModifier() {
if (this == ANNOTATION || this == ABSTRACT_CLASS || this == CLASS || this == INTERFACE || this == ENUM
|| this == OBJECT || this == ENTITY) {
return true;
}
return false;
}
// public boolean manageModifier() {
// if (this == ANNOTATION || this == ABSTRACT_CLASS || this == CLASS || this == INTERFACE || this == ENUM
// || this == OBJECT || this == ENTITY) {
// return true;
// }
// return false;
// }
}

View File

@ -45,9 +45,10 @@ import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.skin.VisibilityModifier;
public class Member {
public class Member implements CharSequence {
private final String display;
private final CharSequence raw;
private final boolean staticModifier;
private final boolean abstractModifier;
private final Url url;
@ -57,11 +58,40 @@ public class Member {
@Override
public String toString() {
return super.toString() + " " + display;
return raw.toString();
}
public Member(String tmpDisplay, boolean isMethod, boolean manageModifier) {
tmpDisplay = tmpDisplay.replaceAll("(?i)\\{(method|field)\\}\\s*", "");
public char charAt(int index) {
return raw.charAt(index);
}
public int length() {
return raw.length();
}
public CharSequence subSequence(int start, int end) {
return raw.subSequence(start, end);
}
public static Member method(CharSequence tmpDisplay) {
return new Member(true, tmpDisplay, true);
}
public static Member field(CharSequence tmpDisplay) {
return new Member(true, tmpDisplay, false);
}
public static Member method(CharSequence tmpDisplay, boolean manageModifier) {
return new Member(manageModifier, tmpDisplay, true);
}
public static Member field(CharSequence tmpDisplay, boolean manageModifier) {
return new Member(manageModifier, tmpDisplay, false);
}
private Member(boolean manageModifier, CharSequence tmpDisplay, boolean isMethod) {
this.raw = tmpDisplay;
tmpDisplay = tmpDisplay.toString().replaceAll("(?i)\\{(method|field)\\}\\s*", "");
if (manageModifier) {
final Pattern2 finalUrl = MyPattern.cmpile("^(.*?)(?:\\[(" + UrlBuilder.getRegexp() + ")\\])?$");
final Matcher2 matcher = finalUrl.matcher(tmpDisplay);
@ -79,12 +109,13 @@ public class Member {
this.url = null;
}
this.hasUrl = this.url != null;
final String lower = StringUtils.goLowerCase(tmpDisplay);
final String lower = StringUtils.goLowerCase(tmpDisplay.toString());
if (manageModifier) {
this.staticModifier = lower.contains("{static}") || lower.contains("{classifier}");
this.abstractModifier = lower.contains("{abstract}");
String displayClean = tmpDisplay.replaceAll("(?i)\\{(static|classifier|abstract)\\}\\s*", "").trim();
String displayClean = tmpDisplay.toString().replaceAll("(?i)\\{(static|classifier|abstract)\\}\\s*", "")
.trim();
if (displayClean.length() == 0) {
displayClean = " ";
}
@ -100,9 +131,9 @@ public class Member {
this.staticModifier = false;
this.visibilityModifier = null;
this.abstractModifier = false;
tmpDisplay = StringUtils.trin(tmpDisplay);
tmpDisplay = StringUtils.trin(tmpDisplay.toString());
this.display = tmpDisplay.length() == 0 ? " "
: Guillemet.GUILLEMET.manageGuillemet(StringUtils.trin(tmpDisplay));
: Guillemet.GUILLEMET.manageGuillemet(StringUtils.trin(tmpDisplay.toString()));
}
}
@ -114,8 +145,6 @@ public class Member {
}
private String getDisplayWithoutVisibilityChar() {
// assert display.length() == 0 ||
// VisibilityModifier.isVisibilityCharacter(display.charAt(0)) == false;
return display;
}
@ -193,14 +222,6 @@ public class Member {
return hasUrl;
}
public static boolean isMethod(String s) {
final String purged = s.replaceAll(UrlBuilder.getRegexp(), "");
if (purged.contains("{method}")) {
return true;
}
if (purged.contains("{field}")) {
return false;
}
return purged.contains("(") || purged.contains(")");
}
}

View File

@ -37,14 +37,11 @@ package net.sourceforge.plantuml.cucadiagram;
import java.awt.geom.Dimension2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
@ -55,11 +52,9 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockLineBefore;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.TextBlockWidth;
import net.sourceforge.plantuml.graphic.TextBlockWithUrl;
import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.svek.Ports;
import net.sourceforge.plantuml.svek.WithPorts;
@ -72,7 +67,7 @@ import net.sourceforge.plantuml.ugraphic.ULayoutGroup;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.utils.CharHidder;
public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockWidth, TextBlock, WithPorts {
public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlock, WithPorts {
public TextBlock asBlockMemberImpl() {
return new TextBlockLineBefore(TextBlockUtils.withMargin(this, 6, 4));
@ -81,33 +76,36 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW
private final FontParam fontParam;
private final ISkinParam skinParam;
private final Rose rose = new Rose();
private final List<Member> members = new ArrayList<Member>();
private final Display members;
private final HorizontalAlignment align;
private final Stereotype stereotype;
private final ILeaf leaf;
private final Style style;
public MethodsOrFieldsArea(List<Member> members, FontParam fontParam, ISkinParam skinParam, Stereotype stereotype,
public MethodsOrFieldsArea(Display members, FontParam fontParam, ISkinParam skinParam, Stereotype stereotype,
ILeaf leaf, Style style) {
this(members, fontParam, skinParam, HorizontalAlignment.LEFT, stereotype, leaf, style);
}
public MethodsOrFieldsArea(List<Member> members, FontParam fontParam, ISkinParam skinParam,
HorizontalAlignment align, Stereotype stereotype, ILeaf leaf, Style style) {
public MethodsOrFieldsArea(Display members, FontParam fontParam, ISkinParam skinParam, HorizontalAlignment align,
Stereotype stereotype, ILeaf leaf, Style style) {
this.style = style;
this.leaf = leaf;
this.stereotype = stereotype;
this.align = align;
this.skinParam = skinParam;
this.fontParam = fontParam;
this.members.addAll(members);
this.members = members;
}
private boolean hasSmallIcon() {
if (skinParam.classAttributeIconSize() == 0) {
return false;
}
for (Member m : members) {
for (CharSequence cs : members) {
if (cs instanceof Member == false)
continue;
final Member m = (Member) cs;
if (m.getVisibilityModifier() != null) {
return true;
}
@ -122,8 +120,8 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW
}
double x = 0;
double y = 0;
for (Member m : members) {
final TextBlock bloc = createTextBlock(m);
for (CharSequence cs : members) {
final TextBlock bloc = createTextBlock(cs);
final Dimension2D dim = bloc.calculateDimension(stringBounder);
x = Math.max(dim.getWidth(), x);
y += dim.getHeight();
@ -136,14 +134,19 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW
final Ports result = new Ports();
double y = 0;
final Election election = new Election();
for (Member m : members) {
election.addCandidate(m.getDisplay(false), m);
for (CharSequence cs : members) {
if (cs instanceof Member) {
final Member m = (Member) cs;
election.addCandidate(m.getDisplay(false), m);
} else {
election.addCandidate(cs.toString(), cs);
}
}
final Map<Member, String> memberWithPort = election.getAllElected(leaf.getPortShortNames());
for (Member m : members) {
final TextBlock bloc = createTextBlock(m);
final Map<CharSequence, String> memberWithPort = election.getAllElected(leaf.getPortShortNames());
for (CharSequence cs : members) {
final TextBlock bloc = createTextBlock(cs);
final Dimension2D dim = bloc.calculateDimension(stringBounder);
final String port = memberWithPort.get(m);
final String port = memberWithPort.get(cs);
if (port != null) {
result.add(port, y, dim.getHeight());
}
@ -152,29 +155,39 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW
return result;
}
private TextBlock createTextBlock(Member m) {
final boolean withVisibilityChar = skinParam.classAttributeIconSize() == 0;
String s = m.getDisplay(withVisibilityChar);
if (withVisibilityChar && s.startsWith("#")) {
s = CharHidder.addTileAtBegin(s);
}
private TextBlock createTextBlock(CharSequence cs) {
FontConfiguration config;
if (style != null) {
config = new FontConfiguration(skinParam, style);
} else {
config = new FontConfiguration(skinParam, fontParam, stereotype);
}
if (m.isAbstract()) {
config = config.italic();
}
if (m.isStatic()) {
config = config.underline();
if (cs instanceof Member) {
final Member m = (Member) cs;
final boolean withVisibilityChar = skinParam.classAttributeIconSize() == 0;
String s = m.getDisplay(withVisibilityChar);
if (withVisibilityChar && s.startsWith("#")) {
s = CharHidder.addTileAtBegin(s);
}
if (m.isAbstract()) {
config = config.italic();
}
if (m.isStatic()) {
config = config.underline();
}
TextBlock bloc = Display.getWithNewlines(s).create8(config, align, skinParam, CreoleMode.SIMPLE_LINE,
skinParam.wrapWidth());
bloc = TextBlockUtils.fullInnerPosition(bloc, m.getDisplay(false));
return new TextBlockTracer(m, bloc);
}
TextBlock bloc = Display.getWithNewlines(s).create8(config, align, skinParam, CreoleMode.SIMPLE_LINE,
skinParam.wrapWidth());
bloc = TextBlockUtils.fullInnerPosition(bloc, m.getDisplay(false));
return new TextBlockTracer(m, bloc);
TextBlock bloc = Display.getWithNewlines(cs.toString()).create8(config, align, skinParam,
CreoleMode.SIMPLE_LINE, skinParam.wrapWidth());
return bloc;
}
static class TextBlockTracer extends AbstractTextBlock implements TextBlock {
@ -235,12 +248,9 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW
return TextBlockWithUrl.withUrl(uBlock, url);
}
public TextBlock asTextBlock(final double widthToUse) {
return this;
}
public boolean contains(String member) {
for (Member att : members) {
for (CharSequence cs : members) {
final Member att = (Member) cs;
if (att.getDisplay(false).startsWith(member)) {
return true;
}
@ -260,7 +270,8 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW
if (hasSmallIcon()) {
group = new ULayoutGroup(
new PlacementStrategyVisibility(stringBounder, skinParam.getCircledCharacterRadius() + 3));
for (Member att : members) {
for (CharSequence cs : members) {
final Member att = (Member) cs;
final TextBlock bloc = createTextBlock(att);
final VisibilityModifier modifier = att.getVisibilityModifier();
group.add(getUBlock(modifier, att.getUrl()));
@ -276,8 +287,8 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW
placementStrategy = new PlacementStrategyY1Y2Left(stringBounder);
}
group = new ULayoutGroup(placementStrategy);
for (Member att : members) {
final TextBlock bloc = createTextBlock(att);
for (CharSequence cs : members) {
final TextBlock bloc = createTextBlock(cs);
group.add(bloc);
}
}

View File

@ -78,7 +78,7 @@ abstract class AbstractGraphviz implements Graphviz {
this.type = type;
}
private File searchDotExe() {
protected File searchDotExe() {
String getenv = GraphvizUtils.getenvGraphvizDot();
if (getenv == null) {
getenv = findExecutableOnPath(getExeName());

View File

@ -132,23 +132,28 @@ public final class CucaDiagramTxtMaker {
final int w = getWidth(ent);
final int h = getHeight(ent);
ug.getCharArea().drawBoxSimple(0, 0, w, h);
ug.getCharArea().drawStringsLR(ent.getDisplay().as(), 1, 1);
ug.getCharArea().drawStringsLRSimple(ent.getDisplay().as(), 1, 1);
if (showMember(ent)) {
int y = 2;
ug.getCharArea().drawHLine('-', y, 1, w - 1);
y++;
for (Member att : ent.getBodier().getFieldsToDisplay()) {
final List<String> disp = BackSlash.getWithNewlines(att.getDisplay(true));
ug.getCharArea().drawStringsLR(disp, 1, y);
y += StringUtils.getHeight(disp);
}
ug.getCharArea().drawHLine('-', y, 1, w - 1);
y++;
for (Member att : ent.getBodier().getMethodsToDisplay()) {
final List<String> disp = BackSlash.getWithNewlines(att.getDisplay(true));
ug.getCharArea().drawStringsLR(disp, 1, y);
for (CharSequence att : ent.getBodier().getRawBody()) {
final List<String> disp = BackSlash.getWithNewlines(att.toString());
ug.getCharArea().drawStringsLRSimple(disp, 1, y);
y += StringUtils.getHeight(disp);
}
// for (Member att : ent.getBodier().getFieldsToDisplay()) {
// final List<String> disp = BackSlash.getWithNewlines(att.getDisplay(true));
// ug.getCharArea().drawStringsLR(disp, 1, y);
// y += StringUtils.getHeight(disp);
// }
// ug.getCharArea().drawHLine('-', y, 1, w - 1);
// y++;
// for (Member att : ent.getBodier().getMethodsToDisplay()) {
// final List<String> disp = BackSlash.getWithNewlines(att.getDisplay(true));
// ug.getCharArea().drawStringsLR(disp, 1, y);
// y += StringUtils.getHeight(disp);
// }
}
}
@ -164,33 +169,42 @@ public final class CucaDiagramTxtMaker {
private int getHeight(IEntity entity) {
int result = StringUtils.getHeight(entity.getDisplay());
if (showMember(entity)) {
for (Member att : entity.getBodier().getMethodsToDisplay()) {
result += StringUtils.getHeight(Display.getWithNewlines(att.getDisplay(true)));
for (CharSequence att : entity.getBodier().getRawBody()) {
result += StringUtils.getHeight(Display.getWithNewlines(att.toString()));
}
result++;
for (Member att : entity.getBodier().getFieldsToDisplay()) {
result += StringUtils.getHeight(Display.getWithNewlines(att.getDisplay(true)));
}
result++;
// for (Member att : entity.getBodier().getMethodsToDisplay()) {
// result += StringUtils.getHeight(Display.getWithNewlines(att.getDisplay(true)));
// }
// result++;
// for (Member att : entity.getBodier().getFieldsToDisplay()) {
// result += StringUtils.getHeight(Display.getWithNewlines(att.getDisplay(true)));
// }
// result++;
}
return result + 2;
return result + 3;
}
private int getWidth(IEntity entity) {
int result = StringUtils.getWcWidth(entity.getDisplay());
if (showMember(entity)) {
for (Member att : entity.getBodier().getMethodsToDisplay()) {
final int w = StringUtils.getWcWidth(Display.getWithNewlines(att.getDisplay(true)));
if (w > result) {
result = w;
}
}
for (Member att : entity.getBodier().getFieldsToDisplay()) {
final int w = StringUtils.getWcWidth(Display.getWithNewlines(att.getDisplay(true)));
for (CharSequence att : entity.getBodier().getRawBody()) {
final int w = StringUtils.getWcWidth(Display.getWithNewlines(att.toString()));
if (w > result) {
result = w;
}
}
// for (Member att : entity.getBodier().getMethodsToDisplay()) {
// final int w = StringUtils.getWcWidth(Display.getWithNewlines(att.getDisplay(true)));
// if (w > result) {
// result = w;
// }
// }
// for (Member att : entity.getBodier().getFieldsToDisplay()) {
// final int w = StringUtils.getWcWidth(Display.getWithNewlines(att.getDisplay(true)));
// if (w > result) {
// result = w;
// }
// }
}
return result + 2;
}

View File

@ -36,26 +36,23 @@
package net.sourceforge.plantuml.cucadiagram.dot;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.windowsdot.WindowsDotArchive;
class GraphvizWindows extends AbstractGraphviz {
static private File specificDotExe;
@Override
protected File searchDotExe() {
return specificDotExe();
}
@Override
protected File specificDotExe() {
synchronized (GraphvizWindows.class) {
if (specificDotExe == null) {
specificDotExe = specificDotExeSlow();
}
if (specificDotExe == null)
try {
specificDotExe = new WindowsDotArchive().getWindowsExeLite();
@ -68,60 +65,7 @@ class GraphvizWindows extends AbstractGraphviz {
}
public boolean graphviz244onWindows() {
try {
return GraphvizUtils.getDotVersion() == 244;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
private File specificDotExeSlow() {
for (File tmp : new File("c:/").listFiles(new FileFilter() {
public boolean accept(java.io.File pathname) {
return pathname.isDirectory() && pathname.canRead();
}
})) {
final File result = searchInDir(tmp);
if (result != null) {
return result;
}
}
return null;
}
private static File searchInDir(final File dir) {
if (dir.exists() == false || dir.isDirectory() == false) {
return null;
}
final List<File> dots = new ArrayList<File>();
final File[] files = dir.listFiles(new FileFilter() {
public boolean accept(java.io.File pathname) {
return pathname.isDirectory() && StringUtils.goLowerCase(pathname.getName()).startsWith("graphviz");
}
});
if (files == null) {
return null;
}
for (File f : files) {
final File result = new File(new File(f, "bin"), "dot.exe");
if (result.exists() && result.canRead()) {
dots.add(result.getAbsoluteFile());
}
final File result2 = new File(new File(f, "release/bin"), "dot.exe");
if (result2.exists() && result2.canRead()) {
dots.add(result2.getAbsoluteFile());
}
}
return higherVersion(dots);
}
static File higherVersion(List<File> dots) {
if (dots.size() == 0) {
return null;
}
Collections.sort(dots, Collections.reverseOrder());
return dots.get(0);
return false;
}
GraphvizWindows(ISkinParam skinParam, String dotString, String... type) {

View File

@ -0,0 +1,136 @@
/* ========================================================================
* 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.cucadiagram.dot;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.windowsdot.WindowsDotArchive;
class GraphvizWindowsOld extends AbstractGraphviz {
static private File specificDotExe;
@Override
protected File specificDotExe() {
synchronized (GraphvizWindowsOld.class) {
if (specificDotExe == null) {
specificDotExe = specificDotExeSlow();
}
if (specificDotExe == null)
try {
specificDotExe = new WindowsDotArchive().getWindowsExeLite();
} catch (IOException e) {
e.printStackTrace();
}
return specificDotExe;
}
}
public boolean graphviz244onWindows() {
try {
return GraphvizUtils.getDotVersion() == 244;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
private File specificDotExeSlow() {
for (File tmp : new File("c:/").listFiles(new FileFilter() {
public boolean accept(java.io.File pathname) {
return pathname.isDirectory() && pathname.canRead();
}
})) {
final File result = searchInDir(tmp);
if (result != null) {
return result;
}
}
return null;
}
private static File searchInDir(final File dir) {
if (dir.exists() == false || dir.isDirectory() == false) {
return null;
}
final List<File> dots = new ArrayList<File>();
final File[] files = dir.listFiles(new FileFilter() {
public boolean accept(java.io.File pathname) {
return pathname.isDirectory() && StringUtils.goLowerCase(pathname.getName()).startsWith("graphviz");
}
});
if (files == null) {
return null;
}
for (File f : files) {
final File result = new File(new File(f, "bin"), "dot.exe");
if (result.exists() && result.canRead()) {
dots.add(result.getAbsoluteFile());
}
final File result2 = new File(new File(f, "release/bin"), "dot.exe");
if (result2.exists() && result2.canRead()) {
dots.add(result2.getAbsoluteFile());
}
}
return higherVersion(dots);
}
static File higherVersion(List<File> dots) {
if (dots.size() == 0) {
return null;
}
Collections.sort(dots, Collections.reverseOrder());
return dots.get(0);
}
GraphvizWindowsOld(ISkinParam skinParam, String dotString, String... type) {
super(skinParam, dotString, type);
}
@Override
protected String getExeName() {
return "dot.exe";
}
}

View File

@ -51,8 +51,8 @@ import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.UseStyle;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.cucadiagram.Bodier;
import net.sourceforge.plantuml.cucadiagram.BodierImpl;
import net.sourceforge.plantuml.cucadiagram.BodierMap;
import net.sourceforge.plantuml.cucadiagram.BodyFactory;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.cucadiagram.Display;
@ -224,7 +224,7 @@ public final class EntityFactory {
if (entityType == null) {
throw new IllegalArgumentException();
}
final Bodier bodier = entityType == LeafType.MAP ? new BodierMap() : new BodierImpl(entityType, hides);
final Bodier bodier = entityType == LeafType.MAP ? new BodierMap() : BodyFactory.createLeaf(entityType, hides);
final EntityImpl result = new EntityImpl(ident, code, this, bodier, parentContainer, entityType,
namespaceSeparator, rawLayout);
bodier.setLeaf(result);
@ -242,7 +242,7 @@ public final class EntityFactory {
return ent.getValue();
}
}
final Bodier bodier = new BodierImpl(null, hides);
final Bodier bodier = BodyFactory.createGroup(hides);
final EntityImpl result = new EntityImpl(ident, code, this, bodier, parentContainer, groupType, namespace,
namespaceSeparator, rawLayout);
if (Display.isNull(display) == false) {

View File

@ -45,7 +45,7 @@ import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.creole.Stencil;
import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
import net.sourceforge.plantuml.cucadiagram.BodyFactory;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
@ -56,7 +56,6 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.svek.AbstractEntityImage;
import net.sourceforge.plantuml.svek.ShapeType;
import net.sourceforge.plantuml.ugraphic.AbstractUGraphicHorizontalLine;
@ -78,8 +77,8 @@ public class EntityImageRequirement extends AbstractEntityImage {
super(entity, skinParam);
final Stereotype stereotype = entity.getStereotype();
final TextBlock tmp = new BodyEnhanced(entity.getDisplay(), FontParam.REQUIREMENT, skinParam,
HorizontalAlignment.CENTER, stereotype, true, false, entity, null);
final TextBlock tmp = BodyFactory.create2(entity.getDisplay(), FontParam.REQUIREMENT, skinParam,
HorizontalAlignment.CENTER, stereotype, entity, null);
if (stereotype == null || stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR) == null) {
this.desc = tmp;

View File

@ -82,7 +82,7 @@ public class CommandCreateElementMultilines extends CommandMultilines2<AbstractE
return "(?i)^(.*)[%g]$";
}
if (type == 1) {
return "(?i)^(.*)\\]$";
return "(?i)^([^\\[\\]]*)\\]$";
}
throw new IllegalArgumentException();
}

View File

@ -218,7 +218,7 @@ public abstract class PSystemError extends AbstractPSystem {
if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) {
final UGraphicTxt ugt = new UGraphicTxt();
final UmlCharArea area = ugt.getCharArea();
area.drawStringsLR(getPureAsciiFormatted(), 0, 0);
area.drawStringsLRSimple(getPureAsciiFormatted(), 0, 0);
area.print(SecurityUtils.createPrintStream(os));
return new ImageDataSimple(1, 1);

View File

@ -40,7 +40,7 @@ import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class TextBlockEmpty extends AbstractTextBlock implements TextBlockWidth, TextBlock {
public class TextBlockEmpty extends AbstractTextBlock {
private final double width;
private final double height;
@ -61,16 +61,4 @@ public class TextBlockEmpty extends AbstractTextBlock implements TextBlockWidth,
public void drawU(UGraphic ug) {
}
public TextBlock asTextBlock(final double widthToUse) {
return new AbstractTextBlock() {
public void drawU(UGraphic ug) {
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return TextBlockEmpty.this.calculateDimension(stringBounder);
}
};
}
}

View File

@ -107,6 +107,9 @@ public class TextBlockUtils {
}
public static TextBlock withMargin(TextBlock textBlock, double marginX, double marginY) {
if (marginX == 0 && marginY == 0) {
return textBlock;
}
return new TextBlockMarged(textBlock, marginY, marginX, marginY, marginX);
}

View File

@ -1,45 +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.graphic;
import java.awt.geom.Dimension2D;
public interface TextBlockWidth {
Dimension2D calculateDimension(StringBounder stringBounder);
TextBlock asTextBlock(double widthToUse);
}

View File

@ -1,64 +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.graphic;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class TextBlockWidthAdapter implements TextBlockWidth {
private final TextBlock textBlock;
private final double width;
public TextBlockWidthAdapter(TextBlock textBlock, double widthToUse) {
this.textBlock = textBlock;
this.width = widthToUse;
}
public void drawU(UGraphic ug) {
textBlock.drawU(ug);
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return textBlock.calculateDimension(stringBounder);
}
public TextBlock asTextBlock(double widthToUse) {
return textBlock;
}
}

View File

@ -161,10 +161,6 @@ public abstract class USymbol {
}
}
public boolean manageHorizontalLine() {
return false;
}
public int suppHeightBecauseOfShape() {
return 0;
}

View File

@ -88,11 +88,6 @@ class USymbolArtifact extends USymbol {
private Margin getMargin() {
return new Margin(10, 10 + 10, 10 + 3, 10);
}
public boolean manageHorizontalLine() {
return true;
}
@Override
public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype,
final SymbolContext symbolContext, final HorizontalAlignment stereoAlignment) {

View File

@ -121,9 +121,4 @@ class USymbolCard extends USymbol {
};
}
@Override
public boolean manageHorizontalLine() {
return true;
}
}

View File

@ -264,9 +264,4 @@ class USymbolCloud extends USymbol {
};
}
@Override
public boolean manageHorizontalLine() {
return true;
}
}

View File

@ -139,9 +139,4 @@ class USymbolCollections extends USymbol {
};
}
@Override
public boolean manageHorizontalLine() {
return true;
}
}

View File

@ -104,9 +104,4 @@ class USymbolComponent1 extends USymbol {
stereoAlignment);
}
@Override
public boolean manageHorizontalLine() {
return true;
}
}

View File

@ -127,9 +127,4 @@ class USymbolComponent2 extends USymbol {
};
}
@Override
public boolean manageHorizontalLine() {
return true;
}
}

View File

@ -166,10 +166,6 @@ class USymbolDatabase extends USymbol {
};
}
public boolean manageHorizontalLine() {
return true;
}
@Override
public int suppHeightBecauseOfShape() {
return 15;

View File

@ -159,9 +159,4 @@ class USymbolFile extends USymbol {
};
}
@Override
public boolean manageHorizontalLine() {
return true;
}
}

View File

@ -196,9 +196,4 @@ public class USymbolFolder extends USymbol {
};
}
@Override
public boolean manageHorizontalLine() {
return true;
}
}

View File

@ -179,9 +179,4 @@ class USymbolFrame extends USymbol {
//
// }
@Override
public boolean manageHorizontalLine() {
return true;
}
}

View File

@ -117,9 +117,4 @@ class USymbolLabel extends USymbol {
};
}
@Override
public boolean manageHorizontalLine() {
return true;
}
}

View File

@ -183,10 +183,6 @@ class USymbolNode extends USymbol {
};
}
public boolean manageHorizontalLine() {
return true;
}
@Override
public int suppHeightBecauseOfShape() {
return 5;

View File

@ -175,8 +175,4 @@ class USymbolQueue extends USymbol {
};
}
public boolean manageHorizontalLine() {
return true;
}
}

View File

@ -134,9 +134,4 @@ class USymbolRect extends USymbol {
};
}
@Override
public boolean manageHorizontalLine() {
return true;
}
}

View File

@ -138,9 +138,4 @@ class USymbolStack extends USymbol {
};
}
@Override
public boolean manageHorizontalLine() {
return true;
}
}

View File

@ -110,9 +110,4 @@ class USymbolStorage extends USymbol {
};
}
@Override
public boolean manageHorizontalLine() {
return true;
}
}

View File

@ -49,7 +49,6 @@ import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.Member;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.security.SFile;
@ -140,9 +139,9 @@ public final class CucaDiagramHtmlMaker {
} else {
pw.println("<h2>Fields:</h2>");
pw.println("<ul>");
for (Member m : entity.getBodier().getFieldsToDisplay()) {
for (CharSequence m : entity.getBodier().getFieldsToDisplay()) {
pw.println("<li>");
pw.println(StringUtils.unicodeForHtml(m.getDisplay(true)));
pw.println(StringUtils.unicodeForHtml(m.toString()));
pw.println("</li>");
}
pw.println("</ul>");
@ -154,9 +153,9 @@ public final class CucaDiagramHtmlMaker {
} else {
pw.println("<h2>Methods:</h2>");
pw.println("<ul>");
for (Member m : entity.getBodier().getMethodsToDisplay()) {
for (CharSequence m : entity.getBodier().getMethodsToDisplay()) {
pw.println("<li>");
pw.println(StringUtils.unicodeForHtml(m.getDisplay(true)));
pw.println(StringUtils.unicodeForHtml(m.toString()));
pw.println("</li>");
}
pw.println("</ul>");

View File

@ -92,7 +92,6 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockEmpty;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.TextBlockWidth;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.style.SName;
@ -259,14 +258,9 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker {
final TextBlock stereoAndTitle = TextBlockUtils.mergeTB(stereo, title, HorizontalAlignment.CENTER);
final Dimension2D dimLabel = stereoAndTitle.calculateDimension(stringBounder);
if (dimLabel.getWidth() > 0) {
final List<Member> members = ((IEntity) g).getBodier().getFieldsToDisplay();
final TextBlockWidth attribute;
if (members.size() == 0) {
attribute = new TextBlockEmpty();
} else {
attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, diagram.getSkinParam(),
g.getStereotype(), null, getStyle(FontParam.STATE_ATTRIBUTE));
}
final TextBlock attribute = GeneralImageBuilder.stateHeader(g, null, diagram.getSkinParam());
final Dimension2D dimAttribute = attribute.calculateDimension(stringBounder);
final double attributeHeight = dimAttribute.getHeight();
final double attributeWidth = dimAttribute.getWidth();

View File

@ -75,7 +75,7 @@ public class JsonDiagram extends UmlDiagram {
private final List<String> highlighted;
public JsonDiagram(JsonValue json, List<String> highlighted) {
if (json.isString() || json.isBoolean() || json.isNumber()) {
if (json != null && (json.isString() || json.isBoolean() || json.isNumber())) {
this.root = new JsonArray();
((JsonArray) this.root).add(json);
} else {
@ -110,8 +110,9 @@ public class JsonDiagram extends UmlDiagram {
margin2 = 10;
}
final ClockwiseTopRightBottomLeft margins = ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2);
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null, dpiFactor, "",
"", margins, null);
final String metadata = fileFormatOption.isWithMetadata() ? getMetadata() : null;
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null, dpiFactor,
metadata, "", margins, null);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
TextBlock result = getTextBlock();
result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder(getSkinParam()))

View File

@ -148,9 +148,20 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol
if (value.isString()) {
return value.asString();
}
if (value.isNumber() || value.isBoolean()) {
if (value.isNull()) {
return "<U+2400>";
// return "<U+2205> null";
}
if (value.isNumber()) {
return value.toString();
}
if (value.isBoolean()) {
if (value.isTrue()) {
return "<U+2611> true";
} else {
return "<U+2610> false";
}
}
return " ";
}

View File

@ -48,8 +48,8 @@ public class MessageNumber implements CharSequence {
this.representation = s;
}
public String getNumber() {
return representation;
public String getNumberRaw() {
return representation.replaceAll("\\</?b\\>", "");
}
public char charAt(int arg0) {

View File

@ -119,7 +119,7 @@ public class SequenceDiagramTxtMaker implements FileMaker {
if (title.isWhite() == false) {
final int widthTitle = StringUtils.getWcWidth(title);
final UmlCharArea charArea = ug.getCharArea();
charArea.drawStringsLR(title.as(), (int) ((fullDimension.getWidth() - widthTitle) / 2), 0);
charArea.drawStringsLRSimple(title.as(), (int) ((fullDimension.getWidth() - widthTitle) / 2), 0);
}
}

View File

@ -43,7 +43,7 @@ import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.UseStyle;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.cucadiagram.BodyEnhanced2;
import net.sourceforge.plantuml.cucadiagram.BodyFactory;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
@ -111,8 +111,8 @@ public abstract class AbstractTextualComponent extends AbstractComponent {
if (this.display.size() == 1 && this.display.get(0).length() == 0) {
textBlock = new TextBlockEmpty();
} else if (enhanced) {
textBlock = new BodyEnhanced2(this.display, FontParam.NOTE, spriteContainer, horizontalAlignment, fc,
maxMessageSize, spriteContainer.minClassWidth());
textBlock = BodyFactory.create3(this.display, FontParam.NOTE, spriteContainer, horizontalAlignment, fc,
maxMessageSize);
} else {
textBlock = this.display.create0(fc, horizontalAlignment, spriteContainer, maxMessageSize, CreoleMode.FULL,
fontForStereotype, htmlColorForStereotype);

View File

@ -40,6 +40,7 @@ import java.awt.geom.Rectangle2D;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder;
@ -54,26 +55,31 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorNone;
public enum VisibilityModifier {
PRIVATE_FIELD(ColorParam.iconPrivate, null), PROTECTED_FIELD(ColorParam.iconProtected, null),
PACKAGE_PRIVATE_FIELD(ColorParam.iconPackage, null), PUBLIC_FIELD(ColorParam.iconPublic, null),
PRIVATE_FIELD(StringUtils.PRIVATE_FIELD, ColorParam.iconPrivate, null),
PROTECTED_FIELD(StringUtils.PROTECTED_FIELD, ColorParam.iconProtected, null),
PACKAGE_PRIVATE_FIELD(StringUtils.PACKAGE_PRIVATE_FIELD, ColorParam.iconPackage, null),
PUBLIC_FIELD(StringUtils.PUBLIC_FIELD, ColorParam.iconPublic, null),
PRIVATE_METHOD(ColorParam.iconPrivate, ColorParam.iconPrivateBackground),
PROTECTED_METHOD(ColorParam.iconProtected, ColorParam.iconProtectedBackground),
PACKAGE_PRIVATE_METHOD(ColorParam.iconPackage, ColorParam.iconPackageBackground),
PUBLIC_METHOD(ColorParam.iconPublic, ColorParam.iconPublicBackground),
PRIVATE_METHOD(StringUtils.PRIVATE_METHOD, ColorParam.iconPrivate, ColorParam.iconPrivateBackground),
PROTECTED_METHOD(StringUtils.PROTECTED_METHOD, ColorParam.iconProtected, ColorParam.iconProtectedBackground),
PACKAGE_PRIVATE_METHOD(StringUtils.PACKAGE_PRIVATE_METHOD, ColorParam.iconPackage,
ColorParam.iconPackageBackground),
PUBLIC_METHOD(StringUtils.PUBLIC_METHOD, ColorParam.iconPublic, ColorParam.iconPublicBackground),
IE_MANDATORY(ColorParam.iconIEMandatory, ColorParam.iconIEMandatory);
IE_MANDATORY(StringUtils.IE_MANDATORY, ColorParam.iconIEMandatory, ColorParam.iconIEMandatory);
private final ColorParam foregroundParam;
private final ColorParam backgroundParam;
private final char unicode;
public static String regexForVisibilityCharacterInClassName() {
return "[-#+~]";
}
private VisibilityModifier(ColorParam foreground, ColorParam background) {
private VisibilityModifier(char unicode, ColorParam foreground, ColorParam background) {
this.foregroundParam = foreground;
this.backgroundParam = background;
this.unicode = unicode;
}
public UDrawable getUDrawable(final int size, final HColor foregroundColor, final HColor backgoundColor) {
@ -218,6 +224,23 @@ public enum VisibilityModifier {
return false;
}
public static VisibilityModifier getByUnicode(char c) {
for (VisibilityModifier modifier : VisibilityModifier.values()) {
if (modifier.unicode == c) {
return modifier;
}
}
return null;
}
public static String replaceVisibilityModifierByUnicodeChar(String s, boolean isField) {
final VisibilityModifier modifier = getVisibilityModifier(s, isField);
if (modifier == null) {
return s;
}
return "" + modifier.unicode + s.substring(1);
}
public static VisibilityModifier getVisibilityModifier(CharSequence s, boolean isField) {
if (s.length() <= 2) {
return null;

View File

@ -62,15 +62,11 @@ import net.sourceforge.plantuml.cucadiagram.EntityPosition;
import net.sourceforge.plantuml.cucadiagram.EntityUtils;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.IGroup;
import net.sourceforge.plantuml.cucadiagram.Member;
import net.sourceforge.plantuml.cucadiagram.MethodsOrFieldsArea;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockEmpty;
import net.sourceforge.plantuml.graphic.TextBlockWidth;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.graphic.color.Colors;
@ -481,7 +477,8 @@ public class Cluster implements Moveable {
stateBack = getColor(skinParam2, ColorParam.stateBackground, group.getStereotype());
}
final HColor background = getColor(skinParam2, ColorParam.background, null);
final TextBlockWidth attribute = getTextBlockAttribute(skinParam2);
final Style style = getStyle(FontParam.STATE_ATTRIBUTE, skinParam2);
final TextBlock attribute = GeneralImageBuilder.stateHeader(group, style, skinParam2);
final double attributeHeight = attribute.calculateDimension(ug.getStringBounder()).getHeight();
if (total.getWidth() == 0) {
System.err.println("Cluster::drawUState issue");
@ -497,7 +494,7 @@ public class Cluster implements Moveable {
}
if (attributeHeight > 0) {
attribute.asTextBlock(total.getWidth()).drawU(
attribute.drawU(
ug.apply(new UTranslate(minX + IEntityImage.MARGIN, minY + suppY + IEntityImage.MARGIN / 2.0)));
}
@ -509,18 +506,6 @@ public class Cluster implements Moveable {
}
private TextBlockWidth getTextBlockAttribute(ISkinParam skinParam) {
final TextBlockWidth attribute;
final List<Member> members = group.getBodier().getFieldsToDisplay();
if (members.size() == 0) {
attribute = new TextBlockEmpty();
} else {
attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, skinParam, group.getStereotype(),
null, getStyle(FontParam.STATE_ATTRIBUTE, skinParam));
}
return attribute;
}
public void setPosition(double minX, double minY, double maxX, double maxY) {
this.minX = minX;
this.maxX = maxX;

View File

@ -100,7 +100,6 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockEmpty;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.TextBlockWidth;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.graphic.USymbolInterface;
import net.sourceforge.plantuml.style.PName;
@ -172,7 +171,7 @@ public final class GeneralImageBuilder {
final Cluster stateParent = bibliotekon.getCluster(leaf.getParentContainer());
return new EntityImageStateBorder(leaf, skinParam, stateParent, bibliotekon);
}
if (isHideEmptyDescriptionForState && leaf.getBodier().getFieldsToDisplay().size() == 0) {
if (isHideEmptyDescriptionForState && leaf.getBodier().getRawBody().size() == 0) {
return new EntityImageStateEmptyDescription(leaf, skinParam);
}
if (leaf.getStereotype() != null
@ -463,10 +462,11 @@ public final class GeneralImageBuilder {
try {
svg = dotStringFactory.getSvg(basefile, dotStrings);
} catch (IOException e) {
return new GraphvizCrash(source.getPlainString(), GraphvizUtils.graphviz244onWindows());
return new GraphvizCrash(source.getPlainString(), GraphvizUtils.graphviz244onWindows(), e);
}
if (svg.length() == 0) {
return new GraphvizCrash(source.getPlainString(), GraphvizUtils.graphviz244onWindows());
return new GraphvizCrash(source.getPlainString(), GraphvizUtils.graphviz244onWindows(),
new EmptySvgException());
}
final String graphvizVersion = extractGraphvizVersion(svg);
try {
@ -629,15 +629,8 @@ public final class GeneralImageBuilder {
final TextBlock stereoAndTitle = TextBlockUtils.mergeTB(stereo, title, HorizontalAlignment.CENTER);
final Dimension2D dimLabel = stereoAndTitle.calculateDimension(stringBounder);
if (dimLabel.getWidth() > 0) {
final List<Member> members = ((IEntity) g).getBodier().getFieldsToDisplay();
final TextBlockWidth attribute;
if (members.size() == 0) {
attribute = new TextBlockEmpty();
} else {
attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, dotData.getSkinParam(),
g.getStereotype(), null, getStyle(FontParam.STATE_ATTRIBUTE));
}
final Dimension2D dimAttribute = attribute.calculateDimension(stringBounder);
final Dimension2D dimAttribute = stateHeader((IEntity) g, getStyle(FontParam.STATE_ATTRIBUTE),
dotData.getSkinParam()).calculateDimension(stringBounder);
final double attributeHeight = dimAttribute.getHeight();
final double attributeWidth = dimAttribute.getWidth();
final double marginForFields = attributeHeight > 0 ? IEntityImage.MARGIN : 0;
@ -658,6 +651,31 @@ public final class GeneralImageBuilder {
dotStringFactory.closeCluster();
}
public static TextBlock stateHeader(IEntity group, Style style, ISkinParam skinParam) {
final List<CharSequence> details = group.getBodier().getRawBody();
if (details.size() == 0) {
return new TextBlockEmpty();
}
final FontConfiguration fontConfiguration;
if (style == null) {
fontConfiguration = new FontConfiguration(skinParam, FontParam.STATE_ATTRIBUTE, null);
} else {
fontConfiguration = new FontConfiguration(skinParam, style);
}
Display display = null;
for (CharSequence s : details) {
if (display == null) {
display = Display.getWithNewlines(s.toString());
} else {
display = display.addAll(Display.getWithNewlines(s.toString()));
}
}
return display.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam);
}
private Style getStyle(FontParam fontParam) {
return fontParam.getStyleDefinition(SName.stateDiagram)
.getMergedStyle(dotData.getSkinParam().getCurrentStyleBuilder());

View File

@ -44,6 +44,7 @@ import java.util.List;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.OptionPrint;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
import net.sourceforge.plantuml.flashcode.FlashCodeFactory;
import net.sourceforge.plantuml.flashcode.FlashCodeUtils;
@ -72,12 +73,12 @@ public class GraphvizCrash extends AbstractTextBlock implements IEntityImage {
private final String text;
private final boolean graphviz244onWindows;
public GraphvizCrash(String text, boolean graphviz244onWindows) {
public GraphvizCrash(String text, boolean graphviz244onWindows, Throwable rootCause) {
this.text = text;
this.graphviz244onWindows = graphviz244onWindows;
final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils();
this.flashCode = utils.exportFlashcode(text, Color.BLACK, Color.WHITE);
this.text1 = GraphicStrings.createBlackOnWhite(init(), IconLoader.getRandom(),
this.text1 = GraphicStrings.createBlackOnWhite(init(rootCause), IconLoader.getRandom(),
GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT);
}
@ -132,9 +133,15 @@ public class GraphvizCrash extends AbstractTextBlock implements IEntityImage {
strings.add(" - a problem in GraphViz");
}
private List<String> init() {
private List<String> init(Throwable rootCause) {
final List<String> strings = anErrorHasOccured(null, text);
strings.add("For some reason, dot/GraphViz has crashed.");
strings.add("");
strings.add("RootCause " + rootCause);
if (rootCause != null) {
strings.addAll(CommandExecutionResult.getStackTrace(rootCause));
}
strings.add("");
strings.add("This has been generated with PlantUML (" + Version.versionString() + ").");
checkOldVersionWarning(strings);
strings.add(" ");
@ -217,7 +224,7 @@ public class GraphvizCrash extends AbstractTextBlock implements IEntityImage {
final UImage dotd = new UImage(new PixelImage(PSystemVersion.getDotd(), AffineTransformType.TYPE_BILINEAR));
result = TextBlockUtils.mergeTB(result, dotd, HorizontalAlignment.LEFT);
}
}
return result;
}

View File

@ -60,9 +60,6 @@ import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockEmpty;
import net.sourceforge.plantuml.graphic.TextBlockWidth;
import net.sourceforge.plantuml.graphic.TextBlockWidthAdapter;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.style.SName;
@ -158,7 +155,7 @@ public final class GroupPngMakerState {
final HColor backColor = group.getColors(skinParam).getColor(ColorType.BACK) == null
? getColor(ColorParam.stateBackground, stereo)
: group.getColors(skinParam).getColor(ColorType.BACK);
final TextBlockWidth attribute = getAttributes(skinParam);
final TextBlock attribute = GeneralImageBuilder.stateHeader((IEntity) group, null, skinParam);
final Stereotype stereotype = group.getStereotype();
final boolean withSymbol = stereotype != null && stereotype.isWithOOSymbol();
@ -175,27 +172,6 @@ public final class GroupPngMakerState {
}
private TextBlockWidth getAttributes(final ISkinParam skinParam) {
final List<String> details = ((IEntity) group).getBodier().getRawBody();
if (details.size() == 0) {
return new TextBlockEmpty();
}
final FontConfiguration fontConfiguration = new FontConfiguration(skinParam, FontParam.STATE_ATTRIBUTE, null);
Display display = null;
for (String s : details) {
if (display == null) {
display = Display.getWithNewlines(s);
} else {
display = display.addAll(Display.getWithNewlines(s));
}
}
final TextBlock result = display.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam);
return new TextBlockWidthAdapter(result, 0);
}
private IEntityImage buildImageForConcurrentState(DotData dotData) {
final List<IEntityImage> inners = new ArrayList<IEntityImage>();
for (ILeaf inner : dotData.getLeafs()) {

View File

@ -42,7 +42,6 @@ import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockWidth;
import net.sourceforge.plantuml.svek.image.EntityImageState;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UStroke;
@ -53,7 +52,7 @@ public final class InnerStateAutonom extends AbstractTextBlock implements IEntit
private final IEntityImage im;
private final TextBlock title;
private final TextBlockWidth attribute;
private final TextBlock attribute;
private final HColor borderColor;
private final HColor backColor;
private final boolean shadowing;
@ -61,8 +60,8 @@ public final class InnerStateAutonom extends AbstractTextBlock implements IEntit
private final boolean withSymbol;
private final UStroke stroke;
public InnerStateAutonom(final IEntityImage im, final TextBlock title, TextBlockWidth attribute,
HColor borderColor, HColor backColor, boolean shadowing, Url url, boolean withSymbol, UStroke stroke) {
public InnerStateAutonom(final IEntityImage im, final TextBlock title, TextBlock attribute, HColor borderColor,
HColor backColor, boolean shadowing, Url url, boolean withSymbol, UStroke stroke) {
this.im = im;
this.withSymbol = withSymbol;
this.title = title;
@ -90,9 +89,8 @@ public final class InnerStateAutonom extends AbstractTextBlock implements IEntit
r.drawU(ug, shadowing);
title.drawU(ug.apply(new UTranslate((total.getWidth() - text.getWidth()) / 2, IEntityImage.MARGIN)));
attribute.asTextBlock(total.getWidth()).drawU(
ug.apply(new UTranslate(0 + IEntityImage.MARGIN, IEntityImage.MARGIN + text.getHeight()
+ IEntityImage.MARGIN)));
attribute.drawU(ug.apply(
new UTranslate(0 + IEntityImage.MARGIN, IEntityImage.MARGIN + text.getHeight() + IEntityImage.MARGIN)));
final double spaceYforURL = getSpaceYforURL(ug.getStringBounder());
im.drawU(ug.apply(new UTranslate(IEntityImage.MARGIN, spaceYforURL)));
@ -128,8 +126,8 @@ public final class InnerStateAutonom extends AbstractTextBlock implements IEntit
final Dimension2D dim = Dimension2DDouble.mergeTB(text, attr, img);
final double marginForFields = attr.getHeight() > 0 ? IEntityImage.MARGIN : 0;
final Dimension2D result = Dimension2DDouble.delta(dim, IEntityImage.MARGIN * 2 + 2 * IEntityImage.MARGIN_LINE
+ marginForFields);
final Dimension2D result = Dimension2DDouble.delta(dim,
IEntityImage.MARGIN * 2 + 2 * IEntityImage.MARGIN_LINE + marginForFields);
return result;
}
@ -145,10 +143,9 @@ public final class InnerStateAutonom extends AbstractTextBlock implements IEntit
public boolean isHidden() {
return im.isHidden();
}
public double getOverscanX(StringBounder stringBounder) {
return 0;
}
}

View File

@ -47,8 +47,7 @@ import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UseStyle;
import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
import net.sourceforge.plantuml.cucadiagram.BodyEnhanced2;
import net.sourceforge.plantuml.cucadiagram.BodyFactory;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.cucadiagram.IEntity;
@ -175,9 +174,9 @@ public class EntityImageDescription extends AbstractEntityImage {
desc = TextBlockUtils.empty(getSkinParam().minClassWidth(), 0);
} else {
desc = new BodyEnhanced2(entity.getDisplay(), symbol.getFontParam(), getSkinParam(),
desc = BodyFactory.create3(entity.getDisplay(), symbol.getFontParam(), getSkinParam(),
getSkinParam().getDefaultTextAlignment(HorizontalAlignment.LEFT), fcTitle,
getSkinParam().wrapWidth(), getSkinParam().minClassWidth());
getSkinParam().wrapWidth());
}
stereo = TextBlockUtils.empty(0, 0);
@ -191,8 +190,8 @@ public class EntityImageDescription extends AbstractEntityImage {
HorizontalAlignment.CENTER, getSkinParam());
}
name = new BodyEnhanced(codeDisplay, symbol.getFontParam(), getSkinParam(), HorizontalAlignment.CENTER,
stereotype, symbol.manageHorizontalLine(), false, entity, style);
name = BodyFactory.create2(codeDisplay, symbol.getFontParam(), getSkinParam(), HorizontalAlignment.CENTER,
stereotype, entity, style);
if (hideText) {
asSmall = symbol.asSmall(TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0),

View File

@ -43,7 +43,7 @@ import net.sourceforge.plantuml.Guillemet;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
import net.sourceforge.plantuml.cucadiagram.BodyFactory;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
@ -85,8 +85,8 @@ public class EntityImageLollipopInterfaceEye2 extends AbstractEntityImage {
throw new IllegalArgumentException();
}
this.desc = new BodyEnhanced(entity.getDisplay(), symbol.getFontParam(), skinParam, HorizontalAlignment.CENTER,
stereotype, symbol.manageHorizontalLine(), false, entity, getStyle(symbol.getFontParam()));
this.desc = BodyFactory.create2(entity.getDisplay(), symbol.getFontParam(), skinParam,
HorizontalAlignment.CENTER, stereotype, entity, getStyle(symbol.getFontParam()));
this.url = entity.getUrl99();

View File

@ -51,7 +51,7 @@ import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UseStyle;
import net.sourceforge.plantuml.creole.Stencil;
import net.sourceforge.plantuml.cucadiagram.BodyEnhanced2;
import net.sourceforge.plantuml.cucadiagram.BodyFactory;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
@ -125,9 +125,9 @@ public class EntityImageNote extends AbstractEntityImage implements Stencil {
if (strings.size() == 1 && strings.get(0).length() == 0) {
textBlock = new TextBlockEmpty();
} else {
textBlock = new BodyEnhanced2(strings, FontParam.NOTE, getSkinParam(), HorizontalAlignment.LEFT,
new FontConfiguration(getSkinParam(), FontParam.NOTE, null), getSkinParam().wrapWidth(),
getSkinParam().minClassWidth());
final FontConfiguration fc = new FontConfiguration(getSkinParam(), FontParam.NOTE, null);
textBlock = BodyFactory.create3(strings, FontParam.NOTE, getSkinParam(), HorizontalAlignment.LEFT, fc,
getSkinParam().wrapWidth());
}
}

View File

@ -92,10 +92,11 @@ public class EntityImageState extends AbstractEntityImage {
this.desc = entity.getDisplay().create8(new FontConfiguration(getSkinParam(), FontParam.STATE, stereotype),
HorizontalAlignment.CENTER, skinParam, CreoleMode.FULL, skinParam.wrapWidth());
Display list = Display.empty();
for (Member att : entity.getBodier().getFieldsToDisplay()) {
list = list.addAll(Display.getWithNewlines(att.getDisplay(true)));
}
// Display list = Display.empty();
// for (Member att : entity.getBodier().getFieldsToDisplay()) {
// list = list.addAll(Display.getWithNewlines(att.getDisplay(true)));
// }
final Display list = Display.create(entity.getBodier().getRawBody());
this.url = entity.getUrl99();

View File

@ -42,10 +42,8 @@ import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineConfigurable;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.BodyFactory;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.Member;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder;
@ -75,10 +73,11 @@ public class EntityImageState2 extends AbstractEntityImage {
this.lineConfig = entity;
final Stereotype stereotype = entity.getStereotype();
Display list = Display.empty();
for (Member att : entity.getBodier().getFieldsToDisplay()) {
list = list.addAll(Display.getWithNewlines(att.getDisplay(true)));
}
// Display list = Display.empty();
// for (Member att : entity.getBodier().getFieldsToDisplay()) {
// list = list.addAll(Display.getWithNewlines(att.getDisplay(true)));
// }
// final Display list = Display.create(entity.getBodier().getRawBody());
final USymbol symbol = USymbol.FRAME;
@ -95,9 +94,8 @@ public class EntityImageState2 extends AbstractEntityImage {
this.url = entity.getUrl99();
TextBlock stereo = TextBlockUtils.empty(0, 0);
final TextBlock desc = new BodyEnhanced(entity.getDisplay(), symbol.getFontParam(), skinParam,
HorizontalAlignment.CENTER, stereotype, symbol.manageHorizontalLine(), false, entity,
getStyle(symbol.getFontParam()));
final TextBlock desc = BodyFactory.create2(entity.getDisplay(), symbol.getFontParam(), skinParam,
HorizontalAlignment.CENTER, stereotype, entity, getStyle(symbol.getFontParam()));
asSmall = symbol.asSmall(null, desc, stereo, ctx, skinParam.getStereotypeAlignment());

View File

@ -77,10 +77,11 @@ public class EntityImageStateEmptyDescription extends AbstractEntityImage {
this.desc = entity.getDisplay().create8(new FontConfiguration(getSkinParam(), FontParam.STATE, stereotype),
HorizontalAlignment.CENTER, skinParam, CreoleMode.FULL, skinParam.wrapWidth());
Display list = Display.empty();
for (Member att : entity.getBodier().getFieldsToDisplay()) {
list = list.addAll(Display.getWithNewlines(att.getDisplay(true)));
}
// Display list = Display.empty();
// for (Member att : entity.getBodier().getFieldsToDisplay()) {
// list = list.addAll(Display.getWithNewlines(att.getDisplay(true)));
// }
// final Display list = Display.create(entity.getBodier().getRawBody());
this.url = entity.getUrl99();

View File

@ -47,7 +47,7 @@ import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.command.Position;
import net.sourceforge.plantuml.cucadiagram.BodyEnhanced2;
import net.sourceforge.plantuml.cucadiagram.BodyFactory;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
@ -163,11 +163,9 @@ public class EntityImageTips extends AbstractEntityImage {
}
private Opale getOpale(final Display display) {
// final HtmlColor fontColor = rose.getFontColor(skinParam, FontParam.NOTE);
// final UFont fontNote = skinParam.getFont(FontParam.NOTE, null, false);
final TextBlock textBlock = new BodyEnhanced2(display, FontParam.NOTE, skinParam, HorizontalAlignment.LEFT,
new FontConfiguration(skinParam, FontParam.NOTE, null), LineBreakStrategy.NONE,
skinParam.minClassWidth());
final FontConfiguration fc = new FontConfiguration(skinParam, FontParam.NOTE, null);
final TextBlock textBlock = BodyFactory.create3(display, FontParam.NOTE, skinParam, HorizontalAlignment.LEFT,
fc, LineBreakStrategy.NONE);
final double shadowing = skinParam.shadowing(getEntity().getStereotype()) ? 4 : 0;
final Opale opale = new Opale(shadowing, borderColor, noteBackgroundColor, textBlock, true);
return opale;

View File

@ -47,7 +47,7 @@ import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UseStyle;
import net.sourceforge.plantuml.creole.Stencil;
import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
import net.sourceforge.plantuml.cucadiagram.BodyFactory;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
@ -87,8 +87,8 @@ public class EntityImageUseCase extends AbstractEntityImage {
super(entity, skinParam);
final Stereotype stereotype = entity.getStereotype();
final TextBlock tmp = new BodyEnhanced(entity.getDisplay(), FontParam.USECASE, skinParam,
HorizontalAlignment.CENTER, stereotype, true, false, entity, getStyle());
final TextBlock tmp = BodyFactory.create2(entity.getDisplay(), FontParam.USECASE, skinParam,
HorizontalAlignment.CENTER, stereotype, entity, getStyle());
if (stereotype == null || stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR) == null
|| portionShower.showPortion(EntityPortion.STEREOTYPE, entity) == false) {

View File

@ -44,7 +44,7 @@ public class Version {
private static final int MAJOR_SEPARATOR = 1000000;
public static int version() {
return 1202022;
return 1202023;
}
public static int versionPatched() {
@ -93,7 +93,7 @@ public class Version {
}
public static long compileTime() {
return 1607247387732L;
return 1607886898413L;
}
public static String compileTimeString() {

View File

@ -180,7 +180,8 @@ abstract class XmiClassDiagramAbstract implements IXmiClassDiagram {
final Element feature = document.createElement("UML:Classifier.feature");
cla.appendChild(feature);
for (Member m : entity.getBodier().getFieldsToDisplay()) {
for (CharSequence cs : entity.getBodier().getFieldsToDisplay()) {
final Member m = (Member) cs;
// <UML:Attribute xmi.id="UMLAttribute.6" name="Attribute1"
// visibility="public" isSpecification="false"
// ownerScope="instance" changeability="changeable"
@ -195,7 +196,8 @@ abstract class XmiClassDiagramAbstract implements IXmiClassDiagram {
feature.appendChild(attribute);
}
for (Member m : entity.getBodier().getMethodsToDisplay()) {
for (CharSequence cs : entity.getBodier().getMethodsToDisplay()) {
final Member m = (Member) cs;
// <UML:Operation xmi.id="UMLOperation.7" name="Operation1"
// visibility="public" isSpecification="false"
// ownerScope="instance" isQuery="false" concurrency="sequential"

View File

@ -210,19 +210,19 @@ public class XmiDescriptionDiagram implements IXmiClassDiagram {
final Element feature = document.createElement("UML:Classifier.feature");
cla.appendChild(feature);
for (Member m : entity.getBodier().getFieldsToDisplay()) {
final Element attribute = document.createElement("UML:Attribute");
attribute.setAttribute("xmi.id", "att" + UniqueSequence.getValue());
attribute.setAttribute("name", m.getDisplay(false));
feature.appendChild(attribute);
}
for (Member m : entity.getBodier().getMethodsToDisplay()) {
final Element operation = document.createElement("UML:Operation");
operation.setAttribute("xmi.id", "att" + UniqueSequence.getValue());
operation.setAttribute("name", m.getDisplay(false));
feature.appendChild(operation);
}
// for (Member m : entity.getBodier().getFieldsToDisplay()) {
// final Element attribute = document.createElement("UML:Attribute");
// attribute.setAttribute("xmi.id", "att" + UniqueSequence.getValue());
// attribute.setAttribute("name", m.getDisplay(false));
// feature.appendChild(attribute);
// }
//
// for (Member m : entity.getBodier().getMethodsToDisplay()) {
// final Element operation = document.createElement("UML:Operation");
// operation.setAttribute("xmi.id", "att" + UniqueSequence.getValue());
// operation.setAttribute("name", m.getDisplay(false));
// feature.appendChild(operation);
// }
return cla;
}

View File

@ -215,28 +215,28 @@ public class XmiStateDiagram implements IXmiClassDiagram {
final Element feature = document.createElement("UML:Classifier.feature");
cla.appendChild(feature);
for (Member m : entity.getBodier().getFieldsToDisplay()) {
// <UML:Attribute xmi.id="UMLAttribute.6" name="Attribute1"
// visibility="public" isSpecification="false"
// ownerScope="instance" changeability="changeable"
// targetScope="instance" type="" owner="UMLClass.5"/>
final Element attribute = document.createElement("UML:Attribute");
attribute.setAttribute("xmi.id", "att" + UniqueSequence.getValue());
attribute.setAttribute("name", m.getDisplay(false));
feature.appendChild(attribute);
}
for (Member m : entity.getBodier().getMethodsToDisplay()) {
// <UML:Operation xmi.id="UMLOperation.7" name="Operation1"
// visibility="public" isSpecification="false"
// ownerScope="instance" isQuery="false" concurrency="sequential"
// isRoot="false" isLeaf="false"
// isAbstract="false" specification="" owner="UMLClass.5"/>
final Element operation = document.createElement("UML:Operation");
operation.setAttribute("xmi.id", "att" + UniqueSequence.getValue());
operation.setAttribute("name", m.getDisplay(false));
feature.appendChild(operation);
}
// for (Member m : entity.getBodier().getFieldsToDisplay()) {
// // <UML:Attribute xmi.id="UMLAttribute.6" name="Attribute1"
// // visibility="public" isSpecification="false"
// // ownerScope="instance" changeability="changeable"
// // targetScope="instance" type="" owner="UMLClass.5"/>
// final Element attribute = document.createElement("UML:Attribute");
// attribute.setAttribute("xmi.id", "att" + UniqueSequence.getValue());
// attribute.setAttribute("name", m.getDisplay(false));
// feature.appendChild(attribute);
// }
//
// for (Member m : entity.getBodier().getMethodsToDisplay()) {
// // <UML:Operation xmi.id="UMLOperation.7" name="Operation1"
// // visibility="public" isSpecification="false"
// // ownerScope="instance" isQuery="false" concurrency="sequential"
// // isRoot="false" isLeaf="false"
// // isAbstract="false" specification="" owner="UMLClass.5"/>
// final Element operation = document.createElement("UML:Operation");
// operation.setAttribute("xmi.id", "att" + UniqueSequence.getValue());
// operation.setAttribute("name", m.getDisplay(false));
// feature.appendChild(operation);
// }
return cla;
}