public void backtrackXTimes(int steps) { for (int i = steps; i > 0; i--) { domain.getCommandStack().undo(); trajectory.backtrack(); } activationCodes.updateActivationCodes(); logger.debug("Backtracked " + steps + " times."); }
public void undoUntilRoot() { while(trajectory.canStepBack()) { domain.getCommandStack().undo(); trajectory.backtrack(); } activationCodes.updateActivationCodes(); logger.debug("Backtracked to root."); }
public int backtrackUntilLastCommonActivation(Object[] newTrajectory) { Iterator<Object> currentTrajectoryIterator = trajectory.getTrajectory().iterator(); if (!currentTrajectoryIterator.hasNext()) { return 0; } int indexOfLastCommonActivation = 0; for (Object activationCode : newTrajectory) { if (currentTrajectoryIterator.hasNext()) { Object activationCodeFromCurrent = currentTrajectoryIterator.next(); if (activationCodeFromCurrent.equals(activationCode)) { indexOfLastCommonActivation++; } else { break; } } else { // current trajectory is smaller break; } } int numberOfBacktracks = trajectory.getDepth() - indexOfLastCommonActivation; if (numberOfBacktracks > 0) { for (int i = numberOfBacktracks; i > 0; i--) { domain.getCommandStack().undo(); trajectory.backtrack(); } activationCodes.updateActivationCodes(); } logger.debug("Backtracked " + numberOfBacktracks + " times."); return indexOfLastCommonActivation; }
public boolean undoLastTransformation() { if (!trajectory.canStepBack()) { return false; } domain.getCommandStack().undo(); activationCodes.updateActivationCodes(); Object lastActivationId = trajectory.getLastActivationId(); trajectory.backtrack(); if (handlers != null) { for (IExploreEventHandler iExploreEventHandler : handlers) { iExploreEventHandler.undo(lastActivationId); } } logger.debug("Backtrack."); return true; }