fix unlabelled circle/square with desired width/height
This commit is contained in:
parent
9d1aeebfea
commit
c4db001781
1 changed files with 23 additions and 12 deletions
|
|
@ -1093,10 +1093,21 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler
|
||||||
desiredHeight, _ = strconv.Atoi(obj.Attributes.Height.Value)
|
desiredHeight, _ = strconv.Atoi(obj.Attributes.Height.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dslShape := strings.ToLower(obj.Attributes.Shape.Value)
|
||||||
|
|
||||||
if obj.Attributes.Label.Value == "" &&
|
if obj.Attributes.Label.Value == "" &&
|
||||||
obj.Attributes.Shape.Value != d2target.ShapeImage &&
|
dslShape != d2target.ShapeImage &&
|
||||||
obj.Attributes.Shape.Value != d2target.ShapeSQLTable &&
|
dslShape != d2target.ShapeSQLTable &&
|
||||||
obj.Attributes.Shape.Value != d2target.ShapeClass {
|
dslShape != d2target.ShapeClass {
|
||||||
|
|
||||||
|
if dslShape == d2target.ShapeCircle || dslShape == d2target.ShapeSquare {
|
||||||
|
sideLength := DEFAULT_SHAPE_SIZE
|
||||||
|
if desiredWidth != 0 || desiredHeight != 0 {
|
||||||
|
sideLength = math.Max(float64(desiredWidth), float64(desiredHeight))
|
||||||
|
}
|
||||||
|
obj.Width = sideLength
|
||||||
|
obj.Height = sideLength
|
||||||
|
} else {
|
||||||
obj.Width = DEFAULT_SHAPE_SIZE
|
obj.Width = DEFAULT_SHAPE_SIZE
|
||||||
obj.Height = DEFAULT_SHAPE_SIZE
|
obj.Height = DEFAULT_SHAPE_SIZE
|
||||||
if desiredWidth != 0 {
|
if desiredWidth != 0 {
|
||||||
|
|
@ -1105,10 +1116,10 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler
|
||||||
if desiredHeight != 0 {
|
if desiredHeight != 0 {
|
||||||
obj.Height = float64(desiredHeight)
|
obj.Height = float64(desiredHeight)
|
||||||
}
|
}
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dslShape := strings.ToLower(obj.Attributes.Shape.Value)
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
labelDims, err := obj.GetLabelSize(mtexts, ruler, fontFamily)
|
labelDims, err := obj.GetLabelSize(mtexts, ruler, fontFamily)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue