source: imaps-frontend/src/scripts/rendered_shapes/RenderedMapShape.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.0 KB
RevLine 
[d565449]1import Konva from "konva";
2
3export default class RenderedMapShape extends Konva.Rect{
4 constructor(config){
5 if (new.target === RenderedMapShape) {
6 throw new Error("Cannot instantiate abstract class RenderedMapShape directly.");
7 }
8
9 super(config);
10
11 this.info = {
12 name: "",
13 description: "",
14 }
15 this.infoText = null;
16 this.textOffsetX = 0;
17 this.textOffsetY = 0;
18 }
19
20 initText() {
21 this.infoText = new Konva.Text({
22 x: this.x() + this.textOffsetX,
23 y: this.y() + this.textOffsetY,
24 text: this.info.name || "no name",
25 fontSize: 12,
26 fontFamily: 'Verdana',
27 fill: 'black',
28 });
29 }
30
31 updateTextPosition() {
32 if(this.infoText){
33 this.infoText.x(this.x() + this.textOffsetX);
34 this.infoText.y(this.y() + this.textOffsetY);
35 }
36 }
37
38 displayName(layer) {
39 if(this.infoText != null){
40 layer.add(this.infoText);
41 }
42
43 }
44
45}
Note: See TracBrowser for help on using the repository browser.