1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 02:49:06 +00:00

Skinparam fix

This commit is contained in:
Arnaud Roques 2022-02-15 19:29:18 +01:00
parent e7785ff144
commit 90a19ab7e1
3 changed files with 75 additions and 29 deletions

View File

@ -206,7 +206,8 @@ public class SkinParam implements ISkinParam {
if (UseStyle.useBetaStyle()) {
applyPendingStyleMigration();
final FromSkinparamToStyle convertor = new FromSkinparamToStyle(key2, value, getCurrentStyleBuilder());
final FromSkinparamToStyle convertor = new FromSkinparamToStyle(key2);
convertor.convertNow(value, getCurrentStyleBuilder());
for (Style style : convertor.getStyles())
muteStyle(style);
} else {
@ -231,8 +232,8 @@ public class SkinParam implements ISkinParam {
public void applyPendingStyleMigration() {
for (Entry<String, String> ent : paramsPendingForStyleMigration.entrySet()) {
final FromSkinparamToStyle convertor = new FromSkinparamToStyle(ent.getKey(), ent.getValue(),
getCurrentStyleBuilder());
final FromSkinparamToStyle convertor = new FromSkinparamToStyle(ent.getKey());
convertor.convertNow(ent.getValue(), getCurrentStyleBuilder());
for (Style style : convertor.getStyles())
muteStyle(style);
}
@ -726,7 +727,7 @@ public class SkinParam implements ISkinParam {
public ColorMapper getColorMapper() {
if (themeStyle == ThemeStyle.DARK)
return new ColorMapperForceDark();
final String monochrome = getValue("monochrome");
if ("true".equals(monochrome))
return new ColorMapperMonochrome(false);

View File

@ -46,13 +46,27 @@ import java.util.StringTokenizer;
public class FromSkinparamToStyle {
static class Data {
final private PName propertyName;
final private SName[] styleNames;
final private PName propertyName;
Data(PName propertyName, SName[] styleNames) {
Data(SName[] styleNames, PName propertyName) {
this.propertyName = propertyName;
this.styleNames = styleNames;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("[");
for (SName s : styleNames) {
sb.append(s.toString());
sb.append(".");
}
sb.setLength(sb.length() - 1);
sb.append("]");
sb.append(propertyName.toString());
return sb.toString();
}
}
private static final Map<String, List<Data>> knowlegde = new HashMap<String, List<Data>>();
@ -117,7 +131,7 @@ public class FromSkinparamToStyle {
addConvert("activityStartColor", PName.BackGroundColor, SName.circle, SName.start);
addConvert("activityEndColor", PName.LineColor, SName.circle, SName.end);
addConvert("activityStopColor", PName.LineColor, SName.circle, SName.stop);
addConvert("activityBarColor", PName.LineColor, SName.activityBar);
addConvert("activityBarColor", PName.BackGroundColor, SName.activityBar);
addConvert("activityBorderColor", PName.LineColor, SName.activity);
addConvert("activityBorderThickness", PName.LineThickness, SName.activity);
addConvert("activityBackgroundColor", PName.BackGroundColor, SName.activity);
@ -206,38 +220,70 @@ public class FromSkinparamToStyle {
}
private final List<Style> styles = new ArrayList<>();
private String stereo = null;
private final String stereo;
private final String key;
public FromSkinparamToStyle(String key) {
public FromSkinparamToStyle(String key, String value, final AutomaticCounter counter) {
if (value.equals("right:right")) {
value = "right";
}
if (key.contains("<<")) {
final StringTokenizer st = new StringTokenizer(key, "<>");
key = st.nextToken();
stereo = st.nextToken();
this.key = st.nextToken();
this.stereo = st.nextToken();
} else {
this.key = key;
this.stereo = null;
}
}
public void convertNow(String value, final AutomaticCounter counter) {
if (value.equals("right:right"))
value = "right";
final List<Data> datas = knowlegde.get(key.toLowerCase());
if (datas != null) {
for (Data data : datas) {
addStyle(data.propertyName, ValueImpl.regular(value, counter), data.styleNames);
}
} else if (key.equalsIgnoreCase("shadowing")) {
addStyle(PName.Shadowing, getShadowingValue(value, counter), SName.root);
} else if (key.equalsIgnoreCase("noteshadowing")) {
addStyle(PName.Shadowing, getShadowingValue(value, counter), SName.root, SName.note);
if (datas == null) {
if (key.equalsIgnoreCase("shadowing"))
addStyle(PName.Shadowing, getShadowingValue(value, counter), SName.root);
else if (key.equalsIgnoreCase("noteshadowing"))
addStyle(PName.Shadowing, getShadowingValue(value, counter), SName.root, SName.note);
return;
}
final boolean complex = value.contains(";");
if (complex) {
// System.err.println("key=" + key + " value=" + value);
final StringTokenizer st = new StringTokenizer(value, ";");
value = st.nextToken();
while (st.hasMoreTokens()) {
final String read = st.nextToken();
// System.err.println("read:" + read);
if (read.startsWith("text:")) {
final String value2 = read.split(":")[1];
for (Data data : datas)
addStyle(PName.FontColor, ValueImpl.regular(value2, counter), data.styleNames);
} else if (read.startsWith("line.dotted")) {
for (Data data : datas)
addStyle(PName.LineStyle, ValueImpl.regular("1;3", counter), data.styleNames);
} else if (read.startsWith("line.dashed")) {
for (Data data : datas)
addStyle(PName.LineStyle, ValueImpl.regular("7;7", counter), data.styleNames);
}
}
}
for (Data data : datas)
addStyle(data.propertyName, ValueImpl.regular(value, counter), data.styleNames);
}
private ValueImpl getShadowingValue(final String value, final AutomaticCounter counter) {
if (value.equalsIgnoreCase("false") || value.equalsIgnoreCase("no")) {
if (value.equalsIgnoreCase("false") || value.equalsIgnoreCase("no"))
return ValueImpl.regular("0", counter);
}
if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes")) {
if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes"))
return ValueImpl.regular("3", counter);
}
return ValueImpl.regular(value, counter);
}
@ -263,7 +309,7 @@ public class FromSkinparamToStyle {
datas = new ArrayList<>();
knowlegde.put(skinparam, datas);
}
datas.add(new Data(propertyName, styleNames));
datas.add(new Data(styleNames, propertyName));
}
private static void addConFont(String skinparam, SName... styleNames) {

View File

@ -207,8 +207,7 @@ public class HColorSimple extends HColorAbstract implements HColor {
}
public HColor withDark(HColor dark) {
return this;
// return new HColorSimple(color, monochrome, dark);
return new HColorSimple(color, monochrome, dark);
}
@Override