![]() |
AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
|
Simple framework for single stepping code. More...
Public Member Functions | |
SingleStepper (JFrame parent) | |
create new instance More... | |
SingleStepper (String caption) | |
create new instance More... | |
JFrame | parent () |
get parent widget More... | |
void | halt (String text, int timeout) |
display text and wait for user or timeout More... | |
void | setTimeout (int timeout) |
Set global timeout. More... | |
SingleStepper | whereAmI () |
print location of calling code More... | |
SingleStepper | showSource () |
jmp to caller's location in editor (emacs only) More... | |
void | halt (String text) |
display text and wait for user (or global timeout) More... | |
void | halt () |
wait for user More... | |
Static Public Member Functions | |
static void | main (String[] args) |
Protected Member Functions | |
JComponent | createComponents () |
void | onNext () |
call on button pressed More... | |
void | println (String text) |
print to both, text area and stdout More... | |
void | onHalt () |
Protected Attributes | |
JFrame | frame |
JTextArea | history |
JButton | next |
Object | monitor = new Object() |
int | timeout = 0 |
Simple framework for single stepping code.
The SingleStepper
widget consists of a text area that displays messages and a push button that triggers the next step.
The idea is to include calls to halt
in your code: this prints a message and waits for the user to push the button to continue execution.
The following environment variables are recognized envionment variables.
environment variable | purpose |
AUD_TIMEOUT | set global timeout for halt in milliseconds setTimeout |
DotViewer
can be used to visualize the state of an algorithm that is run with SingleStepper
. GraphDemo
shows an example.
Definition at line 44 of file SingleStepper.java.
aud.util.SingleStepper.SingleStepper | ( | JFrame | parent | ) |
create new instance
Definition at line 53 of file SingleStepper.java.
References aud.util.SingleStepper.createComponents(), aud.util.Sys.env(), aud.util.SingleStepper.frame, aud.util.SingleStepper.parent(), and aud.util.SingleStepper.timeout.
aud.util.SingleStepper.SingleStepper | ( | String | caption | ) |
create new instance
Definition at line 63 of file SingleStepper.java.
References aud.util.SingleStepper.parent().
|
protected |
Definition at line 84 of file SingleStepper.java.
References aud.util.SingleStepper.history, aud.util.SingleStepper.next, and aud.util.SingleStepper.onNext().
Referenced by aud.util.SingleStepper.SingleStepper().
void aud.util.SingleStepper.halt | ( | ) |
wait for user
Definition at line 188 of file SingleStepper.java.
References aud.util.SingleStepper.halt(), and aud.util.Sys.whereAmI().
Referenced by aud.util.SingleStepper.halt(), aud.example.expr.ExpressionTreeTraversal.levelorder(), aud.example.BinaryTreeTraversal.levelorder(), aud.example.expr.ExpressionTreeTraversal.output(), aud.example.BinaryTreeTraversal.output(), aud.example.BinaryTreeTraversal.traverse(), and aud.example.expr.ExpressionTreeTraversal.traverse().
void aud.util.SingleStepper.halt | ( | String | text | ) |
display text
and wait for user (or global timeout)
Definition at line 183 of file SingleStepper.java.
References aud.util.SingleStepper.halt(), and aud.util.SingleStepper.timeout.
void aud.util.SingleStepper.halt | ( | String | text, |
int | timeout | ||
) |
display text
and wait for user or timeout
Definition at line 138 of file SingleStepper.java.
References aud.util.SingleStepper.history, aud.util.SingleStepper.monitor, aud.util.SingleStepper.onHalt(), aud.util.SingleStepper.println(), and aud.util.SingleStepper.timeout.
Referenced by aud.util.GraphDemo.main(), aud.util.SingleStepperDemo.main(), aud.example.A234TreeExample.main(), aud.example.AVLTreeExample.main(), aud.example.BinarySearchTreeExample.main(), aud.example.BinaryTreeTraversal.main(), aud.example.BTreeExample.main(), aud.example.expr.ExpressionTreeTraversal.main(), aud.example.graph.TraversalExample.main(), aud.example.RedBlackTreeExample.main(), and aud.util.SingleStepper.main().
|
static |
Reimplemented in aud.util.GraphDemo, aud.util.SingleStepperDemo, aud.example.A234TreeExample, aud.example.AVLTreeExample, aud.example.BinarySearchTreeExample, aud.example.BinaryTreeTraversal, aud.example.BTreeExample, aud.example.expr.ExpressionTreeTraversal, aud.example.graph.MaxFlowExample, aud.example.graph.TraversalExample, and aud.example.RedBlackTreeExample.
Definition at line 190 of file SingleStepper.java.
References aud.util.SingleStepper.halt().
|
protected |
Reimplemented in aud.example.A234TreeExample, aud.example.AVLTreeExample, aud.example.BinarySearchTreeExample, aud.example.BinaryTreeTraversal, aud.example.BTreeExample, aud.example.expr.ExpressionTreeTraversal, aud.example.graph.MaxFlowExample, aud.example.graph.TraversalExample, aud.example.RedBlackTreeExample, aud.util.GraphDemo, and aud.util.SingleStepperDemo.
Definition at line 161 of file SingleStepper.java.
Referenced by aud.util.SingleStepper.halt().
|
protected |
call on button pressed
Definition at line 126 of file SingleStepper.java.
References aud.util.SingleStepper.monitor.
Referenced by aud.util.SingleStepper.createComponents().
JFrame aud.util.SingleStepper.parent | ( | ) |
get parent widget
Definition at line 81 of file SingleStepper.java.
References aud.util.SingleStepper.frame.
Referenced by aud.util.SingleStepper.SingleStepper().
|
protected |
print to both, text area and stdout
Definition at line 156 of file SingleStepper.java.
References aud.util.SingleStepper.history.
Referenced by aud.util.SingleStepper.halt(), and aud.util.SingleStepper.whereAmI().
void aud.util.SingleStepper.setTimeout | ( | int | timeout | ) |
Set global timeout.
Continue halt
after timeout
milliseconds.
timeout | in milliseconds |
Definition at line 167 of file SingleStepper.java.
References aud.util.SingleStepper.timeout.
Referenced by aud.example.A234TreeExample.main(), aud.example.AVLTreeExample.main(), aud.example.BTreeExample.main(), and aud.example.RedBlackTreeExample.main().
SingleStepper aud.util.SingleStepper.showSource | ( | ) |
jmp to caller's location in editor (emacs only)
Definition at line 177 of file SingleStepper.java.
References aud.util.Sys.openCallersSourceInEmacs().
Referenced by aud.util.GraphDemo.main().
SingleStepper aud.util.SingleStepper.whereAmI | ( | ) |
print location of calling code
Definition at line 172 of file SingleStepper.java.
References aud.util.SingleStepper.println(), and aud.util.Sys.whereAmI().
Referenced by aud.util.GraphDemo.main().
|
protected |
Definition at line 46 of file SingleStepper.java.
Referenced by aud.util.SingleStepper.parent(), and aud.util.SingleStepper.SingleStepper().
|
protected |
Definition at line 47 of file SingleStepper.java.
Referenced by aud.util.SingleStepper.createComponents(), aud.util.SingleStepper.halt(), and aud.util.SingleStepper.println().
|
protected |
Definition at line 49 of file SingleStepper.java.
Referenced by aud.util.SingleStepper.halt(), and aud.util.SingleStepper.onNext().
|
protected |
Definition at line 48 of file SingleStepper.java.
Referenced by aud.util.SingleStepper.createComponents().
|
protected |
Definition at line 50 of file SingleStepper.java.
Referenced by aud.util.SingleStepper.halt(), aud.util.SingleStepper.setTimeout(), and aud.util.SingleStepper.SingleStepper().