UNPKG

@rcsb/rcsb-saguaro

Version:
62 lines (61 loc) 2.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RcsbPinDisplay = void 0; const RcsbAbstractDisplay_1 = require("./RcsbAbstractDisplay"); const RcsbD3PinManager_1 = require("../RcsbD3/RcsbD3DisplayManager/RcsbD3PinManager"); const RcsbD3Constants_1 = require("../RcsbD3/RcsbD3Constants"); const RcsbD3ScaleFactory_1 = require("../RcsbD3/RcsbD3ScaleFactory"); class RcsbPinDisplay extends RcsbAbstractDisplay_1.RcsbAbstractDisplay { constructor() { super(...arguments); this.yScale = RcsbD3ScaleFactory_1.RcsbD3ScaleFactory.getLinearScale(); this.radius = 5; this.labelShift = 10; this.definedScale = false; this.rcsbD3PinManager = new RcsbD3PinManager_1.RcsbD3PinManager(); } yDomain(domain) { this._yDomain = domain; } 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); e.append(RcsbD3Constants_1.RcsbD3Constants.TEXT); } plot(elements) { super.plot(elements); if (!this.definedScale) this.setScale(); const config = { elements: elements, radius: this.radius, labelShift: this.labelShift, xScale: this.xScale, yScale: this.yScale, height: this.height(), color: this._displayColor }; this.rcsbD3PinManager.plot(config); } move() { const config = { xScale: this.xScale, labelShift: this.labelShift, yScale: this.yScale, height: this.height(), }; this.rcsbD3PinManager.move(config); } } exports.RcsbPinDisplay = RcsbPinDisplay;