/* ControlPanel class */ package ciips.animation; import java.awt.*; import java.applet.*; import java.io.*; import java.net.*; import java.util.*; /** * This class extends the java.awt.Panel class to form * a panel which holds the buttons that control * the animation of the algorithm. *

* In this particular application, it only consists of four image buttons, * namely, run, stop, step, and skip. * * @see Panel */ public class ControlPanel extends Panel { private AlgAnimFrame frame; private Button control_buttons[]; private Button runButton; private Button stopButton; private Button stepButton, skipButton; private Font font; private static final String[] button_names = { "stop", "run", "step", "skip" }; private static final int STOP_BTN = 0; private static final int RUN_BTN = 1; private static final int STEP_BTN = 2; private static final int SKIP_BTN = 3; /** * Creates a panel to hold the control buttons of the animation * tool. * @param frame The parent window frame that contains this panel * @param algname The algorithm name parsed from the applet parameter */ public ControlPanel(AlgAnimFrame frame, String algname) { setLayout( new FlowLayout(FlowLayout.LEFT) ); this.frame = frame; final Font helv10 = frame.helv10; setBackground(Color.white); control_buttons = new Button[ button_names.length ]; for( int k=0;krepaint() on each of the image buttons. */ public void refreshButtons() { for(int k=0;kImageButton, which is * cast to java.awt.Button * @return Run button to initiate the animation of the algorithm. */ public Button getRunButton() { return control_buttons[RUN_BTN]; } /** * Returns an instance of the stop ImageButton, which is * cast to java.awt.Button * @return Stop button to terminate the execution of algorithm. */ public Button getStopButton() { return control_buttons[STOP_BTN]; } /** * Returns an instance of the step ImageButton, which is * casted to java.awt.Button * @return Step button to trace through the execution of the algorithm. * If the Run button has already been pressed, the * execution mode will be switched from RUN to * STEP. */ public Button getStepButton() { return control_buttons[STEP_BTN]; } /** * Returns an instance of the skip ImageButton, which is * casted to java.awt.Button * @return Skip button to bypass the animation of the algorithm. */ public Button getSkipButton() { return control_buttons[SKIP_BTN]; } } // class ControlPanel