@rcsb/rcsb-saguaro
Version:
RCSB 1D Feature Viewer
108 lines (107 loc) • 3.08 kB
JavaScript
import { Subject } from "rxjs";
export class RcsbCompositeDisplay {
constructor() {
this.innerDisplays = new Array();
this.elementSubject = {
mouseclick: new Subject(),
mouseenter: new Subject(),
mouseleave: new Subject(),
};
this.trackSubject = {
mousemove: new Subject(),
mouseenter: new Subject(),
mouseleave: new Subject()
};
}
setCompositeHeight(h) {
this.compositeHeight = h;
}
reset() {
this.innerDisplays.forEach(de => {
de.display.reset();
});
}
init(scale) {
this.innerDisplays.forEach((de) => {
de.display.init(scale, true, this.compositeHeight);
});
}
update() {
this.innerDisplays.forEach(de => {
de.display.update(de.id);
});
}
displayEmpty() {
this.innerDisplays.forEach(de => {
de.display.displayEmpty();
});
}
move() {
this.innerDisplays.forEach(de => {
de.display.move();
});
}
moveSelection(mode) {
this.innerDisplays.forEach(de => {
de.display.moveSelection(mode);
});
}
addDisplay(displayId, display) {
this.innerDisplays.push({ id: displayId, display: display });
this.trackSubject.mouseenter.subscribe(e => display.trackSubject.mouseenter.next(e));
this.trackSubject.mouseleave.subscribe(e => display.trackSubject.mouseleave.next(e));
this.trackSubject.mousemove.subscribe(e => display.trackSubject.mousemove.next(e));
}
setManagers(d3Manager, contextManager) {
this.innerDisplays.forEach(de => {
de.display.setManagers(d3Manager, contextManager);
});
}
setBoardHighlight(f) {
this.innerDisplays.forEach(de => {
de.display.setBoardHighlight(f);
});
}
subscribeElementHighlight(action) {
this.innerDisplays.forEach(de => {
de.display.subscribeElementHighlight(action);
});
}
height(h) {
if (typeof h === "number") {
this._height = h;
}
this.innerDisplays.forEach(de => {
de.display.height(h);
});
return this._height;
}
trackColor(c) {
if (typeof c === "string") {
this._bgColor = c;
}
this.innerDisplays.forEach(de => {
de.display.trackColor(c);
});
return this._bgColor;
}
data(d) {
if (d != undefined) {
const e = d;
this._data = e;
this.innerDisplays.forEach(de => {
const deData = e.get(de.id);
if (deData != undefined)
de.display.data(deData);
});
}
return this._data;
}
highlightRegion(d, options) {
if (this.innerDisplays.length > 0) {
this.innerDisplays[0].display.highlightRegion(d, options);
}
}
setDisplayColor(color) {
}
}