|
@@ -92,66 +92,21 @@ export class SImageMarkerItem extends SImageItem {
|
|
|
this.data = data;
|
|
|
this.id = data.ID;
|
|
|
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 (data.Scale) {
|
|
|
+ // this.scaleX = data.Scale.X;
|
|
|
+ // this.scaleY = data.Scale.Y;
|
|
|
// }
|
|
|
- // if (this.data.Rolate && this.data.Rolate.Z) {
|
|
|
- // this.rolate = this.data.Rolate.Z;
|
|
|
+ // if (data.Rolate && data.Rolate.Z) {
|
|
|
+ // this.rolate = data.Rolate.Z;
|
|
|
// }
|
|
|
- if (this.data.Size) {
|
|
|
- this.width = this.data.Size.Width;
|
|
|
- this.height = this.data.Size.Height;
|
|
|
+ if (data.Size) {
|
|
|
+ this.width = data.Size.Width;
|
|
|
+ this.height = data.Size.Height;
|
|
|
}
|
|
|
- if (this.data.Properties && this.data.Properties.Url) {
|
|
|
- if (this.data.Properties.Url instanceof String) {
|
|
|
- this.url = this.data.Properties.Url;
|
|
|
+ if (data.Properties && data.Properties.Url) {
|
|
|
+ if (data.Properties.Url instanceof String) {
|
|
|
+ this.url = data.Properties.Url;
|
|
|
}
|
|
|
}
|
|
|
} // Constructor
|
|
|
-
|
|
|
- /**
|
|
|
- * Item绘制操作
|
|
|
- *
|
|
|
- * @param painter 绘画类
|
|
|
- */
|
|
|
- onDraw(painter: SPainter): void {
|
|
|
- if (this.img) {
|
|
|
- // 要绘制图片的宽度
|
|
|
- let width = 0;
|
|
|
- // 要绘制图片的宽度
|
|
|
- let height = 0;
|
|
|
- // 图片item的宽高比
|
|
|
- let itemAspectRatio: number = this.width / this.height;
|
|
|
- // 原始图片的宽高比
|
|
|
- let imgAspectRatio: number =
|
|
|
- (this.img.width as number) / (this.img.height as number);
|
|
|
- // 原始图片的高宽比
|
|
|
- let imgHwRatio: number =
|
|
|
- (this.img.height as number) / (this.img.width as number);
|
|
|
- if (this.showType == SImageShowType.Full) {
|
|
|
- width = this.width;
|
|
|
- height = this.height;
|
|
|
- } else if (this.showType == SImageShowType.Equivalency) {
|
|
|
- if (itemAspectRatio > imgAspectRatio) {
|
|
|
- height = this.height;
|
|
|
- width = imgAspectRatio * height;
|
|
|
- } else if (itemAspectRatio < imgAspectRatio) {
|
|
|
- width = this.width;
|
|
|
- height = width * imgHwRatio;
|
|
|
- } else {
|
|
|
- width = this.width;
|
|
|
- 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.scale(this.scaleX, this.scaleY);
|
|
|
- // painter.rotate(this.rolate);
|
|
|
- painter.drawImage(this.img, -width / 2, -height / 2, width, height);
|
|
|
- }
|
|
|
- } // Function onDraw()
|
|
|
} // Class SImageMarkerItem
|