import VectorType from '../enum/VectorType.js'
import Geometry from './Geometry.js'
import { coordinate } from '../Coordinate'
import Style from '../Style.js'

const defaultValue = '某某案发现场';
export default class Title extends Geometry {
    constructor(value,vectorId, floor) {
        super()
        this.value = value?value:defaultValue;
        this.height = 50     //里顶部距离50像素
        this.floor = floor?floor:0
        this.geoType = VectorType.Title
        this.setId(vectorId)
    }

    setValue(value){
        this.value = value
    }

    isContain(position) {
        const point = coordinate.getScreenXY(position)
        if(point.y>this.height-Style.Title.fontSize && point.y<this.height+Style.Title.fontSize){
            if(point.x > coordinate.width/2 - this.value.length * Style.Title.fontSize && point.x < coordinate.width/2 + this.value.length * Style.Title.fontSize){
                return true;
            }
        }
        return false;
    }
}
