package com.ys.bdtp.cad.items

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

/**
 * Created by lihao.
 * Date: 2021/6/7
 * 服务区域图形
 */
class ServeAreaItem(datas: ArrayList<PointF>, parent: SGraphyItem? = null) :
    SGraphyItem(parent) {
    /** 画笔 */
    val paint = Paint()
    val innerPaint = Paint()
    val path = Path()

    init {
        try {
//            flags = EnumSet.of(SGraphyItemFlag.ItemIsMovable, SGraphyItemFlag.ItemIsSelectable, SGraphyItemFlag.ItemIsFocusable)

        } catch (e: Exception) {
            e.printStackTrace()
        }
        paint.style = Paint.Style.STROKE
        paint.strokeJoin = Paint.Join.ROUND
        paint.isAntiAlias = true
        paint.color = Color.rgb(0x66, 0x66, 0xff)
        paint.strokeWidth = 150f

        innerPaint.color = Color.parseColor("#33ffb6c1")
        innerPaint.isAntiAlias = true
        innerPaint.style = Paint.Style.FILL

        val data1 = datas[0]
        val data2 = datas[1]
        path.moveTo(data1.x, -data1.y)
        path.lineTo(data1.x, -data2.y)
        path.lineTo(data2.x, -data2.y)
        path.lineTo(data2.x, -data1.y)
        path.close()
    } // Constructor

    override fun boundingRect(): RectF {
//        return RectF(data.x - 200f, -data.y - 200f, data.x + 200f, -data.y + 200f)
        return RectF()
    }


    /**
     * Item绘制操作
     *
     * @param   canvas          画布
     * @param   rect            绘制区域
     */
    override fun onDraw(canvas: Canvas) {
        canvas.drawPath(path, paint)
        canvas.drawPath(path, innerPaint)
    } // Function onDraw()

}