|
@@ -1,5 +1,5 @@
|
|
import { SObjectItem } from "./SObjectItem";
|
|
import { SObjectItem } from "./SObjectItem";
|
|
-import { SPainter, SRect, SColor, SFont } from "@saga-web/draw/lib";
|
|
|
|
|
|
+import { SPainter, SRect, SColor, SFont, SPoint } from "@saga-web/draw/lib";
|
|
import { SGraphItem } from "../SGraphItem";
|
|
import { SGraphItem } from "../SGraphItem";
|
|
import { SLineStyle } from "../enums/SLineStyle";
|
|
import { SLineStyle } from "../enums/SLineStyle";
|
|
|
|
|
|
@@ -110,7 +110,7 @@ export class STextItem extends SObjectItem {
|
|
* @return 边界区域
|
|
* @return 边界区域
|
|
*/
|
|
*/
|
|
boundingRect(): SRect {
|
|
boundingRect(): SRect {
|
|
- return new SRect(0, 0, this.width, this.height);
|
|
|
|
|
|
+ return new SRect(-this.origin.x, -this.origin.y, this.width, this.height);
|
|
} // Function boundingRect()
|
|
} // Function boundingRect()
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -178,6 +178,7 @@ export class STextItem extends SObjectItem {
|
|
// 在绘制文本后计算文本的宽高
|
|
// 在绘制文本后计算文本的宽高
|
|
this.width = textMaxWidth;
|
|
this.width = textMaxWidth;
|
|
this.height = (fontSize * 1.25) * this._textArr.length + (fontSize / 8);
|
|
this.height = (fontSize * 1.25) * this._textArr.length + (fontSize / 8);
|
|
|
|
+ this.origin = new SPoint(this.width / 2, this.height / 2);
|
|
this._painter.restore();
|
|
this._painter.restore();
|
|
}
|
|
}
|
|
} // Function drawFormatText()
|
|
} // Function drawFormatText()
|
|
@@ -188,6 +189,7 @@ export class STextItem extends SObjectItem {
|
|
* @param painter 绘画类
|
|
* @param painter 绘画类
|
|
*/
|
|
*/
|
|
onDraw(painter: SPainter): void {
|
|
onDraw(painter: SPainter): void {
|
|
|
|
+ painter.translate(-this.origin.x, -this.origin.y);
|
|
if (!(this._painter instanceof SPainter)) {
|
|
if (!(this._painter instanceof SPainter)) {
|
|
this._painter = painter;
|
|
this._painter = painter;
|
|
this.drawFormatText();
|
|
this.drawFormatText();
|