fix class shape in sequence diagram render

This commit is contained in:
Alexander Wang 2023-02-24 20:17:09 -08:00
parent 1fcb075e04
commit 4411fbdabc
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
6 changed files with 285 additions and 6 deletions

View file

@ -338,6 +338,12 @@ func (l ContainerLevel) LabelSize() int {
func (obj *Object) GetFill() string {
level := int(obj.Level())
shape := obj.Attributes.Shape.Value
if strings.EqualFold(shape, d2target.ShapeSQLTable) || strings.EqualFold(shape, d2target.ShapeClass) {
return color.N1
}
if obj.IsSequenceDiagramNote() {
return color.N7
} else if obj.IsSequenceDiagramGroup() {
@ -366,8 +372,6 @@ func (obj *Object) GetFill() string {
return color.N7
}
shape := obj.Attributes.Shape.Value
if shape == "" || strings.EqualFold(shape, d2target.ShapeSquare) || strings.EqualFold(shape, d2target.ShapeCircle) || strings.EqualFold(shape, d2target.ShapeOval) || strings.EqualFold(shape, d2target.ShapeRectangle) {
if level == 1 {
if !obj.IsContainer() {
@ -409,10 +413,6 @@ func (obj *Object) GetFill() string {
return color.N5
}
if strings.EqualFold(shape, d2target.ShapeSQLTable) || strings.EqualFold(shape, d2target.ShapeClass) {
return color.N1
}
return color.N7
}

View file

@ -39,6 +39,17 @@ group.nested: {
`,
expErr: "no actors declared in sequence diagram",
},
{
name: "class_font_style_sequence",
script: `shape: sequence_diagram
a: {
shape: class
style: {
font-color: red
}
}
`,
},
{
name: "nested_steps",
script: `a: {

View file

@ -0,0 +1,91 @@
{
"name": "",
"fontFamily": "SourceSansPro",
"shapes": [
{
"id": "a",
"type": "class",
"pos": {
"x": 12,
"y": 52
},
"width": 117,
"height": 92,
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "N1",
"stroke": "N7",
"shadow": false,
"3d": false,
"multiple": false,
"double-border": false,
"tooltip": "",
"link": "",
"icon": null,
"iconPosition": "",
"blend": false,
"fields": null,
"methods": null,
"columns": null,
"label": "a",
"fontSize": 20,
"fontFamily": "DEFAULT",
"language": "",
"color": "red",
"italic": false,
"bold": false,
"underline": false,
"labelWidth": 12,
"labelHeight": 31,
"labelPosition": "INSIDE_MIDDLE_CENTER",
"zIndex": 0,
"level": 1,
"primaryAccentColor": "B2",
"secondaryAccentColor": "AA2",
"neutralAccentColor": "N2"
}
],
"connections": [
{
"id": "(a -- )[0]",
"src": "a",
"srcArrow": "none",
"srcLabel": "",
"dst": "a-lifeline-end-2251863791",
"dstArrow": "none",
"dstLabel": "",
"opacity": 1,
"strokeDash": 6,
"strokeWidth": 2,
"stroke": "B2",
"label": "",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "N2",
"italic": true,
"bold": false,
"underline": false,
"labelWidth": 0,
"labelHeight": 0,
"labelPosition": "",
"labelPercentage": 0,
"route": [
{
"x": 70.5,
"y": 144
},
{
"x": 70.5,
"y": 214
}
],
"animated": false,
"tooltip": "",
"icon": null,
"zIndex": 1
}
]
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 186 KiB

View file

@ -0,0 +1,91 @@
{
"name": "",
"fontFamily": "SourceSansPro",
"shapes": [
{
"id": "a",
"type": "class",
"pos": {
"x": 12,
"y": 52
},
"width": 117,
"height": 92,
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "N1",
"stroke": "N7",
"shadow": false,
"3d": false,
"multiple": false,
"double-border": false,
"tooltip": "",
"link": "",
"icon": null,
"iconPosition": "",
"blend": false,
"fields": null,
"methods": null,
"columns": null,
"label": "a",
"fontSize": 20,
"fontFamily": "DEFAULT",
"language": "",
"color": "red",
"italic": false,
"bold": false,
"underline": false,
"labelWidth": 12,
"labelHeight": 31,
"labelPosition": "INSIDE_MIDDLE_CENTER",
"zIndex": 0,
"level": 1,
"primaryAccentColor": "B2",
"secondaryAccentColor": "AA2",
"neutralAccentColor": "N2"
}
],
"connections": [
{
"id": "(a -- )[0]",
"src": "a",
"srcArrow": "none",
"srcLabel": "",
"dst": "a-lifeline-end-2251863791",
"dstArrow": "none",
"dstLabel": "",
"opacity": 1,
"strokeDash": 6,
"strokeWidth": 2,
"stroke": "B2",
"label": "",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "N2",
"italic": true,
"bold": false,
"underline": false,
"labelWidth": 0,
"labelHeight": 0,
"labelPosition": "",
"labelPercentage": 0,
"route": [
{
"x": 70.5,
"y": 144
},
{
"x": 70.5,
"y": 214
}
],
"animated": false,
"tooltip": "",
"icon": null,
"zIndex": 1
}
]
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 186 KiB