| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- import { Marker } from "../../types/topology/Marker";
- import { SGraphItem, STextItem } from "@saga-web/graph/lib";
- import { SPainter, SColor } from "@saga-web/draw";
- /**
- * 标识对象Item(文本类型)
- *
- * * @author 张宇(taohuzy@163.com)
- */
- export class STextMarkerItem extends STextItem {
- /** 标识对象数据 */
- data: Marker;
- /** x轴缩放属性 */
- _scaleX: number = 1;
- get scaleX(): number {
- return this._scaleX;
- }
- set scaleX(v: number) {
- this._scaleX = v;
- if (this.data.Scale) {
- this.data.Scale.X = v;
- }
- this.update();
- }
- /** y轴缩放属性 */
- _scaleY: number = 1;
- get scaleY(): number {
- return this._scaleY;
- }
- set scaleY(v: number) {
- this._scaleY = v;
- if (this.data.Scale) {
- this.data.Scale.Y = v;
- }
- this.update();
- }
- /** y轴旋转属性 */
- _rolate: number = 0;
- get rolate(): number {
- return this._rolate;
- }
- set rolate(v: number) {
- this._rolate = v;
- if (this.data.Rolate) {
- this.data.Rolate.Z = v;
- }
- this.update();
- }
- set name(v: string) {
- this.data.Name = v;
- }
- set text(v: string) {
- if (this.data.Properties) {
- this.data.Properties.Text = v;
- }
- }
- set x(v: number) {
- this.data.Pos.X = v;
- }
- set y(v: number) {
- this.data.Pos.Y = v;
- }
- set width(v: number) {
- if (this.data.Size) {
- this.data.Size.Width = v;
- }
- }
- set height(v: number) {
- if (this.data.Size) {
- this.data.Size.Height = v;
- }
- }
- /**
- * 构造函数
- *
- * @param parent 指向父对象
- * @param data 标识对象数据
- */
- constructor(parent: SGraphItem | null, data: Marker) {
- super(parent);
- this.data = data;
- this.moveTo(data.Pos.X, data.Pos.Y);
- if (this.data.Scale) {
- this.scaleX = this.data.Scale.X;
- this.scaleY = this.data.Scale.Y;
- }
- if (this.data.Rolate && this.data.Rolate.Z) {
- this.rolate = this.data.Rolate.Z;
- }
- if (this.data.Size) {
- this.width = this.data.Size.Width;
- this.height = this.data.Size.Height;
- }
- if (this.data.Properties && this.data.Properties.Text) {
- if (this.data.Properties.Text instanceof String) {
- this.text = this.data.Properties.Text;
- }
- }
- } // Constructor
- /**
- * Item绘制操作
- *
- * @param painter 绘画类
- */
- onDraw(painter: SPainter): void {
- // 绘制文本
- painter.brush.color = new SColor(this.color);
- painter.font = this.font;
- painter.scale(this.scaleX, this.scaleY);
- painter.rotate(this.rolate);
- this.drawFormatText(painter);
- } // Function onDraw()
- } // Class STextMarkerItem
|