|
@@ -1,5 +1,5 @@
|
|
import { SObjectItem } from "./SObjectItem";
|
|
import { SObjectItem } from "./SObjectItem";
|
|
-import { SPainter, SRect, SSize } from "@saga-web/draw/lib";
|
|
|
|
|
|
+import { SPainter, SRect, SSize, SColor } from "@saga-web/draw/lib";
|
|
import { SImageShowType } from "../enums/SImageShowType";
|
|
import { SImageShowType } from "../enums/SImageShowType";
|
|
import { SGraphItem } from "../SGraphItem";
|
|
import { SGraphItem } from "../SGraphItem";
|
|
|
|
|
|
@@ -22,6 +22,9 @@ export class SImageItem extends SObjectItem {
|
|
this.update();
|
|
this.update();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /** 图片加载是否完成 */
|
|
|
|
+ isLoadOver: boolean = false;
|
|
|
|
+
|
|
/** 图片地址 */
|
|
/** 图片地址 */
|
|
private _url: string = "";
|
|
private _url: string = "";
|
|
get url(): string {
|
|
get url(): string {
|
|
@@ -32,8 +35,15 @@ export class SImageItem extends SObjectItem {
|
|
this.img = new Image();
|
|
this.img = new Image();
|
|
this.img.src = v;
|
|
this.img.src = v;
|
|
this.img.onload = (): void => {
|
|
this.img.onload = (): void => {
|
|
|
|
+ this.isLoadOver = true;
|
|
this.update();
|
|
this.update();
|
|
};
|
|
};
|
|
|
|
+ this.img.onerror = (e): void => {
|
|
|
|
+ this.isLoadOver = false;
|
|
|
|
+ this.update();
|
|
|
|
+ console.log("加载图片错误!");
|
|
|
|
+ console.log(e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -77,7 +87,7 @@ export class SImageItem extends SObjectItem {
|
|
* @param painter 绘画类
|
|
* @param painter 绘画类
|
|
*/
|
|
*/
|
|
onDraw(painter: SPainter): void {
|
|
onDraw(painter: SPainter): void {
|
|
- if (this.img) {
|
|
|
|
|
|
+ if (this.isLoadOver) {
|
|
// 要绘制图片的宽度
|
|
// 要绘制图片的宽度
|
|
let width: number = 0;
|
|
let width: number = 0;
|
|
// 要绘制图片的宽度
|
|
// 要绘制图片的宽度
|
|
@@ -111,6 +121,15 @@ export class SImageItem extends SObjectItem {
|
|
height = this.height;
|
|
height = this.height;
|
|
}
|
|
}
|
|
painter.drawImage(this.img, -width / 2, -height / 2, width, height);
|
|
painter.drawImage(this.img, -width / 2, -height / 2, width, height);
|
|
|
|
+ } else {
|
|
|
|
+ painter.pen.lineWidth = painter.toPx(1);
|
|
|
|
+ painter.pen.lineDash = [
|
|
|
|
+ painter.toPx(3),
|
|
|
|
+ painter.toPx(7)
|
|
|
|
+ ];
|
|
|
|
+ painter.pen.color = new SColor("#c0ccda");
|
|
|
|
+ painter.brush.color = SColor.Transparent;
|
|
|
|
+ painter.drawRect(this.boundingRect());
|
|
}
|
|
}
|
|
} // Function onDraw()
|
|
} // Function onDraw()
|
|
} // Class SImageItem
|
|
} // Class SImageItem
|