forked from KleeGroup-BaseCamp/appviz-map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
element.js
35 lines (31 loc) · 873 Bytes
/
element.js
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
class Element {
constructor({ column, row, numOfColumns, numOfRows }) {
this.column = column;
this.row = row;
this.numOfColumns = numOfColumns;
this.numOfRows = numOfRows;
}
render (){
//This method must ne overridden
}
contains(x, y){
//This method must ne overridden
}
getBoundingBox() {
const padding = this.layer.level * 30;
const rowSize = windowHeight / this.layer.rows;
const columnSize = windowWidth / this.layer.columns;
const x = this.column * columnSize + padding;
const y = this.row * rowSize + padding;
const height = rowSize * this.numOfRows - 2 * padding;
const width = columnSize * this.numOfColumns - 2 * padding;
return { x, y, width, height };
}
initStyle() {
this.style = {
fill: COLORS[this.layer.level],
stroke: 255,
strokeWeight: 2,
};
}
}