gishur.awt
Class TraceBar

java.lang.Object
  |
  +--java.awt.Component
        |
        +--gishur.awt.Symbolbar
              |
              +--gishur.awt.TraceBar
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.lang.Runnable, java.io.Serializable, ToolTip

public class TraceBar
extends Symbolbar
implements java.lang.Runnable

A TraceBar is a Symbolbar that support algorithm recording via a Tracer object. It uses the TraceExecutor interface to execute the algorithm collecting debugging information and the TraceVisualizer interface in order to visualize a recorded TraceLabel. The bar provides complete navigation through the recorded algorithm. The default images for the used buttons are stored at TraceSymbols.

Version:
1.0
Author:
Thomas Wolf
See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static java.lang.String end_com
          ActionEvent Label.
static java.lang.String home_com
          ActionEvent Label.
static java.lang.String level_com
          ActionEvent Label.
static java.lang.String next_com
          ActionEvent Label.
static java.lang.String power_com
          ActionEvent Label.
static java.lang.String prev_com
          ActionEvent Label.
static java.lang.String slider_com
          ActionEvent Label.
static java.lang.String speed_com
          ActionEvent Label.
static java.lang.String start_com
          ActionEvent Label.
 
Fields inherited from class gishur.awt.Symbolbar
ALIGN_LEFT, ALIGN_RIGHT, alignment, name
 
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
TraceBar(java.lang.String name)
           
 
Method Summary
 void disableBar()
           
 void doCommand(java.lang.String com)
           
 void enableBar()
           
 void generateMenu(java.awt.Menu menu)
          Generates the standard menu bar for the TraceBar (according to switched buttons).
 boolean goBackOnLevelDown()
           
 float playbackFPS()
          Returns the playback speed in frames per second.
 long playbackSpeed()
          Returns the playback speed in milliseconds.
 void processActionEvent(java.awt.event.ActionEvent e)
          Processes action events.
 void run()
          The run method calls the visualization methods and controls the playback.
 void setButtonLabels(java.lang.String power_label, java.lang.String start_label, java.lang.String go_start_label, java.lang.String prev_label, java.lang.String slider_label, java.lang.String next_label, java.lang.String go_end_label, java.lang.String level_label)
          Sets the text labels of all buttons.
 void setButtons(boolean power, boolean start, boolean go_start, boolean prev, boolean slider, boolean next, boolean go_end, boolean level, boolean speed)
          Sets the specified buttons.
 void setGoBackOnLevelDown(boolean gb)
           
 void setPlaybackFPS(float fps)
          Sets the playback speed in frames per second.
 void setPlaybackSpeed(long pause)
          Sets the playback speed in milliseconds.
 void setTraceExecutor(TraceExecutor exec)
          Sets the TraceExecutor, that manages algorithm execution.
 void setTraceVisualizer(TraceVisualizer visu)
          Sets the TraceVisualizer for visualization of the recorded TraceLabels.
 void setUseAfterLastStep(boolean al)
           
 void setUseBeforeFirstStep(boolean bf)
           
 void setUseThreadForExecution(boolean th)
           
 void switchOff()
          Switches the TraceBar off.
 void switchOn()
          Switches the TraceBar on.
 boolean useAfterLastStep()
           
 boolean useBeforeFirstStep()
           
 boolean useThreadForExecution()
           
 
Methods inherited from class gishur.awt.Symbolbar
add, addActionListener, addSymbolbarGrasp, clearAll, disableAll, element, element, enableAll, getBounds, getMinimumSize, getPreferredSize, getStatusTip, getToolTip, indexOf, insert, localize, paint, processEvent, processMouseEvent, processMouseMotionEvent, removeActionListener, set, stripDisabledImage, stripEnabledImage, stripImages, update
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

home_com

public static final java.lang.String home_com
ActionEvent Label. Command strings should be used to handle ActionEvents.

end_com

public static final java.lang.String end_com
ActionEvent Label. Command strings should be used to handle ActionEvents.

start_com

public static final java.lang.String start_com
ActionEvent Label. Command strings should be used to handle ActionEvents.

power_com

