diff --git a/src/net/sourceforge/plantuml/command/CommandMultilines.java b/src/net/sourceforge/plantuml/command/CommandMultilines.java index 79007fa72..d511c305b 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilines.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilines.java @@ -72,15 +72,15 @@ public abstract class CommandMultilines implements Command if (m1.matches() == false) return CommandControl.OK_PARTIAL; - actionIfCommandValid(); - return CommandControl.OK; + return finalVerification(); } protected boolean isCommandForbidden() { return false; } - protected void actionIfCommandValid() { + protected CommandControl finalVerification() { + return CommandControl.OK; } protected final Pattern2 getStartingPattern() { diff --git a/src/net/sourceforge/plantuml/command/CommandMultilines2.java b/src/net/sourceforge/plantuml/command/CommandMultilines2.java index 7bc1dc30f..0e56f5bb4 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilines2.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilines2.java @@ -96,8 +96,7 @@ public abstract class CommandMultilines2 implements Command implements Command implements Command implements Command implements Com return new String[] { "BRACKET: " + starting.pattern() }; } - protected void actionIfCommandValid() { + protected CommandControl finalVerification() { + return CommandControl.OK; } protected final Pattern2 getStartingPattern() { @@ -98,8 +99,7 @@ public abstract class CommandMultilinesBracket implements Com if (level != 0) return CommandControl.OK_PARTIAL; - actionIfCommandValid(); - return CommandControl.OK; + return finalVerification(); } protected abstract boolean isLineConsistent(String line, int level); diff --git a/src/net/sourceforge/plantuml/command/SingleLineCommand2.java b/src/net/sourceforge/plantuml/command/SingleLineCommand2.java index 95723c695..6d9cd4ffc 100644 --- a/src/net/sourceforge/plantuml/command/SingleLineCommand2.java +++ b/src/net/sourceforge/plantuml/command/SingleLineCommand2.java @@ -104,9 +104,9 @@ public abstract class SingleLineCommand2 implements Command implements Command { private final HorizontalAlignment naturalHorizontalAlignment; private final boolean isNull; private final CreoleMode defaultCreoleMode; + private final boolean showStereotype; - public final static Display NULL = new Display(null, null, true, CreoleMode.FULL); + public final static Display NULL = new Display(true, null, null, true, CreoleMode.FULL); + + public boolean showStereotype() { + return showStereotype; + } public Display withoutStereotypeIfNeeded(Style usedStyle) { if (this == NULL) return NULL; - final boolean showStereotype = usedStyle.value(PName.ShowStereotype).asBoolean(); - if (showStereotype) + final Value showStereotype = usedStyle.value(PName.ShowStereotype); + if (showStereotype instanceof ValueNull || showStereotype.asBoolean()) return this; - final List copy = new ArrayList<>(displayData); - final Display result = new Display(naturalHorizontalAlignment, isNull, defaultCreoleMode); - for (Iterator it = copy.iterator(); it.hasNext();) { - final CharSequence cs = it.next(); - if (cs instanceof Stereotype && usedStyle.getSignature().match(((Stereotype) cs))) - it.remove(); + return new Display(false, this, this.defaultCreoleMode); - } - result.displayData.addAll(copy); - return result; } public Stereotype getStereotypeIfAny() { @@ -121,7 +120,7 @@ public class Display implements Iterable { } public Display replaceBackslashT() { - final Display result = new Display(this, defaultCreoleMode); + final Display result = new Display(this.showStereotype, this, defaultCreoleMode); for (int i = 0; i < result.displayData.size(); i++) { final CharSequence s = displayData.get(i); if (s.toString().contains("\\t")) @@ -138,7 +137,7 @@ public class Display implements Iterable { newDisplay.add(cs); } - return new Display(newDisplay, naturalHorizontalAlignment, isNull, defaultCreoleMode); + return new Display(showStereotype, newDisplay, naturalHorizontalAlignment, isNull, defaultCreoleMode); } public boolean isWhite() { @@ -147,7 +146,7 @@ public class Display implements Iterable { } public static Display empty() { - return new Display((HorizontalAlignment) null, false, CreoleMode.FULL); + return new Display(true, (HorizontalAlignment) null, false, CreoleMode.FULL); } public static Display create(CharSequence... s) { @@ -165,7 +164,7 @@ public class Display implements Iterable { } public static Display create(Collection other) { - return new Display(other, null, false, CreoleMode.FULL); + return new Display(true, other, null, false, CreoleMode.FULL); } public static Display getWithNewlines(Code s) { @@ -221,24 +220,26 @@ public class Display implements Iterable { } } result.add(current.toString()); - return new Display(result, naturalHorizontalAlignment, false, CreoleMode.FULL); + return new Display(true, result, naturalHorizontalAlignment, false, CreoleMode.FULL); } - private Display(Display other, CreoleMode mode) { - this(other.naturalHorizontalAlignment, other.isNull, mode); + private Display(boolean showStereotype, Display other, CreoleMode mode) { + this(showStereotype, other.naturalHorizontalAlignment, other.isNull, mode); this.displayData.addAll(other.displayData); } - private Display(HorizontalAlignment naturalHorizontalAlignment, boolean isNull, CreoleMode defaultCreoleMode) { + private Display(boolean showStereotype, HorizontalAlignment naturalHorizontalAlignment, boolean isNull, + CreoleMode defaultCreoleMode) { + this.showStereotype = showStereotype; this.defaultCreoleMode = defaultCreoleMode; this.isNull = isNull; this.displayData = isNull ? null : new ArrayList(); this.naturalHorizontalAlignment = isNull ? null : naturalHorizontalAlignment; } - private Display(Collection other, HorizontalAlignment naturalHorizontalAlignment, - boolean isNull, CreoleMode defaultCreoleMode) { - this(naturalHorizontalAlignment, isNull, defaultCreoleMode); + private Display(boolean showStereotype, Collection other, + HorizontalAlignment naturalHorizontalAlignment, boolean isNull, CreoleMode defaultCreoleMode) { + this(showStereotype, naturalHorizontalAlignment, isNull, defaultCreoleMode); if (isNull == false) this.displayData.addAll(manageEmbeddedDiagrams(other)); @@ -284,7 +285,8 @@ public class Display implements Iterable { } first = false; } - return new Display(result, this.naturalHorizontalAlignment, this.isNull, this.defaultCreoleMode); + return new Display(showStereotype, result, this.naturalHorizontalAlignment, this.isNull, + this.defaultCreoleMode); } public Display withPage(int page, int lastpage) { @@ -297,7 +299,8 @@ public class Display implements Iterable { line = line.toString().replace("%lastpage%", "" + lastpage); result.add(line); } - return new Display(result, this.naturalHorizontalAlignment, this.isNull, this.defaultCreoleMode); + return new Display(showStereotype, result, this.naturalHorizontalAlignment, this.isNull, + this.defaultCreoleMode); } public Display removeEndingStereotype() { @@ -305,7 +308,8 @@ public class Display implements Iterable { if (m.matches()) { final List result = new ArrayList<>(this.displayData); result.set(result.size() - 1, m.group(1)); - return new Display(result, this.naturalHorizontalAlignment, this.isNull, this.defaultCreoleMode); + return new Display(showStereotype, result, this.naturalHorizontalAlignment, this.isNull, + this.defaultCreoleMode); } return this; } @@ -325,7 +329,8 @@ public class Display implements Iterable { for (CharSequence line : displayData) result.add("" + line); - return new Display(result, this.naturalHorizontalAlignment, this.isNull, this.defaultCreoleMode); + return new Display(showStereotype, result, this.naturalHorizontalAlignment, this.isNull, + this.defaultCreoleMode); } public Display underlinedName() { @@ -342,14 +347,15 @@ public class Display implements Iterable { result.add("" + line); } } - return new Display(result, this.naturalHorizontalAlignment, this.isNull, this.defaultCreoleMode); + return new Display(showStereotype, result, this.naturalHorizontalAlignment, this.isNull, + this.defaultCreoleMode); } public Display withCreoleMode(CreoleMode mode) { if (isNull) throw new IllegalArgumentException(); - return new Display(this, mode); + return new Display(this.showStereotype, this, mode); } @Override @@ -371,25 +377,25 @@ public class Display implements Iterable { } public Display addAll(Display other) { - final Display result = new Display(this, this.defaultCreoleMode); + final Display result = new Display(this.showStereotype, this, this.defaultCreoleMode); result.displayData.addAll(other.displayData); return result; } public Display addFirst(CharSequence s) { - final Display result = new Display(this, this.defaultCreoleMode); + final Display result = new Display(this.showStereotype, this, this.defaultCreoleMode); result.displayData.add(0, s); return result; } public Display add(CharSequence s) { - final Display result = new Display(this, this.defaultCreoleMode); + final Display result = new Display(this.showStereotype, this, this.defaultCreoleMode); result.displayData.add(s); return result; } public Display addGeneric(CharSequence s) { - final Display result = new Display(this, this.defaultCreoleMode); + final Display result = new Display(this.showStereotype, this, this.defaultCreoleMode); final int size = displayData.size(); if (size == 0) result.displayData.add("<" + s + ">"); @@ -415,7 +421,7 @@ public class Display implements Iterable { } public Display subList(int i, int size) { - return new Display(displayData.subList(i, size), this.naturalHorizontalAlignment, this.isNull, + return new Display(showStereotype, displayData.subList(i, size), this.naturalHorizontalAlignment, this.isNull, this.defaultCreoleMode); } @@ -448,7 +454,8 @@ public class Display implements Iterable { public List splitMultiline(Pattern2 separator) { final List result = new ArrayList<>(); - Display pending = new Display(this.naturalHorizontalAlignment, this.isNull, this.defaultCreoleMode); + Display pending = new Display(showStereotype, this.naturalHorizontalAlignment, this.isNull, + this.defaultCreoleMode); result.add(pending); for (CharSequence line : displayData) { final Matcher2 m = separator.matcher(line); @@ -456,7 +463,8 @@ public class Display implements Iterable { final CharSequence s1 = line.subSequence(0, m.start()); pending.displayData.add(s1); final CharSequence s2 = line.subSequence(m.end(), line.length()); - pending = new Display(this.naturalHorizontalAlignment, this.isNull, this.defaultCreoleMode); + pending = new Display(showStereotype, this.naturalHorizontalAlignment, this.isNull, + this.defaultCreoleMode); result.add(pending); pending.displayData.add(s2); } else { diff --git a/src/net/sourceforge/plantuml/graphic/Img.java b/src/net/sourceforge/plantuml/graphic/Img.java index ceda56359..840a19d2d 100644 --- a/src/net/sourceforge/plantuml/graphic/Img.java +++ b/src/net/sourceforge/plantuml/graphic/Img.java @@ -63,17 +63,17 @@ public class Img implements HtmlCommand { static int getVspace(String html) { final Matcher2 m = vspacePattern.matcher(html); - if (m.find() == false) { + if (m.find() == false) return 0; - } + return Integer.parseInt(m.group(1)); } static ImgValign getValign(String html) { final Matcher2 m = valignPattern.matcher(html); - if (m.find() == false) { + if (m.find() == false) return ImgValign.TOP; - } + return ImgValign.valueOf(StringUtils.goUpperCase(m.group(1))); } @@ -99,28 +99,28 @@ public class Img implements HtmlCommand { // Check if valid URL if (src.startsWith("http:") || src.startsWith("https:")) { final SURL tmp = SURL.create(src); - if (tmp == null) { + if (tmp == null) return new Text("(Cannot decode: " + src + ")"); - } + final BufferedImage read = tmp.readRasterImageFromURL(); - if (read == null) { + if (read == null) return new Text("(Cannot decode: " + src + ")"); - } + return new Img(new TileImage(read, valign, vspace)); } return new Text("(Cannot decode: " + f + ")"); } if (f.getName().endsWith(".svg")) { final String tmp = FileUtils.readSvg(f); - if (tmp == null) { + if (tmp == null) return new Text("(Cannot decode: " + f + ")"); - } - return new Img(new TileImageSvg(tmp)); + + return new Img(new TileImageSvg(tmp, 1)); } final BufferedImage read = f.readRasterImageFromFile(); - if (read == null) { + if (read == null) return new Text("(Cannot decode: " + f + ")"); - } + return new Img(new TileImage(f.readRasterImageFromFile(), valign, vspace)); } catch (IOException e) { e.printStackTrace(); diff --git a/src/net/sourceforge/plantuml/graphic/TileImageSvg.java b/src/net/sourceforge/plantuml/graphic/TileImageSvg.java index 82911a800..06be3a753 100644 --- a/src/net/sourceforge/plantuml/graphic/TileImageSvg.java +++ b/src/net/sourceforge/plantuml/graphic/TileImageSvg.java @@ -43,9 +43,11 @@ import net.sourceforge.plantuml.ugraphic.UImageSvg; public class TileImageSvg extends AbstractTextBlock implements TextBlock { private final UImageSvg svg; + private final double scale; - public TileImageSvg(String svg) { - this.svg = new UImageSvg(svg, 1); + public TileImageSvg(String svg, double scale) { + this.svg = new UImageSvg(svg, scale); + this.scale = scale; } public Dimension2D calculateDimension(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJson.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJson.java index 39d5f4ea0..b3c816297 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJson.java +++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateJson.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.StringLocated; import net.sourceforge.plantuml.UrlBuilder; import net.sourceforge.plantuml.command.BlocLines; +import net.sourceforge.plantuml.command.CommandControl; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandMultilines2; import net.sourceforge.plantuml.command.MultilinesStrategy; @@ -97,22 +98,46 @@ public class CommandCreateJson extends CommandMultilines2 0; - System.err.println("l=" + line); sb.append(line); } sb.append("}"); - - final DefaultHandler handler = new DefaultHandler(); - new JsonParser(handler).parse(sb.toString()); - final JsonValue json = handler.getValue(); - ((BodierJSon) entity1.getBodier()).setJson(json); - - return CommandExecutionResult.ok(); + return sb.toString(); } private IEntity executeArg0(AbstractClassOrObjectDiagram diagram, RegexResult line0) throws NoSuchColorException { diff --git a/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java index 8a4effb9d..d4ec560d8 100644 --- a/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java +++ b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java @@ -55,8 +55,6 @@ import net.sourceforge.plantuml.ugraphic.color.HColorSet; public abstract class AbstractTextualComponent extends AbstractComponent { - private final Display display; - private final int marginX1; private final int marginX2; private final int marginY; @@ -91,20 +89,18 @@ public abstract class AbstractTextualComponent extends AbstractComponent { final UFont fontForStereotype = stereo.getUFont(); final HColor htmlColorForStereotype = stereo.value(PName.FontColor).asColor(spriteContainer.getThemeStyle(), getIHtmlColorSet()); - this.display = display.withoutStereotypeIfNeeded(style); + display = display.withoutStereotypeIfNeeded(style); this.marginX1 = marginX1; this.marginX2 = marginX2; this.marginY = marginY; - // this.display = keepStereotype ? display : display.withoutStereotype(); - if (this.display.size() == 1 && this.display.get(0).length() == 0) + if (display.size() == 1 && display.get(0).length() == 0) textBlock = new TextBlockEmpty(); else if (enhanced) - textBlock = BodyFactory.create3(this.display, spriteContainer, horizontalAlignment, fc, maxMessageSize, - style); + textBlock = BodyFactory.create3(display, spriteContainer, horizontalAlignment, fc, maxMessageSize, style); else - textBlock = this.display.create0(fc, horizontalAlignment, spriteContainer, maxMessageSize, CreoleMode.FULL, + textBlock = display.create0(fc, horizontalAlignment, spriteContainer, maxMessageSize, CreoleMode.FULL, fontForStereotype, htmlColorForStereotype, marginX1, marginX2); this.alignment = horizontalAlignment; diff --git a/src/net/sourceforge/plantuml/style/FromSkinparamToStyle.java b/src/net/sourceforge/plantuml/style/FromSkinparamToStyle.java index 7d9a33c6c..fb956333f 100644 --- a/src/net/sourceforge/plantuml/style/FromSkinparamToStyle.java +++ b/src/net/sourceforge/plantuml/style/FromSkinparamToStyle.java @@ -210,7 +210,16 @@ public class FromSkinparamToStyle { addMagic(SName.usecase); addMagic(SName.map); addMagic(SName.archimate); - + + addConvert("IconPrivateColor", PName.LineColor, SName.visibilityIcon, SName.private_); + addConvert("IconPrivateBackgroundColor", PName.BackGroundColor, SName.visibilityIcon, SName.private_); + addConvert("IconPackageColor", PName.LineColor, SName.visibilityIcon, SName.package_); + addConvert("IconPackageBackgroundColor", PName.BackGroundColor, SName.visibilityIcon, SName.package_); + addConvert("IconProtectedColor", PName.LineColor, SName.visibilityIcon, SName.protected_); + addConvert("IconProtectedBackgroundColor", PName.BackGroundColor, SName.visibilityIcon, SName.protected_); + addConvert("IconPublicColor", PName.LineColor, SName.visibilityIcon, SName.public_); + addConvert("IconPublicBackgroundColor", PName.BackGroundColor, SName.visibilityIcon, SName.public_); + // addConvert("nodeStereotypeFontSize", PName.FontSize, SName.node, SName.stereotype); // addConvert("sequenceStereotypeFontSize", PName.FontSize, SName.stereotype); diff --git a/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java b/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java index 6152a05ff..cc4b988c4 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java +++ b/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java @@ -128,12 +128,12 @@ public class UImageSvg implements UShape { throw new IllegalStateException("Cannot find " + name); } - public int getHeight() { - return this.getData("height"); + public double getHeight() { + return this.getData("height") * scale; } - public int getWidth() { - return this.getData("width"); + public double getWidth() { + return this.getData("width") * scale; } public double getScale() { diff --git a/src/net/sourceforge/plantuml/ugraphic/UPolygon.java b/src/net/sourceforge/plantuml/ugraphic/UPolygon.java index 23bb3f404..13ad6fa58 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UPolygon.java +++ b/src/net/sourceforge/plantuml/ugraphic/UPolygon.java @@ -73,7 +73,7 @@ public class UPolygon extends AbstractShadowable { (pt1.getY() + pt2.getY()) / 2); final double delta = middle.distance(center); if (delta < 1) - return all.get((i - 1) % all.size()); + return all.get((i + all.size() - 1) % all.size()); } return null;