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