2020-06-06 00:03:37 +02:00
|
|
|
"use strict";
|
2016-07-22 13:27:52 +02:00
|
|
|
|
2020-06-06 00:03:37 +02:00
|
|
|
const events = require("../events.js");
|
|
|
|
const Point = require("./point.js");
|
|
|
|
const PointList = require("./point_list.js");
|
2016-07-22 13:27:52 +02:00
|
|
|
|
|
|
|
class Note extends events.EventTarget {
|
|
|
|
constructor() {
|
|
|
|
super();
|
2020-06-06 00:03:37 +02:00
|
|
|
this._text = "…";
|
2016-07-22 13:27:52 +02:00
|
|
|
this._polygon = new PointList();
|
|
|
|
}
|
|
|
|
|
2020-06-04 20:09:35 +02:00
|
|
|
get text() {
|
|
|
|
return this._text;
|
|
|
|
}
|
|
|
|
|
|
|
|
get polygon() {
|
|
|
|
return this._polygon;
|
|
|
|
}
|
2016-07-22 13:27:52 +02:00
|
|
|
|
2020-06-04 20:09:35 +02:00
|
|
|
set text(value) {
|
|
|
|
this._text = value;
|
|
|
|
}
|
2016-07-22 13:27:52 +02:00
|
|
|
|
|
|
|
static fromResponse(response) {
|
|
|
|
const note = new Note();
|
|
|
|
note._updateFromResponse(response);
|
|
|
|
return note;
|
|
|
|
}
|
|
|
|
|
|
|
|
_updateFromResponse(response) {
|
|
|
|
this._text = response.text;
|
|
|
|
this._polygon.clear();
|
|
|
|
for (let point of response.polygon) {
|
|
|
|
this._polygon.add(new Point(point[0], point[1]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Note;
|