package cn.sagacloud.android.cadengine.items


import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.drawable.BitmapDrawable
import android.util.Log
import android.view.GestureDetector
import android.view.MotionEvent
import cn.sagacloud.android.cadengine.types.Point
import com.sybotan.android.graphy.SGraphyItem
import com.sybotan.android.graphy.SMotionEvent
import com.sybotan.android.graphy.enums.SGraphyItemFlag
import java.util.*


/**
 * Created by lihao.
 * Date: 2021/6/4
 */
class EquipItem(val data: Point, parent: SGraphyItem? = null, defaultScale: Float? = null) :
    SGraphyItem(parent) {
    /** 新建 画笔 */
    val mPaint_inner = Paint()
    val mPaint_center = Paint()
    var mDefaultScale = 0f

    init {
        if (defaultScale != null) {
            mDefaultScale = defaultScale
        }

        /** 新建 */
        //内圈
        mPaint_inner.color = Color.parseColor("#66272727")
        mPaint_inner.isAntiAlias = true
        mPaint_inner.style = Paint.Style.FILL
        //中圈
        mPaint_center.color = Color.parseColor("#ff00ff")
        mPaint_center.isAntiAlias = true
        mPaint_center.style = Paint.Style.FILL
        flags = EnumSet.of(
            SGraphyItemFlag.ItemIsMovable,
            SGraphyItemFlag.ItemIsSelectable,
            SGraphyItemFlag.ItemIsFocusable
        )
    }

    override fun onSingleTapUp(e: SMotionEvent): Boolean {
        Log.e("TAG", "x=" + e.viewX.toString() + "，y=" + e.viewY.toString())
        return super.onSingleTapUp(e)
    }

    /**
     * Item绘制操作
     *
     * @param   canvas          画布
     * @param   rect            绘制区域
     */

    override fun onDraw(canvas: Canvas) {
        data.scalePoint = mDefaultScale / scene!!.view!!.scale
        canvas.drawCircle(data.mX, data.mY, 500f, mPaint_center)
//        canvas.drawCircle(data.mX, -data.mY, 1500f, mPaint_inner)
        super.onDraw(canvas)
    } // Function onDraw()

}