import { svgArrows, update } from ".."; import { SVGArrow } from "../graphics/SVGArrow"; import { Node } from "./Node"; import { Transition } from "./Transition"; export class Edge { renderedElement: SVGArrow; end: Node; trans: Transition; inEdge: boolean; dimension = 1; constructor(end: Node, trans: Transition, inEdge = true) { this.end = end; this.trans = trans; this.inEdge = inEdge; this.renderedElement = inEdge ? new SVGArrow(end, trans) : new SVGArrow(trans, end); this.renderedElement.appendIt(svgArrows); end.updateList.push(this); this.renderedElement.onClick(() => { let aws = parseInt(prompt("Gebe die Dimension ein:", this.dimension + "") || ""); if (isNaN(aws) || !isFinite(aws) || aws < 1) return; this.dimension = aws; this.renderedElement.setDimension(aws + ""); update(); }) } canSuck() { return this.end.marks >= this.dimension; } suck() { this.end.marks -= this.dimension; this.end.updatePoints(); } canPush() { return this.end.capacity >= this.end.marks + this.dimension; } push() { this.end.marks += this.dimension; this.end.updatePoints(); } updatePosition() { this.renderedElement.updatePosition(); } }