package dev.bytevibe.hyperpoint;

import java.io.Serializable;

/**
 * 可绘制对象的抽象基类
 */
public abstract class DrawableObject implements Serializable {
    protected double x;
    protected double y;
    protected double width;
    protected double height;
    protected String id;
    protected boolean selected;

    public DrawableObject(double x, double y, double width, double height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        this.id = java.util.UUID.randomUUID().toString();
        this.selected = false;
    }

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    /**
     * 检查点是否在对象内
     */
    public abstract boolean contains(double px, double py);

    /**
     * 获取对象类型名称
     */
    public abstract String getTypeName();
}

