source: imaps-frontend/src/scripts/shapes/InfoPin.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.8 KB
RevLine 
[d565449]1import Konva from "konva";
2import MapShape from "./MapShape";
3import Factory from "../util/Factory";
4import { _registerNode } from "konva/lib/Global";
5export default class InfoPin extends MapShape {
6 constructor(mousePos, blockSize, layer, snappable,id) {
7 super(
8 {
9 x: mousePos.x,
10 y: mousePos.y,
11 radiusX: blockSize * 0.5,
12 radiusY: blockSize * 0.7,
13 tailHeight: blockSize * 1.2,
14 fill: "#d70113",
15 stroke: "#1b1b1b",
16 strokeWidth: 0.2,
17 draggable: true,
18 name: "mapObj",
19 },
20 layer,
21 blockSize,
22 snappable
23 );
24
25 this.id = id;
26
27 this.modalEventName = "openPinModalEvent";
28 this.type = "InfoPin";
29 this._info = {
30 name: `Pin ${id}`,
31 selectedPins: [],
32 description: "",
33 };
34
35 this.on("mouseover", () => {
36 this.fill("yellow");
37 });
38 this.on("mouseout", () => {
39 this.fill("red");
40 });
41
42 this.initText();
43 }
44 _sceneFunc(context, shape) {
45 const { radiusX, radiusY, tailHeight } = this.attrs;
46
47 context.beginPath();
48 context.ellipse(0, 0, radiusX, radiusY, 0, 0, Math.PI * 2);
49 context.closePath();
50 context.fillStrokeShape(shape);
51
52 context.beginPath();
53 context.moveTo(-radiusX, radiusY);
54 context.lineTo(0, radiusY + tailHeight);
55 context.lineTo(radiusX, radiusY);
56 context.closePath();
57
58 context.fillStrokeShape(shape);
59 }
60
61 loadInfo(attrs) {
62 this.info.name = attrs.obj_name;
63 this.info.selectedPins = attrs.connected_pins;
64 this.info.description = attrs.description;
65 }
66
67 saveShapeDetails() {
68 this.setAttr("obj_name", this.info.name);
69 this.setAttr("connected_pins", this.info.selectedPins);
70 this.setAttr("description", this.info.description);
71 console.log(this.info, "vnatre vo info");
72 }
73}
74
75InfoPin.prototype.className = "InfoPin";
76_registerNode(InfoPin);
Note: See TracBrowser for help on using the repository browser.