"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SGraphMoveCommand = void 0; const SGraphCommand_1 = require("./SGraphCommand"); const lib_1 = require("@persagy-web/draw/lib"); class SGraphMoveCommand extends SGraphCommand_1.SGraphCommand { constructor(scene, item, old, pos) { super(scene); this.item = item; this.old = old; this.pos = pos; this.command = "SGraphMoveCommand"; this.desc = `移动对象=${item.id}`; } mergeWith(command) { if (command instanceof SGraphMoveCommand && command.item == this.item) { command.pos = this.pos; return true; } return false; } redo() { this.item.pos = new lib_1.SPoint(this.pos.x, this.pos.y); this.item.update(); } undo() { this.item.pos = new lib_1.SPoint(this.old.x, this.old.y); this.item.update(); } toString() { return `oldPos=${JSON.stringify(this.old)};\nnewPos=${JSON.stringify(this.pos)}`; } } exports.SGraphMoveCommand = SGraphMoveCommand;