public static final java.lang.String power_com
ActionEvent Label. Command strings should be used to handle ActionEvents.

next_com

public static final java.lang.String next_com
ActionEvent Label. Command strings should be used to handle ActionEvents.

prev_com

public static final java.lang.String prev_com
ActionEvent Label. Command strings should be used to handle ActionEvents.

level_com

public static final java.lang.String level_com
ActionEvent Label. Command strings should be used to handle ActionEvents.

slider_com

public static final java.lang.String slider_com
ActionEvent Label. Command strings should be used to handle ActionEvents.

speed_com

public static final java.lang.String speed_com
ActionEvent Label. Command strings should be used to handle ActionEvents.
Constructor Detail

TraceBar

public TraceBar(java.lang.String name)
Method Detail

setButtonLabels

public void setButtonLabels(java.lang.String power_label,
                            java.lang.String start_label,
                            java.lang.String go_start_label,
                            java.lang.String prev_label,
                            java.lang.String slider_label,
                            java.lang.String next_label,
                            java.lang.String go_end_label,
                            java.lang.String level_label)
Sets the text labels of all buttons. If a given label is null, the label will not be changed.

setButtons

public void setButtons(boolean power,
                       boolean start,
                       boolean go_start,
                       boolean prev,
                       boolean slider,
                       boolean next,
                       boolean go_end,
                       boolean level,
                       boolean speed)
Sets the specified buttons.
Parameters:
power - if true then the power button will be added
start - if true then the start button will be added
go_start - if true then the go start button will be added
go_prev - if true then the previous step button will be added
slider - if true then the step slider will be added
next - if true then the next step button will be added
go_end - if true then the go end button will be added
level - if true then the level button will be added
speed - if true then the speed button will be added

generateMenu

public void generateMenu(java.awt.Menu menu)
Generates the standard menu bar for the TraceBar (according to switched buttons).
Overrides:
generateMenu in class Symbolbar
Parameters:
menu - the Menu, where to add menu entries.

useBeforeFirstStep

public boolean useBeforeFirstStep()

setUseBeforeFirstStep

public void setUseBeforeFirstStep(boolean bf)

useAfterLastStep

public boolean useAfterLastStep()

setUseAfterLastStep

public void setUseAfterLastStep(boolean al)

goBackOnLevelDown

public boolean goBackOnLevelDown()

setGoBackOnLevelDown

public void setGoBackOnLevelDown(boolean gb)

useThreadForExecution

public boolean useThreadForExecution()

setUseThreadForExecution

public void setUseThreadForExecution(boolean th)

playbackSpeed

public long playbackSpeed()
Returns the playback speed in milliseconds. The returned value is the pause between two frames in milliseconds.
Returns:
playback speed in milliseconds

setPlaybackSpeed

public void setPlaybackSpeed(long pause)
Sets the playback speed in milliseconds. The given value is the pause between two frames in milliseconds.
Parameters:
pause - pause time between two frames in milliseconds

setPlaybackFPS

public void setPlaybackFPS(float fps)
Sets the playback speed in frames per second.
Parameters:
fps - frames per second for playback

playbackFPS

public float playbackFPS()
Returns the playback speed in frames per second.
Returns:
frames per second for playback

enableBar

public void enableBar()

disableBar

public void disableBar()

switchOff

public void switchOff()
Switches the TraceBar off.

switchOn

public void switchOn()
Switches the TraceBar on.

setTraceExecutor

public void setTraceExecutor(TraceExecutor exec)
Sets the TraceExecutor, that manages algorithm execution.
Parameters:
exec - the algorithm executor to use

setTraceVisualizer

public void setTraceVisualizer(TraceVisualizer visu)
Sets the TraceVisualizer for visualization of the recorded TraceLabels.
Parameters:
visu - the TraceVisualizer to use

processActionEvent

public void processActionEvent(java.awt.event.ActionEvent e)
Processes action events.
Overrides:
processActionEvent in class Symbolbar
Parameters:
e - the action event to process

doCommand

public void doCommand(java.lang.String com)

run

public void run()
The run method calls the visualization methods and controls the playback.
Specified by:
run in interface java.lang.Runnable