forked from ZenUml/core
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/alignment-issues-#88-#89
- Loading branch information
Showing
4 changed files
with
105 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 33 additions & 24 deletions
57
...components/DiagramFrame/SeqDiagram/MessageLayer/Block/Statement/Fragment/FragmentMixin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,64 @@ | ||
import { Participants } from '@/parser'; | ||
import { mapGetters } from 'vuex'; | ||
import { Participants } from "@/parser"; | ||
import { mapGetters } from "vuex"; | ||
import FrameBuilder from "@/parser/FrameBuilder"; | ||
import FrameBorder from "@/positioning/FrameBorder"; | ||
import {Coordinates} from "@/positioning/Coordinates"; | ||
import WidthProviderOnBrowser from "@/positioning/WidthProviderFunc"; | ||
import {TotalWidth} from "@/components/DiagramFrame/SeqDiagram/WidthOfContext"; | ||
import CollapseButton from './CollapseButton.vue'; | ||
import EventBus from '../../../../../../../EventBus'; | ||
import { TotalWidth } from "@/components/DiagramFrame/SeqDiagram/WidthOfContext"; | ||
import CollapseButton from "./CollapseButton.vue"; | ||
import EventBus from "../../../../../../../EventBus"; | ||
|
||
export default { | ||
computed: { | ||
...mapGetters(['coordinates']), | ||
...mapGetters(["coordinates"]), | ||
offsetX: function () { | ||
const allParticipants = this.coordinates.orderedParticipantNames(); | ||
let frameBuilder = new FrameBuilder(allParticipants); | ||
const frame = frameBuilder.getFrame(this.context); | ||
const border = FrameBorder(frame); | ||
const localParticipants = [this.context.Origin(), ...Participants(this.context).Names()] | ||
const leftParticipant = allParticipants.find((p) => localParticipants.includes(p)); | ||
const localParticipants = [ | ||
this.context.Origin(), | ||
...Participants(this.context).Names(), | ||
]; | ||
const leftParticipant = allParticipants.find((p) => | ||
localParticipants.includes(p), | ||
); | ||
// TODO: consider using this.getParticipantGap(this.participantModels[0]) | ||
let halfLeftParticipant = Coordinates.half(WidthProviderOnBrowser, leftParticipant); | ||
console.debug(`left participant: ${leftParticipant} ${halfLeftParticipant}`); | ||
return this.coordinates.distance(leftParticipant, this.from) + border.left + halfLeftParticipant; | ||
let halfLeftParticipant = this.coordinates.half(leftParticipant); | ||
console.debug( | ||
`left participant: ${leftParticipant} ${halfLeftParticipant}`, | ||
); | ||
return ( | ||
this.coordinates.distance(leftParticipant, this.from) + | ||
border.left + | ||
halfLeftParticipant | ||
); | ||
}, | ||
fragmentStyle: function () { | ||
return { | ||
// +1px for the border of the fragment | ||
transform: 'translateX(' + (this.offsetX + 1) * -1 + 'px)', | ||
width: TotalWidth(this.context, this.coordinates) + 'px', | ||
transform: "translateX(" + (this.offsetX + 1) * -1 + "px)", | ||
width: TotalWidth(this.context, this.coordinates) + "px", | ||
}; | ||
}, | ||
}, | ||
data: function() { | ||
return {collapsed: false}; | ||
data: function () { | ||
return { collapsed: false }; | ||
}, | ||
methods: { | ||
toggle($event) { | ||
toggle() { | ||
this.collapsed = !this.collapsed; | ||
|
||
//update participant top in two cases: 1) has child creation statement 2) has sibling creation statement | ||
//e.g. 1): if(a) { new B } | ||
//e.g. 1): if(a) { new B } | ||
// 2): if(a) { while(b) { A.foo }; new B } | ||
EventBus.$emit('participant_set_top'); | ||
} | ||
EventBus.$emit("participant_set_top"); | ||
}, | ||
}, | ||
components: { CollapseButton }, | ||
watch: { | ||
context(v) { | ||
if(this.collapsed) { | ||
context() { | ||
if (this.collapsed) { | ||
this.collapsed = false; | ||
} | ||
} | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,55 @@ | ||
import {AllMessages} from "@/positioning/MessageContextListener"; | ||
import { AllMessages } from "@/positioning/MessageContextListener"; | ||
import WidthProviderOnBrowser from "../../../positioning/WidthProviderFunc"; | ||
import {TextType} from "@/positioning/Coordinate"; | ||
import {Participants} from "@/parser"; | ||
import { TextType } from "@/positioning/Coordinate"; | ||
import { Participants } from "@/parser"; | ||
import FrameBuilder from "@/parser/FrameBuilder"; | ||
import FrameBorder, {Frame} from "@/positioning/FrameBorder"; | ||
import {Coordinates} from "@/positioning/Coordinates"; | ||
import FrameBorder, { Frame } from "@/positioning/FrameBorder"; | ||
import { Coordinates } from "@/positioning/Coordinates"; | ||
|
||
export function TotalWidth(ctx: any, coordinates: Coordinates) { | ||
const allParticipants = coordinates.orderedParticipantNames(); | ||
const localParticipants = [ctx.Origin(),...Participants(ctx).Names()] | ||
const leftParticipant = allParticipants.find((p) => localParticipants.includes(p)) || ''; | ||
const rightParticipant = allParticipants.slice().reverse().find((p) => localParticipants.includes(p)) || ''; | ||
// console.debug(`allParticipants: ${JSON.stringify(allParticipants)}, localParticipants: ${JSON.stringify(localParticipants)}, leftParticipant: ${leftParticipant}, rightParticipant: ${rightParticipant}`); | ||
let frameBuilder = new FrameBuilder(allParticipants as string[]); | ||
const localParticipants = [ctx.Origin(), ...Participants(ctx).Names()]; | ||
const leftParticipant = | ||
allParticipants.find((p) => localParticipants.includes(p)) || ""; | ||
const rightParticipant = | ||
allParticipants | ||
.slice() | ||
.reverse() | ||
.find((p) => localParticipants.includes(p)) || ""; | ||
const frameBuilder = new FrameBuilder(allParticipants as string[]); | ||
const frame = frameBuilder.getFrame(ctx); | ||
const border = FrameBorder(frame as Frame); | ||
const extraWidth = extraWidthDueToSelfMessage(ctx, rightParticipant, coordinates); | ||
console.debug(`frame: ${JSON.stringify(frame)} extraWidth: ${extraWidth}, leftParticipant: ${leftParticipant}, rightParticipant: ${rightParticipant}, border: ${JSON.stringify(border)}`); | ||
return coordinates.distance(leftParticipant, rightParticipant) + | ||
const extraWidth = extraWidthDueToSelfMessage( | ||
ctx, | ||
rightParticipant, | ||
coordinates, | ||
); | ||
|
||
return ( | ||
coordinates.distance(leftParticipant, rightParticipant) + | ||
border.left + | ||
border.right + | ||
Coordinates.half(WidthProviderOnBrowser, leftParticipant) + | ||
Coordinates.half(WidthProviderOnBrowser, rightParticipant) + | ||
extraWidth; | ||
coordinates.half(leftParticipant) + | ||
coordinates.half(rightParticipant) + | ||
extraWidth | ||
); | ||
} | ||
|
||
function extraWidthDueToSelfMessage(ctx: any, rightParticipant: string, coordinates: Coordinates) { | ||
function extraWidthDueToSelfMessage( | ||
ctx: any, | ||
rightParticipant: string, | ||
coordinates: Coordinates, | ||
) { | ||
const allMessages = AllMessages(ctx); | ||
const widths = allMessages | ||
.filter((m) => m.from === m.to) | ||
// 37 is arrow width (30) + half occurrence width(7) | ||
.map((s) => WidthProviderOnBrowser(s.signature, TextType.MessageContent) + 37 | ||
- coordinates.distance(s.from, rightParticipant) - Coordinates.half(WidthProviderOnBrowser, rightParticipant)) | ||
.map( | ||
(s) => | ||
WidthProviderOnBrowser(s.signature, TextType.MessageContent) + | ||
37 - | ||
coordinates.distance(s.from, rightParticipant) - | ||
coordinates.half(rightParticipant), | ||
); | ||
return Math.max.apply(null, [0, ...widths]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters