|
@@ -24,10 +24,7 @@
|
|
|
* *********************************************************************************************************************
|
|
|
*/
|
|
|
|
|
|
-import {
|
|
|
- SAnchorItem,
|
|
|
- SGraphItem,
|
|
|
-} from "@persagy-web/graph";
|
|
|
+import { SAnchorItem, SGraphItem } from "@persagy-web/graph";
|
|
|
import { SItemStatus, ItemOrder } from "@persagy-web/big";
|
|
|
import { SMouseEvent } from "@persagy-web/base";
|
|
|
import {
|
|
@@ -55,7 +52,7 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
} // Get data
|
|
|
set data(v: Marker | null) {
|
|
|
this._data = v;
|
|
|
- this.initData()
|
|
|
+ this.initData();
|
|
|
this.update();
|
|
|
} // Set data
|
|
|
|
|
@@ -69,19 +66,19 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
if (v == SItemStatus.Normal) {
|
|
|
this.moveable = true;
|
|
|
this.textItemList.map(item => {
|
|
|
- item.moveable = false
|
|
|
+ item.moveable = false;
|
|
|
});
|
|
|
this.img.moveable = false;
|
|
|
} else if (v == SItemStatus.Edit) {
|
|
|
this.moveable = false;
|
|
|
this.textItemList.map(item => {
|
|
|
- item.moveable = true
|
|
|
+ item.moveable = true;
|
|
|
});
|
|
|
this.img.moveable = true;
|
|
|
} else if (v == SItemStatus.Create) {
|
|
|
this.moveable = true;
|
|
|
this.textItemList.map(item => {
|
|
|
- item.moveable = false
|
|
|
+ item.moveable = false;
|
|
|
});
|
|
|
this.img.moveable = false;
|
|
|
}
|
|
@@ -104,11 +101,11 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
this._showText = v;
|
|
|
if (v) {
|
|
|
this.textItemList.map(item => {
|
|
|
- item.show()
|
|
|
+ item.show();
|
|
|
});
|
|
|
} else {
|
|
|
this.textItemList.map(item => {
|
|
|
- item.hide()
|
|
|
+ item.hide();
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -145,13 +142,13 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
if (v) {
|
|
|
this.cursor = "pointer";
|
|
|
this.textItemList.map(item => {
|
|
|
- item.cursor = "pointer"
|
|
|
+ item.cursor = "pointer";
|
|
|
});
|
|
|
this.img.cursor = "pointer";
|
|
|
} else {
|
|
|
this.cursor = "auto";
|
|
|
this.textItemList.map(item => {
|
|
|
- item.cursor = "auto"
|
|
|
+ item.cursor = "auto";
|
|
|
});
|
|
|
this.img.cursor = "auto";
|
|
|
}
|
|
@@ -238,7 +235,7 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
this._color = v;
|
|
|
this.textItemList.forEach(item => {
|
|
|
item.color = v;
|
|
|
- })
|
|
|
+ });
|
|
|
this.update();
|
|
|
}
|
|
|
|
|
@@ -252,7 +249,7 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
this.textItemList.forEach((item: SBaseTextEdit, index: number) => {
|
|
|
item.font = v;
|
|
|
// item.moveTo(this.img.width * 0.5, v.size * (index - 0.125 - 0.5 * this.textItemList.length));
|
|
|
- })
|
|
|
+ });
|
|
|
this.update();
|
|
|
} // Set font
|
|
|
|
|
@@ -270,7 +267,7 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
*
|
|
|
* @param parent 父节点
|
|
|
* @param data 锚点数据
|
|
|
- */
|
|
|
+ */
|
|
|
constructor(parent: SGraphItem | null, data: Marker | null = null) {
|
|
|
super(parent);
|
|
|
this.showSelect = false;
|
|
@@ -288,9 +285,7 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
this.sHeight = this.data.size.height;
|
|
|
}
|
|
|
this.img.connect("onMove", this, this.changeAnchorPoint.bind(this));
|
|
|
- const anchorPoint = [
|
|
|
- { x: this.img.x, y: this.img.y, id: "" },
|
|
|
- ];
|
|
|
+ const anchorPoint = [{ x: this.img.x, y: this.img.y, id: "" }];
|
|
|
this.anchorList = anchorPoint.map(t => {
|
|
|
let item = new SAnchorItem(this);
|
|
|
if (t.id) {
|
|
@@ -302,7 +297,11 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
|
|
|
this.showAnchor = false;
|
|
|
// 对文本数据进行处理
|
|
|
- if (this.data.style && this.data.style.default && this.data.style.default.textList) {
|
|
|
+ if (
|
|
|
+ this.data.style &&
|
|
|
+ this.data.style.default &&
|
|
|
+ this.data.style.default.textList
|
|
|
+ ) {
|
|
|
const textList = this.data.style.default.textList;
|
|
|
if (textList.length) {
|
|
|
const textItemList: any[] = [];
|
|
@@ -311,31 +310,31 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
obj.propertyData = item;
|
|
|
obj.text = item.text;
|
|
|
if (item.pos) {
|
|
|
- obj.moveTo(item.pos.x, item.pos.x)
|
|
|
+ obj.moveTo(item.pos.x, item.pos.x);
|
|
|
} else {
|
|
|
obj.moveTo(
|
|
|
this.img.width * 0.5,
|
|
|
- -(this.font.size * 1.25 * 0.5) + (index) * 10
|
|
|
+ -(this.font.size * 1.25 * 0.5) + index * 10
|
|
|
);
|
|
|
}
|
|
|
obj.font.size = item.font;
|
|
|
obj.isTransform = false;
|
|
|
obj.showSelect = false;
|
|
|
obj.color = new SColor(item.color);
|
|
|
- obj.connect('textSelect', this, this.textSelectChange)
|
|
|
- textItemList.push(obj)
|
|
|
- })
|
|
|
+ obj.connect("textSelect", this, this.textSelectChange);
|
|
|
+ textItemList.push(obj);
|
|
|
+ });
|
|
|
this.textItemList = textItemList;
|
|
|
}
|
|
|
}
|
|
|
this.img.url = this.data.style.default.url;
|
|
|
|
|
|
this.x = this.data.pos.x;
|
|
|
- this.y = this.data.pos.y
|
|
|
+ this.y = this.data.pos.y;
|
|
|
|
|
|
this.moveable = true;
|
|
|
this.selectable = true;
|
|
|
- }// Function initData()
|
|
|
+ } // Function initData()
|
|
|
|
|
|
/**
|
|
|
* 添加文本
|
|
@@ -343,8 +342,8 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
* @param item 文本图例
|
|
|
*/
|
|
|
addTextItem(item: SBaseTextEdit) {
|
|
|
- this.textItemList.push(item)
|
|
|
- }// Function addTextItem
|
|
|
+ this.textItemList.push(item);
|
|
|
+ } // Function addTextItem
|
|
|
|
|
|
/**
|
|
|
* 删除文本
|
|
@@ -354,9 +353,9 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
removeTextItem(index: number) {
|
|
|
let [delteItem] = this.textItemList.splice(index, 1);
|
|
|
if (this.scene) {
|
|
|
- this.scene.removeItem(delteItem)
|
|
|
+ this.scene.removeItem(delteItem);
|
|
|
}
|
|
|
- }// Function removeTextItem
|
|
|
+ } // Function removeTextItem
|
|
|
|
|
|
/**
|
|
|
* 计算并移动锚点的位置
|
|
@@ -378,7 +377,7 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
|
|
|
/**
|
|
|
* 选中的文本item变化
|
|
|
- */
|
|
|
+ */
|
|
|
textSelectChange(item: SBaseTextEdit): void {
|
|
|
this.curTextItem = item;
|
|
|
} // Function textSelectChange()
|
|
@@ -388,15 +387,31 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
*
|
|
|
* @param event 事件对象
|
|
|
* @return 是否处理事件
|
|
|
- */
|
|
|
+ */
|
|
|
onMouseDown(event: SMouseEvent): boolean {
|
|
|
this.curTextItem = null;
|
|
|
if (this.status == SItemStatus.Normal) {
|
|
|
- super.onMouseDown(event)
|
|
|
+ super.onMouseDown(event);
|
|
|
return true;
|
|
|
} else if (this.status == SItemStatus.Edit) {
|
|
|
- return super.onMouseDown(event);
|
|
|
+ // @ts-ignore
|
|
|
+ const ce = SGraphItem.toChildMouseEvent(this, event);
|
|
|
+ return super.onMouseDown(ce);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 鼠标抬起事件
|
|
|
+ *
|
|
|
+ * @param event 事件对象
|
|
|
+ * @return 是否处理事件
|
|
|
+ */
|
|
|
+ onMouseUp(event: SMouseEvent): boolean {
|
|
|
+ if (this.status == SItemStatus.Edit) {
|
|
|
+ return true;
|
|
|
}
|
|
|
+ super.onMouseUp(event);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -405,7 +420,7 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
*
|
|
|
* @param oldSize 改之前的大小
|
|
|
* @param newSize 改之后大小
|
|
|
- */
|
|
|
+ */
|
|
|
onResize(oldSize: SSize, newSize: SSize) {
|
|
|
// console.log(arguments);
|
|
|
} // Function onResize()
|
|
@@ -415,7 +430,7 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
*
|
|
|
* @param event 鼠标事件
|
|
|
* @return 是否处理事件
|
|
|
- */
|
|
|
+ */
|
|
|
onDoubleClick(event: SMouseEvent): boolean {
|
|
|
// 如果位show状态 双击改对象则需改为编辑状态
|
|
|
if (SItemStatus.Normal == this.status) {
|
|
@@ -434,7 +449,7 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
* 宽高发生变化
|
|
|
*
|
|
|
* @return SRect 所有子对象的并集
|
|
|
- */
|
|
|
+ */
|
|
|
boundingRect(): SRect {
|
|
|
let rect = this.img
|
|
|
.boundingRect()
|
|
@@ -442,11 +457,9 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
if (this.showText) {
|
|
|
this.textItemList.forEach(item => {
|
|
|
rect = rect.unioned(
|
|
|
- item
|
|
|
- .boundingRect()
|
|
|
- .adjusted(item.pos.x, item.pos.y, 0, 0)
|
|
|
+ item.boundingRect().adjusted(item.pos.x, item.pos.y, 0, 0)
|
|
|
);
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
return rect.adjusted(-5, -5, 10, 10);
|
|
|
}
|
|
@@ -472,10 +485,10 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
if (this.status == SItemStatus.Edit) {
|
|
|
painter.pen.lineDash = [];
|
|
|
painter.brush.color = SColor.White;
|
|
|
- painter.drawCircle(rect.x, rect.y, 5 * lw)
|
|
|
- painter.drawCircle(rect.right, rect.bottom, 5 * lw)
|
|
|
- painter.drawCircle(rect.x, rect.bottom, 5 * lw)
|
|
|
- painter.drawCircle(rect.right, rect.y, 5 * lw)
|
|
|
+ painter.drawCircle(rect.x, rect.y, 5 * lw);
|
|
|
+ painter.drawCircle(rect.right, rect.bottom, 5 * lw);
|
|
|
+ painter.drawCircle(rect.x, rect.bottom, 5 * lw);
|
|
|
+ painter.drawCircle(rect.right, rect.y, 5 * lw);
|
|
|
}
|
|
|
if (this.isActive) {
|
|
|
painter.pen.color = SColor.Transparent;
|
|
@@ -513,10 +526,10 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
} // Function onDraw()
|
|
|
|
|
|
/**
|
|
|
- * 返回对象储存的相关数据
|
|
|
- *
|
|
|
- * @return 相关数据
|
|
|
- */
|
|
|
+ * 返回对象储存的相关数据
|
|
|
+ *
|
|
|
+ * @return 相关数据
|
|
|
+ */
|
|
|
toData(): any {
|
|
|
if (this.data) {
|
|
|
if (this.data.size) {
|
|
@@ -530,9 +543,7 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
this.data.style.default.url = this.img.url;
|
|
|
}
|
|
|
|
|
|
- const anchorPoint = [
|
|
|
- { x: this.img.x, y: this.img.y, id: "" },
|
|
|
- ];
|
|
|
+ const anchorPoint = [{ x: this.img.x, y: this.img.y, id: "" }];
|
|
|
this.anchorList = anchorPoint.map(t => {
|
|
|
let item = new SAnchorItem(this);
|
|
|
if (t.id) {
|
|
@@ -546,8 +557,7 @@ export class SBaseIconTextEdit extends SGraphEdit {
|
|
|
// this.img.url = this.data.style.default.url;
|
|
|
if (this.data) {
|
|
|
this.x = this.data.pos.x;
|
|
|
- this.y = this.data.pos.y
|
|
|
-
|
|
|
+ this.y = this.data.pos.y;
|
|
|
}
|
|
|
} // Function toData()
|
|
|
} // Class SBaseIconTextEdit
|