|
@@ -20,6 +20,7 @@
|
|
|
|
|
|
import { SGraphyItem, SMouseEvent } from "@sybotan-web/graphy/lib";
|
|
import { SGraphyItem, SMouseEvent } from "@sybotan-web/graphy/lib";
|
|
import { SColor, SPainter, SPoint, SRect } from "@sybotan-web/draw/lib";
|
|
import { SColor, SPainter, SPoint, SRect } from "@sybotan-web/draw/lib";
|
|
|
|
+import {Column} from "../types/Column";
|
|
|
|
|
|
/**
|
|
/**
|
|
* 柱子item
|
|
* 柱子item
|
|
@@ -27,173 +28,151 @@ import { SColor, SPainter, SPoint, SRect } from "@sybotan-web/draw/lib";
|
|
* @author 郝建龙
|
|
* @author 郝建龙
|
|
*/
|
|
*/
|
|
export class ColumnItem extends SGraphyItem {
|
|
export class ColumnItem extends SGraphyItem {
|
|
- /** 点坐标list */
|
|
|
|
- pointArr: SPoint[];
|
|
|
|
- /** 填充色 */
|
|
|
|
- fillColor: SColor = new SColor("#F2F6FC");
|
|
|
|
- /** 边框色 */
|
|
|
|
- color: SColor = SColor.Black;
|
|
|
|
- /** 边框宽度 */
|
|
|
|
- width: number = 200;
|
|
|
|
- /** 空间id */
|
|
|
|
- id: string;
|
|
|
|
- /** 中心坐标 */
|
|
|
|
- centerOfGravityPoint: { x: number; y: number };
|
|
|
|
- /** 空间名称 */
|
|
|
|
- initName: null | string | undefined;
|
|
|
|
- /** 绘制文案 */
|
|
|
|
- viewText: string = "";
|
|
|
|
- /** 需要缓存的边框颜色 */
|
|
|
|
- cacheColor: SColor = SColor.Black;
|
|
|
|
- /** 需要缓存的填充色 */
|
|
|
|
- cacheFillColor: SColor = new SColor("#F2F6FC");
|
|
|
|
- /** 需要缓存的边框宽度 */
|
|
|
|
- cacheWidth: number = 100;
|
|
|
|
- /** 是否激活 */
|
|
|
|
- actived: boolean = false;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 构造函数
|
|
|
|
- *
|
|
|
|
- * @param PolygonItemData
|
|
|
|
- */
|
|
|
|
- constructor(PolygonItemData: ColumnItemInterface) {
|
|
|
|
- super(PolygonItemData.parent);
|
|
|
|
- // 修改绘制路径格式
|
|
|
|
- let newSpacePaths: SPoint[] = PolygonItemData.space.Paths[0].map(
|
|
|
|
- (item: SPoint) => {
|
|
|
|
- return new SPoint(item.x, item.y);
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
- this.pointArr = newSpacePaths;
|
|
|
|
- // 填充色
|
|
|
|
- this.fillColor = PolygonItemData.space.fillColor
|
|
|
|
- ? PolygonItemData.space.fillColor
|
|
|
|
- : new SColor("#F2F6FC");
|
|
|
|
- // 边框色
|
|
|
|
- this.color = PolygonItemData.space.color
|
|
|
|
- ? PolygonItemData.space.color
|
|
|
|
- : SColor.Black;
|
|
|
|
- //边框宽度
|
|
|
|
- this.width = PolygonItemData.space.width
|
|
|
|
- ? PolygonItemData.space.width
|
|
|
|
- : 100;
|
|
|
|
- //中心点
|
|
|
|
- this.centerOfGravityPoint = {
|
|
|
|
- x: PolygonItemData.space.LocationPoint.X,
|
|
|
|
- y: -PolygonItemData.space.LocationPoint.Y
|
|
|
|
- };
|
|
|
|
- this.initName = PolygonItemData.space.Name;
|
|
|
|
- this.id = PolygonItemData.space.id;
|
|
|
|
- this.viewText = PolygonItemData.space.Name;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Item对象边界区域
|
|
|
|
- *
|
|
|
|
- * @return SRect
|
|
|
|
- */
|
|
|
|
- boundingRect(): SRect {
|
|
|
|
- let minX = this.pointArr[0].x;
|
|
|
|
- let maxX = minX;
|
|
|
|
- let minY = this.pointArr[0].y;
|
|
|
|
- let maxY = minY;
|
|
|
|
- for (let i = 1; i < this.pointArr.length; i++) {
|
|
|
|
- if (this.pointArr[i].x < minX) {
|
|
|
|
- minX = this.pointArr[i].x;
|
|
|
|
- }
|
|
|
|
- if (this.pointArr[i].y < minY) {
|
|
|
|
- minY = this.pointArr[i].y;
|
|
|
|
- }
|
|
|
|
- if (this.pointArr[i].x > maxX) {
|
|
|
|
- maxX = this.pointArr[i].x;
|
|
|
|
- }
|
|
|
|
- if (this.pointArr[i].y > maxY) {
|
|
|
|
- maxY = this.pointArr[i].y;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return new SRect(minX, minY, maxX - minX, maxY - minY);
|
|
|
|
- } // Function boundingRect()
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 判断点是否在区域内
|
|
|
|
- *
|
|
|
|
- * @param x
|
|
|
|
- * @param y
|
|
|
|
- */
|
|
|
|
- contains(x: number, y: number): boolean {
|
|
|
|
- let nCross = 0,
|
|
|
|
- point = [x, y],
|
|
|
|
- APoints = this.pointArr,
|
|
|
|
- length = APoints.length,
|
|
|
|
- p1,
|
|
|
|
- p2,
|
|
|
|
- i,
|
|
|
|
- xinters;
|
|
|
|
- p1 = APoints[0];
|
|
|
|
- for (i = 1; i <= length; i++) {
|
|
|
|
- p2 = APoints[i % length];
|
|
|
|
- if (
|
|
|
|
- point[0] > Math.min(p1.x, p2.x) &&
|
|
|
|
- point[0] <= Math.max(p1.x, p2.x)
|
|
|
|
- ) {
|
|
|
|
- if (point[1] <= Math.max(p1.y, p2.y)) {
|
|
|
|
- if (p1.x != p2.x) {
|
|
|
|
- //计算位置信息
|
|
|
|
- xinters =
|
|
|
|
- ((point[0] - p1.x) * (p2.y - p1.y)) /
|
|
|
|
- (p2.x - p1.x) +
|
|
|
|
- p1.y;
|
|
|
|
- if (p1.y == p2.y || point[1] <= xinters) {
|
|
|
|
- nCross++;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- p1 = p2;
|
|
|
|
- }
|
|
|
|
- return nCross % 2 === 1;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- *
|
|
|
|
- * @param text 修改的文字
|
|
|
|
- * @param centerOfGravityPoint 文字的坐标
|
|
|
|
- */
|
|
|
|
- addText(text: string, centerOfGravityPoint?: { x: number; y: number }) {
|
|
|
|
- this.viewText = text;
|
|
|
|
- if (centerOfGravityPoint) {
|
|
|
|
- this.centerOfGravityPoint = centerOfGravityPoint;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Item绘制操作
|
|
|
|
- *
|
|
|
|
- * @param painter painter对象
|
|
|
|
- * @param rect 绘制区域
|
|
|
|
- */
|
|
|
|
- onDraw(painter: SPainter, rect?: SRect): void {
|
|
|
|
- if (this.pointArr.length) {
|
|
|
|
- painter.pen.color = this.color;
|
|
|
|
- painter.brush.color = this.fillColor;
|
|
|
|
- painter.pen.lineWidth = this.width;
|
|
|
|
- painter.drawPolygon(this.pointArr);
|
|
|
|
- // let text = ''
|
|
|
|
- // if (this.businessName || this.businessId) {
|
|
|
|
- // text = '👇 ' + this.businessName
|
|
|
|
- // } else {
|
|
|
|
- // text = '⬇️ ' + this.initName
|
|
|
|
- // }
|
|
|
|
- painter.font.size = this.scale * 200;
|
|
|
|
- painter.brush.color = SColor.Black;
|
|
|
|
- // painter.drawText(text,this.centerOfGravityPoint.x,this.centerOfGravityPoint.y)
|
|
|
|
- painter.drawText(
|
|
|
|
- this.viewText,
|
|
|
|
- this.centerOfGravityPoint.x,
|
|
|
|
- this.centerOfGravityPoint.y
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // data
|
|
|
|
+ //
|
|
|
|
+ // /**
|
|
|
|
+ // * 构造函数
|
|
|
|
+ // *
|
|
|
|
+ // * @param PolygonItemData
|
|
|
|
+ // */
|
|
|
|
+ // constructor(PolygonItemData: Column) {
|
|
|
|
+ // super(null);
|
|
|
|
+ // // super(PolygonItemData.parent);
|
|
|
|
+ // // // 修改绘制路径格式
|
|
|
|
+ // // let newSpacePaths: SPoint[] = PolygonItemData.space.Paths[0].map(
|
|
|
|
+ // // (item: SPoint) => {
|
|
|
|
+ // // return new SPoint(item.x, item.y);
|
|
|
|
+ // // }
|
|
|
|
+ // // );
|
|
|
|
+ // // this.pointArr = newSpacePaths;
|
|
|
|
+ // // // 填充色
|
|
|
|
+ // // this.fillColor = PolygonItemData.space.fillColor
|
|
|
|
+ // // ? PolygonItemData.space.fillColor
|
|
|
|
+ // // : new SColor("#F2F6FC");
|
|
|
|
+ // // // 边框色
|
|
|
|
+ // // this.color = PolygonItemData.space.color
|
|
|
|
+ // // ? PolygonItemData.space.color
|
|
|
|
+ // // : SColor.Black;
|
|
|
|
+ // // //边框宽度
|
|
|
|
+ // // this.width = PolygonItemData.space.width
|
|
|
|
+ // // ? PolygonItemData.space.width
|
|
|
|
+ // // : 100;
|
|
|
|
+ // // //中心点
|
|
|
|
+ // // this.centerOfGravityPoint = {
|
|
|
|
+ // // x: PolygonItemData.space.LocationPoint.X,
|
|
|
|
+ // // y: -PolygonItemData.space.LocationPoint.Y
|
|
|
|
+ // // };
|
|
|
|
+ // // this.initName = PolygonItemData.space.Name;
|
|
|
|
+ // // this.id = PolygonItemData.space.id;
|
|
|
|
+ // // this.viewText = PolygonItemData.space.Name;
|
|
|
|
+ // }
|
|
|
|
+ //
|
|
|
|
+ // /**
|
|
|
|
+ // * Item对象边界区域
|
|
|
|
+ // *
|
|
|
|
+ // * @return SRect
|
|
|
|
+ // */
|
|
|
|
+ // boundingRect(): SRect {
|
|
|
|
+ // let minX = this.pointArr[0].x;
|
|
|
|
+ // let maxX = minX;
|
|
|
|
+ // let minY = this.pointArr[0].y;
|
|
|
|
+ // let maxY = minY;
|
|
|
|
+ // for (let i = 1; i < this.pointArr.length; i++) {
|
|
|
|
+ // if (this.pointArr[i].x < minX) {
|
|
|
|
+ // minX = this.pointArr[i].x;
|
|
|
|
+ // }
|
|
|
|
+ // if (this.pointArr[i].y < minY) {
|
|
|
|
+ // minY = this.pointArr[i].y;
|
|
|
|
+ // }
|
|
|
|
+ // if (this.pointArr[i].x > maxX) {
|
|
|
|
+ // maxX = this.pointArr[i].x;
|
|
|
|
+ // }
|
|
|
|
+ // if (this.pointArr[i].y > maxY) {
|
|
|
|
+ // maxY = this.pointArr[i].y;
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //
|
|
|
|
+ // return new SRect(minX, minY, maxX - minX, maxY - minY);
|
|
|
|
+ // } // Function boundingRect()
|
|
|
|
+ //
|
|
|
|
+ // /**
|
|
|
|
+ // * 判断点是否在区域内
|
|
|
|
+ // *
|
|
|
|
+ // * @param x
|
|
|
|
+ // * @param y
|
|
|
|
+ // */
|
|
|
|
+ // contains(x: number, y: number): boolean {
|
|
|
|
+ // let nCross = 0,
|
|
|
|
+ // point = [x, y],
|
|
|
|
+ // APoints = this.pointArr,
|
|
|
|
+ // length = APoints.length,
|
|
|
|
+ // p1,
|
|
|
|
+ // p2,
|
|
|
|
+ // i,
|
|
|
|
+ // xinters;
|
|
|
|
+ // p1 = APoints[0];
|
|
|
|
+ // for (i = 1; i <= length; i++) {
|
|
|
|
+ // p2 = APoints[i % length];
|
|
|
|
+ // if (
|
|
|
|
+ // point[0] > Math.min(p1.x, p2.x) &&
|
|
|
|
+ // point[0] <= Math.max(p1.x, p2.x)
|
|
|
|
+ // ) {
|
|
|
|
+ // if (point[1] <= Math.max(p1.y, p2.y)) {
|
|
|
|
+ // if (p1.x != p2.x) {
|
|
|
|
+ // //计算位置信息
|
|
|
|
+ // xinters =
|
|
|
|
+ // ((point[0] - p1.x) * (p2.y - p1.y)) /
|
|
|
|
+ // (p2.x - p1.x) +
|
|
|
|
+ // p1.y;
|
|
|
|
+ // if (p1.y == p2.y || point[1] <= xinters) {
|
|
|
|
+ // nCross++;
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // p1 = p2;
|
|
|
|
+ // }
|
|
|
|
+ // return nCross % 2 === 1;
|
|
|
|
+ // }
|
|
|
|
+ //
|
|
|
|
+ // /**
|
|
|
|
+ // *
|
|
|
|
+ // * @param text 修改的文字
|
|
|
|
+ // * @param centerOfGravityPoint 文字的坐标
|
|
|
|
+ // */
|
|
|
|
+ // addText(text: string, centerOfGravityPoint?: { x: number; y: number }) {
|
|
|
|
+ // this.viewText = text;
|
|
|
|
+ // if (centerOfGravityPoint) {
|
|
|
|
+ // this.centerOfGravityPoint = centerOfGravityPoint;
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //
|
|
|
|
+ // /**
|
|
|
|
+ // * Item绘制操作
|
|
|
|
+ // *
|
|
|
|
+ // * @param painter painter对象
|
|
|
|
+ // * @param rect 绘制区域
|
|
|
|
+ // */
|
|
|
|
+ // onDraw(painter: SPainter, rect?: SRect): void {
|
|
|
|
+ // if (this.pointArr.length) {
|
|
|
|
+ // painter.pen.color = this.color;
|
|
|
|
+ // painter.brush.color = this.fillColor;
|
|
|
|
+ // painter.pen.lineWidth = this.width;
|
|
|
|
+ // painter.drawPolygon(this.pointArr);
|
|
|
|
+ // // let text = ''
|
|
|
|
+ // // if (this.businessName || this.businessId) {
|
|
|
|
+ // // text = '👇 ' + this.businessName
|
|
|
|
+ // // } else {
|
|
|
|
+ // // text = '⬇️ ' + this.initName
|
|
|
|
+ // // }
|
|
|
|
+ // painter.font.size = this.scale * 200;
|
|
|
|
+ // painter.brush.color = SColor.Black;
|
|
|
|
+ // // painter.drawText(text,this.centerOfGravityPoint.x,this.centerOfGravityPoint.y)
|
|
|
|
+ // painter.drawText(
|
|
|
|
+ // this.viewText,
|
|
|
|
+ // this.centerOfGravityPoint.x,
|
|
|
|
+ // this.centerOfGravityPoint.y
|
|
|
|
+ // );
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
} // Class ColumnItem
|
|
} // Class ColumnItem
|