mirror of
https://github.com/octoleo/plantuml.git
synced 2025-04-10 20:21:49 +00:00
Change default theme for YAML and JSON
This commit is contained in:
parent
160a356c68
commit
d14f00fdbf
1
pom.xml
1
pom.xml
@ -136,6 +136,7 @@
|
|||||||
<include>net/sourceforge/plantuml/dedication/*.png</include>
|
<include>net/sourceforge/plantuml/dedication/*.png</include>
|
||||||
<include>net/sourceforge/plantuml/math/*.js</include>
|
<include>net/sourceforge/plantuml/math/*.js</include>
|
||||||
<include>net/sourceforge/plantuml/windowsdot/*.dat</include>
|
<include>net/sourceforge/plantuml/windowsdot/*.dat</include>
|
||||||
|
<include>net/sourceforge/plantuml/utils/*.txt</include>
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
<resource>
|
<resource>
|
||||||
|
@ -323,7 +323,10 @@ usecase {
|
|||||||
HorizontalAlignment center
|
HorizontalAlignment center
|
||||||
}
|
}
|
||||||
|
|
||||||
yamlDiagram {
|
yamlDiagram,jsonDiagram {
|
||||||
|
BackGroundColor white
|
||||||
|
FontColor black
|
||||||
|
LineColor black
|
||||||
arrow {
|
arrow {
|
||||||
LineThickness 1
|
LineThickness 1
|
||||||
LineStyle 3;3
|
LineStyle 3;3
|
||||||
@ -333,25 +336,9 @@ yamlDiagram {
|
|||||||
RoundCorner 10
|
RoundCorner 10
|
||||||
separator {
|
separator {
|
||||||
LineThickness 1
|
LineThickness 1
|
||||||
LineColor #A80036
|
|
||||||
}
|
}
|
||||||
highlight {
|
header {
|
||||||
BackGroundColor #ccff02
|
FontStyle bold
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonDiagram {
|
|
||||||
arrow {
|
|
||||||
LineThickness 1
|
|
||||||
LineStyle 3;3
|
|
||||||
}
|
|
||||||
node {
|
|
||||||
LineThickness 1.5
|
|
||||||
RoundCorner 10
|
|
||||||
separator {
|
|
||||||
LineThickness 1
|
|
||||||
LineColor #A80036
|
|
||||||
}
|
}
|
||||||
highlight {
|
highlight {
|
||||||
BackGroundColor #ccff02
|
BackGroundColor #ccff02
|
||||||
|
@ -109,16 +109,22 @@ public class SmetanaForJson {
|
|||||||
this.ug = ug;
|
this.ug = ug;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UGraphic getUgFor(SName name) {
|
|
||||||
return getStyle(name).applyStrokeAndLineColor(ug, skinParam.getIHtmlColorSet(), skinParam.getThemeStyle());
|
|
||||||
}
|
|
||||||
|
|
||||||
private SName getDiagramType() {
|
private SName getDiagramType() {
|
||||||
return skinParam.getUmlDiagramType() == UmlDiagramType.YAML ? SName.yamlDiagram : SName.jsonDiagram;
|
return skinParam.getUmlDiagramType() == UmlDiagramType.YAML ? SName.yamlDiagram : SName.jsonDiagram;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Style getStyle(SName name) {
|
private Style getStyleArrow() {
|
||||||
return StyleSignature.of(SName.root, SName.element, getDiagramType(), name)
|
return StyleSignature.of(SName.root, SName.element, getDiagramType(), SName.arrow)
|
||||||
|
.getMergedStyle(skinParam.getCurrentStyleBuilder());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Style getStyleNode() {
|
||||||
|
return StyleSignature.of(SName.root, SName.element, getDiagramType(), SName.node)
|
||||||
|
.getMergedStyle(skinParam.getCurrentStyleBuilder());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Style getStyleNodeHeader() {
|
||||||
|
return StyleSignature.of(SName.root, SName.element, getDiagramType(), SName.header, SName.node)
|
||||||
.getMergedStyle(skinParam.getCurrentStyleBuilder());
|
.getMergedStyle(skinParam.getCurrentStyleBuilder());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,9 +133,14 @@ public class SmetanaForJson {
|
|||||||
.getMergedStyle(skinParam.getCurrentStyleBuilder());
|
.getMergedStyle(skinParam.getCurrentStyleBuilder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Style getStyleNodeHeaderHighlight() {
|
||||||
|
return StyleSignature.of(SName.root, SName.element, getDiagramType(), SName.header, SName.node, SName.highlight)
|
||||||
|
.getMergedStyle(skinParam.getCurrentStyleBuilder());
|
||||||
|
}
|
||||||
|
|
||||||
private ST_Agnode_s manageOneNode(JsonValue current, List<String> highlighted) {
|
private ST_Agnode_s manageOneNode(JsonValue current, List<String> highlighted) {
|
||||||
final TextBlockJson block = new TextBlockJson(skinParam, current, highlighted, getStyle(SName.node),
|
final TextBlockJson block = new TextBlockJson(skinParam, current, highlighted, getStyleNode(),
|
||||||
getStyleNodeHighlight());
|
getStyleNodeHighlight(), getStyleNodeHeader(), getStyleNodeHeaderHighlight());
|
||||||
final ST_Agnode_s node1 = createNode(block.calculateDimension(stringBounder), block.size(), current.isArray(),
|
final ST_Agnode_s node1 = createNode(block.calculateDimension(stringBounder), block.size(), current.isArray(),
|
||||||
(int) block.getWidthColA(stringBounder), (int) block.getWidthColB(stringBounder));
|
(int) block.getWidthColA(stringBounder), (int) block.getWidthColB(stringBounder));
|
||||||
nodes.add(new InternalNode(block, node1));
|
nodes.add(new InternalNode(block, node1));
|
||||||
@ -171,16 +182,20 @@ public class SmetanaForJson {
|
|||||||
xMirror = new Mirror(max);
|
xMirror = new Mirror(max);
|
||||||
|
|
||||||
for (InternalNode node : nodes) {
|
for (InternalNode node : nodes) {
|
||||||
node.block.drawU(getUgFor(SName.node).apply(getPosition(node.node)));
|
node.block.drawU(
|
||||||
|
getStyleNode().applyStrokeAndLineColor(ug, skinParam.getIHtmlColorSet(), skinParam.getThemeStyle())
|
||||||
|
.apply(getPosition(node.node)));
|
||||||
}
|
}
|
||||||
final HColor color = getStyle(SName.arrow).value(PName.LineColor).asColor(skinParam.getThemeStyle(),
|
final HColor color = getStyleArrow().value(PName.LineColor).asColor(skinParam.getThemeStyle(),
|
||||||
skinParam.getIHtmlColorSet());
|
skinParam.getIHtmlColorSet());
|
||||||
|
|
||||||
for (ST_Agedge_s edge : edges) {
|
for (ST_Agedge_s edge : edges) {
|
||||||
final JsonCurve curve = getCurve(edge, 13);
|
final JsonCurve curve = getCurve(edge, 13);
|
||||||
// curve.drawCurve(color, getUgFor(SName.arrow).apply(new UStroke(3, 3, 1)));
|
curve.drawCurve(color, getStyleArrow().applyStrokeAndLineColor(ug, skinParam.getIHtmlColorSet(),
|
||||||
curve.drawCurve(color, getUgFor(SName.arrow));
|
skinParam.getThemeStyle()));
|
||||||
curve.drawSpot(getUgFor(SName.arrow).apply(color.bg()));
|
curve.drawSpot(
|
||||||
|
getStyleArrow().applyStrokeAndLineColor(ug, skinParam.getIHtmlColorSet(), skinParam.getThemeStyle())
|
||||||
|
.apply(color.bg()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,8 +70,10 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol
|
|||||||
|
|
||||||
private final List<Line> lines = new ArrayList<>();
|
private final List<Line> lines = new ArrayList<>();
|
||||||
|
|
||||||
private final Style style;
|
private final Style styleNode;
|
||||||
private final Style styleHightlight;
|
private final Style styleNodeHightlight;
|
||||||
|
private final Style styleNodeHeader;
|
||||||
|
private final Style styleNodeHeaderHighlight;
|
||||||
private final ISkinParam skinParam;
|
private final ISkinParam skinParam;
|
||||||
private double totalWidth;
|
private double totalWidth;
|
||||||
private final JsonValue root;
|
private final JsonValue root;
|
||||||
@ -93,24 +95,26 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol
|
|||||||
|
|
||||||
double getHeightOfRow(StringBounder stringBounder) {
|
double getHeightOfRow(StringBounder stringBounder) {
|
||||||
final double height = b1.calculateDimension(stringBounder).getHeight();
|
final double height = b1.calculateDimension(stringBounder).getHeight();
|
||||||
if (b2 == null) {
|
if (b2 == null)
|
||||||
return height;
|
return height;
|
||||||
}
|
|
||||||
return Math.max(height, b2.calculateDimension(stringBounder).getHeight());
|
return Math.max(height, b2.calculateDimension(stringBounder).getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private HColor getBackColor() {
|
private HColor getBackColor() {
|
||||||
return styleHightlight.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(),
|
return styleNodeHightlight.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(),
|
||||||
skinParam.getIHtmlColorSet());
|
skinParam.getIHtmlColorSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextBlockJson(ISkinParam skinParam, JsonValue root, List<String> allHighlighteds, Style style,
|
TextBlockJson(ISkinParam skinParam, JsonValue root, List<String> allHighlighteds, Style styleNode,
|
||||||
Style styleHightlight) {
|
Style styleNodeHightlight, Style styleNodeHeader, Style styleNodeHeaderHighlight) {
|
||||||
this.styleHightlight = styleHightlight;
|
|
||||||
this.skinParam = skinParam;
|
this.skinParam = skinParam;
|
||||||
this.style = style;
|
this.styleNode = styleNode;
|
||||||
|
this.styleNodeHeaderHighlight = styleNodeHeaderHighlight;
|
||||||
|
this.styleNodeHightlight = styleNodeHightlight;
|
||||||
|
this.styleNodeHeader = styleNodeHeader;
|
||||||
this.root = root;
|
this.root = root;
|
||||||
if (root instanceof JsonObject)
|
if (root instanceof JsonObject)
|
||||||
for (Member member : (JsonObject) root) {
|
for (Member member : (JsonObject) root) {
|
||||||
@ -118,104 +122,105 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol
|
|||||||
final String value = getShortString(member.getValue());
|
final String value = getShortString(member.getValue());
|
||||||
|
|
||||||
final boolean highlighted = isHighlighted(key, allHighlighteds);
|
final boolean highlighted = isHighlighted(key, allHighlighteds);
|
||||||
final TextBlock block1 = getTextBlock(getRightStyle(highlighted), key);
|
final TextBlock block1 = getTextBlock(getStyleToUse(true, highlighted), key);
|
||||||
final TextBlock block2 = getTextBlock(getRightStyle(highlighted), value);
|
final TextBlock block2 = getTextBlock(getStyleToUse(false, highlighted), value);
|
||||||
this.lines.add(new Line(block1, block2, highlighted));
|
this.lines.add(new Line(block1, block2, highlighted));
|
||||||
}
|
}
|
||||||
if (root instanceof JsonArray) {
|
if (root instanceof JsonArray) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (JsonValue value : (JsonArray) root) {
|
for (JsonValue value : (JsonArray) root) {
|
||||||
final boolean highlighted = isHighlighted("" + i, allHighlighteds);
|
final boolean highlighted = isHighlighted("" + i, allHighlighteds);
|
||||||
final TextBlock block2 = getTextBlock(getRightStyle(highlighted), getShortString(value));
|
final TextBlock block2 = getTextBlock(getStyleToUse(false, highlighted), getShortString(value));
|
||||||
this.lines.add(new Line(block2, highlighted));
|
this.lines.add(new Line(block2, highlighted));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Style getRightStyle(boolean highlighted) {
|
private Style getStyleToUse(boolean header, boolean highlighted) {
|
||||||
if (highlighted) {
|
if (header && highlighted)
|
||||||
return styleHightlight;
|
return styleNodeHeaderHighlight;
|
||||||
}
|
|
||||||
return style;
|
if (highlighted)
|
||||||
|
return styleNodeHightlight;
|
||||||
|
|
||||||
|
if (header)
|
||||||
|
return styleNodeHeader;
|
||||||
|
|
||||||
|
return styleNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isHighlighted(String key, List<String> highlighted) {
|
private boolean isHighlighted(String key, List<String> highlighted) {
|
||||||
for (String tmp : highlighted) {
|
for (String tmp : highlighted)
|
||||||
if (tmp.trim().equals("\"" + key + "\"")) {
|
if (tmp.trim().equals("\"" + key + "\""))
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
if (root instanceof JsonObject) {
|
if (root instanceof JsonObject)
|
||||||
for (Member member : (JsonObject) root)
|
for (Member member : (JsonObject) root)
|
||||||
size++;
|
size++;
|
||||||
}
|
|
||||||
if (root instanceof JsonArray) {
|
if (root instanceof JsonArray)
|
||||||
for (JsonValue value : (JsonArray) root)
|
for (JsonValue value : (JsonArray) root)
|
||||||
size++;
|
size++;
|
||||||
}
|
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getShortString(JsonValue value) {
|
private String getShortString(JsonValue value) {
|
||||||
if (value.isString()) {
|
if (value.isString())
|
||||||
return value.asString();
|
return value.asString();
|
||||||
}
|
|
||||||
if (value.isNull()) {
|
if (value.isNull())
|
||||||
return "<U+2400>";
|
return "<U+2400>";
|
||||||
// return "<U+2205> null";
|
// return "<U+2205> null";
|
||||||
}
|
|
||||||
if (value.isNumber()) {
|
if (value.isNumber())
|
||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
|
||||||
if (value.isBoolean()) {
|
if (value.isBoolean())
|
||||||
if (value.isTrue()) {
|
if (value.isTrue())
|
||||||
return "<U+2611> true";
|
return "<U+2611> true";
|
||||||
} else {
|
else
|
||||||
return "<U+2610> false";
|
return "<U+2610> false";
|
||||||
}
|
|
||||||
}
|
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<JsonValue> children() {
|
public List<JsonValue> children() {
|
||||||
final List<JsonValue> result = new ArrayList<>();
|
final List<JsonValue> result = new ArrayList<>();
|
||||||
if (root instanceof JsonObject) {
|
if (root instanceof JsonObject)
|
||||||
for (Member member : (JsonObject) root) {
|
for (Member member : (JsonObject) root) {
|
||||||
final JsonValue value = member.getValue();
|
final JsonValue value = member.getValue();
|
||||||
if (value instanceof JsonObject || value instanceof JsonArray) {
|
if (value instanceof JsonObject || value instanceof JsonArray)
|
||||||
result.add(value);
|
result.add(value);
|
||||||
} else {
|
else
|
||||||
result.add(null);
|
result.add(null);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
if (root instanceof JsonArray)
|
||||||
if (root instanceof JsonArray) {
|
for (JsonValue value : (JsonArray) root)
|
||||||
for (JsonValue value : (JsonArray) root) {
|
if (value instanceof JsonObject || value instanceof JsonArray)
|
||||||
if (value instanceof JsonObject || value instanceof JsonArray) {
|
|
||||||
result.add(value);
|
result.add(value);
|
||||||
} else {
|
else
|
||||||
result.add(null);
|
result.add(null);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Collections.unmodifiableList(result);
|
return Collections.unmodifiableList(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> keys() {
|
public List<String> keys() {
|
||||||
final List<String> result = new ArrayList<>();
|
final List<String> result = new ArrayList<>();
|
||||||
if (root instanceof JsonObject) {
|
if (root instanceof JsonObject)
|
||||||
for (Member member : (JsonObject) root) {
|
for (Member member : (JsonObject) root) {
|
||||||
final String key = member.getName();
|
final String key = member.getName();
|
||||||
result.add(key);
|
result.add(key);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (root instanceof JsonArray) {
|
if (root instanceof JsonArray) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (JsonValue value : (JsonArray) root) {
|
for (JsonValue value : (JsonArray) root) {
|
||||||
@ -233,19 +238,18 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol
|
|||||||
|
|
||||||
public double getWidthColA(StringBounder stringBounder) {
|
public double getWidthColA(StringBounder stringBounder) {
|
||||||
double width = 0;
|
double width = 0;
|
||||||
for (Line line : lines) {
|
for (Line line : lines)
|
||||||
width = Math.max(width, line.b1.calculateDimension(stringBounder).getWidth());
|
width = Math.max(width, line.b1.calculateDimension(stringBounder).getWidth());
|
||||||
}
|
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getWidthColB(StringBounder stringBounder) {
|
public double getWidthColB(StringBounder stringBounder) {
|
||||||
double width = 0;
|
double width = 0;
|
||||||
for (Line line : lines) {
|
for (Line line : lines)
|
||||||
if (line.b2 != null) {
|
if (line.b2 != null)
|
||||||
width = Math.max(width, line.b2.calculateDimension(stringBounder).getWidth());
|
width = Math.max(width, line.b2.calculateDimension(stringBounder).getWidth());
|
||||||
}
|
|
||||||
}
|
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +262,7 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol
|
|||||||
final double widthColB = getWidthColB(stringBounder);
|
final double widthColB = getWidthColB(stringBounder);
|
||||||
|
|
||||||
double y = 0;
|
double y = 0;
|
||||||
final UGraphic ugNode = style.applyStrokeAndLineColor(ug, skinParam.getIHtmlColorSet(),
|
final UGraphic ugNode = styleNode.applyStrokeAndLineColor(ug, skinParam.getIHtmlColorSet(),
|
||||||
skinParam.getThemeStyle());
|
skinParam.getThemeStyle());
|
||||||
for (Line line : lines) {
|
for (Line line : lines) {
|
||||||
final double heightOfRow = line.getHeightOfRow(stringBounder);
|
final double heightOfRow = line.getHeightOfRow(stringBounder);
|
||||||
@ -269,13 +273,13 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol
|
|||||||
if (trueWidth == 0)
|
if (trueWidth == 0)
|
||||||
trueWidth = 30;
|
trueWidth = 30;
|
||||||
|
|
||||||
final double round = style.value(PName.RoundCorner).asDouble();
|
final double round = styleNode.value(PName.RoundCorner).asDouble();
|
||||||
final URectangle fullNodeRectangle = new URectangle(trueWidth, y).rounded(round);
|
final URectangle fullNodeRectangle = new URectangle(trueWidth, y).rounded(round);
|
||||||
final HColor backColor = style.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(),
|
final HColor backColor = styleNode.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(),
|
||||||
skinParam.getIHtmlColorSet());
|
skinParam.getIHtmlColorSet());
|
||||||
ugNode.apply(backColor.bg()).apply(backColor).draw(fullNodeRectangle);
|
ugNode.apply(backColor.bg()).apply(backColor).draw(fullNodeRectangle);
|
||||||
|
|
||||||
final Style styleSeparator = style.getSignature().add(SName.separator)
|
final Style styleSeparator = styleNode.getSignature().add(SName.separator)
|
||||||
.getMergedStyle(skinParam.getCurrentStyleBuilder());
|
.getMergedStyle(skinParam.getCurrentStyleBuilder());
|
||||||
final UGraphic ugSeparator = styleSeparator.applyStrokeAndLineColor(ug, skinParam.getIHtmlColorSet(),
|
final UGraphic ugSeparator = styleSeparator.applyStrokeAndLineColor(ug, skinParam.getIHtmlColorSet(),
|
||||||
skinParam.getThemeStyle());
|
skinParam.getThemeStyle());
|
||||||
@ -292,7 +296,7 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol
|
|||||||
if (y > 0)
|
if (y > 0)
|
||||||
ugline.draw(ULine.hline(trueWidth));
|
ugline.draw(ULine.hline(trueWidth));
|
||||||
|
|
||||||
final HorizontalAlignment horizontalAlignment = style.getHorizontalAlignment();
|
final HorizontalAlignment horizontalAlignment = styleNode.getHorizontalAlignment();
|
||||||
horizontalAlignment.draw(ugline, line.b1, 0, widthColA);
|
horizontalAlignment.draw(ugline, line.b1, 0, widthColA);
|
||||||
|
|
||||||
if (line.b2 != null) {
|
if (line.b2 != null) {
|
||||||
@ -309,9 +313,9 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol
|
|||||||
|
|
||||||
private double getTotalHeight(StringBounder stringBounder) {
|
private double getTotalHeight(StringBounder stringBounder) {
|
||||||
double height = 0;
|
double height = 0;
|
||||||
for (Line line : lines) {
|
for (Line line : lines)
|
||||||
height += line.getHeightOfRow(stringBounder);
|
height += line.getHeightOfRow(stringBounder);
|
||||||
}
|
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ public class Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int beta() {
|
public static int beta() {
|
||||||
final int beta = 8;
|
final int beta = 9;
|
||||||
return beta;
|
return beta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user