|
@@ -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
|
|
@@ -38,6 +39,46 @@ export class STextItem extends SObjectItem {
|
|
|
this.update();
|
|
|
}
|
|
|
|
|
|
+ /** 背景色 */
|
|
|
+ private _backgroundColor: string = "#00000000";
|
|
|
+ get backgroundColor(): string {
|
|
|
+ return this._backgroundColor;
|
|
|
+ }
|
|
|
+ set backgroundColor(v: string) {
|
|
|
+ this._backgroundColor = v;
|
|
|
+ this.update();
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 边框宽度 */
|
|
|
+ private _borderWidth: number = 1;
|
|
|
+ get borderWidth(): number {
|
|
|
+ return this._borderWidth;
|
|
|
+ }
|
|
|
+ set borderWidth(v: number) {
|
|
|
+ this._borderWidth = v;
|
|
|
+ this.update();
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 边框色 */
|
|
|
+ private _borderColor: string = "#00000000";
|
|
|
+ get borderColor(): string {
|
|
|
+ return this._borderColor;
|
|
|
+ }
|
|
|
+ set borderColor(v: string) {
|
|
|
+ this._borderColor = v;
|
|
|
+ this.update();
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 边框样式 */
|
|
|
+ private _borderStyle: SLineStyle = SLineStyle.Soild;
|
|
|
+ get borderStyle(): SLineStyle {
|
|
|
+ return this._borderStyle;
|
|
|
+ }
|
|
|
+ set borderStyle(v: SLineStyle) {
|
|
|
+ this._borderStyle = v;
|
|
|
+ this.update();
|
|
|
+ }
|
|
|
+
|
|
|
/** 文本绘制最大宽 */
|
|
|
maxWidth: number | undefined = undefined;
|
|
|
|
|
@@ -64,39 +105,26 @@ export class STextItem extends SObjectItem {
|
|
|
} // Function boundingRect()
|
|
|
|
|
|
/**
|
|
|
- * 绘制编辑和创建状态文本Item
|
|
|
+ * 绘制显示状态文本Item
|
|
|
*
|
|
|
* @param painter 绘制类
|
|
|
*/
|
|
|
- protected drawEditText(painter: SPainter): void {
|
|
|
- //绘制文本
|
|
|
- painter.brush.color = new SColor(this.color);
|
|
|
- painter.font = this.font;
|
|
|
- this.drawFormatText(painter);
|
|
|
-
|
|
|
+ protected drawShowText(painter: SPainter): void {
|
|
|
//绘制矩形轮廓
|
|
|
- painter.brush.color = SColor.Transparent;
|
|
|
- painter.pen.color = new SColor("#17B8EA");
|
|
|
- painter.pen.lineDash = [3, 2];
|
|
|
- painter.pen.lineWidth = painter.toPx(1);
|
|
|
+ painter.brush.color = this.backgroundColor;
|
|
|
+ painter.pen.color = this.borderColor;
|
|
|
+ painter.pen.lineWidth = painter.toPx(this.borderWidth);
|
|
|
+ if (this.borderStyle == SLineStyle.Dashed) {
|
|
|
+ painter.pen.lineDash = [painter.toPx(this.borderWidth * 3), painter.toPx(this.borderWidth * 7)];
|
|
|
+ } else if (this.borderStyle == SLineStyle.Dotted) {
|
|
|
+ painter.pen.lineDash = [painter.toPx(this.borderWidth), painter.toPx(this.borderWidth)];
|
|
|
+ }
|
|
|
painter.drawRect(this.boundingRect());
|
|
|
- } // Function drawEditText()
|
|
|
|
|
|
- /**
|
|
|
- * 绘制显示状态文本Item
|
|
|
- *
|
|
|
- * @param painter 绘制类
|
|
|
- */
|
|
|
- protected drawShowText(painter: SPainter): void {
|
|
|
- // 绘制文本
|
|
|
+ //绘制文本
|
|
|
painter.brush.color = new SColor(this.color);
|
|
|
painter.font = this.font;
|
|
|
this.drawFormatText(painter);
|
|
|
-
|
|
|
- // 绘制矩形轮廓
|
|
|
- painter.brush.color = SColor.Transparent;
|
|
|
- painter.pen.color = SColor.Transparent;
|
|
|
- painter.drawRect(this.boundingRect());
|
|
|
} // Function drawShowText()
|
|
|
|
|
|
/**
|