line-model.js 739 B

12345678910111213141516171819202122
  1. import { ELEMENTS_CLASS } from "../../../core/enums/elements-class-enum";
  2. import { LineSegmentModel } from "../../line-segment-component/models/line-segment-model";
  3. export class LineModel extends LineSegmentModel {
  4. constructor(pointA, pointB, label, id) {
  5. super(pointA, pointB, label, id);
  6. this.setClass(ELEMENTS_CLASS.LINE);
  7. this.color = -16776961;
  8. }
  9. static do(map, list) {
  10. const id = map.get("id");
  11. const pointAId = map.get("param")[0];
  12. const pointBId = map.get("param")[1];
  13. const pointA = list.find(x => x.id === pointAId);
  14. const pointB = list.find(x => x.id === pointBId);
  15. const label = map.get("label")[0];
  16. const line = new LineModel(pointA, pointB, label, id);
  17. return line;
  18. }
  19. }