37 lines
1 KiB
TypeScript
37 lines
1 KiB
TypeScript
|
import { svgArrows } 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);
|
||
|
}
|
||
|
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();
|
||
|
}
|
||
|
}
|