package dev.bytevibe.hyperpoint;

/**
 * 删除对象命令
 */
public class DeleteObjectCommand implements Command {
    private PageContent pageContent;
    private DrawableObject object;
    private int originalIndex;

    public DeleteObjectCommand(PageContent pageContent, DrawableObject object) {
        this.pageContent = pageContent;
        this.object = object;
        this.originalIndex = pageContent.getObjectIndex(object);
    }

    @Override
    public void execute() {
        pageContent.removeObject(object);
    }

    @Override
    public void undo() {
        pageContent.addObjectAt(originalIndex, object);
    }
}

