SGraphyWallItem.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = function (d, b) {
  3. extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6. return extendStatics(d, b);
  7. };
  8. return function (d, b) {
  9. extendStatics(d, b);
  10. function __() { this.constructor = d; }
  11. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12. };
  13. })();
  14. import { SGraphyItem } from '@sybotan-web/graphy';
  15. import { SRect } from "@sybotan-web/base";
  16. import { SColor } from "@sybotan-web/draw";
  17. /**
  18. * 墙Item类
  19. *
  20. */
  21. var SGraphyWallItem = /** @class */ (function (_super) {
  22. __extends(SGraphyWallItem, _super);
  23. /**
  24. * 构造函数
  25. *
  26. * @param pointArr 点坐标list
  27. * @param isVirtual 墙类型(实体墙-虚拟墙)
  28. * @param color 墙的颜色
  29. * @param fillColor 墙的填充颜色
  30. * @param width 墙的宽度
  31. * @param parent
  32. */
  33. function SGraphyWallItem(parent, pointArr, isVirtual, fillColor, color, width) {
  34. if (isVirtual === void 0) { isVirtual = false; }
  35. if (fillColor === void 0) { fillColor = SColor.White; }
  36. if (color === void 0) { color = SColor.Black; }
  37. if (width === void 0) { width = 1; }
  38. var _this = _super.call(this, parent) || this;
  39. _this.isVirtual = false;
  40. _this.fillColor = SColor.White;
  41. _this.color = SColor.Black;
  42. _this.width = 1;
  43. _this.isVirtual = isVirtual;
  44. _this.pointArr = pointArr;
  45. _this.color = color;
  46. _this.fillColor = fillColor;
  47. _this.width = width;
  48. return _this;
  49. } // Constructor()
  50. /**
  51. * Item对象边界区域
  52. *
  53. * @return SRect
  54. */
  55. SGraphyWallItem.prototype.boundingRect = function () {
  56. var minX = this.pointArr[0].x;
  57. var maxX = minX;
  58. var minY = this.pointArr[0].y;
  59. var maxY = minY;
  60. for (var i = 1; i < this.pointArr.length; i++) {
  61. if (this.pointArr[i].x < minX) {
  62. minX = this.pointArr[i].x;
  63. }
  64. if (this.pointArr[i].y < minY) {
  65. minY = this.pointArr[i].y;
  66. }
  67. if (this.pointArr[i].x > maxX) {
  68. maxX = this.pointArr[i].x;
  69. }
  70. if (this.pointArr[i].y > maxY) {
  71. maxY = this.pointArr[i].y;
  72. }
  73. }
  74. return new SRect(minX, minY, maxX - minX, maxY - minY);
  75. }; // Function boundingRect()
  76. /**
  77. * Item绘制操作
  78. *
  79. * @param painter painter对象
  80. * @param rect 绘制区域
  81. */
  82. SGraphyWallItem.prototype.onDraw = function (painter, rect) {
  83. if (this.pointArr.length) {
  84. // painter.pen = new SPen(this.color, this.width);
  85. painter.pen.color = this.color;
  86. painter.brush.color = this.fillColor;
  87. painter.drawPolyline(this.pointArr);
  88. }
  89. };
  90. return SGraphyWallItem;
  91. }(SGraphyItem)); // Class SGraphyPolygonItem
  92. export default SGraphyWallItem;