Add vertical pad to activation boxes
This commit is contained in:
parent
a0c0546059
commit
d002531768
3 changed files with 7 additions and 3 deletions
|
|
@ -15,7 +15,7 @@ const MIN_EDGE_DISTANCE = 100.
|
||||||
const ACTIVATION_BOX_WIDTH = 20.
|
const ACTIVATION_BOX_WIDTH = 20.
|
||||||
|
|
||||||
// small pad so that edges don't touch lifelines and activation boxes
|
// small pad so that edges don't touch lifelines and activation boxes
|
||||||
const ACTIVATION_BOX_EDGE_PAD = 2.
|
const ACTIVATION_BOX_EDGE_PAD = 5.
|
||||||
|
|
||||||
// as the activation boxes start getting nested, their size grows
|
// as the activation boxes start getting nested, their size grows
|
||||||
const ACTIVATION_BOX_DEPTH_GROW_FACTOR = 10.
|
const ACTIVATION_BOX_DEPTH_GROW_FACTOR = 10.
|
||||||
|
|
|
||||||
|
|
@ -203,10 +203,14 @@ func (sd *sequenceDiagram) placeActivationBoxes() {
|
||||||
minY := math.Min(minEdgeY, minChildY)
|
minY := math.Min(minEdgeY, minChildY)
|
||||||
if minY == minChildY {
|
if minY == minChildY {
|
||||||
minY -= ACTIVATION_BOX_DEPTH_GROW_FACTOR
|
minY -= ACTIVATION_BOX_DEPTH_GROW_FACTOR
|
||||||
|
} else {
|
||||||
|
minY -= ACTIVATION_BOX_EDGE_PAD
|
||||||
}
|
}
|
||||||
maxY := math.Max(maxEdgeY, maxChildY)
|
maxY := math.Max(maxEdgeY, maxChildY)
|
||||||
if maxY == maxChildY {
|
if maxY == maxChildY {
|
||||||
maxY += ACTIVATION_BOX_DEPTH_GROW_FACTOR
|
maxY += ACTIVATION_BOX_DEPTH_GROW_FACTOR
|
||||||
|
} else {
|
||||||
|
maxY += ACTIVATION_BOX_EDGE_PAD
|
||||||
}
|
}
|
||||||
|
|
||||||
height := math.Max(maxY-minY, DEFAULT_ACTIVATION_BOX_HEIGHT)
|
height := math.Max(maxY-minY, DEFAULT_ACTIVATION_BOX_HEIGHT)
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ func TestActivationBoxesSequenceDiagram(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Y diff of the 2 first edges
|
// Y diff of the 2 first edges
|
||||||
expectedHeight := g.Edges[1].Route[0].Y - g.Edges[0].Route[0].Y
|
expectedHeight := g.Edges[1].Route[0].Y - g.Edges[0].Route[0].Y + (2 * ACTIVATION_BOX_EDGE_PAD)
|
||||||
if a_t1.Height != expectedHeight {
|
if a_t1.Height != expectedHeight {
|
||||||
t.Fatalf("expected a.t1 height to be %.5f, got %.5f", expectedHeight, a_t1.Height)
|
t.Fatalf("expected a.t1 height to be %.5f, got %.5f", expectedHeight, a_t1.Height)
|
||||||
}
|
}
|
||||||
|
|
@ -231,7 +231,7 @@ func TestActivationBoxesSequenceDiagram(t *testing.T) {
|
||||||
if a_t1.TopLeft.Y != b_t1.TopLeft.Y {
|
if a_t1.TopLeft.Y != b_t1.TopLeft.Y {
|
||||||
t.Fatal("expected a.t1 and b.t1 to be placed at the same Y")
|
t.Fatal("expected a.t1 and b.t1 to be placed at the same Y")
|
||||||
}
|
}
|
||||||
if a_t1.TopLeft.Y != g.Edges[0].Route[0].Y {
|
if a_t1.TopLeft.Y != g.Edges[0].Route[0].Y-ACTIVATION_BOX_EDGE_PAD {
|
||||||
t.Fatal("expected a.t1 to be placed at the same Y of the first edge")
|
t.Fatal("expected a.t1 to be placed at the same Y of the first edge")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue