package com.ys.bdtp.graph.items

import android.graphics.*
import com.ys.bdtp.graph.SGraphyItem
import com.ys.bdtp.graph.enums.SGraphyItemFlag
import java.util.*

/**
 * SGraphy图形引擎图像Item
 *
 * @author  庞利祥(sybotan@126.com)
 *
 * @param   image       图像
 * @param   parent      指向父节点
 */
open class SGraphyImageItem(var image: Bitmap, parent: SGraphyItem? = null) : SGraphyItem(parent) {

    /** 画笔 */
    private var pen = Paint()

    /**
     * 默认构造函数
     */
    init {
        flags = EnumSet.of(SGraphyItemFlag.ItemIsMovable)
    } // init()

    /**
     * Item对象边界区域
     *
     * @return  边界区域
     */
    override fun boundingRect(): RectF {
        return RectF(0f, 0f, image.width.toFloat(), image.height.toFloat())
    } // Function boundingRect()

    /**
     * Item绘制操作
     *
     * @param   canvas      画布对象
     * @param   rect        更新区域
     */
    override fun onDraw(canvas: Canvas) {
        canvas.drawBitmap(image, 0f, 0f, pen)
        return
    } // Function paint()

} // Class SGraphyImageItem