_changeAminoAcidsGraph()

in client/client/modules/render/tracks/reference/referenceRenderer.js [187:261]


    _changeAminoAcidsGraph(viewport, aminoAcidsData, isReverse) {
        let index = 0;
        aminoAcidsData.forEach(aminoAcids => {
            const heightBlock = this._config.aminoAcidsHeight;
            let startY;
            if (this.isRenderingStartsAtMiddle) {
                startY = isReverse ?
                    this.height / 2.0 + this._config.nucleotidesHeight + index * heightBlock :
                    this.height / 2.0 - this._config.nucleotidesHeight - index * heightBlock;
            } else {
                startY = isReverse ?
                    this._config.nucleotidesHeight + index * heightBlock :
                    this.height - this._config.nucleotidesHeight - index * heightBlock;
            }

            const block = new PIXI.Graphics();
            const pixelsPerBp = viewport.factor;
            const padding = pixelsPerBp / 2.0;
            const lowScaleMarginOffset = 0.5;

            for (let i = 0; i < aminoAcids.length; i++) {
                const item = aminoAcids[i];
                const {fill} = this._getLabelStyleConfig(item);

                if (viewport.isShortenedIntronsMode && !viewport.shortenedIntronsViewport.checkFeature(item))
                    continue;
                const startX = this.correctCanvasXPosition(Math.round(this.correctedXPosition(item.xStart) - padding), viewport);
                const endX = this.correctCanvasXPosition(Math.round(this.correctedXPosition(item.xEnd) + padding), viewport);

                block.beginFill(fill, 1).lineStyle(0, fill, 0);
                block.moveTo(startX, isReverse ? startY + lowScaleMarginOffset : startY - lowScaleMarginOffset);
                block.lineTo(startX, isReverse ? startY + heightBlock : startY - heightBlock);
                block.lineTo(endX, isReverse ? startY + heightBlock : startY - heightBlock);
                block.lineTo(endX, isReverse ? startY + lowScaleMarginOffset : startY - lowScaleMarginOffset);
                block.lineTo(startX, isReverse ? startY + lowScaleMarginOffset : startY - lowScaleMarginOffset);
                block.endFill();
            }
            this.dataContainer.addChild(block);

            for (let i = 0; i < aminoAcids.length; i++) {
                const item = aminoAcids[i];
                const {labelStyle} = this._getLabelStyleConfig(item);
                if (viewport.isShortenedIntronsMode && !viewport.shortenedIntronsViewport.checkFeature(item))
                    continue;
                if (pixelsPerBp >= this._config.aminoacid.labelDisplayAfterPixelsPerBp) {
                    const label = this.labelsManager
                        ? this.labelsManager.getLabel(this._getAminoAcidText(item.value), labelStyle)
                        : undefined;
                    if (label) {
                        let labelPadding;
                        const labelWidth = label.width;
                        const labelHeight = label.height;
                        switch (item.value.toLowerCase()) {
                            case 'stop':
                                labelPadding = labelHeight / 4.0;
                                break;
                            case 'uncovered':
                                labelPadding = labelHeight / 2.0;
                                break;
                            default:
                                labelPadding = labelHeight / 2.0;
                                break;
                        }
                        label.x = this.correctCanvasXPosition(
                            Math.round(this.correctedXPosition(item.xStart) + (item.xEnd - item.xStart) / 2.0 - labelWidth / 2.0),
                            viewport
                        );
                        label.y = Math.round(isReverse ? startY + heightBlock / 2.0 - labelPadding : startY - heightBlock / 2.0 - labelPadding - 1);
                        this.dataContainer.addChild(label);
                    }
                }
            }
            index++;
        });
    }