ciips.animation
Class AlgAnimFrame

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended byciips.animation.AlgAnimFrame
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.ItemListener, java.awt.MenuContainer, java.io.Serializable

public class AlgAnimFrame
extends java.awt.Frame
implements java.awt.event.ItemListener

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, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int COMPANEL_LINES
           
static int UI_SELECTED
          Value returned by getSelected() when user input has been selected
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AlgAnimFrame(AlgAnimApp parentApp, java.net.URL sourceURL)
          Creates and shows the frame consists of a drawing panel, commentary panel and control panel.
 
Method Summary
 boolean action(java.awt.Event e, java.lang.Object arg)
          Action handler for the buttons and choice buttons in the control panel.
 void clearPanels()
           
 void drawBeforeLabel(ShadowLabel label)
          Shuffles the images down and draws a label on the "before" image (the one immediately preceding the current one
 void finishAlg()
          This method is invoked at the end of the animation or when the stop button is pressed.
 AlgThread getAlg()
          Returns the reference to the AlgThread which contains the details and execution sequences of the algorithm.
 AlgAnimApp getApplet()
          Get the applet which contains a button to start up this window.
 BasicDrawingPanel getBeforeDp()
           
 ComPanel getComPanel()
          Get the commentary panel that displays messages of any type.
 DrawingPanel getCurrentPanel()
           
 int getDataChoice()
          Get the index of selected choice from the 'Select' pull menu.
 java.lang.String getDataFileName()
           
 int getDelay()
          Get the delay for highlighting text.
 java.awt.CheckboxMenuItem getDisableAnim()
          Get the menu item which specify if the animation is disabled.
 BasicDrawingPanel[] getDrawingPanel()
          Returns an instance of the drawing panel which is cast to its super class Panel.
 java.awt.CheckboxMenuItem getEnableAnim()
          Get the menu item which specify if the animation is enabled.
 NamedIntList getNamedIntList(int k)
           
 boolean[] getOptions()
          Get the option settings
static DrawingPanel getPanel()
           
 BasicDrawingPanel getPreviousPanel()
           
 java.awt.Button getRunItem()
          Get the run button from the control panel.
 java.awt.Button getSkipItem()
          Get the skip button from the control panel.
 java.awt.Button getStopItem()
          Get the stop button from the control panel.
 TextFrame getTextFrame()
          Returns an instance of the TextFrame used to set the layout constraints and highlight certain lines of the source code.
 UIFrame getUIFrame()
          Return a reference to the user input frame
 boolean handleEvent(java.awt.Event event)
          Event handler of the frame.
 void Highlight(int n)
          Highlights the specified line of the source code on the text panel.
static void highlightText(int n)
           
 boolean isNoAnim()
          Obtain the status of the preferred animation style.
 void itemStateChanged(java.awt.event.ItemEvent e)
           
static AlgAnimFrame makeAlgAnimFrame(AlgAnimApp parentApp, java.net.URL sourceURL)
           
static void pause()
           
static void pauseSkip()
           
static void pauseStep()
           
 java.awt.Dimension preferredSize()
          Returns the preferred size of the frame.
 void restoreDrawingPanel()
          Restore the drawing panel at the end of the animation or during initialization.
 void setDelay(int delay)
          Set the delay for highlighting text.
 void setDimension(java.awt.Dimension size)
          Sets the size of the frame.
 void setDrawingPanel(DrawingPanel panel)
          Sets the drawing panel which is cast to its super class Panel.
 void setSkip(boolean skip)
          Sets the attribute which indicate if the skip execution mode is current.
 void setStep(boolean step)
          Sets the attribute which indicate if the step execution mode is current.
 void setText(int n, java.lang.String s)
          Sets the text string to be displayed on a specific text field on the commentary panel return from getComPanel.
static void showText(int n, java.lang.String s)
           
 void startAlg()
          Start the animation algorithm if the run or step button is pressed.
 void waitSkip()
          This method is called when the skip execution mode is used.
 void waitStep()
          This method is called when the step execution mode is used.
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, paramString, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

COMPANEL_LINES

public static int COMPANEL_LINES

UI_SELECTED

public static final int UI_SELECTED
Value returned by getSelected() when user input has been selected

See Also:
Constant Field Values
Constructor Detail

AlgAnimFrame

public AlgAnimFrame(AlgAnimApp parentApp,
                    java.net.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
Method Detail

getOptions

public boolean[] getOptions()
Get the option settings


getDataFileName

public java.lang.String getDataFileName()

preferredSize

public java.awt.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

setDimension

public void setDimension(java.awt.Dimension size)
Sets the size of the frame.

Parameters:
size - The desired sized of the frame.

handleEvent

public boolean handleEvent(java.awt.Event event)
Event handler of the frame. The main purpose of this method is to cleanup upon receival of the WINDOW_DESTROY event message.


action

public boolean action(java.awt.Event e,
                      java.lang.Object arg)
Action handler for the buttons and choice buttons in the control panel.

Parameters:
e - Event invoked
arg - Object that invokes the event

setText

public void setText(int n,
                    java.lang.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

getUIFrame

public UIFrame getUIFrame()
Return a reference to the user input frame

See Also:
UIFrame

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 BasicDrawingPanel[] getDrawingPanel()
Returns an instance of the drawing panel which is cast to its super class Panel.


getBeforeDp

public BasicDrawingPanel getBeforeDp()

drawBeforeLabel

public void drawBeforeLabel(ShadowLabel label)
Shuffles the images down and draws a label on the "before" image (the one immediately preceding the current one


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 index of the data set selected or UI_SELECTED to indicate user input has been selected

getSkipItem

public java.awt.Button getSkipItem()
Get the skip button from the control panel.

Returns:
The skip button.

getRunItem

public java.awt.Button getRunItem()
Get the run button from the control panel.

Returns:
The run button.

getStopItem

public java.awt.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 java.awt.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 java.awt.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.

getCurrentPanel

public DrawingPanel getCurrentPanel()

getPreviousPanel

public BasicDrawingPanel getPreviousPanel()

getNamedIntList

public NamedIntList getNamedIntList(int k)

makeAlgAnimFrame

public static AlgAnimFrame makeAlgAnimFrame(AlgAnimApp parentApp,
                                            java.net.URL sourceURL)

pause

public static void pause()

pauseStep

public static void pauseStep()

pauseSkip

public static void pauseSkip()

highlightText

public static void highlightText(int n)

showText

public static void showText(int n,
                            java.lang.String s)

getPanel

public static DrawingPanel getPanel()

clearPanels

public void clearPanels()

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
Specified by:
itemStateChanged in interface java.awt.event.ItemListener