notes106

notes106 - 02/04/02 Lab 2: Undo BoilerDraw->Graphic...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
02/04/02 Lab 2: Undo BoilerDraw->Graphic editor BoilerDrawMain->BoilerDrawUndoListner(filter)->BoilerDrawGraphicEditor Events (mouse keyboard) mouseDragged(x,y) mousePressed(x,y) mouseReleased(x,y) pull down menu options menuOption(option) openFile(fileName) saveFile(fileName) AddText(text) -BoilerDraw currently prints a message and calls the equivalent function every time one of the functions above are called. Implementation of Undo -Add code to BoilerDrawUndoListner to store the method invocation in a double linked list. ->mouse X->menu option->mouse X(current)->null -When menu option “Undo” is called -Don’t pass to BoilerDraw -Clear screen call _bDraw->menuOption(“New”) -Replay the calls to one node before current -Make current point to previous node. Hints -You may use List.java and ListNode. Java already provided. -Create different subclasses of ListNode for each call that needs to be replaced. 1). MouseEventNode 2). MenuOptionNode 3). OpenFileNode 4). AddTextNode 1). Store Xp, Yp(pressed) Xd1, Yd1(dragged) Xd2,Yd2(dragged) Xr, Yr(released)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2). Store String option 3). Store FileName 4). Store StringText -Each subclass should contain enough member variables to redo the event. -You may have a “do it” method in each node that executes the event. -When a method such as menuOption(option) is called -Create a new node MenuOptionNode -Adds node to end of list. -Increment current _The BoilerDrawUndoListner When it receives undo -Iterates over all list until current -Calls “doIt” for each node. _For mouse events store only enough information to reply the event.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

notes106 - 02/04/02 Lab 2: Undo BoilerDraw->Graphic...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online