SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
if the action is "fill part X with colour Y", then you need to store:
- that part X should get colour Y for redoing.
- that part X should get its original colour for undoing.
luck, db
There are no new questions, but there may be new answers.
Darryl Burke wrote:
Let's say I decided to support 20 undo-s. Then my cached image would be the image as it was 20 steps earlier. When I perform a new action, I would pop the earliest action from the stack and apply it to the cached image, and push the latest action on the stack.
To undo the last action, I would paint the cached image to the 'live' one and apply all but the last action.
Rob Spoor wrote:
Usually you need to store what action was taken, and how to undo that action. For instance, if the action is "fill part X with colour Y", then you need to store:
- that part X should get colour Y for redoing.
- that part X should get its original colour for undoing.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Tarun Bolla wrote:
Darryl Burke wrote:
Let's say I decided to support 20 undo-s. Then my cached image would be the image as it was 20 steps earlier. When I perform a new action, I would pop the earliest action from the stack and apply it to the cached image, and push the latest action on the stack.
To undo the last action, I would paint the cached image to the 'live' one and apply all but the last action.
Thats exactly what i did, but its throwing heap space errors.
luck, db
There are no new questions, but there may be new answers.
Darryl Burke wrote:And new action after one or more undo actions would remove the undone actions from the list
Darryl Burke wrote: An undo would cause the baseImage to be painted to the liveImage, followed by painting 19 (all but the last) EditAction. An index would record the present position in the list, permitting a redo.
Rob Spoor wrote:
If you're having heap space problems, you can try to use the -Xmx JVM flag. For instance, to be able to use up to 1.5GB of memory, you use -Xmx1536m. With a 32-bit JVM on Windows, that's about as much as the OS will give you. (A little experimenting has shown that my Java 6 update 26 gives me at most 1582 MB.)
Consider Paul's rocket mass heater. |