All files / app/codeCharta/util/algorithm/streetLayout boundingBox.ts

91.66% Statements 11/12
100% Branches 0/0
66.66% Functions 2/3
91.66% Lines 11/12

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 25 26 27 28 29 3017x   17x   17x 14x 14x     14x     14x                     8x 8x 8x 8x      
import { Vector2 } from "three"
import { CodeMapNode } from "../../../codeCharta.model"
import Rectangle from "./rectangle"
 
export default abstract class BoundingBox {
    height = 0
    width = 0
    mapNode: CodeMapNode
    protected metricValue: number
    protected FIXED_MARGIN = 0.5
 
    constructor(mapNode: CodeMapNode) {
        this.mapNode = mapNode
    }
 
    getNode() {
        return this.mapNode
    }
 
    abstract calculateDimension(metricName: string): void
    abstract layout(margin: number, origin: Vector2): CodeMapNode[]
 
    protected createMarginatedRectangle(origin: Vector2) {
        const newOrigin = new Vector2(origin.x + this.FIXED_MARGIN, origin.y + this.FIXED_MARGIN)
        const width = this.width - 2 * this.FIXED_MARGIN
        const height = this.height - 2 * this.FIXED_MARGIN
        return new Rectangle(newOrigin, width, height)
    }
}