UNPKG

@rcsb/rcsb-saguaro

Version:
57 lines (56 loc) 2.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RcsbBondDisplay = void 0; const RcsbAbstractDisplay_1 = require("./RcsbAbstractDisplay"); const RcsbD3BondManager_1 = require("../RcsbD3/RcsbD3DisplayManager/RcsbD3BondManager"); const RcsbD3Constants_1 = require("../RcsbD3/RcsbD3Constants"); const RcsbD3ScaleFactory_1 = require("../RcsbD3/RcsbD3ScaleFactory"); class RcsbBondDisplay extends RcsbAbstractDisplay_1.RcsbAbstractDisplay { constructor(boardId, trackId) { super(boardId, trackId); this.yScale = RcsbD3ScaleFactory_1.RcsbD3ScaleFactory.getLinearScale(); this.radius = 5; this._yDomain = [0, 1]; this.definedScale = false; this.rcsbD3BondManager = new RcsbD3BondManager_1.RcsbD3BondManager(); } setScale() { if (typeof this.height() === "number" && this._yDomain.length == 2 && typeof this._yDomain[0] === "number" && typeof this._yDomain[1] === "number") { this.yScale .domain(this._yDomain) .range([this.radius, this.height() - this.radius]); this.definedScale = true; } else { throw "FATAL ERROR: d3 scale unknown format"; } } enter(e) { e.append(RcsbD3Constants_1.RcsbD3Constants.LINE); e.append(RcsbD3Constants_1.RcsbD3Constants.CIRCLE).classed(RcsbD3Constants_1.RcsbD3Constants.BOND_BEGIN, true); e.append(RcsbD3Constants_1.RcsbD3Constants.CIRCLE).classed(RcsbD3Constants_1.RcsbD3Constants.BOND_END, true); } plot(elements) { super.plot(elements); if (!this.definedScale) this.setScale(); const config = { elements: elements, radius: this.radius, xScale: this.xScale, yScale: this.yScale, height: this.height(), color: this._displayColor }; this.rcsbD3BondManager.plot(config); } move() { const config = { xScale: this.xScale, yScale: this.yScale, height: this.height(), }; this.rcsbD3BondManager.move(config); } } exports.RcsbBondDisplay = RcsbBondDisplay;