|
@@ -41,7 +41,7 @@ import { Anchor } from "../types/topology/Anchor";
|
|
*
|
|
*
|
|
* */
|
|
* */
|
|
export class SIconTextItem extends SObjectItem {
|
|
export class SIconTextItem extends SObjectItem {
|
|
- /** item状态 */
|
|
|
|
|
|
+ /** item状态 */
|
|
_status: SItemStatus = SItemStatus.Normal;
|
|
_status: SItemStatus = SItemStatus.Normal;
|
|
get status(): SItemStatus {
|
|
get status(): SItemStatus {
|
|
return this._status;
|
|
return this._status;
|
|
@@ -64,7 +64,7 @@ export class SIconTextItem extends SObjectItem {
|
|
this.update();
|
|
this.update();
|
|
}
|
|
}
|
|
|
|
|
|
- /** 是否显示文字 */
|
|
|
|
|
|
+ /** 是否显示文字 */
|
|
_showText: boolean = true;
|
|
_showText: boolean = true;
|
|
get showText(): boolean {
|
|
get showText(): boolean {
|
|
return this._showText;
|
|
return this._showText;
|
|
@@ -101,7 +101,7 @@ export class SIconTextItem extends SObjectItem {
|
|
this.update();
|
|
this.update();
|
|
} // Set selected
|
|
} // Set selected
|
|
|
|
|
|
- /** 是否激活 */
|
|
|
|
|
|
+ /** 是否激活 */
|
|
_isActive: boolean = false;
|
|
_isActive: boolean = false;
|
|
get isActive(): boolean {
|
|
get isActive(): boolean {
|
|
return this._isActive;
|
|
return this._isActive;
|
|
@@ -120,7 +120,7 @@ export class SIconTextItem extends SObjectItem {
|
|
this.update();
|
|
this.update();
|
|
} // Set isActive
|
|
} // Set isActive
|
|
|
|
|
|
- /** 激活显示颜色 */
|
|
|
|
|
|
+ /** 激活显示颜色 */
|
|
_activeColor: SColor = new SColor("#00000033");
|
|
_activeColor: SColor = new SColor("#00000033");
|
|
get activeColor(): SColor {
|
|
get activeColor(): SColor {
|
|
return this._activeColor;
|
|
return this._activeColor;
|
|
@@ -156,22 +156,22 @@ export class SIconTextItem extends SObjectItem {
|
|
set sWidth(v: number) {
|
|
set sWidth(v: number) {
|
|
this.img.width = v;
|
|
this.img.width = v;
|
|
this.img.origin = new SPoint(this.img.width * 0.5, this.img.height * 0.5);
|
|
this.img.origin = new SPoint(this.img.width * 0.5, this.img.height * 0.5);
|
|
- this.changeAhchorPoint();
|
|
|
|
|
|
+ this.changeAnchorPoint();
|
|
this.update();
|
|
this.update();
|
|
}
|
|
}
|
|
|
|
|
|
- /** icon宽 */
|
|
|
|
|
|
+ /** icon高 */
|
|
get sHeight(): number {
|
|
get sHeight(): number {
|
|
return this.img.height;
|
|
return this.img.height;
|
|
}
|
|
}
|
|
set sHeight(v: number) {
|
|
set sHeight(v: number) {
|
|
this.img.height = v;
|
|
this.img.height = v;
|
|
this.img.origin = new SPoint(this.img.width * 0.5, this.img.height * 0.5);
|
|
this.img.origin = new SPoint(this.img.width * 0.5, this.img.height * 0.5);
|
|
- this.changeAhchorPoint();
|
|
|
|
|
|
+ this.changeAnchorPoint();
|
|
this.update();
|
|
this.update();
|
|
}
|
|
}
|
|
|
|
|
|
- /** 是否显示锚点 */
|
|
|
|
|
|
+ /** 是否显示锚点 */
|
|
private _showAnchor: boolean = false;
|
|
private _showAnchor: boolean = false;
|
|
get showAnchor(): boolean {
|
|
get showAnchor(): boolean {
|
|
return this._showAnchor;
|
|
return this._showAnchor;
|
|
@@ -182,7 +182,7 @@ export class SIconTextItem extends SObjectItem {
|
|
t.visible = v;
|
|
t.visible = v;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ /** 文本内容 */
|
|
get text(): string {
|
|
get text(): string {
|
|
return this.textItem.text;
|
|
return this.textItem.text;
|
|
}
|
|
}
|
|
@@ -190,6 +190,7 @@ export class SIconTextItem extends SObjectItem {
|
|
this.textItem.text = v;
|
|
this.textItem.text = v;
|
|
this.update();
|
|
this.update();
|
|
}
|
|
}
|
|
|
|
+ /** 文本颜色 */
|
|
get color(): SColor {
|
|
get color(): SColor {
|
|
return this.textItem.color;
|
|
return this.textItem.color;
|
|
}
|
|
}
|
|
@@ -197,6 +198,7 @@ export class SIconTextItem extends SObjectItem {
|
|
this.textItem.color = v;
|
|
this.textItem.color = v;
|
|
this.update();
|
|
this.update();
|
|
}
|
|
}
|
|
|
|
+ /** 文本字体 */
|
|
get font(): SFont {
|
|
get font(): SFont {
|
|
return this.textItem.font;
|
|
return this.textItem.font;
|
|
}
|
|
}
|
|
@@ -204,22 +206,24 @@ export class SIconTextItem extends SObjectItem {
|
|
this.textItem.font = v;
|
|
this.textItem.font = v;
|
|
this.update();
|
|
this.update();
|
|
}
|
|
}
|
|
- /** img Item */
|
|
|
|
|
|
+ /** img Item */
|
|
img: SImageItem = new SImageItem(this);
|
|
img: SImageItem = new SImageItem(this);
|
|
|
|
|
|
- /** text item */
|
|
|
|
|
|
+ /** text item */
|
|
textItem: STextItem = new STextItem(this);
|
|
textItem: STextItem = new STextItem(this);
|
|
|
|
|
|
/**
|
|
/**
|
|
* 构造体
|
|
* 构造体
|
|
*
|
|
*
|
|
|
|
+ * @param parent 父类
|
|
|
|
+ * @param data 锚点数据
|
|
* */
|
|
* */
|
|
constructor(parent: SGraphItem | null, data?: Anchor[]) {
|
|
constructor(parent: SGraphItem | null, data?: Anchor[]) {
|
|
super(parent);
|
|
super(parent);
|
|
this.img.width = 32;
|
|
this.img.width = 32;
|
|
this.img.height = 32;
|
|
this.img.height = 32;
|
|
this.img.origin = new SPoint(this.img.width * 0.5, this.img.height * 0.5);
|
|
this.img.origin = new SPoint(this.img.width * 0.5, this.img.height * 0.5);
|
|
- this.img.connect("onMove", this, this.changeAhchorPoint.bind(this));
|
|
|
|
|
|
+ this.img.connect("onMove", this, this.changeAnchorPoint.bind(this));
|
|
let anchorPoint;
|
|
let anchorPoint;
|
|
if (data && data.length) {
|
|
if (data && data.length) {
|
|
anchorPoint = data.map(t => {
|
|
anchorPoint = data.map(t => {
|
|
@@ -253,7 +257,10 @@ export class SIconTextItem extends SObjectItem {
|
|
this.textItem.text = "";
|
|
this.textItem.text = "";
|
|
this.textItem.font.size = 12;
|
|
this.textItem.font.size = 12;
|
|
// 偏移二分之一文本高度
|
|
// 偏移二分之一文本高度
|
|
- this.textItem.moveTo((this.img.width * 0.5), -(this.font.size * 1.25 * 0.5));
|
|
|
|
|
|
+ this.textItem.moveTo(
|
|
|
|
+ this.img.width * 0.5,
|
|
|
|
+ -(this.font.size * 1.25 * 0.5)
|
|
|
|
+ );
|
|
this.moveable = true;
|
|
this.moveable = true;
|
|
this.selectable = true;
|
|
this.selectable = true;
|
|
}
|
|
}
|
|
@@ -262,7 +269,7 @@ export class SIconTextItem extends SObjectItem {
|
|
* 计算并移动锚点的位置
|
|
* 计算并移动锚点的位置
|
|
*
|
|
*
|
|
* */
|
|
* */
|
|
- private changeAhchorPoint(): void {
|
|
|
|
|
|
+ private changeAnchorPoint(): void {
|
|
// 判断是否有锚点
|
|
// 判断是否有锚点
|
|
if (this.anchorList.length) {
|
|
if (this.anchorList.length) {
|
|
let anchorPoint = [
|
|
let anchorPoint = [
|
|
@@ -279,11 +286,13 @@ export class SIconTextItem extends SObjectItem {
|
|
item.moveTo(anchorPoint[index].x, anchorPoint[index].y);
|
|
item.moveTo(anchorPoint[index].x, anchorPoint[index].y);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- } // Function changeAhchorPoint()
|
|
|
|
|
|
+ } // Function changeAnchorPoint()
|
|
|
|
|
|
/**
|
|
/**
|
|
* 鼠标按下事件
|
|
* 鼠标按下事件
|
|
*
|
|
*
|
|
|
|
+ * @param event 事件对象
|
|
|
|
+ * @return 是否处理事件
|
|
* */
|
|
* */
|
|
onMouseDown(event: SMouseEvent): boolean {
|
|
onMouseDown(event: SMouseEvent): boolean {
|
|
if (this.status == SItemStatus.Normal) {
|
|
if (this.status == SItemStatus.Normal) {
|
|
@@ -379,4 +388,4 @@ export class SIconTextItem extends SObjectItem {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} // Function onDraw()
|
|
} // Function onDraw()
|
|
-}
|
|
|
|
|
|
+} // Class SIconTextItem
|