Class AlgThread

java.lang.Object
   |
   +----java.lang.Thread
           |
           +----AlgThread

public class AlgThread
extends Thread
AlgThread is an extension of the provided Java multi-threading package. It enables the graphical display of the main execution thread to be updated during the execution of the algorithm.

A section of this source file is normally displayed on the TextFrame. This section starts with the line after /*------------------*/ and finishes before the line //------------ . Every line starting with /*-*/ will be discarded in the source code display area and each line is terminated by the first encounter of /*-*/.

The source file AlgThread.java is to be modified/completed for separate animation algorithms.


Variable Index

 o dataSets
Array of strings used to set the choices of the data choice button in data menu.
 o drawingPanel
A reference to the drawing panel in order to update the animation during the execution of the algorithm.
 o frame
The initial caller of the constructor of this class.
 o max_data
Size of the data set appropriate for algorighm animation.

Constructor Index

 o AlgThread(AlgAnimFrame)
Creates a new thread using the frame passed in as the parameter.

Method Index

 o generateData()
Generate data based on the choice made on the menu.
 o restoreDrawingPanel()
Restore the drawing panel at the beginning or the end of each simulation.
 o run()
This method is invoked when the Thread class start() method is called.
 o setDelay(int)
Sets the delay between each animation step.
 o waitSkip()
This method is to be placed after the line where the fast forward function is to be performed.

Variables

 o max_data
 public int max_data
Size of the data set appropriate for algorighm animation.

 o dataSets
 public static String dataSets[]
Array of strings used to set the choices of the data choice button in data menu.

 o frame
 public AlgAnimFrame frame
The initial caller of the constructor of this class. It holds the references to all existing panels.

 o drawingPanel
 public DrawingPanel drawingPanel
A reference to the drawing panel in order to update the animation during the execution of the algorithm.

See Also:
DrawingPanel

Constructors

 o AlgThread
 public AlgThread(AlgAnimFrame frame)
Creates a new thread using the frame passed in as the parameter. If this constructor is called from the frame constructor, a drawingPanel will be initialized and assigned to the frame class.

Parameters:
frame - An extended frame where the algorithm is going to execute in.
See Also:
AlgAnimFrame

Methods

 o setDelay
 public void setDelay(int delay)
Sets the delay between each animation step. This determines the rate the drawingPanel is updated. The setDelay method is normally called by the action listener of the delay choice button on the control panel.

Parameters:
delay - The delay set in milliseconds.
 o generateData
 public void generateData()
Generate data based on the choice made on the menu. This method is application specific and the contents for the satisfaction of each 'if' statement have to be filled in based on the algorithm.

 o run
 public void run()
This method is invoked when the Thread class start() method is called. It contains the statements to execute the methods which perform the algorithm. This method is to be completed based on separate animation algorithms.

Overrides:
run in class Thread
See Also:
Thread
 o restoreDrawingPanel
 public void restoreDrawingPanel()
Restore the drawing panel at the beginning or the end of each simulation.

 o waitSkip
 public void waitSkip()
This method is to be placed after the line where the fast forward function is to be performed.