All files / app/codeCharta/ui/codeMap/threeViewer/floorLabels floorLabelHelper.ts

100% Statements 8/8
100% Branches 4/4
100% Functions 3/3
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24      51x   51x   10x   10x   10x       10x 10x       31x      
"use strict"
 
import { Node } from "../../../../codeCharta.model"
import { HIERARCHY_LEVELS_WITH_LABLES_UPPER_BOUNDARY } from "../../../../util/algorithm/treeMapLayout/treeMapGenerator"
 
export class FloorLabelHelper {
    static getMapResolutionScaling(mapWidth: number) {
        const { width: displayWidth } = <HTMLCanvasElement>document.getElementById("codeMapScene")
 
        const scalingThreshold = FloorLabelHelper.getScalingThreshold(displayWidth)
 
        return mapWidth > scalingThreshold ? scalingThreshold / mapWidth : 1
    }
 
    private static getScalingThreshold(displayWidth: number) {
        const fullHdPlusWidth = 2560
        return Math.min(displayWidth * 4, fullHdPlusWidth * 4)
    }
 
    static isLabelNode(node: Node) {
        return !node.isLeaf && node.mapNodeDepth < HIERARCHY_LEVELS_WITH_LABLES_UPPER_BOUNDARY
    }
}