
import { SPainter, SRect, SSize, SColor, SPoint } from "@persagy-web/draw";
import { SImageShowType, STextOrigin } from "@persagy-web/graph";
import { SGraphItem, SImageItem } from "@persagy-web/graph";

/**
 * 图片item
 *
 * @author  张宇(taohuzy@163.com)
 */
export class EditImageItem extends SImageItem {
    constructor(parent: SGraphItem | null, url:string) {
        super(parent);
        this.url = url;
        this.initItem();
        this.origin = new SPoint(this.width / 2, this.height / 2);
    }
    // 初始化item
    initItem() {
        if (!this.url) {
            this.strokeColor = SColor.Black;
            this.width = 100;
            this.height = 100
        }
    }

    /**
     * 根据显示模式计算图片的宽高
     */
    computeImgSize(): void {
        super.computeImgSize();
        this.origin = new SPoint(this.width / 2, this.height / 2);
        this.update();
    } // Function computeImgSize()
} // Class SImageItem