/
featureTilePointIcon.ts
100 lines (99 loc) · 2.06 KB
/
featureTilePointIcon.ts
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { GeoPackageImage } from '../../image/geoPackageImage';
/**
* Constructor
* @class FeatureTilePointIcon
* @param {Image} icon
* @constructor
*/
export class FeatureTilePointIcon {
icon: GeoPackageImage;
width: number;
height: number;
xOffset: number;
yOffset: number;
constructor(icon: GeoPackageImage) {
this.icon = icon;
this.width = icon.getWidth();
this.height = icon.getHeight();
this.pinIconDefault();
}
/**
* Pin the icon to the point, lower middle on the point
*/
pinIconDefault(): void {
this.xOffset = this.width / 2.0;
this.yOffset = this.height;
}
/**
* Center the icon on the point
*/
pinIconCenter(): void {
this.xOffset = this.width / 2.0;
this.yOffset = this.height / 2.0;
}
/**
* Get the icon
* @returns {GeoPackageImage} icon
*/
getIcon(): GeoPackageImage {
return this.icon;
}
/**
* Get the width
* @return {Number} width
*/
getWidth(): number {
return this.width;
}
/**
* Set the display width and adjust the x offset
* @param {Number} width icon display width
*/
setWidth(width: number): void {
this.xOffset = (this.xOffset / this.width) * width;
this.width = width;
}
/**
* Get the height
* @return {Number} height
*/
getHeight(): number {
return this.height;
}
/**
* Set the display height and adjust the y offset
* @param {Number} height icon display height
*/
setHeight(height: number): void {
this.yOffset = (this.yOffset / this.height) * height;
this.height = height;
}
/**
* Get the x offset
* @return {Number} x offset
*/
getXOffset(): number {
return this.xOffset;
}
/**
* Set the x offset
* @param {Number} xOffset x offset
*/
setXOffset(xOffset: number): void {
this.xOffset = xOffset;
}
/**
* Get the y offset
* @return {Number} y offset
*/
getYOffset(): number {
return this.yOffset;
}
/**
* Set the y offset
* @param {Number} yOffset y offset
*/
setYOffset(yOffset: number): void {
this.yOffset = yOffset;
}
}