|
@@ -1,6 +1,7 @@
|
|
|
import { SObjectItem } from "./SObjectItem";
|
|
|
import { SPainter, SRect, SColor, SFont } from "@saga-web/draw/lib";
|
|
|
import { SGraphItem } from "../SGraphItem";
|
|
|
+import { SLineStyle } from "../enums/SLineStyle";
|
|
|
|
|
|
/**
|
|
|
* 文本item
|
|
@@ -27,11 +28,11 @@ export class STextItem extends SObjectItem {
|
|
|
private _textArr: string[] = [];
|
|
|
|
|
|
/** 文本颜色 */
|
|
|
- private _color: string = "#333333";
|
|
|
- get color(): string {
|
|
|
+ private _color: SColor = new SColor("#333333");
|
|
|
+ get color(): SColor {
|
|
|
return this._color;
|
|
|
}
|
|
|
- set color(v: string) {
|
|
|
+ set color(v: SColor) {
|
|
|
this._color = v;
|
|
|
this.update();
|
|
|
}
|
|
@@ -48,7 +49,7 @@ export class STextItem extends SObjectItem {
|
|
|
}
|
|
|
|
|
|
/** 背景色 */
|
|
|
- private _backgroundColor: SColor = new SColor("#00000000");
|
|
|
+ private _backgroundColor: SColor = SColor.Transparent;
|
|
|
get backgroundColor(): SColor {
|
|
|
return this._backgroundColor;
|
|
|
}
|
|
@@ -58,7 +59,7 @@ export class STextItem extends SObjectItem {
|
|
|
}
|
|
|
|
|
|
/** 边框色 */
|
|
|
- private _strokeColor: SColor = new SColor("#00000000");
|
|
|
+ private _strokeColor: SColor = SColor.Black;
|
|
|
get strokeColor(): SColor {
|
|
|
return this._strokeColor;
|
|
|
}
|
|
@@ -67,15 +68,23 @@ export class STextItem extends SObjectItem {
|
|
|
this.update();
|
|
|
}
|
|
|
|
|
|
- private _showBorder: boolean = false;
|
|
|
- get showBorder(): boolean {
|
|
|
- return this._showBorder;
|
|
|
+ /** 边框宽度 */
|
|
|
+ private _lineWidth: number = 1;
|
|
|
+ get lineWidth(): number {
|
|
|
+ return this._lineWidth;
|
|
|
}
|
|
|
- set showBorder(v: boolean) {
|
|
|
- if (this._showBorder === v) {
|
|
|
- return;
|
|
|
- }
|
|
|
- this._showBorder = v;
|
|
|
+ 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();
|
|
|
}
|
|
|
|
|
@@ -121,7 +130,17 @@ export class STextItem extends SObjectItem {
|
|
|
*/
|
|
|
protected drawShowText(painter: SPainter): void {
|
|
|
//绘制矩形轮廓
|
|
|
- if (this.showBorder) {
|
|
|
+ if (this.selected) {
|
|
|
+ this.borderStyle = SLineStyle.Dashed;
|
|
|
+ } else {
|
|
|
+ this.borderStyle = SLineStyle.None;
|
|
|
+ }
|
|
|
+ if (this.borderStyle == SLineStyle.Dashed) {
|
|
|
+ painter.pen.lineDash = [
|
|
|
+ painter.toPx(this.lineWidth * 3),
|
|
|
+ painter.toPx(this.lineWidth * 7)
|
|
|
+ ];
|
|
|
+ painter.pen.lineWidth = painter.toPx(this.lineWidth);
|
|
|
painter.brush.color = this.backgroundColor;
|
|
|
painter.pen.color = this.strokeColor;
|
|
|
painter.drawRect(this.boundingRect());
|