Prechádzať zdrojové kódy

'文本图片icon样式调整'

zhangyu 4 rokov pred
rodič
commit
9c92267a7a

+ 2 - 2
package.json

@@ -9,10 +9,10 @@
   },
   "dependencies": {
     "@saga-web/base": "2.1.22",
-    "@saga-web/big": "1.0.75",
+    "@saga-web/big": "1.0.78",
     "@saga-web/draw": "2.1.100",
     "@saga-web/feng-map": "1.0.23",
-    "@saga-web/graph": "2.1.106",
+    "@saga-web/graph": "2.1.108",
     "ant-design-vue": "^1.6.0",
     "core-js": "^3.6.4",
     "element-ui": "^2.13.2",

+ 11 - 8
src/lib/items/SImageLegendItem.ts

@@ -26,7 +26,7 @@ export class SImageLegendItem extends SIconTextItem {
             this.data.Num = 1;
         }
         this.data.Properties.Num = this._num;
-        this.textItem.text = `${this.name}${this.num > 1 ? ` × ${this.num}` : ''}`;
+        this.textItem.text = `${this.name}${this.num > 1 ? `×${this.num}` : ''}`;
         this.update();
     }
 
@@ -36,7 +36,7 @@ export class SImageLegendItem extends SIconTextItem {
     set text(v: string) {
         this.name = v;
         this.data.Name = v;
-        this.textItem.text = `${this.name}${this.num > 1 ? ` × ${this.num}` : ''}`;
+        this.textItem.text = `${this.name}${this.num > 1 ? `×${this.num}` : ''}`;
         this.update();
     }
 
@@ -78,21 +78,24 @@ export class SImageLegendItem extends SIconTextItem {
         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.ImgPos) {
+            this.img.moveTo(data.Properties.ImgPos.X, data.Properties.ImgPos.Y);
+        }
         if (data.Properties && data.Properties.font) {
             this.font = new SFont("sans-serif", data.Properties.font);
         }
+        if (data.Properties.TextPos) {
+            this.textItem.moveTo(data.Properties.TextPos.X, data.Properties.TextPos.Y);
+        } else {
+            // 偏移二分之一文本高度
+            this.textItem.moveTo((this.img.width * 0.5) + 2, -(this.font.size * 0.5));
+        }
         if (data.Properties && data.Properties.color) {
             this.color = new SColor(data.Properties.color);
         }

+ 11 - 6
src/lib/items/SImageMarkerItem.ts

@@ -1,6 +1,6 @@
 
 import { SGraphItem, SImageItem } from "@saga-web/graph/lib";
-import { SPainter, SColor } from "@saga-web/draw";
+import { SPainter, SColor, SPoint } from "@saga-web/draw";
 import { Marker } from '../types/Marker';
 import { ItemOrder } from '@saga-web/big/lib';
 import { hexify } from "@/components/mapClass/until";
@@ -42,8 +42,18 @@ export class SImageMarkerItem extends SImageItem {
         if (data.Properties.StrokeColor) {
             this.strokeColor = data.Properties.StrokeColor.includes('#') ? new SColor(data.Properties.StrokeColor) : new SColor(hexify(data.Properties.StrokeColor));
         }
+        this.origin = new SPoint(this.width / 2, this.height / 2);
     } // Constructor
 
+    /**
+     * 根据显示模式计算图片的宽高
+     */
+    computeImgSize(): void {
+        super.computeImgSize();
+        this.origin = new SPoint(this.width / 2, this.height / 2);
+        this.update();
+    } // Function computeImgSize()
+
     toData(): Marker {
         this.data.Pos = {X: this.x, Y: this.y};
         this.data.Size = {Width: this.width, Height: this.height};
@@ -52,9 +62,4 @@ export class SImageMarkerItem extends SImageItem {
         this.data.Properties.LineWidth = this.lineWidth;
         return this.data;
     }
-
-    onDraw(painter: SPainter) {
-        painter.translate(-this.width / 2 , -this.height / 2);
-        super.onDraw(painter);
-    } // onDraw
 } // Class SImageMarkerItem

+ 10 - 7
src/lib/items/STextMarkerItem.ts

@@ -1,5 +1,5 @@
 import { SGraphItem, STextItem, SLineStyle } from "@saga-web/graph/lib";
-import { SPainter, SColor,SFont } from "@saga-web/draw";
+import { SPainter, SColor,SFont, SPoint } from "@saga-web/draw";
 import { Marker } from '../types/Marker';
 import { ItemOrder } from '@saga-web/big/lib';
 
@@ -44,6 +44,15 @@ export class STextMarkerItem extends STextItem {
         }
     } // 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};
@@ -53,10 +62,4 @@ export class STextMarkerItem extends STextItem {
         this.data.Properties.BackgroundColor = this.backgroundColor.value;
         return this.data;
     }
-
-
-    onDraw(painter: SPainter) {
-        painter.translate(-this.width / 2 , -this.height / 2);
-        super.onDraw(painter);
-    } // onDraw
 } // Class STextMarkerItem

+ 2 - 2
vue.config.js

@@ -25,8 +25,8 @@ module.exports = {
                 },
             },
             '/data': {
-                target: 'http://192.168.200.87:9003',
-                // target: 'http://60.205.177.43:9903', //阿里云
+                // target: 'http://192.168.200.87:9003',
+                target: 'http://60.205.177.43:9903', //阿里云
                 changeOrigin: true,
                 secure: false,
                 pathRewrite: {