Class AlgAnimFrame

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Window
                           |
                           +----java.awt.Frame
                                   |
                                   +----AlgAnimFrame

public class AlgAnimFrame
extends Frame
The AlgAnimFrame class is a top-level window with a title and border. The layout used is BorderLayout. There is a menubar created at the north part of the panel. The drawing panel is at the center and a commentary panel is located at the south.

This extended frame class holds a set references to the panel/frame objects used in the algorithm animation.

See Also:
Frame

Constructor Index

 o AlgAnimFrame(AlgAnimApp, URL)
Creates and shows the frame consists of a drawing panel, commentary panel and control panel.

Method Index

 o action(Event, Object)
Action handler for the buttons and choice buttons in the control panel.
 o finishAlg()
This method is invoked at the end of the animation or when the stop button is pressed.
 o getAlg()
Returns the reference to the AlgThread which contains the details and execution sequences of the algorithm.
 o getApplet()
Get the applet which contains a button to start up this window.
 o getComPanel()
Get the commentary panel that displays messages of any type.
 o getDataChoice()
Get the index of selected choice from the 'Select' pull menu.
 o getDelay()
Get the delay for highlighting text.
 o getDisableAnim()
Get the menu item which specify if the animation is disabled.
 o getDrawingPanel()
Returns an instance of the drawing panel which is cast to its super class Panel.
 o getEnableAnim()
Get the menu item which specify if the animation is enabled.
 o getRunItem()
Get the run button from the control panel.
 o getSkipItem()
Get the skip button from the control panel.
 o getStopItem()
Get the stop button from the control panel.
 o getTextFrame()
Returns an instance of the TextFrame used to set the layout constraints and highlight certain lines of the source code.
 o handleEvent(Event)
Event handler of the frame.
 o Highlight(int)
Highlights the specified line of the source code on the text panel.
 o isNoAnim()
Obtain the status of the preferred animation style.
 o preferredSize()
Returns the preferred size of the frame.
 o restoreDrawingPanel()
Restore the drawing panel at the end of the animation or during initialization.
 o setDelay(int)
Set the delay for highlighting text.
 o setDimension(Dimension)
Sets the size of the frame.
 o setDrawingPanel(DrawingPanel)
Sets the drawing panel which is cast to its super class Panel.
 o setSkip(boolean)
Sets the attribute which indicate if the skip execution mode is current.
 o setStep(boolean)
Sets the attribute which indicate if the step execution mode is current.
 o setText(int, String)
Sets the text string to be displayed on a specific text field on the commentary panel return from getComPanel.
 o startAlg()
Start the animation algorithm if the run or step button is pressed.
 o waitSkip()
This method is called when the skip execution mode is used.
 o waitStep()
This method is called when the step execution mode is used.

Constructors

 o AlgAnimFrame
 public AlgAnimFrame(AlgAnimApp parentApp,
                     URL sourceURL)
Creates and shows the frame consists of a drawing panel, commentary panel and control panel. The text frame is now displayed on a separate window.

Parameters:
parentApp - The applet which results in the creation of this frame
sourceURL - The URL of the source code to be displayed on the text frame
See Also:
URL

Methods

 o preferredSize
 public Dimension preferredSize()
Returns the preferred size of the frame. By default, it is set to 850x700. It can be modified based on the specific application.

Returns:
the dimension of the frame
Overrides:
preferredSize in class Container
 o setDimension
 public void setDimension(Dimension size)
Sets the size of the frame.

Parameters:
size - The desired sized of the frame.
 o handleEvent
 public boolean handleEvent(Event event)
Event handler of the frame. The main purpose of this method is to perform the cleanup statements upon receival of the WINDOW_DESTROY event message.

Overrides:
handleEvent in class Component
 o action
 public boolean action(Event e,
                       Object arg)
Action handler for the buttons and choice buttons in the control panel.

Parameters:
e - Event invoked
arg - Object that invokes the event
Overrides:
action in class Component
 o setText
 public void setText(int n,
                     String s)
Sets the text string to be displayed on a specific text field on the commentary panel return from getComPanel.

Parameters:
n - The text field to display the string. First is 0.
s - The string to be displayed.
See Also:
getComPanel
 o Highlight
 public void Highlight(int n)
Highlights the specified line of the source code on the text panel. If the line is beyond the scroll pane, it will be scrolled to the center of the window.

Parameters:
n - The line to be highlighted.
 o restoreDrawingPanel
 public void restoreDrawingPanel()
Restore the drawing panel at the end of the animation or during initialization.

 o startAlg
 public void startAlg()
Start the animation algorithm if the run or step button is pressed.

 o finishAlg
 public void finishAlg()
This method is invoked at the end of the animation or when the stop button is pressed. It restores the buttons status on the control panel.

 o waitStep
 public void waitStep()
This method is called when the step execution mode is used. It is normally added to the line where the execution will wait for the step button to be pressed.

 o waitSkip
 public void waitSkip()
This method is called when the skip execution mode is used. It is normally added to the line where the execution will wait after the skip button to be pressed.

 o setSkip
 public void setSkip(boolean skip)
Sets the attribute which indicate if the skip execution mode is current.

 o setStep
 public void setStep(boolean step)
Sets the attribute which indicate if the step execution mode is current.

 o getAlg
 public AlgThread getAlg()
Returns the reference to the AlgThread which contains the details and execution sequences of the algorithm.

See Also:
AlgThread
 o setDelay
 public void setDelay(int delay)
Set the delay for highlighting text.

 o getDelay
 public int getDelay()
Get the delay for highlighting text.

 o getApplet
 public AlgAnimApp getApplet()
Get the applet which contains a button to start up this window.

Returns:
Returns the applet which contains the button to start up this window.
 o getDrawingPanel
 public DrawingPanel getDrawingPanel()
Returns an instance of the drawing panel which is cast to its super class Panel.

 o setDrawingPanel
 public void setDrawingPanel(DrawingPanel panel)
Sets the drawing panel which is cast to its super class Panel. This instance is used to set the GridBagConstraint of the layout manager.

See Also:
DrawingPanel
 o getTextFrame
 public TextFrame getTextFrame()
Returns an instance of the TextFrame used to set the layout constraints and highlight certain lines of the source code.

See Also:
TextFrame
 o getComPanel
 public ComPanel getComPanel()
Get the commentary panel that displays messages of any type.

Returns:
Commentary panel, in which each text field within can be set to display text string from this class.
See Also:
ComPanel
 o getDataChoice
 public int getDataChoice()
Get the index of selected choice from the 'Select' pull menu.

Returns:
The choice of the data selected.
 o getSkipItem
 public Button getSkipItem()
Get the skip button from the control panel.

Returns:
The skip button.
 o getRunItem
 public Button getRunItem()
Get the run button from the control panel.

Returns:
The run button.
 o getStopItem
 public Button getStopItem()
Get the stop button from the control panel.

Returns:
The stop button.
 o isNoAnim
 public boolean isNoAnim()
Obtain the status of the preferred animation style.

Returns:
True is the animation is kept to a minimum for the animated algorithm; false otherwise.
 o getEnableAnim
 public CheckboxMenuItem getEnableAnim()
Get the menu item which specify if the animation is enabled.

Returns:
The checkbox menu item to enable the Animation of the alg.
 o getDisableAnim
 public CheckboxMenuItem getDisableAnim()
Get the menu item which specify if the animation is disabled.

Returns:
The checkbox menu item to disable the Animation of the alg.