import { SGraphItem, STextItem, SLineStyle } from "@saga-web/graph/lib"; import { SPainter, SColor,SFont, SPoint } from "@saga-web/draw"; import { Marker } from '../types/Marker'; import { ItemOrder } from '@saga-web/big/lib'; /** * 标识对象Item(文本类型) * * * @author 张宇(taohuzy@163.com) */ export class STextMarkerItem extends STextItem { /** 标识对象数据 */ data: Marker; /** * 构造函数 * * @param parent 指向父对象 * @param data 标识对象数据 */ constructor(parent: SGraphItem | null, data: Marker) { super(parent); this.zOrder = ItemOrder.textOrder; this.isTransform = false; this.data = data; this.id = data.ID; 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; } if (data.Properties && data.Properties.Text) { this.text = data.Properties.Text; } if (data.Properties && data.Properties.Color) { this.color = new SColor(data.Properties.Color); } if (data.Properties && data.Properties.Font) { this.font = new SFont("sans-serif", data.Properties.Font);; } if (data.Properties && data.Properties.BackgroundColor) { this.backgroundColor = new SColor(data.Properties.BackgroundColor); } } // Constructor /** * 根据换行切割文本,绘制多行并计算外轮廓宽高 * */ protected drawFormatText(): void { super.drawFormatText(); this.origin = new SPoint(this.width / 2, this.height / 2); } // Function drawFormatText() toData(): Marker { this.data.Pos = {X: this.x, Y: this.y}; this.data.Size = {Width: this.width, Height: this.height}; this.data.Properties.Text = this.text; this.data.Properties.Color = this.color.value; this.data.Properties.Font = this.font.size; this.data.Properties.BackgroundColor = this.backgroundColor.value; return this.data; } } // Class STextMarkerItem