|
@@ -40,9 +40,11 @@ export class SImageItem extends SObjectItem {
|
|
* 构造函数
|
|
* 构造函数
|
|
*
|
|
*
|
|
* @param parent 指向父Item
|
|
* @param parent 指向父Item
|
|
|
|
+ * @param url 图片地址
|
|
*/
|
|
*/
|
|
- constructor(parent: SGraphItem | null) {
|
|
|
|
|
|
+ constructor(parent: SGraphItem | null, url?: string) {
|
|
super(parent);
|
|
super(parent);
|
|
|
|
+ if (url) this._url = url;
|
|
} // Constructor
|
|
} // Constructor
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -77,9 +79,9 @@ export class SImageItem extends SObjectItem {
|
|
onDraw(painter: SPainter): void {
|
|
onDraw(painter: SPainter): void {
|
|
if (this.img) {
|
|
if (this.img) {
|
|
// 要绘制图片的宽度
|
|
// 要绘制图片的宽度
|
|
- let width = 0;
|
|
|
|
|
|
+ let width: number = 0;
|
|
// 要绘制图片的宽度
|
|
// 要绘制图片的宽度
|
|
- let height = 0;
|
|
|
|
|
|
+ let height: number = 0;
|
|
// 图片item的宽高比
|
|
// 图片item的宽高比
|
|
let itemAspectRatio: number = this.width / this.height;
|
|
let itemAspectRatio: number = this.width / this.height;
|
|
// 原始图片的宽高比
|
|
// 原始图片的宽高比
|
|
@@ -91,7 +93,7 @@ export class SImageItem extends SObjectItem {
|
|
if (this.showType == SImageShowType.Full) {
|
|
if (this.showType == SImageShowType.Full) {
|
|
width = this.width;
|
|
width = this.width;
|
|
height = this.height;
|
|
height = this.height;
|
|
- } else if (this.showType == SImageShowType.AutoFit) {
|
|
|
|
|
|
+ } else if (this.showType == SImageShowType.Equivalency) {
|
|
if (itemAspectRatio > imgAspectRatio) {
|
|
if (itemAspectRatio > imgAspectRatio) {
|
|
height = this.height;
|
|
height = this.height;
|
|
width = imgAspectRatio * height;
|
|
width = imgAspectRatio * height;
|
|
@@ -102,8 +104,13 @@ export class SImageItem extends SObjectItem {
|
|
width = this.width;
|
|
width = this.width;
|
|
height = this.height;
|
|
height = this.height;
|
|
}
|
|
}
|
|
|
|
+ } else if (this.showType == SImageShowType.AutoFit) {
|
|
|
|
+ this.width = this.img.width as number;
|
|
|
|
+ this.height = this.img.height as number;
|
|
|
|
+ width = this.width;
|
|
|
|
+ height = this.height;
|
|
}
|
|
}
|
|
- painter.drawImage(this.img, -width / 2, -height / 2, width, height);
|
|
|
|
|
|
+ painter.drawImage(this.img, - width / 2, - height / 2, width, height);
|
|
}
|
|
}
|
|
} // Function onDraw()
|
|
} // Function onDraw()
|
|
} // Class SImageItem
|
|
} // Class SImageItem
|