SGraphLineItem.js 1.0 KB

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.SGraphLineItem = void 0;
  4. const lib_1 = require("@persagy-web/draw/lib");
  5. const SGraphItem_1 = require("../SGraphItem");
  6. class SGraphLineItem extends SGraphItem_1.SGraphItem {
  7. constructor(parent, x1, y1, x2, y2, color = lib_1.SColor.Black, width = 1) {
  8. super(parent);
  9. this.color = lib_1.SColor.Black;
  10. this.width = 1;
  11. this.x1 = x1;
  12. this.y1 = y1;
  13. this.x2 = x2;
  14. this.y2 = y2;
  15. }
  16. boundingRect() {
  17. let minX = Math.min(this.x1, this.x2);
  18. let minY = Math.min(this.y1, this.y2);
  19. let maxX = Math.max(this.x1, this.x2);
  20. let maxY = Math.max(this.y1, this.y2);
  21. return new lib_1.SRect(minX - this.width / 2, minY - this.width / 2, maxX - minX + this.width, maxY - minY + this.width);
  22. }
  23. onDraw(painter) {
  24. painter.pen = new lib_1.SPen(this.color, this.width);
  25. painter.drawLine(this.x1, this.y1, this.x2, this.y2);
  26. }
  27. }
  28. exports.SGraphLineItem = SGraphLineItem;