|
@@ -47,7 +47,7 @@ export class SBaseTextEdit extends SGraphEdit {
|
|
|
protected _status: SItemStatus = SItemStatus.Normal;
|
|
|
get status(): SItemStatus {
|
|
|
return this._status;
|
|
|
- }
|
|
|
+ }
|
|
|
set status(value: SItemStatus) {
|
|
|
const oldStatus = this._status;
|
|
|
const newStatus = value;
|
|
@@ -55,7 +55,7 @@ export class SBaseTextEdit extends SGraphEdit {
|
|
|
|
|
|
this.$emit('StatusChange', oldStatus, newStatus)
|
|
|
this.update();
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
private _painter: SPainter | null = null;
|
|
|
|
|
@@ -63,13 +63,13 @@ export class SBaseTextEdit extends SGraphEdit {
|
|
|
private _text: string = "";
|
|
|
get text(): string {
|
|
|
return this._text;
|
|
|
- }
|
|
|
+ }
|
|
|
set text(v: string) {
|
|
|
this._text = v;
|
|
|
this._textArr = this.text.split(/\n/g);
|
|
|
this.drawFormatText();
|
|
|
this.update();
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
private _textArr: string[] = [];
|
|
@@ -79,7 +79,7 @@ export class SBaseTextEdit extends SGraphEdit {
|
|
|
private _width: number = 64;
|
|
|
get width(): number {
|
|
|
return this._width;
|
|
|
- }
|
|
|
+ }
|
|
|
set width(v: number) {
|
|
|
if (v > 0) {
|
|
|
if (v != this._width) {
|
|
@@ -91,13 +91,13 @@ export class SBaseTextEdit extends SGraphEdit {
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
private _height: number = 64;
|
|
|
get height(): number {
|
|
|
return this._height;
|
|
|
- }
|
|
|
+ }
|
|
|
set height(v: number) {
|
|
|
if (v > 0) {
|
|
|
if (v != this._height) {
|
|
@@ -109,7 +109,7 @@ export class SBaseTextEdit extends SGraphEdit {
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
origin = new SPoint();
|
|
@@ -126,73 +126,73 @@ export class SBaseTextEdit extends SGraphEdit {
|
|
|
private _color: SColor = new SColor("#333333");
|
|
|
get color(): SColor {
|
|
|
return this._color;
|
|
|
- }
|
|
|
+ }
|
|
|
set color(v: SColor) {
|
|
|
this._color = v;
|
|
|
this.update();
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- private _font: SFont;
|
|
|
+ private _font: SFont = new SFont("sans-serif", 12);
|
|
|
get font(): SFont {
|
|
|
return this._font;
|
|
|
- }
|
|
|
+ }
|
|
|
set font(v: SFont) {
|
|
|
this._font = v;
|
|
|
this.drawFormatText();
|
|
|
this.update();
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
private _backgroundColor: SColor = SColor.Transparent;
|
|
|
get backgroundColor(): SColor {
|
|
|
return this._backgroundColor;
|
|
|
- }
|
|
|
+ }
|
|
|
set backgroundColor(v: SColor) {
|
|
|
this._backgroundColor = v;
|
|
|
this.update();
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
private _strokeColor: SColor = SColor.Transparent;
|
|
|
get strokeColor(): SColor {
|
|
|
return this._strokeColor;
|
|
|
- }
|
|
|
+ }
|
|
|
set strokeColor(v: SColor) {
|
|
|
this._strokeColor = v;
|
|
|
console.log(this._strokeColor)
|
|
|
this.update();
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
private _lineWidth: number = 1;
|
|
|
get lineWidth(): number {
|
|
|
return this._lineWidth;
|
|
|
- }
|
|
|
+ }
|
|
|
set lineWidth(v: number) {
|
|
|
this._lineWidth = v;
|
|
|
this.update();
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
private _borderStyle: SLineStyle = SLineStyle.None;
|
|
|
get borderStyle(): SLineStyle {
|
|
|
return this._borderStyle;
|
|
|
- }
|
|
|
+ }
|
|
|
set borderStyle(v: SLineStyle) {
|
|
|
this._borderStyle = v;
|
|
|
this.update();
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
private _originPosition: STextOrigin = STextOrigin.LeftTop;
|
|
|
get originPosition(): STextOrigin {
|
|
|
return this._originPosition;
|
|
|
- }
|
|
|
+ }
|
|
|
set originPosition(v: STextOrigin) {
|
|
|
this._originPosition = v;
|
|
|
this.update();
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
maxWidth: number | undefined = undefined;
|
|
@@ -203,7 +203,7 @@ export class SBaseTextEdit extends SGraphEdit {
|
|
|
* @param parent 指向父Item
|
|
|
* @param str 文本内容
|
|
|
*/
|
|
|
- constructor(parent: SGraphItem | null,data:Marker) {
|
|
|
+ constructor(parent: SGraphItem | null, data: Marker) {
|
|
|
super(parent);
|
|
|
this.showSelect = false;
|
|
|
this.zOrder = ItemOrder.textOrder;
|
|
@@ -212,8 +212,8 @@ export class SBaseTextEdit extends SGraphEdit {
|
|
|
this.name = data.name;
|
|
|
this.moveTo(data.pos.x, data.pos.y);
|
|
|
if (data.size) {
|
|
|
- this.width = data.size.Width;
|
|
|
- this.height = data.size.Height;
|
|
|
+ this.width = data.size.width;
|
|
|
+ this.height = data.size.height;
|
|
|
}
|
|
|
if (data.style && data.style.default) {
|
|
|
|
|
@@ -225,12 +225,12 @@ export class SBaseTextEdit extends SGraphEdit {
|
|
|
this.text = data.style.default.text;
|
|
|
}
|
|
|
|
|
|
- if (data.style.default.color) {
|
|
|
- this.color = new SColor(data.style.default.color);
|
|
|
+ if (data.style.default.strokeColor) {
|
|
|
+ this.strokeColor = new SColor(data.style.default.strokeColor);
|
|
|
}
|
|
|
|
|
|
if (data.style.default.font) {
|
|
|
- this.font = new SFont("sans-serif", data.style.default.font);;
|
|
|
+ this.font = new SFont("sans-serif", data.style.default.font);
|
|
|
}
|
|
|
|
|
|
if (data.style.default.backgroundColor) {
|
|
@@ -320,7 +320,7 @@ export class SBaseTextEdit extends SGraphEdit {
|
|
|
this.width = textMaxWidth;
|
|
|
this.height = fontSize * 1.25 * this._textArr.length + fontSize / 8;
|
|
|
|
|
|
- if (this.originPosition == STextOrigin.Centrum) {
|
|
|
+ if (this.originPosition == STextOrigin.entrum) {
|
|
|
this.origin = new SPoint(this.width / 2, this.height / 2);
|
|
|
}
|
|
|
this._painter.restore();
|
|
@@ -328,6 +328,24 @@ export class SBaseTextEdit extends SGraphEdit {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ * 返回对象储存的相关数据
|
|
|
+ *
|
|
|
+ * @return formData
|
|
|
+ */
|
|
|
+ toData(): any {
|
|
|
+ if (this.data.size) {
|
|
|
+ this.data.size.width = this.width
|
|
|
+ this.data.size.height = this.height;
|
|
|
+ }
|
|
|
+ this.data.style.default.zorder = this.zOrder;
|
|
|
+ this.data.style.default.text = this.text;
|
|
|
+ this.data.style.default.strokeColor = this.strokeColor.value;
|
|
|
+ this.data.style.default.font = this.font.size;
|
|
|
+ this.data.style.default.backgroundColor = this.backgroundColor.value;
|
|
|
+ return this.data
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
* Item绘制操作
|
|
|
*
|
|
|
* @param painter 绘画类
|