Skip to content

Commit 29f435a

Browse files
committed
implement route highlight
1 parent 39929c2 commit 29f435a

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/Frontend/src/components/messages/SequenceDiagram/RoutesComponent.vue

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,28 @@ const arrows = computed(() =>
2626
const arrowIndex = fromHandler.outMessages.findIndex((out) => route.fromRoutedMessage?.messageId === out.messageId) + 1;
2727
const y = fromHandlerLocation.y + (fromHandlerLocation.height / (fromHandler.outMessages.length + 1)) * arrowIndex; //TODO work out the reason - 15 is applied in WPF;
2828
29-
const [direction, width, x] = (() => {
29+
const [direction, width, fromX] = (() => {
3030
if (fromHandlerLocation.id === toHandlerLocation.id) return [Direction.Right, 15 + Arrow_Head_Width, fromHandlerLocation.right];
3131
if (handlerLocations.value.indexOf(fromHandlerLocation) < handlerLocations.value.indexOf(toHandlerLocation)) return [Direction.Right, toHandlerLocation.left - fromHandlerLocation.right - Arrow_Head_Width, fromHandlerLocation.right];
3232
return [Direction.Left, toHandlerLocation.left - fromHandlerLocation.right - Arrow_Head_Width, toHandlerLocation.left];
3333
})();
3434
route.fromRoutedMessage.direction = direction;
3535
36+
const toX = toHandlerLocation.left + (toHandlerLocation.right - toHandlerLocation.left) / 2;
3637
const messageTypeElement = messageTypeRefs.value[index];
3738
const messageTypeElementBounds = messageTypeElement?.getBBox();
3839
3940
return {
4041
id: route.name,
41-
x,
42+
fromX,
4243
y,
4344
direction,
4445
width,
46+
toX,
47+
height: Math.abs(y - toHandlerLocation.y),
4548
type: route.fromRoutedMessage.type,
4649
messageType: route.fromRoutedMessage.name,
47-
messageTypeOffset: x + width + Arrow_Head_Width + 10, //TODO: apply using messageTypeRef if arrow is left
50+
messageTypeOffset: toX + 3, //TODO: apply using messageTypeRef if arrow is left
4851
highlight: highlightId.value === route.name,
4952
highlightTextWidth: messageTypeElementBounds?.width,
5053
highlightTextHeight: messageTypeElementBounds?.height,
@@ -60,9 +63,17 @@ function setMessageTypeRef(el: SVGTextElement, index: number) {
6063
<template>
6164
<template v-for="(arrow, i) in arrows" :key="arrow?.id">
6265
<g v-if="arrow != null">
63-
<path :d="`M${arrow.x} ${arrow.y} h${arrow.width}`" stroke-width="4" stroke="black" />
64-
<path v-if="arrow.direction === Direction.Right" :d="`M${arrow.x + arrow.width} ${arrow.y - 7.5} l10 7.5 -10,7.5z`" fill="black" />
65-
<path v-if="arrow.direction === Direction.Left" :d="`M${arrow.x - Arrow_Head_Width} ${arrow.y} l10,-7.5 0,15z`" fill="black" />
66+
<!--Main Arrow-->
67+
<g>
68+
<path :d="`M${arrow.fromX} ${arrow.y} h${arrow.width}`" stroke-width="4" stroke="black" />
69+
<path v-if="arrow.direction === Direction.Right" :d="`M${arrow.fromX + arrow.width} ${arrow.y - 7.5} l10 7.5 -10,7.5z`" fill="black" />
70+
<path v-if="arrow.direction === Direction.Left" :d="`M${arrow.fromX - Arrow_Head_Width} ${arrow.y} l10,-7.5 0,15z`" fill="black" />
71+
</g>
72+
<!--Highlight Arrow-->
73+
<g v-if="arrow.highlight" :transform="`translate(${arrow.toX},${arrow.y})`" stroke="var(--highlight)" fill="var(--highlight)">
74+
<path :d="`M0 0 v${arrow.height - 6}`" stroke-width="2" />
75+
<path :d="`M0 ${arrow.height} l-3,-6 6,0z`" />
76+
</g>
6677
<!--Message Type and Icon-->
6778
<g
6879
class="clickable"

0 commit comments

Comments
 (0)