2c2 < * @(#)BoxHandleKit.java 5.2 --- > * @(#)BoxHandleKit.java 3a4,9 > * Project: JHotdraw - a GUI framework for technical drawings > * http://www.jhotdraw.org > * http://jhotdraw.sourceforge.net > * Copyright: © by the original author(s) and all contributors > * License: Lesser GNU Public License (LGPL) > * http://www.opensource.org/licenses/lgpl-license.html 8a15,16 > import CH.ifa.draw.util.Undoable; > import CH.ifa.draw.util.UndoableAdapter; 14a23 > * 15a25,26 > * > * @version <$CURRENT_VERSION$> 71a83 > 77c89,164 < class NorthEastHandle extends LocatorHandle { --- > class ResizeHandle extends LocatorHandle { > ResizeHandle(Figure owner, Locator loc) { > super(owner, loc); > } > > public void invokeStart(int x, int y, DrawingView view) { > setUndoActivity(createUndoActivity()); > getUndoActivity().setAffectedFigures(new SingleFigureEnumerator(owner())); > ((ResizeHandle.UndoActivity)getUndoActivity()).setOldDisplayBox(owner().displayBox()); > } > > public void invokeEnd(int x, int y, int anchorX, int anchorY, DrawingView view) { > Rectangle oldDisplayBox = ((ResizeHandle.UndoActivity)getUndoActivity()).getOldDisplayBox(); > if (owner().displayBox().equals(oldDisplayBox)) { > // display box hasn't change so there is nothing to undo > setUndoActivity(null); > } > } > > /** > * Factory method for undo activity. To be overriden by subclasses. > */ > protected Undoable createUndoActivity() { > return new ResizeHandle.UndoActivity(); > } > > public static class UndoActivity extends UndoableAdapter { > private Rectangle myOldDisplayBox; > > public UndoActivity() { > super(null); > setUndoable(true); > setRedoable(true); > } > > public boolean undo() { > if (!super.undo()) { > return false; > } > > return resetDisplayBox(); > } > > public boolean redo() { > // do not call execute directly as the selection might has changed > if (!isRedoable()) { > return false; > } > > return resetDisplayBox(); > } > > private boolean resetDisplayBox() { > FigureEnumeration fe = getAffectedFigures(); > if (!fe.hasMoreElements()) { > return false; > } > Figure currentFigure = fe.nextFigure(); > > Rectangle figureDisplayBox = currentFigure.displayBox(); > currentFigure.displayBox(getOldDisplayBox()); > setOldDisplayBox(figureDisplayBox); > return true; > } > > protected void setOldDisplayBox(Rectangle newOldDisplayBox) { > myOldDisplayBox = newOldDisplayBox; > } > > public Rectangle getOldDisplayBox() { > return myOldDisplayBox; > } > } > } > > class NorthEastHandle extends ResizeHandle { 91c178 < class EastHandle extends LocatorHandle { --- > class EastHandle extends ResizeHandle { 104c191 < class NorthHandle extends LocatorHandle { --- > class NorthHandle extends ResizeHandle { 118c205 < class NorthWestHandle extends LocatorHandle { --- > class NorthWestHandle extends ResizeHandle { 132c219 < class SouthEastHandle extends LocatorHandle { --- > class SouthEastHandle extends ResizeHandle { 146c233 < class SouthHandle extends LocatorHandle { --- > class SouthHandle extends ResizeHandle { 160c247 < class SouthWestHandle extends LocatorHandle { --- > class SouthWestHandle extends ResizeHandle { 174c261 < class WestHandle extends LocatorHandle { --- > class WestHandle extends ResizeHandle {