/* This file is part of the algoviz@vt collection of algorithm visualizations. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this distribution. If not, see . */ package splayTree; /** * This class just holds which VirtualState in the current VirtualStateCollection this step refers to * * @author Andy Street, alstreet@vt.edu * @version Apr 22, 2009 * */ public class ChangeState extends State { private int stateNumber; private VirtualStateCollection vt; public ChangeState(VirtualState s, VirtualStateCollection vt, Operation o, String text) { super(o, text); this.stateNumber = vt.addState(s); this.vt = vt; } /** * @see avl.State#onStateFocused(avl.TreePanel) */ @Override public void onStateFocused(TreePanel tp, boolean goingForward) { if(goingForward) vt.animate(tp, stateNumber, stateNumber + 1); else vt.animate(tp, stateNumber + 1, stateNumber); } /** * @see avl.State#onStateUnfocused(avl.TreePanel) */ @Override public void onStateUnfocused(TreePanel tp) { } /** * Draws this state. If prev is true, it will draw the state it would * animate from when going forward, otherwise it will draw the state it would * animate to. * * @see avl.State#draw(avl.TreePanel) */ @Override public void draw(TreePanel tp, boolean prev) { vt.animate(tp, stateNumber + (prev ? 0 : 1), stateNumber + (prev ? 0 : 1)); } @Override public String toString(){ String temp=stateNumber + "" + super.getText(); return temp; } }