I'm working on a very basic shape drawing GUI program. I have everything working (draw/move/select) and am now working on redo/undo functionality. Both redo/undo work for draw, but I'm running into trouble with move that I think should be pretty simple. When my shapes move, they go through the following:
for(IShape i : selectedList){
undoStack.push(i);
drawInstanceTwo.shapeList.remove(i);
move.updateShape(i, start, end);
drawInstanceTwo.shapeList.push(i, canvas, state);
}
The idea here being that it will push the shapes current form (Point x/y) onto the undoStack so that if I wish to undo the movement, I can pop it from the stack upon pressing my undo button. Move.updateShape changes the points of the shape, and then it is pushed onto my overall shapeList to repaint the GUI. The issue I'm running into is that later in my undo method I call:
priorShape = undoStack.pop();
And it returns the shape AFTER the points have been changed. Why is this? I already pushed it onto the stack as it was prior to the points being edited, so why is it changing within the stack? Thanks for any suggestions!