123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.SSpaceItem = void 0;
- const lib_1 = require("@persagy-web/draw/lib");
- const __1 = require("../..");
- const __2 = require("../..");
- const lib_2 = require("@persagy-web/graph/lib");
- class SSpaceItem extends lib_2.SGraphItem {
- constructor(parent, data) {
- super(parent);
- this.pointArr = [];
- this.minX = Number.MAX_SAFE_INTEGER;
- this.maxX = Number.MIN_SAFE_INTEGER;
- this.minY = Number.MAX_SAFE_INTEGER;
- this.maxY = Number.MIN_SAFE_INTEGER;
- this._highLightFlag = false;
- this._showBaseName = false;
- this._nameSize = 10;
- this._nameTransform = false;
- this._nameColor = "#000000";
- this.data = data;
- this.zOrder = __1.ItemOrder.spaceOrder;
- let tempArr = this.data.OutLine;
- this.name = data.Name || "";
- if (tempArr && tempArr.length) {
- this.minX = tempArr[0][0].X;
- this.maxX = this.minX;
- this.minY = -tempArr[0][0].Y;
- this.maxY = this.minY;
- this.pointArr = tempArr.map((t) => {
- let temp = t.map((it) => {
- let x = it.X, y = -it.Y;
- if (x < this.minX) {
- this.minX = x;
- }
- if (y < this.minY) {
- this.minY = y;
- }
- if (x > this.maxX) {
- this.maxX = x;
- }
- if (y > this.maxY) {
- this.maxY = y;
- }
- return new lib_1.SPoint(x, y);
- });
- return temp;
- });
- }
- }
- get highLightFlag() {
- return this._highLightFlag;
- }
- set highLightFlag(value) {
- this._highLightFlag = value;
- this.update();
- }
- get showBaseName() {
- return this._showBaseName;
- }
- set showBaseName(value) {
- this._showBaseName = value;
- this.update();
- }
- get nameSize() {
- return this._nameSize;
- }
- set nameSize(value) {
- this._nameSize = value;
- this.update();
- }
- get nameTransform() {
- return this._nameTransform;
- }
- set nameTransform(value) {
- this._nameTransform = value;
- this.update();
- }
- get nameColor() {
- return this._nameColor;
- }
- set nameColor(value) {
- this._nameColor = value;
- this.update();
- }
- boundingRect() {
- return new lib_1.SRect(this.minX, this.minY, this.maxX - this.minX, this.maxY - this.minY);
- }
- contains(x, y) {
- let arr = this.pointArr;
- if (arr.length < 1 || !lib_1.SPolygonUtil.pointIn(x, y, arr[0])) {
- return false;
- }
- for (let i = 1; i < arr.length; i++) {
- if (lib_1.SPolygonUtil.pointIn(x, y, arr[i])) {
- return false;
- }
- }
- return true;
- }
- onDraw(painter) {
- painter.pen.color = __2.ItemColor.spaceBorderColor;
- if (this.selected) {
- painter.brush.color = __2.ItemColor.selectColor;
- }
- else if (this.highLightFlag) {
- painter.brush.color = __2.ItemColor.spaceHighColor;
- }
- else {
- painter.brush.color = __2.ItemColor.spaceColor;
- }
- painter.pen.lineWidth = painter.toPx(1);
- if (this.pointArr.length) {
- painter.drawPolygon(this.pointArr[0]);
- }
- if (this.showBaseName) {
- if (this.name && this.name != "null") {
- painter.brush.color = new lib_1.SColor(this.nameColor);
- if (this.nameTransform) {
- painter.font.size = this.nameSize;
- }
- else {
- painter.font.size = painter.toPx(this.nameSize);
- }
- painter.font.textAlign = lib_1.STextAlign.Center;
- painter.drawText(this.name, this.data.Location.Points[0].X, -this.data.Location.Points[0].Y);
- }
- }
- }
- }
- exports.SSpaceItem = SSpaceItem;
|