package dev.bytevibe.hyperpoint;

/**
 * 修改对象命令
 */
public class ModifyObjectCommand implements Command {
    private DrawableObject object;
    private double oldX, oldY, oldWidth, oldHeight;
    private double newX, newY, newWidth, newHeight;

    public ModifyObjectCommand(DrawableObject object,
                               double oldX, double oldY, double oldWidth, double oldHeight,
                               double newX, double newY, double newWidth, double newHeight) {
        this.object = object;
        this.oldX = oldX;
        this.oldY = oldY;
        this.oldWidth = oldWidth;
        this.oldHeight = oldHeight;
        this.newX = newX;
        this.newY = newY;
        this.newWidth = newWidth;
        this.newHeight = newHeight;
    }

    @Override
    public void execute() {
        object.setX(newX);
        object.setY(newY);
        object.setWidth(newWidth);
        object.setHeight(newHeight);
    }

    @Override
    public void undo() {
        object.setX(oldX);
        object.setY(oldY);
        object.setWidth(oldWidth);
        object.setHeight(oldHeight);
    }
}

