Title.js 1000 B

123456789101112131415161718192021222324252627282930
  1. import VectorType from '../enum/VectorType.js'
  2. import Geometry from './Geometry.js'
  3. import { coordinate } from '../Coordinate'
  4. import Style from '../Style.js'
  5. const defaultValue = '某某案发现场';
  6. export default class Title extends Geometry {
  7. constructor(value,vectorId, floor) {
  8. super()
  9. this.value = value?value:defaultValue;
  10. this.height = 50 //里顶部距离50像素
  11. this.floor = floor?floor:0
  12. this.geoType = VectorType.Title
  13. this.setId(vectorId)
  14. }
  15. setValue(value){
  16. this.value = value
  17. }
  18. isContain(position) {
  19. const point = coordinate.getScreenXY(position)
  20. if(point.y>this.height-Style.Title.fontSize && point.y<this.height+Style.Title.fontSize){
  21. if(point.x > coordinate.width/2 - this.value.length * Style.Title.fontSize && point.x < coordinate.width/2 + this.value.length * Style.Title.fontSize){
  22. return true;
  23. }
  24. }
  25. return false;
  26. }
  27. }