render()

in client/client/modules/render/tracks/vcf/internal/renderer/expanded/features/drawing/commonVariantFeatureRenderer.js [90:192]


    render(feature, viewport, graphics, labelContainer, dockableElementsContainer, attachedElementsContainer, position) {
        super.render(feature, viewport, graphics, labelContainer, dockableElementsContainer, attachedElementsContainer, position);
        const white = 0xFFFFFF;
        const pixelsInBp = viewport.factor;
        const labelStyle = this.config.variant.allele.label;
        const symbol = this.getFeatureDisplayText(feature);
        const width = Math.max(pixelsInBp, 3);
        const height = this.config.variant.height;
        const cX = Math.round(Math.max(viewport.project.brushBP2pixel(feature.startIndex), -viewport.canvasSize));
        const cY = Math.round(position.y + position.height - height / 2);
        if (this.labelsManager) {
            const label = this.labelsManager.getLabel(symbol, labelStyle);
            if (label) {
                const textX1 = Math.max(viewport.project.brushBP2pixel(feature.startIndex), -viewport.canvasSize) - pixelsInBp / 2 - label.width / 2;
                const labelPosition = {
                    x: Math.round(textX1),
                    y: Math.round(position.y + position.height - height - label.height)
                };
                label.x = Math.round(labelPosition.x);
                label.y = Math.round(labelPosition.y);
                labelContainer.addChild(label);
                this.registerLabel(
                    label,
                    labelPosition,
                    {
                        end: feature.startIndex,
                        start: feature.startIndex,
                    },
                    false,
                    true);
            }
        }
        if (feature.highlightColor) {
            const highlightArea = this.calculateHighlightArea(feature, viewport, {
                cY: Math.floor(cY + height/2),
                height: position.height,
                pixelsInBp: pixelsInBp,
                renderContainerWidth: viewport.canvasSize
            });
            graphics.highlightGraphics
                .lineStyle(0, white, 0)
                .beginFill(feature.highlightColor, 1)
                .drawRect(highlightArea.start, highlightArea.y, highlightArea.length, highlightArea.height);
            graphics.hoveredHighlightGraphics
                .beginFill(ColorProcessor.darkenColor(feature.highlightColor), 1)
                .drawRect(highlightArea.start, highlightArea.y, highlightArea.length, highlightArea.height)
                .endFill();
        }
        graphics.graphics.lineStyle(0, white, 0);
        graphics.hoveredGraphics.lineStyle(0, white, 0);
        const zygosity = feature.zygosity;
        switch (zygosity) {
            case 1: {
                // homozygous
                graphics.graphics
                    .beginFill(this.config.variant.zygosity.homozygousColor, 1)
                    .drawRect(Math.floor(cX - width / 2), Math.floor(cY - height / 2), width, height)
                    .endFill();
                graphics.hoveredGraphics
                    .beginFill(ColorProcessor.darkenColor(this.config.variant.zygosity.homozygousColor), 1)
                    .drawRect(Math.floor(cX - width / 2), Math.floor(cY - height / 2), width, height)
                    .endFill();
            }
                break;
            case 2: {
                // heterozygous
                graphics.graphics
                    .beginFill(this.config.variant.zygosity.homozygousColor, 1)
                    .drawRect(Math.floor(cX - width / 2), Math.floor(cY - height / 2), width, height / 2)
                    .endFill();
                graphics.graphics
                    .beginFill(this.config.variant.zygosity.heterozygousColor, 1)
                    .drawRect(Math.floor(cX - width / 2), Math.floor(cY), width, height / 2)
                    .endFill();

                graphics.hoveredGraphics
                    .beginFill(ColorProcessor.darkenColor(this.config.variant.zygosity.homozygousColor), 1)
                    .drawRect(Math.floor(cX - width / 2), Math.floor(cY - height / 2), width, height / 2)
                    .endFill();
                graphics.hoveredGraphics
                    .beginFill(ColorProcessor.darkenColor(this.config.variant.zygosity.heterozygousColor), 1)
                    .drawRect(Math.floor(cX - width / 2), Math.floor(cY), width, height / 2)
                    .endFill();
            }
                break;
            default: {
                graphics.graphics
                    .beginFill(this.config.variant.zygosity.unknownColor, 1)
                    .drawRect(Math.floor(cX - width / 2), Math.floor(cY - height / 2), width, height)
                    .endFill();
                graphics.hoveredGraphics
                    .beginFill(ColorProcessor.darkenColor(this.config.variant.zygosity.unknownColor), 1)
                    .drawRect(Math.floor(cX - width / 2), Math.floor(cY - height / 2), width, height)
                    .endFill();
            }
                break;
        }
        this.registerFeature(feature, viewport, position);
        this.updateTextureCoordinates({
            x: cX - width / 2,
            y: cY - height / 2,
        });
    }