2022-05-07 16:54:28 +02:00
|
|
|
const DURATION = 500;
|
|
|
|
|
2022-05-15 17:53:12 +02:00
|
|
|
class Record {
|
|
|
|
constructor(tree, message) {
|
|
|
|
this.tree = tree;
|
|
|
|
this.message = message;
|
|
|
|
}
|
|
|
|
|
|
|
|
render(graph, textBox) {
|
|
|
|
graph.renderDot(this.tree);
|
|
|
|
if (textBox) {
|
|
|
|
textBox.textContent = this.message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-07 16:54:28 +02:00
|
|
|
class Recorder {
|
2022-05-15 17:53:12 +02:00
|
|
|
constructor(graph, textBox, id) {
|
2022-05-07 16:54:28 +02:00
|
|
|
this.graph = graph;
|
2022-05-15 17:53:12 +02:00
|
|
|
this.textBox = textBox;
|
2022-05-07 16:54:28 +02:00
|
|
|
this.id = id;
|
|
|
|
|
|
|
|
this.rendered = -1;
|
|
|
|
this.rendering = false;
|
|
|
|
this.atOnce = false;
|
|
|
|
|
|
|
|
this.states = new Array();
|
|
|
|
|
|
|
|
this.initGraph();
|
|
|
|
}
|
|
|
|
|
|
|
|
renderAtOnce() {
|
|
|
|
this.atOnce = true;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
unblockRendering() {
|
|
|
|
this.rendering = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
initGraph() {
|
|
|
|
this.graph.transition(() =>
|
|
|
|
d3
|
|
|
|
.transition("main")
|
|
|
|
.ease(d3.easeLinear)
|
|
|
|
.on("end", this.unblockRendering.bind(this))
|
|
|
|
.delay(500)
|
|
|
|
.duration(DURATION)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
if (this.atOnce) {
|
|
|
|
if (this.rendered != this.states.length - 1) {
|
|
|
|
this.rendered = this.states.length - 1;
|
2022-05-15 17:53:12 +02:00
|
|
|
this.states[this.rendered].render(this.graph, this.textBox);
|
2022-05-07 16:54:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
this.rendering ||
|
|
|
|
!this.states ||
|
|
|
|
this.rendered == this.states.length - 1
|
|
|
|
) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.rendering = true;
|
|
|
|
|
|
|
|
this.rendered++;
|
2022-05-15 17:53:12 +02:00
|
|
|
this.states[this.rendered].render(this.graph, this.textBox);
|
2022-05-07 16:54:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
previous() {
|
|
|
|
throw "not implemented!";
|
|
|
|
}
|
|
|
|
|
|
|
|
next() {
|
|
|
|
throw "not implemented!";
|
|
|
|
}
|
|
|
|
|
2022-05-15 17:53:12 +02:00
|
|
|
record(tree, message) {
|
2022-05-07 16:54:28 +02:00
|
|
|
// TODO: adjust join if necessary
|
2022-05-15 17:53:12 +02:00
|
|
|
this.states.push(new Record(tree.toDot().join(""), message));
|
2022-05-07 16:54:28 +02:00
|
|
|
this.render();
|
|
|
|
}
|
|
|
|
}
|