2,2c2,2 < * @(#)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,23 > * 15a25,26 > * > * @version <$CURRENT_VERSION$> 71a83,83 > 76a89,164 > 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 { 77,77d88 < class NorthEastHandle extends LocatorHandle { 91,91c178,178 < class EastHandle extends LocatorHandle { --- > class EastHandle extends ResizeHandle { 104,104c191,191 < class NorthHandle extends LocatorHandle { --- > class NorthHandle extends ResizeHandle { 118,118c205,205 < class NorthWestHandle extends LocatorHandle { --- > class NorthWestHandle extends ResizeHandle { 132,132c219,219 < class SouthEastHandle extends LocatorHandle { --- > class SouthEastHandle extends ResizeHandle { 146,146c233,233 < class SouthHandle extends LocatorHandle { --- > class SouthHandle extends ResizeHandle { 160,160c247,247 < class SouthWestHandle extends LocatorHandle { --- > class SouthWestHandle extends ResizeHandle { 174,174c261,261 < class WestHandle extends LocatorHandle { --- > class WestHandle extends ResizeHandle {