123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- import { SIconTextItem } from '@saga-web/big/lib/items/SIconTextItem';
- import { ItemOrder } from '@saga-web/big/lib';
- import { SFont, SColor } from '@saga-web/draw/lib';
- /**
- * 图例节点Item(图标类型)
- *
- * * @author 张宇(taohuzy@163.com)
- */
- export class SImageLegendItem extends SIconTextItem {
- /**
- * 构造函数
- *
- * @param parent 指向父对象
- * @param data 图例节点对象数据
- */
- constructor(parent, data) {
- super(parent, data.AnchorList);
- /** 图例数量 */
- this._num = 1;
- this.isTransform = false;
- this.zOrder = ItemOrder.markOrder;
- this.data = data;
- this.id = data.ID;
- this.name = data.Name;
- this.moveTo(data.Pos.X, data.Pos.Y);
- if (data.Num) {
- this._num = data.Num;
- }
- if (data.Size) {
- this.width = data.Size.Width;
- this.height = data.Size.Height;
- }
- if (data.Num) {
- this.text = `${data.Name}${data.Num > 1 ? ` × ${data.Num}` : ''}`;
- }
- if (data.Properties && data.Properties.Url) {
- this.img.url = data.Properties.Url;
- }
- if (data.Properties.ImgPos) {
- this.img.moveTo(data.Properties.ImgPos.X, data.Properties.ImgPos.Y);
- }
- if (data.Properties.TextPos) {
- this.textItem.moveTo(data.Properties.TextPos.X, data.Properties.TextPos.Y);
- }
- if (data.Properties && data.Properties.sWidth) {
- this.sWidth = data.Properties.sWidth;
- }
- if (data.Properties && data.Properties.sHeight) {
- this.sHeight = data.Properties.sHeight;
- }
- if (data.Properties && data.Properties.font) {
- this.font = new SFont("sans-serif", data.Properties.font);
- }
- if (data.Properties && data.Properties.color) {
- this.color = new SColor(data.Properties.color);
- }
- }
- get num() {
- return this._num;
- }
- set num(v) {
- if (v) {
- this._num = v;
- this.data.Num = v;
- }
- else {
- this._num = 1;
- this.data.Num = 1;
- }
- this.data.Properties.Num = this._num;
- this.text = `${this.data.Name}${this.data.Num > 1 ? ` × ${this.data.Num}` : ''}`;
- this.update();
- }
- toData() {
- this.data.Pos = { X: this.x, Y: this.y };
- this.data.Size = { Width: this.width, Height: this.height };
- this.data.Name = this.name;
- this.data.Properties.Url = this.img.url;
- this.data.Properties.TextPos = { X: this.textItem.x, Y: this.textItem.y };
- this.data.Properties.ImgPos = { X: this.img.x, Y: this.img.y };
- this.data.Properties.sWidth = this.sWidth;
- this.data.Properties.sHeight = this.sHeight;
- this.data.Properties.font = this.font.size;
- this.data.Properties.color = this.color.value;
- this.data.AnchorList = this.anchorList.map(t => {
- return {
- ID: t.id,
- Pos: {
- X: t.x,
- Y: t.y
- }
- };
- });
- return this.data;
- }
- } // Class SImageLegendItem
|