2c2 < * @(#)CreationTool.java 5.2 --- > * @(#)CreationTool.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 7a14,16 > import CH.ifa.draw.framework.*; > import CH.ifa.draw.util.UndoableAdapter; > import CH.ifa.draw.util.Undoable; 10,11c19 < < import CH.ifa.draw.framework.*; --- > import java.util.Vector; 22a31 > * 24a34,35 > * > * @version <$CURRENT_VERSION$> 40a52,57 > * the figure that was actually added > * Note, this can be a different figure from the one which has been created. > */ > private Figure myAddedFigure; > > /** 76,77c93,94 < fCreatedFigure.displayBox(fAnchorPoint, fAnchorPoint); < view().add(fCreatedFigure); --- > setAddedFigure((view().add(getCreatedFigure()))); > getAddedFigure().displayBox(fAnchorPoint, fAnchorPoint); 84,85c101,103 < if (fPrototype == null) < throw new HJDError("No protoype defined"); --- > if (fPrototype == null) { > throw new JHotDrawRuntimeException("No protoype defined"); > } 93c111 < fCreatedFigure.displayBox(fAnchorPoint, new Point(x,y)); --- > getAddedFigure().displayBox(fAnchorPoint, new Point(x,y)); 102,103c120,131 < if (fCreatedFigure.isEmpty()) < drawing().remove(fCreatedFigure); --- > if (getCreatedFigure().isEmpty()) { > drawing().remove(getAddedFigure()); > // nothing to undo > setUndoActivity(null); > } > else { > // use undo activity from paste command... > setUndoActivity(createUndoActivity()); > > // put created figure into a figure enumeration > getUndoActivity().setAffectedFigures(new SingleFigureEnumerator(getAddedFigure())); > } 104a133 > setAddedFigure(null); 111c140 < protected Figure createdFigure() { --- > protected Figure getCreatedFigure() { 113a143,165 > > private void setCreatedFigure(Figure newCreatedFigure) { > fCreatedFigure = newCreatedFigure; > } > > /** > * Gets the figure that was actually added > * Note, this can be a different figure from the one which has been created. > */ > protected Figure getAddedFigure() { > return myAddedFigure; > } > > private void setAddedFigure(Figure newAddedFigure) { > myAddedFigure = newAddedFigure; > } > > /** > * Factory method for undo activity > */ > protected Undoable createUndoActivity() { > return new PasteCommand.UndoActivity(view()); > }