|
@@ -26,7 +26,7 @@ export class SLineItem extends SGraphItem {
|
|
|
private maxY = Number.MIN_SAFE_INTEGER;
|
|
|
|
|
|
/** 线段 */
|
|
|
- _line: SPoint[] = [];
|
|
|
+ private _line: SPoint[] = [];
|
|
|
get line(): SPoint[] {
|
|
|
return this._line;
|
|
|
}
|
|
@@ -36,7 +36,7 @@ export class SLineItem extends SGraphItem {
|
|
|
}
|
|
|
|
|
|
/** 是否完成绘制 */
|
|
|
- _status: SItemStatus = SItemStatus.Normal;
|
|
|
+ private _status: SItemStatus = SItemStatus.Normal;
|
|
|
get status(): SItemStatus {
|
|
|
return this._status;
|
|
|
}
|
|
@@ -46,7 +46,7 @@ export class SLineItem extends SGraphItem {
|
|
|
}
|
|
|
|
|
|
/** 线条颜色 */
|
|
|
- _strokeColor: string = "#000000";
|
|
|
+ private _strokeColor: string = "#000000";
|
|
|
get strokeColor(): string {
|
|
|
return this._strokeColor;
|
|
|
}
|
|
@@ -56,7 +56,7 @@ export class SLineItem extends SGraphItem {
|
|
|
}
|
|
|
|
|
|
/** 线条样式 */
|
|
|
- _lineStyle: SLineStyle = SLineStyle.Soild;
|
|
|
+ private _lineStyle: SLineStyle = SLineStyle.Soild;
|
|
|
get lineStyle(): SLineStyle {
|
|
|
return this._lineStyle;
|
|
|
}
|
|
@@ -66,7 +66,7 @@ export class SLineItem extends SGraphItem {
|
|
|
}
|
|
|
|
|
|
/** 端点填充色 */
|
|
|
- _fillColor: string = "#ffffff";
|
|
|
+ private _fillColor: string = "#ffffff";
|
|
|
get fillColor(): string {
|
|
|
return this._fillColor;
|
|
|
}
|
|
@@ -76,7 +76,7 @@ export class SLineItem extends SGraphItem {
|
|
|
}
|
|
|
|
|
|
/** 选中端点填充色 */
|
|
|
- _activeFillColor: string = "#2196f3";
|
|
|
+ private _activeFillColor: string = "#2196f3";
|
|
|
get activeFillColor(): string {
|
|
|
return this._activeFillColor;
|
|
|
}
|
|
@@ -86,7 +86,7 @@ export class SLineItem extends SGraphItem {
|
|
|
}
|
|
|
|
|
|
/** 线条宽度 */
|
|
|
- _lineWidth: number = 1;
|
|
|
+ private _lineWidth: number = 1;
|
|
|
get lineWidth(): number {
|
|
|
return this._lineWidth;
|
|
|
}
|
|
@@ -104,7 +104,7 @@ export class SLineItem extends SGraphItem {
|
|
|
/** 当前点索引 */
|
|
|
curIndex: number = -1;
|
|
|
|
|
|
- /** 当前点索引 */
|
|
|
+ /** 当前点坐标 */
|
|
|
private curPoint: SPoint | null = null;
|
|
|
|
|
|
/** undo/redo堆栈 */
|
|
@@ -178,17 +178,14 @@ export class SLineItem extends SGraphItem {
|
|
|
* @return boolean
|
|
|
*/
|
|
|
onDoubleClick(event: SMouseEvent): boolean {
|
|
|
- // 判断是否点击到线上
|
|
|
- if (this.contains(event.x, event.y)) {
|
|
|
- if (this.status == SItemStatus.Normal) {
|
|
|
- this.status = SItemStatus.Edit;
|
|
|
- this.grabItem(this);
|
|
|
- } else if (this.status == SItemStatus.Edit) {
|
|
|
- this.status = SItemStatus.Normal;
|
|
|
- this.releaseItem();
|
|
|
- }
|
|
|
- this.update();
|
|
|
+ if (this.status == SItemStatus.Normal) {
|
|
|
+ this.status = SItemStatus.Edit;
|
|
|
+ this.grabItem(this);
|
|
|
+ } else if (this.status == SItemStatus.Edit) {
|
|
|
+ this.status = SItemStatus.Normal;
|
|
|
+ this.releaseItem();
|
|
|
}
|
|
|
+ this.update();
|
|
|
return true;
|
|
|
} // Function onDoubleClick()
|
|
|
|
|
@@ -203,7 +200,7 @@ export class SLineItem extends SGraphItem {
|
|
|
this.curPoint = null;
|
|
|
if (event.buttons == SMouseButton.LeftButton) {
|
|
|
if (this.status == SItemStatus.Normal) {
|
|
|
- return super.onMouseDown(event);
|
|
|
+ return false;
|
|
|
} else if (this.status == SItemStatus.Edit) {
|
|
|
// 判断是否点击到端点上(获取端点索引值)
|
|
|
this.findNearestPoint(new SPoint(event.x, event.y));
|
|
@@ -212,7 +209,7 @@ export class SLineItem extends SGraphItem {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
- return super.onMouseDown(event);
|
|
|
+ return true;
|
|
|
} // Function onMouseDown()
|
|
|
|
|
|
/**
|
|
@@ -258,7 +255,7 @@ export class SLineItem extends SGraphItem {
|
|
|
this.line[this.curIndex].y = event.y;
|
|
|
}
|
|
|
} else {
|
|
|
- return super.onMouseMove(event);
|
|
|
+ return false;
|
|
|
}
|
|
|
this.update();
|
|
|
return true;
|
|
@@ -281,10 +278,7 @@ export class SLineItem extends SGraphItem {
|
|
|
if (dis < len) {
|
|
|
len = dis;
|
|
|
this.curIndex = i;
|
|
|
- this.curPoint = new SPoint(
|
|
|
- this.line[this.curIndex].x,
|
|
|
- this.line[this.curIndex].y
|
|
|
- );
|
|
|
+ this.curPoint = this.line[this.curIndex];
|
|
|
}
|
|
|
}
|
|
|
} // Function findNearestPoint()
|