UNPKG

@rcsb/rcsb-saguaro

Version:
114 lines (113 loc) 3.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RcsbAbstractTrack = void 0; const tslib_1 = require("tslib"); const classes = tslib_1.__importStar(require("../../scss/RcsbBoard.module.scss")); const rxjs_1 = require("rxjs"); class RcsbAbstractTrack { constructor() { this._bgColor = "#FFFFFF"; this.trackSubject = { mousemove: new rxjs_1.Subject(), mouseenter: new rxjs_1.Subject(), mouseleave: new rxjs_1.Subject() }; this.dataUpdatedFlag = false; } height(h) { if (typeof h === "number") { this._height = h; } return this._height; } trackColor(c) { if (typeof c === "string") { this._bgColor = c; } return this._bgColor; } init(scale, compositeFlag, compositeHeight) { this.xScale = scale; if (this.g != null) { this.g.remove(); } let height = this._height; let compH = 0; if (compositeFlag === true) { height = 0; if (typeof compositeHeight === "number") compH = compositeHeight; else height = 0; } const config = { trackClass: classes.rcsbTrack, height: height, compositeHeight: compH, bgColor: this._bgColor }; this.g = this.d3Manager.addTrack(config); } data(d) { if (d != null) { const e = d; if (e != null) { this._data = e; this.setDataUpdated(false); } } return this._data; } setDataUpdated(flag) { this.dataUpdatedFlag = flag; } isDataUpdated() { return this.dataUpdatedFlag; } setUpdateDataOnMove(f) { this.updateDataOnMove = f; } setBoardHighlight(f) { this.boardHighlight = f; } getBoardHighlight() { return this.boardHighlight; } setManagers(d3Manager, contextManager) { this.d3Manager = d3Manager; this.contextManager = contextManager; } highlightRegion(d, options) { var _a, _b; const height = this._height; const xScale = this.xScale; if (d != null) { (_a = this.highlightRegionTask) === null || _a === void 0 ? void 0 : _a.unsubscribe(); const highlightRegConfig = { trackG: this.g, height: height, xScale: xScale, rectClass: (_b = options === null || options === void 0 ? void 0 : options.rectClass) !== null && _b !== void 0 ? _b : classes.rcsbSelectRect, color: options === null || options === void 0 ? void 0 : options.color, elements: d }; this.d3Manager.highlightRegion(highlightRegConfig); } else { this.highlightRegionTask = rxjs_1.asyncScheduler.schedule(() => { var _a; this.g.selectAll("." + ((_a = options === null || options === void 0 ? void 0 : options.rectClass) !== null && _a !== void 0 ? _a : classes.rcsbSelectRect)).remove(); }, 10); } } moveSelection(mode) { const xScale = this.xScale; const moveSelectionConfig = { trackG: this.g, xScale: xScale, rectClass: mode === 'select' ? classes.rcsbSelectRect : classes.rcsbHoverRect }; this.d3Manager.moveSelection(moveSelectionConfig); } } exports.RcsbAbstractTrack = RcsbAbstractTrack;