giving ID's to objects? (for undo functionality)
I am making a drawing program. It will create different shapes, allow the user to resize, etc. I've been thinking of ways to do an undo feature, here is what I have so far:
- Every different shape object will know how to draw itself. So when the user resizes an object, a method is called which changes the x,y,w,h values of the object, then the object can redraw itself from that.
- The problem with this is the objects properties are constantly being changed, and I don't want to undo a 1 pixel move
- To fix this, I think I'll have a method which copies the object into an "undo array". This method will only be called on mouse down, so only the important copy is made.
- This is the part where I'm not sure if my current idea will work out. I was thinking of every object containing its own ID number as a variable (whenever an object is created that ID increments by 1). This way when the user selects undo, its easy to figure out what object in the shape array list will be replaced by the object in the undo array list. If the ID doesn't exist (aka undoing a delete) it is added to the array. Since there are a few million numbers that an int can contain, overlapping numbers shouldn't be an issue. But for some reason this seems like an ugly way to do it.
This turned out really long, but I partially did it to help myself think out the situation. Any ideas? Thanks!

