This commit is contained in:
jusax23 2023-06-28 16:06:31 +02:00
parent 484e5022d1
commit 56bd2bec6d
Signed by: jusax23
GPG key ID: 499E2AA870C1CD41
5 changed files with 19 additions and 7 deletions

View file

@ -67,6 +67,11 @@
stroke-width: 4; stroke-width: 4;
} }
.PEdge .lineText {
text-anchor: middle;
fill: black;
}
#arrowhead { #arrowhead {
z-index: -1; z-index: -1;
fill: gray; fill: gray;

View file

@ -38,11 +38,12 @@ export class Transition implements Positionable {
return true; return true;
} }
fire() { fire() {
let canFire = this.#canFireC
let canFireNow = this.canFire() let canFireNow = this.canFire()
if(this.#canFireC && !canFireNow){ if(canFire && !canFireNow){
// TODO: koflikt. // TODO: koflikt.
} }
if (!this.#canFireC || !canFireNow) return false; if (!canFire || !canFireNow) return false;
for (const inE of this.inEdges) { for (const inE of this.inEdges) {
inE.suck(); inE.suck();
} }

View file

@ -16,12 +16,11 @@ export class SVGArrow implements HTMLappendIt {
this.line.setAttribute('marker-end', "url(#arrowhead)"); this.line.setAttribute('marker-end', "url(#arrowhead)");
this.group.setAttribute('transform', `translate(0, 0)`); this.group.setAttribute('transform', `translate(0, 0)`);
// Create the text inside the circle
this.lineText = document.createElementNS(svgNamespace, 'text'); this.lineText = document.createElementNS(svgNamespace, 'text');
this.lineText.classList.add("lineText"); this.lineText.classList.add("lineText");
this.lineText.setAttribute('x', '0'); this.lineText.setAttribute('x', '0');
this.lineText.setAttribute('y', '0'); this.lineText.setAttribute('y', '0');
this.lineText.textContent = ""; this.lineText.textContent = "1";
this.group.appendChild(this.line); this.group.appendChild(this.line);
this.group.appendChild(this.lineText); this.group.appendChild(this.lineText);
@ -38,6 +37,8 @@ export class SVGArrow implements HTMLappendIt {
this.line.setAttribute('y1', (this.from.y + dy * 30) + ""); this.line.setAttribute('y1', (this.from.y + dy * 30) + "");
this.line.setAttribute('x2', (this.to.x - dx * 40) + ""); this.line.setAttribute('x2', (this.to.x - dx * 40) + "");
this.line.setAttribute('y2', (this.to.y - dy * 40) + ""); this.line.setAttribute('y2', (this.to.y - dy * 40) + "");
this.lineText.setAttribute('x', this.from.x + dx / 2 + "");
this.lineText.setAttribute('y', this.from.y + dy / 2 + "");
} }
appendIt(svg) { appendIt(svg) {
svg.appendChild(this.group); svg.appendChild(this.group);

View file

@ -12,11 +12,16 @@ export class Tragable {
initTrag(element: SVGElement) { initTrag(element: SVGElement) {
let svg = Tragable.getRootSVG(element); let svg = Tragable.getRootSVG(element);
let selected = false; let selected = false;
let moved = true;
element.addEventListener('mousedown', () => { element.addEventListener('mousedown', () => {
selected = true; selected = true;
moved = false;
}); });
svg.addEventListener('mousemove', event => { svg.addEventListener('mousemove', event => {
if (selected) this.#moveCB(event); if (selected) {
moved = true;
this.#moveCB(event);
}
}); });
svg.addEventListener('mouseup', () => { svg.addEventListener('mouseup', () => {
selected = false; selected = false;
@ -25,7 +30,7 @@ export class Tragable {
selected = false; selected = false;
}); });
element.addEventListener('click', event => { element.addEventListener('click', event => {
if (!selected) this.#clickCB(event); if (!selected && !moved) this.#clickCB(event);
}); });
} }

View file

@ -15,7 +15,7 @@ svg.appendChild(svgNodes);
let transitions: Transition[] = []; let transitions: Transition[] = [];
let nodes: Node[] = []; let nodes: Node[] = [];
async function loop() { function loop() {
for (const trans of transitions) { for (const trans of transitions) {
trans.canFire(); trans.canFire();
} }